no message
This commit is contained in:
@@ -4,6 +4,10 @@ import Common.Database.riDBObject;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import TestingSystem.Common.Group.Json.GroupJson;
|
||||
import TestingSystem.Common.Group.Json.GroupsJson;
|
||||
import TestingSystem.Common.Test.Json.TestJson;
|
||||
import TestingSystem.Common.Test.Json.TestsJson;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
@@ -11,25 +15,11 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class Configuration extends riDBObject {
|
||||
//конфигурация = данные для пакета.
|
||||
|
||||
//группы
|
||||
//тесты
|
||||
//настройки тестируемого объекта
|
||||
//пакет = запуск конфигурация + тестируемый объект
|
||||
//---
|
||||
@Description("DEFAULT ''")
|
||||
public String packedGroupsIds = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String packedTestsIds = "";
|
||||
//---
|
||||
@Description("DEFAULT ''")
|
||||
public String packedGroupsNames = "";
|
||||
//---
|
||||
@Description("DEFAULT 0")
|
||||
public int groupsCount = 0;
|
||||
@Description("DEFAULT 0")
|
||||
public int testsCount = 0;
|
||||
//--
|
||||
public int maxtime = 300;
|
||||
@Description("DEFAULT 0")
|
||||
public int autoTesting = 0;
|
||||
@@ -39,75 +29,87 @@ public class Configuration extends riDBObject {
|
||||
//--
|
||||
public String getFlags(){return "";}
|
||||
public Vector<String> getFlagsArray(){return new Vector<>();}
|
||||
public Vector<String> getGroupsNamesArray(){
|
||||
return Utils.unpack_s(packedGroupsNames,"\n");
|
||||
}
|
||||
//--
|
||||
@Description("DEFAULT ''")
|
||||
public String packedGroupsJson = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String packedTestsJson = "";
|
||||
//----
|
||||
//---данные для отображения. кешировать их где-то еще?
|
||||
@Description("IGNORE")
|
||||
public GroupsJson groupsJson = null;
|
||||
@Description("IGNORE")
|
||||
public Vector<String> groupsDescriptions = null;
|
||||
@Description("IGNORE")
|
||||
public TestsJson testsJson = null;
|
||||
//--
|
||||
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
Configuration c = (Configuration) src;
|
||||
//--
|
||||
packedGroupsIds = c.packedGroupsIds;
|
||||
packedTestsIds = c.packedTestsIds;
|
||||
//-
|
||||
packedGroupsNames = c.packedGroupsNames;
|
||||
//-
|
||||
groupsCount = c.groupsCount;
|
||||
testsCount = c.testsCount;
|
||||
//-
|
||||
maxtime = c.maxtime;
|
||||
autoTesting= c.autoTesting;
|
||||
//-
|
||||
packedGroupsJson= c.packedGroupsJson;
|
||||
packedTestsJson = c.packedTestsJson;
|
||||
}
|
||||
//-
|
||||
public void saveGroups(Vector<Group> new_groups) {
|
||||
Vector<String> res = new Vector<>();
|
||||
Vector<String> names = new Vector<>();
|
||||
for (Group group : new_groups) {
|
||||
res.add(String.valueOf(group.id));
|
||||
names.add(group.description);
|
||||
public void saveGroupsAsJson(Vector<Group> groups) {
|
||||
packedGroupsJson = Utils.jsonToPrettyFormat(Utils.gson.toJson(new GroupsJson(groups)));
|
||||
}
|
||||
void unpackGroupsAsJson() {
|
||||
if (groupsJson == null) {
|
||||
if (packedGroupsJson.isEmpty())
|
||||
groupsJson = new GroupsJson(); //просто пустой
|
||||
else
|
||||
groupsJson = Utils.gson.fromJson(packedGroupsJson, GroupsJson.class);
|
||||
}
|
||||
packedGroupsIds = String.join("\n", res);
|
||||
packedGroupsNames = String.join("\n", names);
|
||||
groupsCount = new_groups.size();
|
||||
}
|
||||
public void saveTests(Vector<Test> new_tests) {
|
||||
Vector<String> res = new Vector<>();
|
||||
for (Test test : new_tests)
|
||||
res.add(String.valueOf(test.id));
|
||||
packedTestsIds = String.join("\n", res);
|
||||
testsCount = new_tests.size();
|
||||
public Vector<String> getGroupsDescriptions() {
|
||||
if (groupsDescriptions==null) {
|
||||
unpackGroupsAsJson();
|
||||
groupsDescriptions = new Vector<>();
|
||||
for (GroupJson groupJson : groupsJson.array)
|
||||
groupsDescriptions.add(groupJson.description);
|
||||
}
|
||||
return groupsDescriptions;
|
||||
}
|
||||
//--
|
||||
public Vector<Group> getGroups() {
|
||||
//здесь обращение реже так что буферизовать список групп не надо, тем более может меняться.
|
||||
unpackGroupsAsJson();
|
||||
Vector<Group> res = new Vector<>();
|
||||
for (int o_id : Utils.unpackIntegers(packedGroupsIds, "\n"))
|
||||
if (Global.testingServer.db.groups.containsKey(o_id))
|
||||
res.add(Global.testingServer.db.groups.get(o_id));
|
||||
for (GroupJson groupJson: groupsJson.array){
|
||||
if (Global.testingServer.db.groups.containsKey(groupJson.id))
|
||||
res.add(Global.testingServer.db.groups.get(groupJson.id));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//--------------------------------------------------------------------->>>
|
||||
public void saveTestsAsJson(Vector<Test> tests) {
|
||||
packedTestsJson = Utils.jsonToPrettyFormat(Utils.gson.toJson(new TestsJson(tests)));
|
||||
}
|
||||
void unpackTestsAsJson() {
|
||||
if (testsJson == null) {
|
||||
if (packedTestsJson.isEmpty())
|
||||
testsJson = new TestsJson(); //просто пустой
|
||||
else
|
||||
testsJson = Utils.gson.fromJson(packedTestsJson, TestsJson.class);
|
||||
}
|
||||
}
|
||||
public int getTestsCount(){
|
||||
unpackTestsAsJson();
|
||||
return testsJson.array.size();
|
||||
}
|
||||
public Vector<Test> getTests() {
|
||||
//здесь обращение реже так что буферизовать список групп не надо, тем более может меняться.
|
||||
unpackTestsAsJson();
|
||||
Vector<Test> res = new Vector<>();
|
||||
for (int o_id : Utils.unpackIntegers(packedTestsIds, "\n"))
|
||||
if (Global.testingServer.db.tests.containsKey(o_id))
|
||||
res.add(Global.testingServer.db.tests.get(o_id));
|
||||
return res;
|
||||
}
|
||||
public Vector<Test> getTests(Vector<Group> groups, LinkedHashMap<Integer, Vector<Test>> testByGroups) {
|
||||
Vector<Test> res = new Vector<>();
|
||||
for (int o_id : Utils.unpackIntegers(packedTestsIds, "\n"))
|
||||
if (Global.testingServer.db.tests.containsKey(o_id))
|
||||
res.add(Global.testingServer.db.tests.get(o_id));
|
||||
//--
|
||||
for (Group group: groups){
|
||||
Vector<Test> groupTests = new Vector<>();
|
||||
for (Test test:res){
|
||||
if (test.group_id==group.id)
|
||||
groupTests.add(test);
|
||||
}
|
||||
testByGroups.put(group.id, groupTests);
|
||||
for (TestJson testJson: testsJson.array){
|
||||
if (Global.testingServer.db.tests.containsKey(testJson.id))
|
||||
res.add(Global.testingServer.db.tests.get(testJson.id));
|
||||
}
|
||||
//--
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user