1 package org.simantics.plant3d.geometry;
3 import java.util.HashMap;
6 import org.simantics.databoard.Bindings;
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.Resource;
9 import org.simantics.db.common.request.ResourceRead;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.layer0.Layer0;
12 import org.simantics.plant3d.ontology.Plant3D;
14 public class ParameterRead extends ResourceRead<Map<String, Object>> {
16 public ParameterRead(Resource resource) {
21 public Map<String, Object> perform(ReadGraph graph) throws DatabaseException {
22 Map<String,Object> parameters = new HashMap<>();
23 Layer0 L0 = Layer0.getInstance(graph);
24 Plant3D P3D = Plant3D.getInstance(graph);
26 for (Resource assertion : graph.getObjects(resource, L0.Asserts)) {
27 Resource rel = graph.getSingleObject(assertion, L0.HasPredicate);
28 if (!rel.equals(P3D.hasParameter))
30 Resource param = graph.getSingleObject(assertion, L0.HasObject);
31 String name = graph.getRelatedValue(param, L0.HasName, Bindings.STRING);
32 Object value = graph.getRelatedValue(param, P3D.hasParameterValue);
33 parameters.put(name, value);
35 for (Resource param : graph.getObjects(resource, P3D.hasParameter)) {
36 String name = graph.getRelatedValue(param, L0.HasName, Bindings.STRING);
37 Object value = graph.getRelatedValue(param, P3D.hasParameterValue);
38 parameters.put(name, value);