From: Tuukka Lehtonen Date: Fri, 3 Mar 2017 12:43:11 +0000 (+0200) Subject: Support also Resource inputs in standardIssueContexts property function X-Git-Tag: v1.28.0~73 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=894991ee53490cb8e28dd48b0da686203411324a;p=simantics%2Fplatform.git Support also Resource inputs in standardIssueContexts property function Previous version only supported Variables. refs #7064 Change-Id: If309d7c3d6c8d0b270a8344d3abaf9061e92da31 --- diff --git a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/All.java b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/All.java index 9173101ee..d2120cd78 100644 --- a/bundles/org.simantics.issues.common/src/org/simantics/issues/common/All.java +++ b/bundles/org.simantics.issues.common/src/org/simantics/issues/common/All.java @@ -1,11 +1,13 @@ 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; @@ -77,9 +79,20 @@ public class All { } } - @SCLValue(type = "ReadGraph -> Resource -> Variable -> [Resource]") - public static List standardIssueContexts(ReadGraph graph, Resource converter, Variable property) throws DatabaseException { - return IssueUtils.getContextsForProperty(graph, property); + @SCLValue(type = "ReadGraph -> Resource -> a -> [Resource]") + public static List 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); } }