package org.simantics.district.network.ui.techtype.requests; import java.util.Collection; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ResourceRead2; import org.simantics.db.exception.DatabaseException; import org.simantics.district.network.ontology.DistrictNetworkResource; import org.simantics.layer0.Layer0; public class PossibleTechTypeTable extends ResourceRead2 { public PossibleTechTypeTable(Resource model, Resource componentType) { super(model, componentType); } @Override public Resource perform(ReadGraph graph) throws DatabaseException { Layer0 L0 = Layer0.getInstance(graph); DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); Collection children = graph.getObjects(resource, L0.ConsistsOf); for (Resource child : children) { if (!graph.isInstanceOf(child, DN.TechType_TechTypeTable)) continue; if (graph.hasStatement(child, DN.TechType_TechTypeTable_HasComponentType, resource2)) return child; } return null; } }