]> gerrit.simantics Code Review - simantics/platform.git/blob
50a905e8204d3b84e4f094b3de1dd030cf53761a
[simantics/platform.git] /
1 package org.simantics.structural2.scl.procedural;
2
3 import java.util.Map;
4
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.common.procedure.adapter.TransientCacheListener;
8 import org.simantics.db.common.request.IndexRoot;
9 import org.simantics.db.common.request.UnaryRead;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.db.layer0.util.RuntimeEnvironmentRequest;
12 import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification;
13 import org.simantics.scl.compiler.runtime.RuntimeEnvironment;
14 import org.simantics.structural2.scl.ComponentTypeProperty;
15 import org.simantics.structural2.scl.ReadComponentTypeConnectionsRequest;
16 import org.simantics.structural2.scl.ReadComponentTypeInterfaceRequest;
17
18 public class ProceduralComponentTypeCompilationContextRequest extends UnaryRead<Resource,ProceduralComponentTypeCompilationContext> {
19
20     public ProceduralComponentTypeCompilationContextRequest(Resource parameter) {
21         super(parameter);
22     }
23
24     @Override
25     public ProceduralComponentTypeCompilationContext perform(ReadGraph graph)
26             throws DatabaseException {
27         Resource indexRoot = graph.syncRequest(new IndexRoot(parameter));
28         RuntimeEnvironment runtimeEnvironment = graph.syncRequest(new RuntimeEnvironmentRequest(indexRoot) {
29             @Override
30             protected void fillEnvironmentSpecification(
31                     EnvironmentSpecification environmentSpecification) {
32                 environmentSpecification.importModule("Structural/Procedural", "");
33             }
34         });
35         Map<String, ComponentTypeProperty> propertyMap =
36                 graph.syncRequest(new ReadComponentTypeInterfaceRequest(parameter, runtimeEnvironment.getEnvironment()),
37                         TransientCacheListener.<Map<String, ComponentTypeProperty>>instance());
38         Map<String, Resource> connectionPointMap =
39                 graph.syncRequest(new ReadComponentTypeConnectionsRequest(parameter),
40                         TransientCacheListener.<Map<String, Resource>>instance());
41         return new ProceduralComponentTypeCompilationContext(runtimeEnvironment, propertyMap, connectionPointMap);
42     }
43     
44 }