подправил кеширование отображаемых данных ( чтобы не распаковывать каждый раз список имен групп и прочее)

This commit is contained in:
2024-09-18 13:37:11 +03:00
parent f55a3a6324
commit 0cef474233
18 changed files with 181 additions and 85 deletions

View File

@@ -0,0 +1,57 @@
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 Vector<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);
}
//-
groupsDescriptions = new Vector<>();
for (GroupJson groupJson : groupsJson.array)
groupsDescriptions.add(groupJson.description);
}
public int getTestsCount() {
return testsJson.array.size();
}
public Vector<String> getGroupsDescriptions() {
return groupsDescriptions;
}
public Vector<Group> getGroups(){
Vector<Group> 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<Test> getTests(){
Vector<Test> 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;
}
}