private boolean isSynchronizedConnector(ReadGraph graph, Resource templateConnection, Resource instanceConnector) throws DatabaseException {\r
DiagramResource DIA = DiagramResource.getInstance(graph);\r
Resource instanceConnection = graph.getPossibleObject(instanceConnector, DIA.IsConnectorOf);\r
- return graph.hasStatement(instanceConnection, MOD.HasElementSource, templateConnection);\r
+ return graph.hasStatement(instanceConnection, MOD.HasElementSource, templateConnection)\r
+ // If the master connection has been removed, this is all that's left\r
+ // to identify a connection that at least was originally synchronized\r
+ // from the typical master to this instance.\r
+ || graph.hasStatement(instanceConnection, MOD.IsTemplatized);\r
}\r
\r
/**\r
\r
// Perform changes\r
boolean changed = false;\r
+ changed |= synchronizeDiagramChanges(graph, info, template, instance);\r
changed |= removeElements(graph, info, instanceElementsRemovedFromTemplate);\r
changed |= addMissingElements(graph, info, template, instance, templateElementsAddedToTemplate);\r
changed |= synchronizeChangedElements(graph, info, template, instance, changedTemplateElements, templateElementsAddedToTemplate, changedElementsByDiagram == ALL);\r
metadata.addTypical(instance);\r
}\r
\r
+ /**\r
+ * Synchronize any configurable aspects of the typical diagram instance itself.\r
+ * Every rule executed here comes from the ontology, nothing is fixed. \r
+ * \r
+ * @param graph\r
+ * @param typicalInfo\r
+ * @param template\r
+ * @param instance\r
+ * @return if any changes were made. \r
+ * @throws DatabaseException\r
+ */\r
+ private boolean synchronizeDiagramChanges(\r
+ WriteGraph graph,\r
+ TypicalInfo typicalInfo,\r
+ Resource template,\r
+ Resource instance)\r
+ throws DatabaseException\r
+ {\r
+ boolean changed = false;\r
+ for (Resource rule : graph.getObjects(template, MOD.HasTypicalSynchronizationRule)) {\r
+ if (selectedRules != null && !selectedRules.contains(rule))\r
+ continue;\r
+ ITypicalSynchronizationRule r = graph.getPossibleAdapter(rule, ITypicalSynchronizationRule.class);\r
+ if (r != null)\r
+ changed |= r.synchronize(graph, template, instance, typicalInfo);\r
+ }\r
+ return changed;\r
+ }\r
+\r
/**\r
* Add elements from template that do not yet exist in the instance.\r
* \r