X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2Frequest%2FServerSCLValueRequest.java;h=dce4b34ab44e46c7d28ef70b3902b0663ea4fbe6;hp=09f1523a2ede4ba26ff3c4d9a52df435647d302f;hb=d9fee21e1ff594dfbaa51a0597b4695f289aa29d;hpb=2d97029aeaaf5d6a965eae98c1646eef29ae2f8b diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java index 09f1523a2..dce4b34ab 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java @@ -1,5 +1,6 @@ package org.simantics.document.server.request; +import java.util.Collections; import java.util.Map; import org.simantics.databoard.Bindings; @@ -70,7 +71,7 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< } public ServerSCLValueRequest(ReadGraph graph, Resource s, Resource o, Resource p) throws DatabaseException { - this(getComponentTypeAndRoot(graph, s), o, resolveExpectedValueType(graph, p)); + this(getComponentTypeAndRoot(graph, s, o), o, resolveExpectedValueType(graph, p)); } private static Pair getComponentTypeAndRoot(ReadGraph graph, Variable property) throws DatabaseException { @@ -88,7 +89,7 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< return Pair.make(parent.getType(graph), root); } - private static Pair getComponentTypeAndRoot(ReadGraph graph, Resource component) throws DatabaseException { + private static Pair getComponentTypeAndRoot(ReadGraph graph, Resource component, Resource literal) throws DatabaseException { if(component != null) { Resource type = graph.syncRequest(new FindPossibleComponentTypeRequest(component)); if(type != null) { @@ -102,14 +103,20 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< Resource root = graph.syncRequest(new IndexRoot(doc)); return Pair.make(componentType, root); } else { - System.err.println("component = " + component); + //System.err.println("component = " + component); Resource root = graph.syncRequest(new IndexRoot(component)); // Resource componentType = graph.getSingleType(doc); return Pair.make(null, root); } } - } - throw new IllegalStateException(); + // TODO: For Antti to consider and fix later + // Introduced to handle procedural user components where component == null + } else if (literal != null) { + Resource root = graph.syncRequest(new IndexRoot(literal)); + return Pair.make(null, root); + } else { + throw new DatabaseException("Couldn't resolve component type and root for component == null && literal == null"); + } } public static Object compileAndEvaluate(ReadGraph graph, Variable context) throws DatabaseException { @@ -160,9 +167,16 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< public CompilationContext perform(ReadGraph graph) throws DatabaseException { RuntimeEnvironment runtimeEnvironment = graph.syncRequest(getRuntimeEnvironmentRequest(parameter.first, parameter.second)); - Map propertyMap = + Map propertyMap; + if (parameter.first != null) { + propertyMap = graph.syncRequest(new ReadComponentTypeInterfaceRequest(parameter.first, runtimeEnvironment.getEnvironment()), TransientCacheListener.>instance()); + } else { + // TODO: Antti to consider + // To handle procedural user components + propertyMap = Collections.emptyMap(); + } return new CompilationContext(runtimeEnvironment, propertyMap); } });