no message
This commit is contained in:
113
src/TestingSystem/Common/Configuration/Configuration.java
Normal file
113
src/TestingSystem/Common/Configuration/Configuration.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package TestingSystem.Common.Configuration;
|
||||
import Common.Database.DBObject;
|
||||
import Common.Database.riDBObject;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
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;
|
||||
public String printAuto(){
|
||||
return autoTesting>0? "Да":"Нет";
|
||||
}
|
||||
//--
|
||||
public String getFlags(){return "";}
|
||||
public Vector<String> getFlagsArray(){return new Vector<>();}
|
||||
public Vector<String> getGroupsNamesArray(){
|
||||
return Utils.unpack_s(packedGroupsNames,"\n");
|
||||
}
|
||||
//--
|
||||
@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;
|
||||
}
|
||||
//-
|
||||
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);
|
||||
}
|
||||
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<Group> getGroups() {
|
||||
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));
|
||||
return res;
|
||||
}
|
||||
public Vector<Test> getTests() {
|
||||
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);
|
||||
}
|
||||
//--
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user