]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/scl/ontologymodule/SCLRelationInfoRequest.java
Use proper environment to resolve SCL types in ontology module
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / scl / ontologymodule / SCLRelationInfoRequest.java
index 6662463c5b50fc0613e62bd342cc64f2571202b9..e7ed5bd97d5691ea09deb4b36ca198b9be1154ca 100644 (file)
@@ -6,21 +6,23 @@ import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.procedure.adapter.TransientCacheListener;
+import org.simantics.db.common.request.BinaryRead;
 import org.simantics.db.common.request.UnaryRead;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.layer0.Layer0;
+import org.simantics.scl.compiler.environment.Environment;
+import org.simantics.scl.compiler.environment.Environments;
+import org.simantics.scl.compiler.top.SCLExpressionCompilationException;
 import org.simantics.scl.compiler.types.Type;
-import org.simantics.scl.compiler.types.Types;
-import org.simantics.scl.compiler.types.exceptions.SCLTypeParseException;
 import org.simantics.scl.db.SCLCompilationRequestProcessor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SCLRelationInfoRequest extends UnaryRead<Resource,SCLRelationInfo> {
+public class SCLRelationInfoRequest extends BinaryRead<Resource, Environment, SCLRelationInfo> {
     private static final Logger LOGGER = LoggerFactory.getLogger(SCLRelationInfoRequest.class);
     
-    private SCLRelationInfoRequest(Resource resource) {
-        super(resource);
+    private SCLRelationInfoRequest(Resource resource, Environment environment) {
+        super(resource, environment);
     }
 
     @Override
@@ -58,8 +60,8 @@ public class SCLRelationInfoRequest extends UnaryRead<Resource,SCLRelationInfo>
         
         Type type;
         try {
-            type = Types.parseType(valueType);
-        } catch (SCLTypeParseException e) {
+            type = Environments.getType(parameter2, valueType);
+        } catch (SCLExpressionCompilationException e) {
             LOGGER.warn("Couldn't parse the value type of relation {}. Definition was '{}'.", graph.getURI(parameter), valueType);
             return null;
         }
@@ -67,9 +69,9 @@ public class SCLRelationInfoRequest extends UnaryRead<Resource,SCLRelationInfo>
         return new SCLRelationInfo(type, name);
     }
     
-    public static SCLRelationInfo getRelationInfo(Resource resource) {
+    public static SCLRelationInfo getRelationInfo(Resource resource, Environment environment) {
         try {
-            return SCLCompilationRequestProcessor.getRequestProcessor().syncRequest(new SCLRelationInfoRequest(resource), TransientCacheListener.instance());
+            return SCLCompilationRequestProcessor.getRequestProcessor().syncRequest(new SCLRelationInfoRequest(resource, environment), TransientCacheListener.instance());
         } catch(DatabaseException e) {
             LOGGER.error("SCLRelationInfoRequest failed.", e);
             return null;