X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Ftechtype%2Frequests%2FPossibleTechTypeTable.java;fp=org.simantics.district.network%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Ftechtype%2Frequests%2FPossibleTechTypeTable.java;h=68fc12f19f187e5bce051090b9d25511dfc62dec;hb=44fb5c76f6e8a4d4669de3bbbf48850a3d724049;hp=0000000000000000000000000000000000000000;hpb=20e401b6e5ac78b8a586468ea1b3e8bfa818c017;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeTable.java b/org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeTable.java new file mode 100644 index 00000000..68fc12f1 --- /dev/null +++ b/org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeTable.java @@ -0,0 +1,33 @@ +package org.simantics.district.network.techtype.requests; + +import java.util.Collection; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ResourceRead2; +import org.simantics.db.exception.DatabaseException; +import org.simantics.district.network.ontology.DistrictNetworkResource; +import org.simantics.layer0.Layer0; + +public class PossibleTechTypeTable extends ResourceRead2 { + public PossibleTechTypeTable(Resource model, Resource componentType) { + super(model, componentType); + } + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); + + Collection children = graph.getObjects(resource, L0.ConsistsOf); + for (Resource child : children) { + if (!graph.isInstanceOf(child, DN.TechType_TechTypeTable)) + continue; + + if (graph.hasStatement(child, DN.TechType_TechTypeTable_HasComponentType, resource2)) + return child; + } + + return null; + } +} \ No newline at end of file