-public class ServerSCLHandlerValueRequest extends AbstractExpressionCompilationRequest<CompilationContext, Object> {
-
- private final Pair<Resource,Resource> componentTypeAndRoot;
- private final Resource literal;
- protected String possibleExpectedValueType;
-
- public static class CompilationContext extends AbstractExpressionCompilationContext {
- public final Map<String, ComponentTypeProperty> propertyMap;
-
- public CompilationContext(RuntimeEnvironment runtimeEnvironment,
- Map<String, ComponentTypeProperty> propertyMap) {
- super(runtimeEnvironment);
- this.propertyMap = propertyMap;
- }
- }
-
- private ServerSCLHandlerValueRequest(Pair<Resource,Resource> componentTypeAndRoot, Resource literal, String possibleExpectedValueType) {
- assert(literal != null);
- this.literal = literal;
- this.componentTypeAndRoot = componentTypeAndRoot;
- this.possibleExpectedValueType = possibleExpectedValueType;
- }
-
- public ServerSCLHandlerValueRequest(ReadGraph graph, Variable context) throws DatabaseException {
- this(getComponentTypeAndRoot(graph, context), context.getRepresents(graph), resolveExpectedValueType(graph, context.getPredicateResource(graph)));
- }
-
- public ServerSCLHandlerValueRequest(ReadGraph graph, Resource s, Resource o, Resource p) throws DatabaseException {
- this(getComponentTypeAndRoot(graph, s, o), o, resolveExpectedValueType(graph, p));
- }
-
- private static Pair<Resource,Resource> getComponentTypeAndRoot(ReadGraph graph, Variable property) throws DatabaseException {
- Variable parent = property.getParent(graph);
- Resource represents = parent.getRepresents(graph);
- if(represents != null) {
- Resource type = graph.syncRequest(new FindPossibleComponentTypeRequest(represents));
- if(type != null) {
- Resource root = graph.syncRequest(new IndexRoot(type));
- return Pair.make(type, root);
- }
- }
- parent = parent.getParent(graph);
- Resource root = graph.syncRequest(new IndexRoot(property.getRepresents(graph)));
- return Pair.make(parent.getType(graph), root);
- }
-
- private static Pair<Resource,Resource> getComponentTypeAndRoot(ReadGraph graph, Resource component, Resource literal) throws DatabaseException {
- if(component != null) {
- Resource type = graph.syncRequest(new FindPossibleComponentTypeRequest(component));
- if(type != null) {
- Resource root = graph.syncRequest(new IndexRoot(type));
- return Pair.make(type, root);
- } else {
- Resource doc = graph.syncRequest(new PossibleTypedParent(component, DocumentationResource.getInstance(graph).Document));
- Resource componentType = graph.getSingleType(doc);
- Resource root = graph.syncRequest(new IndexRoot(doc));
- return Pair.make(componentType, root);
- }
- // 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");
- }
- //throw new IllegalStateException();
- }
+public class ServerSCLHandlerValueRequest extends ServerSCLValueRequestBase<org.simantics.document.server.request.ServerSCLHandlerValueRequest.CompilationContext> {
+
+ private final Pair<Resource,Resource> componentTypeAndRoot;
+ private final Resource literal;
+ protected String possibleExpectedValueType;
+
+ public static class CompilationContext extends AbstractExpressionCompilationContext {
+ public final Map<String, ComponentTypeProperty> propertyMap;
+
+ public CompilationContext(RuntimeEnvironment runtimeEnvironment,
+ Map<String, ComponentTypeProperty> propertyMap) {
+ super(runtimeEnvironment);
+ this.propertyMap = propertyMap;
+ }
+ }
+
+ private ServerSCLHandlerValueRequest(Pair<Resource,Resource> componentTypeAndRoot, Resource literal, String possibleExpectedValueType) {
+ assert(literal != null);
+ this.literal = literal;
+ this.componentTypeAndRoot = componentTypeAndRoot;
+ this.possibleExpectedValueType = possibleExpectedValueType;
+ }
+
+ public ServerSCLHandlerValueRequest(ReadGraph graph, Variable context) throws DatabaseException {
+ this(getComponentTypeAndRoot(graph, context), context.getRepresents(graph), resolveExpectedValueType(graph, context.getPredicateResource(graph)));
+ }
+
+ public ServerSCLHandlerValueRequest(ReadGraph graph, Resource s, Resource o, Resource p) throws DatabaseException {
+ this(getComponentTypeAndRoot(graph, s, o), o, resolveExpectedValueType(graph, p));
+ }
+
+ private static Pair<Resource,Resource> getComponentTypeAndRoot(ReadGraph graph, Variable property) throws DatabaseException {
+ Variable parent = property.getParent(graph);
+ Resource represents = parent.getRepresents(graph);
+ if(represents != null) {
+ Resource type = graph.syncRequest(new FindPossibleComponentTypeRequest(represents));
+ if(type != null) {
+ Resource root = graph.syncRequest(new IndexRoot(type));
+ return Pair.make(type, root);
+ }
+ }
+ parent = parent.getParent(graph);
+ Resource root = graph.syncRequest(new IndexRoot(property.getRepresents(graph)));
+ return Pair.make(parent.getType(graph), root);
+ }
+