]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeItem.java
Updating of component properties when type code changes
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / techtype / requests / PossibleTechTypeItem.java
1 package org.simantics.district.network.techtype.requests;
2
3 import java.util.Map;
4
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.common.procedure.adapter.TransientCacheListener;
8 import org.simantics.db.common.request.BinaryRead;
9 import org.simantics.db.exception.DatabaseException;
10
11 /**
12  * Query for a possible tech type table item in a table with a given item key.
13  * 
14  * Results in null, if no such item was found.
15  */
16 public class PossibleTechTypeItem extends BinaryRead<Resource, String, Map<String, String>> {
17
18         public PossibleTechTypeItem(Resource table, String itemCode) {
19                 super(table, itemCode);
20         }
21         
22         @Override
23         public Map<String, String> perform(ReadGraph graph) throws DatabaseException {
24                 Resource table = this.parameter;
25                 String itemCode = this.parameter2;
26                 
27                 Map<String, Map<String, String>> map = graph.syncRequest(new TechTypeTableData(table), TransientCacheListener.instance());
28                 return map.get(itemCode);
29         }
30 }