]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Polling and pollingfunction fixes 66/666/3
authorMiro Richard Eklund <miro.eklund@semantum.fi>
Fri, 30 Jun 2017 09:04:33 +0000 (12:04 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 30 Jun 2017 11:13:31 +0000 (14:13 +0300)
Added primitivevaluevariable and handles polling function issues.

Amend: Removed syserr printline and put stackstace to logger.

refs #7342

Change-Id: Iba326499fe5bc00d6a512fc290420ba735d62642

bundles/org.simantics.charts/src/org/simantics/charts/Charts.java
bundles/org.simantics.document.base.ontology/graph/Properties.pgraph
bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java
bundles/org.simantics.document.server/src/org/simantics/document/server/PrimitiveValueVariable.java [new file with mode: 0644]

index 5e4ef406db3b9185f22e553b43e88c90b1383656..8ca1ca1eafef43c9b469d6c1dcfbf40f0f7eac8f 100644 (file)
@@ -53,6 +53,10 @@ public final class Charts {
                 throw new DatabaseException("There is no index root for " + subscriptionItem);
             }
 
+            if(data == null) {
+                throw new DatabaseException("There is no chart data for " + subscriptionItem);
+            }
+
             ItemManager im = new ItemManager(data.history.getItems());
 
             SubscriptionItem i = graph.syncRequest(new SubscriptionItemQuery(subscriptionItem));
index b5d56fc4c7617e1d3310276a6df5a82edee705d0..4fb8b227860e33753fc2c3defaf5bb59ead5518b 100644 (file)
@@ -5,7 +5,9 @@ SEL = <http://www.simantics.org/SelectionView-1.2>
 
 PROPERTIES = DOC.Properties : L0.Library
   @L0.new
-    
+
+DOC.Document.definesAttributeRelation --> DOC.Document.AttributeRelation <R L0.IsRelatedTo : L0.FunctionalRelation
+
 DOC.Document.AttributeRelation <T L0.Relation
   @L0.assert L0.domainProperties L0.Functions.standardPropertyDomainProperties
   @L0.assert L0.domainChildren L0.Functions.standardPropertyDomainChildren
index 8b68cc409cde83d0442ae081163c15e3dcf0071c..6ccffbe973ddecdeef07e4a8bcbdaebe3acf52e2 100644 (file)
@@ -136,7 +136,7 @@ public class Functions {
                 for(Variable property : procedural.getProperties(graph/*, DocumentationResource.URIs.Document_AttributeRelation*/)) {
                     if(property instanceof StandardAssertedGraphPropertyVariable) {
                         StandardAssertedGraphPropertyVariable ass = (StandardAssertedGraphPropertyVariable)property;
-                        if("datadefinitions".equals(ass.property.name) || "commands".equals(ass.property.name)) {
+                        if("datadefinitions".equals(ass.property.name) || "commands".equals(ass.property.name)  || "pollingFunction".equals(ass.property.name)) {
                             Object value = property.getPossibleValue(graph);
                             if(value != null) map.put(ass.property.name, new ConstantPropertyVariable(parent, ass.property.name, value, null));
                         }
@@ -160,15 +160,28 @@ public class Functions {
                 PrimitivePropertyStatementsProcedure foo = new PrimitivePropertyStatementsProcedure();
 
                 dqs.forEachDirectPersistentStatement(graph, parent.getRepresents(graph), foo);
-       
+
                 for(Statement stm : foo.result) {
                     Resource predicate = stm.getPredicate();
                     PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(predicate));
+
                     if(info.isHasProperty && info.hasClassification(DocumentationResource.URIs.Document_AttributeRelation)) {
                         if(map == null) map = new HashMap<String,Variable>();
                         Variable prop = new StandardGraphPropertyVariable(graph, parent, predicate);
                         Object value = prop.getValue(graph);
                         map.put(info.name, new ConstantPropertyVariable(parent, info.name, value, null));
+                    } else {
+                        Resource definition = graph.getPossibleObject(predicate, DOC.Document_definesAttributeRelation);
+                        if(definition != null) {
+                            if(map == null) map = new HashMap<String,Variable>();
+                            try {
+                                PropertyInfo info2 = graph.syncRequest(new PropertyInfoRequest(definition));
+                                Variable prop = new StandardGraphPropertyVariable(graph, parent, definition);
+                                map.put(info2.name, new PrimitiveValueVariable(parent, info2.name, prop));
+                            } catch (DatabaseException e) {
+                                Logger.defaultLogError(e);
+                            }
+                        }
                     }
                 }
 
diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/PrimitiveValueVariable.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/PrimitiveValueVariable.java
new file mode 100644 (file)
index 0000000..26e4f25
--- /dev/null
@@ -0,0 +1,28 @@
+package org.simantics.document.server;
+
+import org.simantics.databoard.binding.Binding;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.ConstantPropertyVariable;
+import org.simantics.db.layer0.variable.Variable;
+
+public class PrimitiveValueVariable extends ConstantPropertyVariable {
+
+       final private Variable property;
+
+       public PrimitiveValueVariable(Variable parent, String name, Variable property) {
+               super(parent, name, null, null);
+               this.property = property;
+       }
+
+       @Override
+       public <T> T getValue(ReadGraph graph) throws DatabaseException {
+               return property.getValue(graph);
+       }
+
+       @Override
+       public <T> T getValue(ReadGraph graph, Binding binding) throws DatabaseException {
+               return property.getValue(graph, binding);
+       }
+
+}