X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fproperty%2FProperties.java;h=2b201df43831d7f888e1dd216b7ec473f5fd454e;hb=48bb50bb6640506d1f150ca8e4fa5a6e878464be;hp=5d5a1183b2794dd8986ee871b6f63f9d02b7e156;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/property/Properties.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/property/Properties.java index 5d5a1183b..2b201df43 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/property/Properties.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/property/Properties.java @@ -1,68 +1,68 @@ -package org.simantics.db.layer0.property; - -import java.util.ArrayList; -import java.util.Collections; - -import org.simantics.databoard.Bindings; -import org.simantics.databoard.binding.Binding; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.Statement; -import org.simantics.db.exception.DatabaseException; -import org.simantics.operation.Layer0X; - -/** - * @author Antti Villberg - * TODO: consider removing since this doesn't seem to be used. - */ -public class Properties { - - public static T getPossibleRelatedValue(ReadGraph graph, Resource resource, Resource relation, Binding binding) throws DatabaseException { - - T result = graph.getPossibleRelatedValue(resource, relation, binding); - if(result != null) return result; - else { - - Layer0X L0X = Layer0X.getInstance(graph); - ArrayList order = new ArrayList(); - for(Statement stm : graph.getStatements(resource, L0X.ObtainsProperty)) { - Integer position = graph.getRelatedValue(stm.getPredicate(), L0X.NaturalNumberOrderRelation, Bindings.INTEGER); - order.add(new OrderedResource(position, stm.getObject())); - } - Collections.sort(order); - for(OrderedResource or : order) { - result = getPossibleRelatedValue(graph, or.r, relation, binding); - if(result != null) return result; - } - - return null; - - } - - } - - public static T getPossibleRelatedAdapter(ReadGraph graph, Resource resource, Resource relation, Class clazz) throws DatabaseException { - - T result = graph.getPossibleRelatedAdapter(resource, relation, clazz); - if(result != null) return result; - else { - - Layer0X L0X = Layer0X.getInstance(graph); - ArrayList order = new ArrayList(); - for(Statement stm : graph.getStatements(resource, L0X.ObtainsProperty)) { - Integer position = graph.getRelatedValue(stm.getPredicate(), L0X.NaturalNumberOrderRelation, Bindings.INTEGER); - order.add(new OrderedResource(position, stm.getObject())); - } - Collections.sort(order); - for(OrderedResource or : order) { - result = getPossibleRelatedAdapter(graph, or.r, relation, clazz); - if(result != null) return result; - } - - return null; - - } - - } - -} +package org.simantics.db.layer0.property; + +import java.util.ArrayList; +import java.util.Collections; + +import org.simantics.databoard.Bindings; +import org.simantics.databoard.binding.Binding; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.Statement; +import org.simantics.db.exception.DatabaseException; +import org.simantics.operation.Layer0X; + +/** + * @author Antti Villberg + * TODO: consider removing since this doesn't seem to be used. + */ +public class Properties { + + public static T getPossibleRelatedValue(ReadGraph graph, Resource resource, Resource relation, Binding binding) throws DatabaseException { + + T result = graph.getPossibleRelatedValue(resource, relation, binding); + if(result != null) return result; + else { + + Layer0X L0X = Layer0X.getInstance(graph); + ArrayList order = new ArrayList(); + for(Statement stm : graph.getStatements(resource, L0X.ObtainsProperty)) { + Integer position = graph.getRelatedValue(stm.getPredicate(), L0X.NaturalNumberOrderRelation, Bindings.INTEGER); + order.add(new OrderedResource(position, stm.getObject())); + } + Collections.sort(order); + for(OrderedResource or : order) { + result = getPossibleRelatedValue(graph, or.r, relation, binding); + if(result != null) return result; + } + + return null; + + } + + } + + public static T getPossibleRelatedAdapter(ReadGraph graph, Resource resource, Resource relation, Class clazz) throws DatabaseException { + + T result = graph.getPossibleRelatedAdapter(resource, relation, clazz); + if(result != null) return result; + else { + + Layer0X L0X = Layer0X.getInstance(graph); + ArrayList order = new ArrayList(); + for(Statement stm : graph.getStatements(resource, L0X.ObtainsProperty)) { + Integer position = graph.getRelatedValue(stm.getPredicate(), L0X.NaturalNumberOrderRelation, Bindings.INTEGER); + order.add(new OrderedResource(position, stm.getObject())); + } + Collections.sort(order); + for(OrderedResource or : order) { + result = getPossibleRelatedAdapter(graph, or.r, relation, clazz); + if(result != null) return result; + } + + return null; + + } + + } + +}