прмежуточный. в процесе рефакторина лишних джсон. частично в разобранном виде поэтому не сливать!
This commit is contained in:
@@ -3,104 +3,35 @@ import Common.Utils.Utils_;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Json.GroupJson;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Json.GroupsJson;
|
||||
import _VisualDVM.TestingSystem.Common.Settings.Json.SettingsArrayJson;
|
||||
import _VisualDVM.TestingSystem.Common.Settings.Json.SettingsJson;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Json.TestJson;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Json.TestsJson;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class ConfigurationCache extends VisualCache {
|
||||
public GroupsJson groupsJson = null;
|
||||
public TestsJson testsJson = null;
|
||||
public int configuration_id;
|
||||
public Vector<String> groupsSummary = null;
|
||||
public int groupsOnly = 0;
|
||||
public SettingsArrayJson settingsJson = null;
|
||||
public String settingsSummary = null;
|
||||
public Vector<String> groupsSummary = null;
|
||||
//--
|
||||
public ConfigurationCache(Configuration configuration) {
|
||||
groupsSummary = new Vector<>();
|
||||
configuration_id = configuration.id;
|
||||
groupsOnly = configuration.groupsOnly;
|
||||
if (configuration.packedGroupsJson.isEmpty())
|
||||
groupsJson = new GroupsJson(); //просто пустой
|
||||
else
|
||||
groupsJson = Utils_.gson.fromJson(configuration.packedGroupsJson, GroupsJson.class);
|
||||
//--
|
||||
if (configuration.packedTestsJson.isEmpty())
|
||||
testsJson = new TestsJson(); //просто пустой
|
||||
else
|
||||
testsJson = Utils_.gson.fromJson(configuration.packedTestsJson, TestsJson.class);
|
||||
//-
|
||||
if (configuration.packedSettingsJson.isEmpty())
|
||||
settingsJson = new SettingsArrayJson(); //просто пустой
|
||||
else
|
||||
settingsJson = Utils_.gson.fromJson(configuration.packedSettingsJson, SettingsArrayJson.class);
|
||||
//-
|
||||
/*
|
||||
LinkedHashMap<String, Vector<String>> gmap = new LinkedHashMap<>();
|
||||
for (GroupJson groupJson : groupsJson.array) {
|
||||
Vector<String> vector = null;
|
||||
if (gmap.containsKey(groupJson.language)) {
|
||||
vector = gmap.get(groupJson.language);
|
||||
} else {
|
||||
vector = new Vector<>();
|
||||
gmap.put(groupJson.language, vector);
|
||||
}
|
||||
vector.add(groupJson.description);
|
||||
}
|
||||
groupsSummary = new Vector<>();
|
||||
for (String language : gmap.keySet()) {
|
||||
groupsSummary.add(language + ": " + String.join(";", gmap.get(language)));
|
||||
}
|
||||
*/
|
||||
Vector<String> settingsDescriptionsVector = new Vector<>();
|
||||
for (SettingsJson settingsJson : settingsJson.array)
|
||||
settingsDescriptionsVector.add(settingsJson.description);
|
||||
settingsSummary = String.join(";", settingsDescriptionsVector);
|
||||
}
|
||||
public int getTestsCount() {
|
||||
return getTests().size();
|
||||
// testsJson.array.size(); временно, до обновления БД.
|
||||
|
||||
}
|
||||
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<>();
|
||||
if (groupsOnly==0) {
|
||||
for (TestJson testJson : testsJson.array) {
|
||||
if (Global.testingServer.db.tests.containsKey(testJson.id))
|
||||
tests.add(Global.testingServer.db.tests.get(testJson.id));
|
||||
}
|
||||
}else {
|
||||
for (Group group: getGroups()){
|
||||
tests.addAll(Global.testingServer.db.getVectorByFK(group,Test.class));
|
||||
}
|
||||
}
|
||||
return tests;
|
||||
}
|
||||
public Vector<Test> getGroupTests(Group group) {
|
||||
Vector<Test> tests = new Vector<>();
|
||||
if (groupsOnly==0) {
|
||||
for (TestJson testJson : testsJson.array) {
|
||||
if (Global.testingServer.db.tests.containsKey(testJson.id)) {
|
||||
Test test = Global.testingServer.db.tests.get(testJson.id);
|
||||
if (test.group_id == group.id)
|
||||
tests.add(test);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return Global.testingServer.db.getVectorByFK(group, Test.class);
|
||||
}
|
||||
return tests;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user