X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Ftechtype%2Frequests%2FPossibleTechTypeTable.java;fp=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Ftechtype%2Frequests%2FPossibleTechTypeTable.java;h=c722dfc09414fdcc4d89d4d30b45bee2363fea1a;hb=ae7fa2cc4cfe235b2a392d6fb7e3038042ac4221;hp=0000000000000000000000000000000000000000;hpb=7b3111c1cbb19842294bffc6a34289a2fecabdf9;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/requests/PossibleTechTypeTable.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/requests/PossibleTechTypeTable.java new file mode 100644 index 00000000..c722dfc0 --- /dev/null +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/requests/PossibleTechTypeTable.java @@ -0,0 +1,33 @@ +package org.simantics.district.network.ui.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