import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import org.simantics.databoard.Bindings;
Pair.make(Dependencies.FIELD_TYPES, "Text"),
Pair.make(Dependencies.FIELD_GUID, "Text"),
Pair.make(Dependencies.FIELD_NAME_SEARCH, "Text"),
- Pair.make(Dependencies.FIELD_TYPES_SEARCH, "Text")
+ Pair.make(Dependencies.FIELD_TYPES_SEARCH, "Text"),
+ Pair.make(Dependencies.FIELD_TYPE_RESOURCE, "Text")
};
final Resource resource;
});
- Map<Resource, String> typeStrings = cs.createMap(String.class);
+ Map<Resource, Pair<String, String>> typeStrings = cs.createMap(String.class);
for(Entry e : result) {
if(e.principalType != null) {
- String typeString = typeStrings.get(e.principalType);
- if(typeString == null) {
- typeString = graph.syncRequest(new SuperTypeString(e.principalType));
- if (typeString.isEmpty()) {
- LOGGER.error("No name for type", new DatabaseException("No name for type " + NameUtils.getURIOrSafeNameInternal(graph, e.resource) + " (" + e.resource + ")"));
- }
- typeStrings.put(e.principalType, typeString);
- }
- e.types = typeString;
+ Pair<String, String> typeString = typeStrings.get(e.principalType);
+ if(typeString == null) {
+ String superTypeString = graph.syncRequest(new SuperTypeString(e.principalType));
+ if (superTypeString.isEmpty()) {
+ LOGGER.error("No name for type", new DatabaseException("No name for type " + NameUtils.getURIOrSafeNameInternal(graph, e.resource) + " (" + e.resource + ")"));
+ }
+ String superTypeIds = IndexQueries.toResourceIdString(e.principalType, graph.getSupertypes(e.principalType));
+ typeString = Pair.make(superTypeString, superTypeIds);
+ typeStrings.put(e.principalType, typeString);
+ }
+ e.types = typeString.first;
+ e.typeId = typeString.second;
} else {
- e.types = graph.syncRequest(new TypeString(L0, graph.getTypes(e.resource)));
+ Set<Resource> typeSet = graph.getTypes(e.resource);
+ e.types = graph.syncRequest(new TypeString(L0, typeSet));
+ e.typeId = IndexQueries.toResourceIdString(typeSet);
}
- GUID id = graph.getPossibleRelatedValue(e.resource, L0.identifier, GUID.BINDING);
- if(id != null)
- e.id = id.indexString();
- else
- e.id = "";
+ e.id = IndexQueries.idFromGUID( graph.getPossibleRelatedValue(e.resource, L0.identifier, GUID.BINDING) );
}
//SessionGarbageCollection.gc(null, graph.getSession(), false, null);
-
+
}
}
long time = System.nanoTime();
- SerialisationSupport ss = graph.getService(SerialisationSupport.class);
+ SerialisationSupport ss = graph.getService(SerialisationSupport.class);
Resource subject = ss.getResource(subjectId);
-
+
Collection<Entry> entries = find(graph, subject);
long time2 = System.nanoTime();
if (PROFILE)
System.out.println("Found " + entries.size() + " dependencies in " + 1e-6 * (time2 - time) + "ms for " + graph.getPossibleURI(subject) + ".");
- ArrayList<Object[]> result = new ArrayList<Object[]>();
+ ArrayList<Object[]> result = new ArrayList<>();
for (Entry entry : entries) {
- result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id, entry.name, entry.types });
+ result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id, entry.name, entry.types, entry.typeId });
}
return result;
if (modifiedComponent == null
|| modifiedComponent.getPredicate().equals(changeInformation))
continue;
- //System.err.println("+comp modi " + NameUtils.getSafeName(graph, renamedComponent, true));
+ //System.err.println("+comp modi " + NameUtils.getSafeName(graph, modifiedComponent.getObject(), true));
w.addComponentModification(modifiedComponent.getObject());
}
for (Resource value : parameter.changedResources()) {
@Override
public synchronized void trackAndIndex(RequestProcessor processor, Resource model__) {
- if(trackers == 0) {
+ if(trackers == 0) {
- if(listener != null) throw new IllegalStateException("Dependency tracking was active");
-
- listener = new GenericChangeListener<DependencyChangesRequest, DependencyChanges>() {
-
- @Override
- public boolean preEventRequest() {
- return !Indexing.isDependenciesIndexingDisabled();
- }
-
- @Override
- public void onEvent(ReadGraph graph, MetadataI metadata, DependencyChanges event) throws DatabaseException {
-
- TimeLogger.log(DependenciesRelation.class, "trackAndIndex.onEvent: starting index update processing");
-
- if(DEBUG)
- System.err.println("Adding metadata " + event + " in revision " + graph.getService(ManagementSupport.class).getHeadRevisionId());
-
- WriteGraph w = (WriteGraph)graph;
- if(!event.isEmpty())
- w.addMetadata(event);
-
- final Session session = graph.getSession();
- final IndexedRelations indexer = session.getService(IndexedRelations.class);
- Layer0 L0 = Layer0.getInstance(graph);
- SerialisationSupport ss = graph.getService(SerialisationSupport.class);
-
- for(Map.Entry<Resource, Change[]> modelEntry : event.get().entrySet()) {
-
- final Resource model = modelEntry.getKey();
- final Change[] changes = modelEntry.getValue();
-
- boolean linkChange = false;
-
- Collection<Object[]> _additions = Collections.emptyList();
- Collection<Object> _removals = Collections.emptyList();
- Collection<Object> _replacementKeys = Collections.emptyList();
- Collection<Object[]> _replacementObjects = Collections.emptyList();
- Collection<Pair<String, String>> _typeChanges = Collections.emptyList();
-
- if(DEBUG) System.out.println("MODEL: " + NameUtils.getSafeLabel(graph, model));
- // final Change[] changes = event.get(model);
- if(DEBUG) System.out.println(" CHANGES: " + Arrays.toString(changes));
- if (changes != null) {
- _additions = new ArrayList<Object[]>();
- _removals = new ArrayList<Object>();
- _replacementKeys = new ArrayList<Object>();
- _replacementObjects = new ArrayList<Object[]>();
- _typeChanges = new HashSet<Pair<String, String>>();
-
- for (Change _entry : changes) {
- if (_entry instanceof ComponentAddition) {
- ComponentAddition entry = (ComponentAddition)_entry;
- final String name = graph.getPossibleRelatedValue(entry.component, L0.HasName, Bindings.STRING);
- final GUID id = graph.getPossibleRelatedValue(entry.component, L0.identifier, GUID.BINDING);
- final String types = graph.syncRequest(new TypeString(L0, graph.getTypes(entry.component)));
- if (name != null && types != null) {
- if(!entry.isValid(graph)) continue;
- Resource parent = graph.getPossibleObject(entry.component, L0.PartOf);
- if (parent != null) {
- _additions.add(new Object[] { ss.getRandomAccessId(parent), ss.getRandomAccessId(entry.component), name, types, id != null ? id.indexString() : "", name, types});
- } else {
- //System.err.println("resource " + entry.component + ": no parent for entry " + name + " " + types);
- }
- } else {
- //System.err.println("resource " + entry.component + ": " + name + " " + types);
- }
- } else if(_entry instanceof ComponentModification) {
- ComponentModification entry = (ComponentModification)_entry;
- final String name = graph.getPossibleRelatedValue(entry.component, L0.HasName, Bindings.STRING);
- final GUID id = graph.getPossibleRelatedValue(entry.component, L0.identifier, GUID.BINDING);
- if(graph.isInstanceOf(entry.component, L0.Type)) {
- SerialisationSupport support = session.getService(SerialisationSupport.class);
- _typeChanges.add(new Pair<String, String>(name, String.valueOf(support.getRandomAccessId((Resource) entry.component))));
- } else {
- final String types = graph.syncRequest(new TypeString(L0, graph.getTypes(entry.component)));
- if (name != null && types != null) {
- Resource part = graph.getPossibleObject(entry.component, L0.PartOf);
- if(part != null) {
- _replacementKeys.add(ss.getRandomAccessId(entry.component));
- _replacementObjects.add(new Object[] { ss.getRandomAccessId(part),
- ss.getRandomAccessId(entry.component), name, types, id != null ? id.indexString() : "", name, types});
- }
- }
- }
- } else if (_entry instanceof ComponentRemoval) {
- ComponentRemoval entry = (ComponentRemoval)_entry;
- if(!entry.isValid(graph)) continue;
- _removals.add(ss.getRandomAccessId(((ComponentRemoval)_entry).component));
- } else if (_entry instanceof LinkChange) {
- linkChange = true;
- }
- }
- }
-
- final boolean reset = linkChange || event.hasUnresolved;
- //System.err.println("dependencies(" + NameUtils.getSafeLabel(graph, model) + "): reset=" + reset + " linkChange=" + linkChange + " unresolved=" + event.hasUnresolved );
-
- if (reset || !_additions.isEmpty() || !_removals.isEmpty() || !_replacementKeys.isEmpty() || !_typeChanges.isEmpty()) {
-
- TimeLogger.log(DependenciesRelation.class, "trackAndIndex.onEvent: starting index update");
-
- final Collection<Object[]> additions = _additions;
- final Collection<Object> removals = _removals;
- final Collection<Object> replacementKeys = _replacementKeys;
- final Collection<Object[]> replacementObjects = _replacementObjects;
- final boolean typeNameChanges = typeNameChanges(graph, indexer, model, _typeChanges);
-
- final UUID pending = Indexing.makeIndexPending();
-
- {
- {
- try {
- boolean didChange = false;
- // Unresolved and linkChanges are not relevant any more
- boolean doReset = typeNameChanges;
-
- if (doReset) {
-
- if(DEBUG) {
- System.err.println("resetIndex " + reset + " " + typeNameChanges);
- }
-
- indexer.removeAll(null, graph, DependenciesRelation.this, resource, model);
- didChange = true;
-
- } else {
-
- if (!replacementKeys.isEmpty() && (replacementKeys.size() == replacementObjects.size())) {
- if(DEBUG) {
- System.out.println(replacementKeys.size() + " index replacements: " + replacementKeys);
- }
- didChange |= indexer.replace(null, graph, DependenciesRelation.this, resource, model, Dependencies.FIELD_RESOURCE, replacementKeys, replacementObjects);
- }
- if (!removals.isEmpty()) {
- if(DEBUG) {
- System.out.println(removals.size() + " index removals: " + removals);
- }
- indexer.remove(null, graph, DependenciesRelation.this, resource, model, Dependencies.FIELD_RESOURCE, removals);
- didChange = true;
- }
- if (!additions.isEmpty()) {
- if(DEBUG) {
- for(Object[] os : additions) System.err.println("Adding to index " + model + ": " + Arrays.toString(os));
- }
- //System.out.println(additions.size() + " index insertions");
- indexer.insert(null, graph, DependenciesRelation.this, resource, model, additions);
- didChange = true;
- }
-
- }
-
- if (didChange)
- // TODO: because this data is ran with
- // ThreadUtils.getBlockingWorkExecutor()
- // fireListeners needs to use peekService,
- // not getService since there is no
- // guarantee that the session isn't being
- // disposed while this method is executing.
- fireListeners(graph, model);
-
- } catch (Throwable t) {
- // Just to know if something unexpected happens here.
- LOGGER.error("Dependencies index update failed for model "
- + model + " and relation " + resource + ".", t);
-
- // NOTE: Last resort: failure to update index
- // properly results in removal of the whole index.
- // This is the only thing that can be done
- // at this point to ensure that the index will
- // return correct results in the future, through
- // complete reinitialization.
- //indexer.removeAll(null, session, DependenciesRelation.this, resource, model);
- } finally {
- Indexing.releaseIndexPending(pending);
- Indexing.clearCaches(model);
- }
- }
- }
-
- TimeLogger.log(DependenciesRelation.class, "trackAndIndex.onEvent: index update done");
- }
- }
-
- }
-
- };
+ if(listener != null) throw new IllegalStateException("Dependency tracking was active");
- GraphChangeListenerSupport changeSupport = processor.getService(GraphChangeListenerSupport.class);
- changeSupport.addMetadataListener(listener);
+ listener = new GenericChangeListener<DependencyChangesRequest, DependencyChanges>() {
- }
+ @Override
+ public boolean preEventRequest() {
+ return !Indexing.isDependenciesIndexingDisabled();
+ }
+
+ @Override
+ public void onEvent(ReadGraph graph, MetadataI metadata, DependencyChanges event) throws DatabaseException {
+
+ TimeLogger.log(DependenciesRelation.class, "trackAndIndex.onEvent: starting index update processing");
+
+ if(DEBUG)
+ System.err.println("Adding metadata " + event + " in revision " + graph.getService(ManagementSupport.class).getHeadRevisionId());
+
+ WriteGraph w = (WriteGraph)graph;
+ if(!event.isEmpty())
+ w.addMetadata(event);
+
+ final Session session = graph.getSession();
+ final IndexedRelations indexer = session.getService(IndexedRelations.class);
+ Layer0 L0 = Layer0.getInstance(graph);
+ SerialisationSupport ss = graph.getService(SerialisationSupport.class);
+
+ for(Map.Entry<Resource, Change[]> modelEntry : event.get().entrySet()) {
+
+ final Resource model = modelEntry.getKey();
+ final Change[] changes = modelEntry.getValue();
+
+ boolean linkChange = false;
+
+ Collection<Object[]> _additions = Collections.emptyList();
+ Collection<Object> _removals = Collections.emptyList();
+ Collection<Object> _replacementKeys = Collections.emptyList();
+ Collection<Object[]> _replacementObjects = Collections.emptyList();
+ Collection<Pair<String, String>> _typeChanges = Collections.emptyList();
+
+ if(DEBUG) System.out.println("MODEL: " + NameUtils.getSafeLabel(graph, model));
+ if (changes != null) {
+ if (DEBUG) {
+ System.out.println(" CHANGE COUNT: " + changes.length);
+ for (Change c : changes)
+ System.out.println(" CHANGE: " + c.toString(graph));
+ }
+ _additions = new ArrayList<>();
+ _removals = new ArrayList<>();
+ _replacementKeys = new ArrayList<>();
+ _replacementObjects = new ArrayList<>();
+ _typeChanges = new HashSet<>();
+
+ for (Change _entry : changes) {
+ if (_entry instanceof ComponentAddition) {
+ ComponentAddition entry = (ComponentAddition)_entry;
+ final String name = graph.getPossibleRelatedValue(entry.component, L0.HasName, Bindings.STRING);
+ Set<Resource> typeSet = graph.getTypes(entry.component);
+ if (name != null && typeSet != null) {
+ if (!entry.isValid(graph))
+ continue;
+ Resource parent = graph.getPossibleObject(entry.component, L0.PartOf);
+ if (parent != null) {
+ final GUID id = graph.getPossibleRelatedValue(entry.component, L0.identifier, GUID.BINDING);
+ final String types = graph.syncRequest(new TypeString(L0, typeSet));
+ final String typeIds = IndexQueries.toResourceIdString(typeSet);
+ _additions.add(new Object[] { ss.getRandomAccessId(parent), ss.getRandomAccessId(entry.component), name, types, IndexQueries.idFromGUID(id), name, types, typeIds});
+ } else {
+ //System.err.println("resource " + entry.component + ": no parent for entry " + name + " " + types);
+ }
+ } else {
+ //System.err.println("resource " + entry.component + ": " + name + " " + types);
+ }
+ } else if(_entry instanceof ComponentModification) {
+ ComponentModification entry = (ComponentModification)_entry;
+ final String name = graph.getPossibleRelatedValue(entry.component, L0.HasName, Bindings.STRING);
+ if(graph.isInstanceOf(entry.component, L0.Type)) {
+ SerialisationSupport support = session.getService(SerialisationSupport.class);
+ _typeChanges.add(new Pair<String, String>(name, String.valueOf(support.getRandomAccessId((Resource) entry.component))));
+ } else {
+ Set<Resource> typeSet = graph.getTypes(entry.component);
+ if (name != null && !typeSet.isEmpty()) {
+ Resource part = graph.getPossibleObject(entry.component, L0.PartOf);
+ if(part != null) {
+ final GUID id = graph.getPossibleRelatedValue(entry.component, L0.identifier, GUID.BINDING);
+ final String types = graph.syncRequest(new TypeString(L0, typeSet));
+ final String typeIds = IndexQueries.toResourceIdString(typeSet);
+ _replacementKeys.add(ss.getRandomAccessId(entry.component));
+ _replacementObjects.add(new Object[] { ss.getRandomAccessId(part),
+ ss.getRandomAccessId(entry.component), name, types, IndexQueries.idFromGUID(id), name, types, typeIds});
+ }
+ }
+ }
+ } else if (_entry instanceof ComponentRemoval) {
+ ComponentRemoval entry = (ComponentRemoval)_entry;
+ if(!entry.isValid(graph)) continue;
+ _removals.add(ss.getRandomAccessId(((ComponentRemoval)_entry).component));
+ } else if (_entry instanceof LinkChange) {
+ linkChange = true;
+ }
+ }
+ }
+
+ final boolean reset = linkChange || event.hasUnresolved;
+ //System.err.println("dependencies(" + NameUtils.getSafeLabel(graph, model) + "): reset=" + reset + " linkChange=" + linkChange + " unresolved=" + event.hasUnresolved );
+
+ if (reset || !_additions.isEmpty() || !_removals.isEmpty() || !_replacementKeys.isEmpty() || !_typeChanges.isEmpty()) {
+
+ TimeLogger.log(DependenciesRelation.class, "trackAndIndex.onEvent: starting index update");
+
+ final Collection<Object[]> additions = _additions;
+ final Collection<Object> removals = _removals;
+ final Collection<Object> replacementKeys = _replacementKeys;
+ final Collection<Object[]> replacementObjects = _replacementObjects;
+ final boolean typeNameChanges = typeNameChanges(graph, indexer, model, _typeChanges);
+
+ final UUID pending = Indexing.makeIndexPending();
+ try {
+ boolean didChange = false;
+ // Unresolved and linkChanges are not relevant any more
+ boolean doReset = typeNameChanges;
+
+ if (doReset) {
+
+ if(DEBUG) {
+ System.err.println("resetIndex " + reset + " " + typeNameChanges);
+ }
+
+ indexer.removeAll(null, graph, DependenciesRelation.this, resource, model);
+ didChange = true;
+
+ } else {
+
+ if (!replacementKeys.isEmpty() && (replacementKeys.size() == replacementObjects.size())) {
+ if(DEBUG) {
+ System.out.println(replacementKeys.size() + " index replacements: " + replacementKeys);
+ }
+ didChange |= indexer.replace(null, graph, DependenciesRelation.this, resource, model, Dependencies.FIELD_RESOURCE, replacementKeys, replacementObjects);
+ }
+ if (!removals.isEmpty()) {
+ if(DEBUG) {
+ System.out.println(removals.size() + " index removals: " + removals);
+ }
+ indexer.remove(null, graph, DependenciesRelation.this, resource, model, Dependencies.FIELD_RESOURCE, removals);
+ didChange = true;
+ }
+ if (!additions.isEmpty()) {
+ if(DEBUG) {
+ for(Object[] os : additions) System.err.println("Adding to index " + model + ": " + Arrays.toString(os));
+ }
+ //System.out.println(additions.size() + " index insertions");
+ indexer.insert(null, graph, DependenciesRelation.this, resource, model, additions);
+ didChange = true;
+ }
+
+ }
+
+ if (didChange)
+ // TODO: because this data is ran with
+ // ThreadUtils.getBlockingWorkExecutor()
+ // fireListeners needs to use peekService,
+ // not getService since there is no
+ // guarantee that the session isn't being
+ // disposed while this method is executing.
+ fireListeners(graph, model);
+
+ } catch (Throwable t) {
+ // Just to know if something unexpected happens here.
+ LOGGER.error("Dependencies index update failed for model "
+ + model + " and relation " + resource + ".", t);
+
+ // NOTE: Last resort: failure to update index
+ // properly results in removal of the whole index.
+ // This is the only thing that can be done
+ // at this point to ensure that the index will
+ // return correct results in the future, through
+ // complete reinitialization.
+ //indexer.removeAll(null, session, DependenciesRelation.this, resource, model);
+ } finally {
+ Indexing.releaseIndexPending(pending);
+ Indexing.clearCaches(model);
+ }
+
+ TimeLogger.log(DependenciesRelation.class, "trackAndIndex.onEvent: index update done");
+ }
+ }
- trackers++;
+ }
+
+ };
+
+ GraphChangeListenerSupport changeSupport = processor.getService(GraphChangeListenerSupport.class);
+ changeSupport.addMetadataListener(listener);
+
+ }
+
+ trackers++;
}
}
public static void addSubtree(ReadGraph graph, Resource indexRoot, Resource subtreeRoot) throws DatabaseException {
-
+
DependenciesRelation dr = new DependenciesRelation(graph, indexRoot);
- SerialisationSupport ss = graph.getService(SerialisationSupport.class);
+ SerialisationSupport ss = graph.getService(SerialisationSupport.class);
- ArrayList<Entry> entries = dr.find(graph, subtreeRoot);
- entries.add(new Entry(graph, subtreeRoot));
+ ArrayList<Entry> entries = dr.find(graph, subtreeRoot);
+ entries.add(new Entry(graph, subtreeRoot));
ArrayList<Object[]> result = new ArrayList<Object[]>(entries.size());
for (Entry entry : entries) {
- result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id, entry.name, entry.types });
+ result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id, entry.name, entry.types, entry.typeId });
}
Layer0X L0X = Layer0X.getInstance(graph);
- IndexedRelations indexer = graph.getService(IndexedRelations.class);
- indexer.insert(null, graph, dr, L0X.DependenciesRelation, indexRoot, result);
-
+ IndexedRelations indexer = graph.getService(IndexedRelations.class);
+ indexer.insert(null, graph, dr, L0X.DependenciesRelation, indexRoot, result);
+
}
-
+
}
*******************************************************************************/
package org.simantics.modeling.adapters;
-import gnu.trove.set.hash.THashSet;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.simantics.databoard.Bindings;
import org.simantics.db.common.request.PossibleObjectWithType;
import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.QueryIndexUtils;
import org.simantics.db.layer0.exception.VariableException;
-import org.simantics.db.layer0.genericrelation.IndexQueries;
import org.simantics.db.layer0.request.PossibleModel;
import org.simantics.db.layer0.variable.RVI;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.layer0.Layer0;
import org.simantics.modeling.ModelingResources;
-import org.simantics.operation.Layer0X;
-import org.simantics.scl.runtime.function.Function;
import org.simantics.structural.stubs.StructuralResource2;
import org.simantics.utils.ui.ErrorLogger;
+import gnu.trove.set.hash.THashSet;
+
/**
* @author Tuukka Lehtonen
*/
return;
NamedResource namedRoot = new NamedResource(rootName, root);
- @SuppressWarnings("rawtypes")
- Function modules = graph.adapt(Layer0X.getInstance(graph).Dependencies, Function.class);
- @SuppressWarnings("unchecked")
- List<Map<String, Object>> rows = (List<Map<String, Object>>) modules.apply(graph, root, "Types:" + IndexQueries.quoteTerm(result.componentType.getName()));
- if (rows.isEmpty())
+ List<Resource> components = QueryIndexUtils.searchByTypeShallow(graph, root, result.componentType.getResource());
+ if (components.isEmpty())
return;
ModelingResources MOD = ModelingResources.getInstance(graph);
StructuralResource2 STR = StructuralResource2.getInstance(graph);
- for (Map<String, Object> row : rows) {
- Resource component = (Resource) row.get("Resource");
- if (graph.isInstanceOf(component, result.componentType.getResource())) {
- String componentName = graph.getPossibleRelatedValue(component, L0.HasName, Bindings.STRING);
- next_connection:
- for (Resource connection : graph.getObjects(component, connectionRelation)) {
- if (graph.isInstanceOf(connection, STR.Connection)) {
-
- if (diagramConnectionRelation != null) {
- // When diagram connection relation is defined, validate that
- // exactly the specified diagram connection relation is being
- // used and not some other relation from another symbol.
- for (Resource element : graph.getObjects(component, MOD.ComponentToElement)) {
- for (Resource diagramConnector : graph.getObjects(element, diagramConnectionRelation)) {
- Resource diagramConnection = ConnectionUtil.tryGetConnection(graph, diagramConnector);
- if (diagramConnection == null)
- continue;
- Resource correspondingConnection = graph.getPossibleObject(diagramConnection, MOD.DiagramConnectionToConnection);
- Resource correspondingConnectionSpecial = graph.getPossibleObject(diagramConnection, MOD.DiagramConnectionToConnectionSpecial);
- if (connection.equals(correspondingConnection) || connection.equals(correspondingConnectionSpecial)) {
- addUse(graph, component, componentName, namedRoot, rootURI, result);
- continue next_connection;
- }
+ for (Resource component : components) {
+ String componentName = graph.getPossibleRelatedValue(component, L0.HasName, Bindings.STRING);
+ next_connection:
+ for (Resource connection : graph.getObjects(component, connectionRelation)) {
+ if (graph.isInstanceOf(connection, STR.Connection)) {
+
+ if (diagramConnectionRelation != null) {
+ // When diagram connection relation is defined, validate that
+ // exactly the specified diagram connection relation is being
+ // used and not some other relation from another symbol.
+ for (Resource element : graph.getObjects(component, MOD.ComponentToElement)) {
+ for (Resource diagramConnector : graph.getObjects(element, diagramConnectionRelation)) {
+ Resource diagramConnection = ConnectionUtil.tryGetConnection(graph, diagramConnector);
+ if (diagramConnection == null)
+ continue;
+ Resource correspondingConnection = graph.getPossibleObject(diagramConnection, MOD.DiagramConnectionToConnection);
+ Resource correspondingConnectionSpecial = graph.getPossibleObject(diagramConnection, MOD.DiagramConnectionToConnectionSpecial);
+ if (connection.equals(correspondingConnection) || connection.equals(correspondingConnectionSpecial)) {
+ addUse(graph, component, componentName, namedRoot, rootURI, result);
+ continue next_connection;
}
}
- } else {
- addUse(graph, component, componentName, namedRoot, rootURI, result);
}
+ } else {
+ addUse(graph, component, componentName, namedRoot, rootURI, result);
}
-
}
- }
+ }
}
}