Commit a34f2757 authored by Jörg Richter's avatar Jörg Richter

Fix: server-side cached view configs include child assocs (#192)

parent fb57c833
Pipeline #5911 passed with stages
in 3 minutes and 22 seconds
......@@ -451,6 +451,9 @@ class DMXObjectModelImpl implements DMXObjectModel {
*/
final void delete() {
try {
if (id == -1) {
throw new RuntimeException("ID not initialzed in " + this);
}
em.fireEvent(getPreDeleteEvent(), instantiate());
//
preDelete();
......
......@@ -395,7 +395,7 @@ public final class PersistenceLayer extends StorageDecorator {
void updateAssociation(AssociationModelImpl assoc, AssociationModelImpl updateModel) {
try {
checkAssociationWriteAccess(assoc.getId());
assoc.checkWriteAccess();
assoc.update(updateModel);
} catch (Exception e) {
throw new RuntimeException("Updating association " + assoc.getId() + " failed, assoc=" + assoc +
......@@ -430,7 +430,7 @@ public final class PersistenceLayer extends StorageDecorator {
void deleteAssociation(AssociationModelImpl assoc) {
try {
checkAssociationWriteAccess(assoc.getId());
assoc.checkWriteAccess();
assoc.delete();
} catch (Exception e) {
throw new RuntimeException("Deleting association " + assoc.getId() + " failed", e);
......
......@@ -692,31 +692,52 @@ class TypeStorage {
// --- Store ---
private void storeViewConfig(TypeModelImpl type) {
_storeViewConfig(newTypeRole(type.id), type.viewConfig);
ViewConfigurationModelImpl viewConfig = type.viewConfig;
TopicModel configTopic = _storeViewConfig(newTypeRole(type.id), viewConfig);
// Note: cached view config must be overridden with the "real thing". Otherwise the child assocs
// would be missing on a cold start. Subsequent migrations operating on them would fail.
if (configTopic != null) {
viewConfig.updateConfigTopic(configTopic);
}
}
void storeViewConfig(AssociationDefinitionModelImpl assocDef) {
_storeViewConfig(newAssocDefRole(assocDef.id), assocDef.viewConfig);
ViewConfigurationModelImpl viewConfig = assocDef.viewConfig;
TopicModel configTopic = _storeViewConfig(newAssocDefRole(assocDef.id), viewConfig);
// Note: cached view config must be overridden with the "real thing". Otherwise the child assocs
// would be missing on a cold start. Subsequent migrations operating on them would fail.
if (configTopic != null) {
viewConfig.updateConfigTopic(configTopic);
}
}
private void _storeViewConfig(RoleModel configurable, ViewConfigurationModelImpl viewConfig) {
/**
* @return may be null
*/
private TopicModel _storeViewConfig(RoleModel configurable, ViewConfigurationModelImpl viewConfig) {
try {
TopicModel topic = null;
for (TopicModelImpl configTopic : viewConfig.getConfigTopics()) {
storeViewConfigTopic(configurable, configTopic);
if (topic != null) {
throw new RuntimeException("DM5 does not support more than one view config topic per configurable");
}
topic = storeViewConfigTopic(configurable, configTopic);
}
return topic;
} catch (Exception e) {
throw new RuntimeException("Storing view configuration failed (configurable=" + configurable +
", viewConfig=" + viewConfig + ")", e);
}
}
void storeViewConfigTopic(RoleModel configurable, TopicModelImpl configTopic) {
pl.createTopic(configTopic);
TopicModel storeViewConfigTopic(RoleModel configurable, TopicModelImpl configTopic) {
TopicImpl topic = pl.createTopic(configTopic);
pl.createAssociation(
"dmx.core.composition",
configurable,
mf.newTopicRoleModel(configTopic.getId(), "dmx.core.child")
mf.newTopicRoleModel(configTopic.id, "dmx.core.child")
);
return topic.getModel();
}
// --- Helper ---
......
......@@ -9,7 +9,7 @@ import 'font-awesome/css/font-awesome.css'
import './element-ui'
import './websocket'
console.log('[DMX] 2019/04/26')
console.log('[DMX] 2019/04/27')
// 1) Init dm5 library
// The dm5 library must be inited *before* the dm5-webclient component is instantiated.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment