]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.district.network/src/org/simantics/district/network/techtype/requests/PossibleTechTypeKeyName.java
Tech type table content validation
[simantics/district.git] / org.simantics.district.network / src / org / simantics / district / network / techtype / requests / PossibleTechTypeKeyName.java
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 PossibleTechTypeKeyName extends ResourceRead<String> {
11         public PossibleTechTypeKeyName(Resource componentType) {
12                 super(componentType);
13         }
14
15         @Override
16         public String perform(ReadGraph graph) throws DatabaseException {
17                 Layer0 L0 = Layer0.getInstance(graph);
18                 DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
19                 
20                 for (Resource r : graph.getObjects(resource, L0.DomainOf)) {
21                         Resource accessor = graph.getPossibleObject(r, L0.valueAccessor);
22                         if (accessor.equals(DN.TechType_Functions_techTypeCodeValueAccessor)) {
23                                 return graph.getRelatedValue2(r, L0.HasName);
24                         }
25                 }
26                 
27                 return null;
28         }
29 }