-
- private static Resource findElement(ReadGraph graph, Resource issue) throws DatabaseException {
-
- IssueResource ISSUE = IssueResource.getInstance(graph);
- DiagramResource DIA = DiagramResource.getInstance(graph);
-
- if(!graph.isInstanceOf(issue, ISSUE.Issue)) return null;
-
- Resource list = graph.getSingleObject(issue, ISSUE.Issue_HasContexts);
- for(Resource context : ListUtils.toList(graph, list)) {
- if(graph.isInstanceOf(context, DIA.Element) && !graph.isInstanceOf(context, DIA.Diagram)) {
- return context;
- }
-
- }
-
- return null;
-
+
+ protected static Pair<Resource, Collection<Object>> findConfigurationAndObjects(ReadGraph graph, Variable v) throws DatabaseException {
+ List<Resource> contexts = v.getPossiblePropertyValue(graph, IssueResource.getInstance(graph).Issue_contexts);
+ return contexts != null ? findConfigurationAndObjects(graph, contexts) : null;
+ }
+
+ protected static Pair<Resource, Collection<Object>> findConfigurationAndObjects(ReadGraph graph, List<Resource> contexts) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ StructuralResource2 STR = StructuralResource2.getInstance(graph);
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+
+ for(Resource context : contexts) {
+ Set<Resource> types = graph.getTypes(context);
+ if (types.contains(DIA.Element)) {
+ Resource config = findConfigurationForElement(graph, context);
+ if (config != null) {
+ Collection<Object> elements = Collections.<Object>singleton(context);
+ return Pair.make(config, elements);
+ }
+ } else if (types.contains(STR.Component) && !types.contains(STR.Composite)) {
+ Resource config = graph.getPossibleObject(context, L0.PartOf);
+ if (config != null) {
+ return Pair.make(config, findElementObjects(graph, context));
+ }
+ } else if (types.contains(STR.Connection)) {
+ Resource element = graph.getPossibleObject(context, MOD.ConnectionToDiagramConnection);
+ if (element != null) {
+ Resource config = findConfigurationForElement(graph, element);
+ if (config != null) {
+ return Pair.make(config, Collections.<Object>singleton(element));
+ }
+ }
+ }
+ }
+
+ return null;