]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/DistrictNetworkUtil.java
Disable throttling for now, as it doens't work.
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / DistrictNetworkUtil.java
index 550553f1b88083249877ed8f20c41073adf3efc3..fd72a67378b62609f3061284aca2528723a78512 100644 (file)
@@ -41,7 +41,7 @@ public class DistrictNetworkUtil {
         Resource edge = graph.newResource();
         graph.claim(edge, L0.InstanceOf, DN.Edge);
         
-        graph.claim(edge, DN.HasMapping, mapping);
+        graph.claim(edge, DN.HasMapping, null, mapping);
         
         OrderedSetUtils.addFirst(graph, composite, edge);
         graph.claim(composite, L0.ConsistsOf, L0.PartOf, edge);
@@ -74,7 +74,7 @@ public class DistrictNetworkUtil {
         graph.claim(vertex, L0.InstanceOf, DN.Vertex);
         graph.claimLiteral(vertex, DIA.HasLocation, coords);
         
-        graph.claim(vertex, DN.HasMapping, mapping);
+        graph.claim(vertex, DN.HasMapping, null, mapping);
         
         OrderedSetUtils.add(graph, composite, vertex);
         graph.claim(composite, L0.ConsistsOf, L0.PartOf, vertex);
@@ -223,13 +223,23 @@ public class DistrictNetworkUtil {
         return current != null ? current : true;
     }
 
-    public static void changeMapBackgroundColor(WriteGraph graph, Resource resource, Integer integer) throws DatabaseException {
+    public static void changeMapBackgroundColor(WriteGraph graph, Resource diagram, Integer integer) throws DatabaseException {
         DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
-        graph.claimLiteral(resource, DN.Diagram_backgroundColor, integer, Bindings.getBindingUnchecked(RGB.Integer.class));
+        graph.claimLiteral(diagram, DN.Diagram_backgroundColor, integer, Bindings.getBindingUnchecked(RGB.Integer.class));
     }
     
     public static Boolean trackChangesEnabled(ReadGraph graph, Resource diagram) throws DatabaseException {
-        return Boolean.TRUE.equals(graph.getPossibleRelatedValue(diagram,
+        if (diagram != null && graph.hasStatement(diagram)) {
+            return Boolean.TRUE.equals(graph.getPossibleRelatedValue(diagram,
                 DistrictNetworkResource.getInstance(graph).Diagram_trackChangesEnabled));
+        } else {
+            return false;
+        }
+    }
+
+    public static RGB.Integer backgroundColor(ReadGraph graph, Resource diagram) throws DatabaseException {
+        return graph.getPossibleRelatedValue(diagram,
+                DistrictNetworkResource.getInstance(graph).Diagram_backgroundColor,
+                Bindings.getBindingUnchecked(RGB.Integer.class));
     }
 }