]> gerrit.simantics Code Review - simantics/district.git/blob
c722dfc09414fdcc4d89d4d30b45bee2363fea1a
[simantics/district.git] /
1 package org.simantics.district.network.ui.techtype.requests;
2
3 import java.util.Collection;
4
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.common.request.ResourceRead2;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.district.network.ontology.DistrictNetworkResource;
10 import org.simantics.layer0.Layer0;
11
12 public class PossibleTechTypeTable extends ResourceRead2<Resource> {
13         public PossibleTechTypeTable(Resource model, Resource componentType) {
14                 super(model, componentType);
15         }
16
17         @Override
18         public Resource perform(ReadGraph graph) throws DatabaseException {
19                 Layer0 L0 = Layer0.getInstance(graph);
20                 DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
21                 
22                 Collection<Resource> children = graph.getObjects(resource, L0.ConsistsOf);
23                 for (Resource child : children) {
24                         if (!graph.isInstanceOf(child, DN.TechType_TechTypeTable))
25                                 continue;
26                         
27                         if (graph.hasStatement(child, DN.TechType_TechTypeTable_HasComponentType, resource2))
28                                 return child;
29                 }
30                 
31                 return null;
32         }
33 }