- public static VariableMap methodsPropertyDomainProperties = new VariableMapImpl() {
-
- @Override
- public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
- Variable parent = context.getParent(graph);
- Resource container = parent.getPossibleRepresents(graph);
- if(container == null)
- return null;
- Map<String,Resource> methods = graph.syncRequest(new UnescapedMethodMapOfResource(container));
- Resource predicate = methods.get(name);
- if(predicate != null) {
- Layer0 L0 = Layer0.getInstance(graph);
- PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(L0.Entity_method));
- Resource value = graph.getSingleObject(container, predicate);
- return new StandardGraphPropertyVariable(context, null, container, info, value);
- }
- return null;
- }
-
- @Override
- public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
- Variable parent = context.getParent(graph);
- Resource container = parent.getPossibleRepresents(graph);
- if(container == null)
- return Collections.emptyMap();
- Map<String,Resource> methods = graph.syncRequest(new UnescapedMethodMapOfResource(container));
- for(Map.Entry<String, Resource> entry : methods.entrySet()) {
- String name = entry.getKey();
- Resource predicate = entry.getValue();
- Layer0 L0 = Layer0.getInstance(graph);
- PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(L0.Entity_method));
- Resource value = graph.getSingleObject(container, predicate);
- if(map == null) map = new HashMap<>();
- map.put(name, new StandardGraphPropertyVariable(context, null, container, info, value));
- }
- return map;
- }
-
- };
-
- public static Variable getStandardPropertyDomainPropertyVariableFromValue(ReadGraph graph, Variable context, String name) throws DatabaseException {
-
- if(context instanceof StandardGraphPropertyVariable) {
- StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
- Resource literal = variable.getPossibleRepresents(graph);
- Object propertyNode = getPossibleNodeProperty(graph, variable, name, false);
-
- if(literal != null) {
- Variable result = getPossiblePropertyFromContext(graph, variable, literal, name, propertyNode);
- if(result != null) return result;
- }
-
- Variable result = getPossibleSubliteralPropertyFromContext(graph, variable, name);
- if(result != null) return result;
- result = getPossiblePropertyFromContext(graph, variable, variable.property.predicate, name, propertyNode);
- if (result != null) return result;
-
- // Get possible property from NodeManager
- if (propertyNode != null)
- return createStandardGraphPropertyVariable(graph, variable, propertyNode);
- return null;
- } else if (context instanceof StandardGraphChildVariable) {
- return standardChildDomainProperties.getVariable(graph, context, name);
- } else {
- throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
- }
-
- }
-
- public static Map<String, Variable> getStandardPropertyDomainPropertyVariablesFromValue(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-
- if(context instanceof StandardGraphPropertyVariable) {
- StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
- map = collectPropertiesFromContext(graph, variable, variable.property.predicate, map);
- if (variable.parentResource != null) {
- Resource literal = graph.getPossibleObject(variable.parentResource, variable.property.predicate);
- if(literal != null) map=collectPropertiesFromContext(graph, variable, literal, map);
- map=collectSubliteralProperties(graph, variable, map);
- }
-
- // Get properties from VariableNode
- map = getStandardNodePropertyVariables(graph, context, map);
- return map;
- } else if (context instanceof StandardGraphChildVariable) {
- return standardChildDomainProperties.getVariables(graph, context, map);
- } else {
- throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
- }
-
- }
-
- public static Map<String, Variable> getStandardPropertyDomainPropertyVariablesFromValue(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
-
- if(context instanceof StandardGraphPropertyVariable) {
- StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
- map = collectPropertiesFromContext(graph, variable, variable.property.predicate, classification, map);
- if (variable.parentResource != null) {
- Resource literal = graph.getPossibleObject(variable.parentResource, variable.property.predicate);
- if(literal != null) map=collectPropertiesFromContext(graph, variable, literal, classification, map);
- }
-
- // Get properties from VariableNode
- map = getStandardNodePropertyVariables(graph, context, map);
- return map;
- } else if (context instanceof StandardGraphChildVariable) {
- return standardChildDomainProperties.getVariables(graph, context, map);
- } else {
- throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
- }
-
- }
-
+ public static VariableMap methodsPropertyDomainProperties = new VariableMapImpl() {
+
+ @Override
+ public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+ Variable parent = context.getParent(graph);
+ Resource container = parent.getPossibleRepresents(graph);
+ if(container == null)
+ return null;
+ Map<String,Resource> methods = graph.syncRequest(new UnescapedMethodMapOfResource(container));
+ Resource predicate = methods.get(name);
+ if(predicate != null) {
+ Layer0 L0 = Layer0.getInstance(graph);
+ PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(L0.Entity_method));
+ Resource value = graph.getSingleObject(container, predicate);
+ return new StandardGraphPropertyVariable(context, null, container, info, value);
+ }
+ return null;
+ }
+
+ @Override
+ public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+ Variable parent = context.getParent(graph);
+ Resource container = parent.getPossibleRepresents(graph);
+ if(container == null)
+ return Collections.emptyMap();
+ Map<String,Resource> methods = graph.syncRequest(new UnescapedMethodMapOfResource(container));
+ for(Map.Entry<String, Resource> entry : methods.entrySet()) {
+ String name = entry.getKey();
+ Resource predicate = entry.getValue();
+ Layer0 L0 = Layer0.getInstance(graph);
+ PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(L0.Entity_method));
+ Resource value = graph.getSingleObject(container, predicate);
+ if(map == null) map = new HashMap<>();
+ map.put(name, new StandardGraphPropertyVariable(context, null, container, info, value));
+ }
+ return map;
+ }
+
+ };
+
+ public static Variable getStandardPropertyDomainPropertyVariableFromValue(ReadGraph graph, Variable context, String name) throws DatabaseException {
+
+ if(context instanceof StandardGraphPropertyVariable) {
+ StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+ Resource literal = variable.getPossibleRepresents(graph);
+ Object propertyNode = getPossibleNodeProperty(graph, variable, name, false);
+
+ if(literal != null) {
+ Variable result = getPossiblePropertyFromContext(graph, variable, literal, name, propertyNode);
+ if(result != null) return result;
+ }
+
+ Variable result = getPossibleSubliteralPropertyFromContext(graph, variable, name);
+ if(result != null) return result;
+ result = getPossiblePropertyFromContext(graph, variable, variable.property.predicate, name, propertyNode);
+ if (result != null) return result;
+
+ // Get possible property from NodeManager
+ if (propertyNode != null)
+ return createStandardGraphPropertyVariable(graph, variable, propertyNode);
+ return null;
+ } else if (context instanceof StandardGraphChildVariable) {
+ return standardChildDomainProperties.getVariable(graph, context, name);
+ } else {
+ throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
+ }
+
+ }
+
+ public static Map<String, Variable> getStandardPropertyDomainPropertyVariablesFromValue(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+
+ if(context instanceof StandardGraphPropertyVariable) {
+ StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+ map = collectPropertiesFromContext(graph, variable, variable.property.predicate, map);
+ if (variable.parentResource != null) {
+ Resource literal = graph.getPossibleObject(variable.parentResource, variable.property.predicate);
+ if(literal != null) map=collectPropertiesFromContext(graph, variable, literal, map);
+ map=collectSubliteralProperties(graph, variable, map);
+ }
+
+ // Get properties from VariableNode
+ map = getStandardNodePropertyVariables(graph, context, map);
+ return map;
+ } else if (context instanceof StandardGraphChildVariable) {
+ return standardChildDomainProperties.getVariables(graph, context, map);
+ } else {
+ throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
+ }
+
+ }
+
+ public static Map<String, Variable> getStandardPropertyDomainPropertyVariablesFromValue(ReadGraph graph, Variable context, String classification, Map<String, Variable> map) throws DatabaseException {
+
+ if(context instanceof StandardGraphPropertyVariable) {
+ StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
+ map = collectPropertiesFromContext(graph, variable, variable.property.predicate, classification, map);
+ if (variable.parentResource != null) {
+ Resource literal = graph.getPossibleObject(variable.parentResource, variable.property.predicate);
+ if(literal != null) map=collectPropertiesFromContext(graph, variable, literal, classification, map);
+ }
+
+ // Get properties from VariableNode
+ map = getStandardNodePropertyVariables(graph, context, map);
+ return map;
+ } else if (context instanceof StandardGraphChildVariable) {
+ return standardChildDomainProperties.getVariables(graph, context, map);
+ } else {
+ throw new DatabaseException("Unknown variable implementation " + context.getClass().getCanonicalName());
+ }
+
+ }
+