package org.simantics.district.network.techtype.requests; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ResourceRead; import org.simantics.db.exception.DatabaseException; import org.simantics.district.network.ontology.DistrictNetworkResource; import org.simantics.layer0.Layer0; public class TechTypeTableKeyName extends ResourceRead { public TechTypeTableKeyName(Resource table) { super(table); } @Override public String perform(ReadGraph graph) throws DatabaseException { Layer0 L0 = Layer0.getInstance(graph); DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph); Resource type = graph.getPossibleObject(resource, DN.TechType_TechTypeTable_HasComponentType); if (type != null) { for (Resource r : graph.getObjects(type, L0.DomainOf)) { Resource accessor = graph.getPossibleObject(r, L0.valueAccessor); if (accessor.equals(DN.TechType_Functions_techTypeCodeValueAccessor)) { return graph.getRelatedValue2(r, L0.HasName); } } } return null; } }