]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeTableData.java
Move tech type table-related request from UI plug-in
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / techtype / requests / PossibleTechTypeTableData.java
diff --git a/org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeTableData.java b/org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeTableData.java
new file mode 100644 (file)
index 0000000..8dd8866
--- /dev/null
@@ -0,0 +1,23 @@
+package org.simantics.district.network.techtype.requests;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.procedure.adapter.TransientCacheListener;
+import org.simantics.db.common.request.ResourceRead2;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.district.network.ontology.DistrictNetworkResource;
+
+public class PossibleTechTypeTableData extends ResourceRead2<String> {
+       public PossibleTechTypeTableData(Resource model, Resource componentType) {
+               super(model, componentType);
+       }
+
+       @Override
+       public String perform(ReadGraph graph) throws DatabaseException {
+               DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
+
+               Resource ttt = graph.syncRequest(new PossibleTechTypeTable(resource, resource2), TransientCacheListener.instance());
+               return ttt != null ? graph.getPossibleRelatedValue2(ttt, DN.TechType_TechTypeTable_HasData, Bindings.STRING) : null;
+       }
+}