]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.issues.common/src/org/simantics/issues/common/All.java
Allow overriding issue hidden-ness/hiding logic in inheriting ontologies
[simantics/platform.git] / bundles / org.simantics.issues.common / src / org / simantics / issues / common / All.java
index d2120cd78345d7fdccfcc7dcbb76d7e6d125c914..d39ee983745bed698ffa35c49342d3228999252b 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.db.layer0.variable.Variables;
 import org.simantics.issues.ontology.IssueResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.reflection.annotations.SCLValue;
+import org.simantics.scl.runtime.function.Function1;
 
 public class All {
        
@@ -71,6 +72,7 @@ public class All {
        if(issueRoot.equals(contextRoot)) {
                String uri = graph.getURI(parent);
                String contextURI = graph.getURI(contextRoot);
+               if (uri.equals(contextURI)) return "";
                return IssueUtils.pathString(uri, contextURI.length()+1);
        } else {
                String uri = graph.getURI(parent);
@@ -95,4 +97,30 @@ public class All {
         throw new IllegalArgumentException("Unsupported property type: " + property);
     }
 
+    @SCLValue(type = "ReadGraph -> Resource -> a -> b")
+    public static Function1<Boolean, Boolean> standardIssueHider(ReadGraph graph, Resource converter, Object property) throws DatabaseException {
+        if (property instanceof Variable) {
+            Variable hider = (Variable) property;
+            Variable issue = hider.getParent(graph);
+            Resource r = issue.getPossibleRepresents(graph);
+            if (r != null)
+                return new HideFunction(r);
+        }
+        return null;
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> a -> Boolean")
+    public static Boolean standardIssueHidden(ReadGraph graph, Resource converter, Object property) throws DatabaseException {
+        if (property instanceof Variable) {
+            Variable hidden = (Variable) property;
+            Variable issue = hidden.getParent(graph);
+            Resource r = issue.getPossibleRepresents(graph);
+            if (r != null) {
+                IssueResource ISSUE = IssueResource.getInstance(graph);
+                return graph.hasStatement(r, ISSUE.Hidden);
+            }
+        }
+        return false;
+    }
+
 }