package Common.UI.VisualCache; import Common.Global; import Common.Utils.Utils; import TestingSystem.Common.Configuration.Configuration; 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 java.util.Vector; public class ConfigurationCache extends VisualCache{ public GroupsJson groupsJson = null; public String groupsDescriptions = null; public TestsJson testsJson = null; //-- public ConfigurationCache(Configuration configuration) { if (configuration.packedGroupsJson.isEmpty()) { groupsJson = new GroupsJson(); //просто пустой } else { groupsJson = Utils.gson.fromJson(configuration.packedGroupsJson, GroupsJson.class); } //-- if (testsJson == null) { if (configuration.packedTestsJson.isEmpty()) testsJson = new TestsJson(); //просто пустой else testsJson = Utils.gson.fromJson(configuration.packedTestsJson, TestsJson.class); } //- Vector groupsDescriptionsVector = new Vector<>(); for (GroupJson groupJson : groupsJson.array) groupsDescriptionsVector.add(groupJson.description); groupsDescriptions= String.join(";", groupsDescriptionsVector); } public int getTestsCount() { return testsJson.array.size(); } public String getGroupsDescriptions() { return groupsDescriptions; } public Vector getGroups(){ Vector groups = new Vector<>(); for (GroupJson groupJson : groupsJson.array){ if (Global.testingServer.db.groups.containsKey(groupJson.id)) groups.add(Global.testingServer.db.groups.get(groupJson.id)); } return groups; } public Vector getTests(){ Vector tests = new Vector<>(); for (TestJson testJson : testsJson.array){ if (Global.testingServer.db.tests.containsKey(testJson.id)) tests.add(Global.testingServer.db.tests.get(testJson.id)); } return tests; } }