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
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;
}
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;