1 package org.simantics.modeling;
3 import gnu.trove.map.hash.THashMap;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.db.layer0.request.PropertyInfo;
9 import org.simantics.db.layer0.request.PropertyInfoRequest;
10 import org.simantics.db.layer0.request.VariableRead;
11 import org.simantics.db.layer0.variable.Variable;
12 import org.simantics.scl.compiler.types.Type;
13 import org.simantics.utils.datastructures.Pair;
15 public class ProceduralSubstructureMapRequest extends VariableRead<THashMap<String, Pair<String,Type>>>{
17 public ProceduralSubstructureMapRequest(Variable composite) {
22 public THashMap<String, Pair<String,Type>> perform(ReadGraph graph) throws DatabaseException {
23 THashMap<String, Pair<String,Type>> propertyMap = new THashMap<String, Pair<String,Type>>();
24 for(Variable child : variable.getChildren(graph)) {
25 for(Variable property : child.getProperties(graph)) {
26 Resource predicate = property.getPossiblePredicateResource(graph);
27 if (predicate == null)
30 PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(predicate));
31 propertyMap.put(child.getName(graph) + "." + propertyInfo.name,
32 Pair.make("/" + child.getName(graph) + "#" + propertyInfo.name,
33 SCLTypeUtils.getType(propertyInfo)));
36 for(Variable property : variable.getProperties(graph)) {
37 Resource predicate = property.getPossiblePredicateResource(graph);
38 if (predicate == null)
41 PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(predicate));
42 propertyMap.put(propertyInfo.name,
43 Pair.make("#" + propertyInfo.name,
44 SCLTypeUtils.getType(propertyInfo)));