1 package org.simantics.modeling;
3 import gnu.trove.map.hash.THashMap;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.layer0.request.PropertyInfo;
8 import org.simantics.db.layer0.request.PropertyInfoRequest;
9 import org.simantics.db.layer0.request.VariableRead;
10 import org.simantics.db.layer0.variable.Variable;
11 import org.simantics.scl.compiler.types.Type;
12 import org.simantics.utils.datastructures.Pair;
14 public class ProceduralSubstructureMapRequest extends VariableRead<THashMap<String, Pair<String,Type>>>{
16 public ProceduralSubstructureMapRequest(Variable composite) {
21 public THashMap<String, Pair<String,Type>> perform(ReadGraph graph) throws DatabaseException {
22 THashMap<String, Pair<String,Type>> propertyMap = new THashMap<String, Pair<String,Type>>();
23 for(Variable child : variable.getChildren(graph)) {
24 for(Variable property : child.getProperties(graph)) {
25 PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(property.getPredicateResource(graph)));
26 propertyMap.put(child.getName(graph) + "." + propertyInfo.name,
27 Pair.make("/" + child.getName(graph) + "#" + propertyInfo.name,
28 SCLTypeUtils.getType(propertyInfo)));
31 for(Variable property : variable.getProperties(graph)) {
32 PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(property.getPredicateResource(graph)));
33 propertyMap.put(propertyInfo.name,
34 Pair.make("#" + propertyInfo.name,
35 SCLTypeUtils.getType(propertyInfo)));