]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeItem.java
TechTypeTable features
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / techtype / requests / PossibleTechTypeItem.java
diff --git a/org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeItem.java b/org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeItem.java
new file mode 100644 (file)
index 0000000..05e4308
--- /dev/null
@@ -0,0 +1,30 @@
+package org.simantics.district.network.techtype.requests;
+
+import java.util.Map;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.procedure.adapter.TransientCacheListener;
+import org.simantics.db.common.request.BinaryRead;
+import org.simantics.db.exception.DatabaseException;
+
+/**
+ * Query for a possible tech type table item in a table with a given item key.
+ * 
+ * Results in null, if no such item was found.
+ */
+public class PossibleTechTypeItem extends BinaryRead<Resource, String, Map<String, String>> {
+
+       public PossibleTechTypeItem(Resource table, String itemCode) {
+               super(table, itemCode);
+       }
+       
+       @Override
+       public Map<String, String> perform(ReadGraph graph) throws DatabaseException {
+               Resource table = this.parameter;
+               String itemCode = this.parameter2;
+               
+               Map<String, Map<String, String>> map = graph.syncRequest(new TechTypeTableData(table), TransientCacheListener.instance());
+               return map.get(itemCode);
+       }
+}
\ No newline at end of file