package org.simantics.issues.common;
+import java.util.Collections;
import java.util.List;
import org.simantics.databoard.Bindings;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.common.request.PossibleIndexRoot;
+import org.simantics.db.common.utils.ListUtils;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.layer0.variable.Variables;
}
}
- @SCLValue(type = "ReadGraph -> Resource -> Variable -> [Resource]")
- public static List<Resource> standardIssueContexts(ReadGraph graph, Resource converter, Variable property) throws DatabaseException {
- return IssueUtils.getContextsForProperty(graph, property);
+ @SCLValue(type = "ReadGraph -> Resource -> a -> [Resource]")
+ public static List<Resource> standardIssueContexts(ReadGraph graph, Resource converter, Object property) throws DatabaseException {
+ if (property instanceof Variable) {
+ return IssueUtils.getContextsForProperty(graph, (Variable) property);
+ } else if (property instanceof Resource) {
+ Resource issue = (Resource) property;
+ IssueResource ISSUE = IssueResource.getInstance(graph);
+ Resource list = graph.getPossibleObject(issue, ISSUE.Issue_HasContexts);
+ if(list != null)
+ return ListUtils.toList(graph, list);
+ else
+ return Collections.emptyList();
+ }
+ throw new IllegalArgumentException("Unsupported property type: " + property);
}
}