From: Miro Richard Eklund Date: Fri, 30 Jun 2017 09:04:33 +0000 (+0300) Subject: Polling and pollingfunction fixes X-Git-Tag: v1.31.0~287 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F66%2F666%2F3;p=simantics%2Fplatform.git Polling and pollingfunction fixes Added primitivevaluevariable and handles polling function issues. Amend: Removed syserr printline and put stackstace to logger. refs #7342 Change-Id: Iba326499fe5bc00d6a512fc290420ba735d62642 --- diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/Charts.java b/bundles/org.simantics.charts/src/org/simantics/charts/Charts.java index 5e4ef406d..8ca1ca1ea 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/Charts.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/Charts.java @@ -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)); diff --git a/bundles/org.simantics.document.base.ontology/graph/Properties.pgraph b/bundles/org.simantics.document.base.ontology/graph/Properties.pgraph index b5d56fc4c..4fb8b2278 100644 --- a/bundles/org.simantics.document.base.ontology/graph/Properties.pgraph +++ b/bundles/org.simantics.document.base.ontology/graph/Properties.pgraph @@ -5,7 +5,9 @@ SEL = PROPERTIES = DOC.Properties : L0.Library @L0.new - + +DOC.Document.definesAttributeRelation --> DOC.Document.AttributeRelation (); 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(); + 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 index 000000000..26e4f2587 --- /dev/null +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/PrimitiveValueVariable.java @@ -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 getValue(ReadGraph graph) throws DatabaseException { + return property.getValue(graph); + } + + @Override + public T getValue(ReadGraph graph, Binding binding) throws DatabaseException { + return property.getValue(graph, binding); + } + +}