]> gerrit.simantics Code Review - simantics/district.git/blob
86b7d720e124a3129e1b4d08a08cf35ecb21cd1a
[simantics/district.git] /
1 package org.simantics.district.network.techtype.requests;
2
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.common.request.ResourceRead;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.district.network.ontology.DistrictNetworkResource;
8 import org.simantics.layer0.Layer0;
9
10 public class TechTypeTableKeyName extends ResourceRead<String> {
11         
12         public TechTypeTableKeyName(Resource table) {
13                 super(table);
14         }
15
16         @Override
17         public String perform(ReadGraph graph) throws DatabaseException {
18                 Layer0 L0 = Layer0.getInstance(graph);
19                 DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
20                 
21                 Resource type = graph.getPossibleObject(resource, DN.TechType_TechTypeTable_HasComponentType);
22                 if (type != null) {
23                         for (Resource r : graph.getObjects(type, L0.DomainOf)) {
24                                 Resource accessor = graph.getPossibleObject(r, L0.valueAccessor);
25                                 if (accessor.equals(DN.TechType_Functions_techTypeCodeValueAccessor)) {
26                                         return graph.getRelatedValue2(r, L0.HasName);
27                                 }
28                         }
29                 }
30                 
31                 return null;
32         }
33 }