исправление бага с кешированием.

This commit is contained in:
2024-09-19 00:24:36 +03:00
parent 660a410a05
commit 54d86d6e4d
7 changed files with 25 additions and 28 deletions

5
.idea/workspace.xml generated
View File

@@ -8,7 +8,12 @@
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/UI/VisualCache/ConfigurationCache.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/VisualCache/ConfigurationCache.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/UI/VisualCache/VisualCaches.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/VisualCache/VisualCaches.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/SaveCurrentConfiguration.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/SaveCurrentConfiguration.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Server/DeleteServerObject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Server/DeleteServerObject.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Server/DeleteServerObjects.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Server/DeleteServerObjects.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Server/EditServerObject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/Server/EditServerObject.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -16,14 +16,10 @@ public class ConfigurationCache extends VisualCache{
public TestsJson testsJson = null;
//--
public ConfigurationCache(Configuration configuration) {
// System.out.println("configuration cache new instance for "+configuration.id);
// System.out.println("packageGroupsJson="+Utils.Brackets(configuration.packedGroupsJson));
if (configuration.packedGroupsJson.isEmpty()) {
// System.out.println("empty");
groupsJson = new GroupsJson(); //просто пустой
}
else {
// System.out.println("not empty");
groupsJson = Utils.gson.fromJson(configuration.packedGroupsJson, GroupsJson.class);
}
//--

View File

@@ -38,11 +38,22 @@ public class VisualCaches {
}
return res;
}
//Принудительно удалить старый и записать новый.
public static void RefreshCache(DBObject object){
// System.out.println("refresh cache for " + object.getPK()+" "+object.getClass().getSimpleName());
LinkedHashMap<Object, VisualCache> data = getDataForClass(object.getClass());
//--
if (data.containsKey(object.getPK())) {
data.remove(object.getPK());
}
data.put(object.getPK(), createCache(object));
}
public static void DeleteCache(DBObject object){
DeleteCache(object.getClass(), object.getPK());
}
public static void DeleteCache(Class class_, Object pk){
// System.out.println("Delete for " + pk+" "+class_);
// System.out.println("Delete cache for " + pk+" "+class_);
LinkedHashMap<Object, VisualCache> data = getDataForClass(class_);
if (data.containsKey(pk))
data.remove(pk);

View File

@@ -1,6 +1,7 @@
package Visual_DVM_2021.Passes;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.UI.VisualCache.ConfigurationCache;
import Common.UI.VisualCache.VisualCaches;
import Common.Utils.Utils;
@@ -45,8 +46,5 @@ public abstract class SaveCurrentConfiguration<C extends Configuration> extends
target.saveTestsAsJson(tests);
//--
super.ServerAction();
//--
// ConfigurationCache cache = (ConfigurationCache) VisualCaches.GetCache(target);
// System.out.println(Utils.Brackets(cache.groupsDescriptions));
}
}

View File

@@ -12,11 +12,6 @@ public class DeleteServerObject<S extends RepositoryServer, D extends DBObject>
target = (D) getDb().tables.get(d).getCurrent();
return getDb().tables.get(d).CheckCurrent(Log) && getDb().tables.get(d).ShowDeleteObjectDialog(target);
}
@Override
protected void performPreparation() throws Exception {
super.performPreparation();
VisualCaches.DeleteCache(target);
}
//Очищаем все связанные таблицы, чтобы не допустить перерисовки во время удаления объекта.
@Override
protected void showPreparation() throws Exception {
@@ -38,6 +33,7 @@ public class DeleteServerObject<S extends RepositoryServer, D extends DBObject>
@Override
protected void ServerAction() throws Exception {
DeleteObject(target);
VisualCaches.DeleteCache(target);
}
@Override
protected void showDone() throws Exception {

View File

@@ -48,13 +48,6 @@ public class DeleteServerObjects <S extends RepositoryServer, D extends DBObject
return false;
}
}
@Override
protected void performPreparation() throws Exception {
super.performPreparation();
for (Object key: target){
VisualCaches.DeleteCache(d, key);
}
}
//Очищаем все связанные таблицы, чтобы не допустить перерисовки во время удаления объекта.
@Override
protected void showPreparation() throws Exception {
@@ -78,5 +71,8 @@ public class DeleteServerObjects <S extends RepositoryServer, D extends DBObject
protected void performFinish() throws Exception {
super.performFinish();
passes.get(getDb().getSynchronizePassCode()).Do();
for (Object key: target){
VisualCaches.DeleteCache(d, key);
}
}
}

View File

@@ -14,12 +14,6 @@ public class EditServerObject<S extends RepositoryServer, D extends DBObject> ex
target = (D) getDb().tables.get(d).getCurrent();
return getDb().tables.get(d).CheckCurrent(Log) && getDb().tables.get(d).ShowEditObjectDialog(target);
}
@Override
protected void performPreparation() throws Exception {
super.performPreparation();
//очистить кэш.
VisualCaches.DeleteCache(target);
}
//--
public EditServerObject(S server_in, Class<D> d_in) {
super(server_in, d_in);
@@ -31,6 +25,7 @@ public class EditServerObject<S extends RepositoryServer, D extends DBObject> ex
}
@Override
protected void showDone() throws Exception {
VisualCaches.RefreshCache(target);
getDb().tables.get(d).ui_.Show(target.getPK());
}
}