package TestingSystem.Common; 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 getFlagsArray(){return new Vector<>();} public Vector 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 new_groups) { Vector res = new Vector<>(); Vector 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 new_tests) { Vector 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 getGroups() { Vector 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 getTests() { Vector 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 getTests(Vector groups, LinkedHashMap> testByGroups) { Vector 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 groupTests = new Vector<>(); for (Test test:res){ if (test.group_id==group.id) groupTests.add(test); } testByGroups.put(group.id, groupTests); } //-- return res; } }