// We assert the range of the property only if we are given a dedicated graph value type
if(g.hasStatement(property, L0.HasRange))
g.deny(property, L0.HasRange);
-
+
if(possibleType != null) {
// We have a dedicated graph type for this SCL value type
if(g.hasStatement(possibleType, L0.Enumeration)) {
return;
}
- Layer0 L0 = Layer0.getInstance(g);
- Resource range = g.getPossibleObject(relation, L0.HasRange);
- if (range != null) {
+ Layer0 L0 = Layer0.getInstance(g);
+ Resource range = g.getPossibleObject(relation, L0.HasRange);
+ if (range != null) {
if(g.hasStatement(range, L0.Enumeration)) {
- Map<String,Resource> values = g.syncRequest(new EnumerationMap(range));
- Resource value = values.get(valueText);
- if (value != null) {
- for(Resource assertion : g.getObjects(type, L0.Asserts)) {
- Resource p = g.getSingleObject(assertion, L0.HasPredicate);
- if (p.equals(relation)) {
- g.deny(assertion, L0.HasObject, object);
- g.claim(assertion, L0.HasObject, value);
- }
- }
- }
- return;
+ Map<String,Resource> values = g.syncRequest(new EnumerationMap(range));
+ Resource value = values.get(valueText);
+ if (value != null) {
+ for(Resource assertion : g.getObjects(type, L0.Asserts)) {
+ Resource p = g.getSingleObject(assertion, L0.HasPredicate);
+ if (p.equals(relation)) {
+ g.deny(assertion, L0.HasObject, object);
+ g.claim(assertion, L0.HasObject, value);
+ }
+ }
+ }
+ return;
}
}
if(valueText.length() > 0 && valueText.charAt(0) == '=') {
- String expression = valueText.substring(1);
+ String expression = valueText.substring(1);
ModelingResources MOD = ModelingResources.getInstance(g);
if(!g.isInstanceOf(object, MOD.SCLValue)) {
Resource assertion = g.getSingleObject(object, L0.HasObjectInverse);
}
return null;
}
-
+
public static void convertDefaultValue(WriteGraph g,
Resource type, Resource relation, String newSCLType, Resource possibleType) throws DatabaseException {
Resource object = getAssertedObject(g, type, relation);
Map<String, Resource> enumMap = g.syncRequest(new EnumerationMap(possibleType));
String firstKey = Collections.min(enumMap.keySet(), AlphanumComparator.COMPARATOR);
Resource defaultValue = enumMap.get(firstKey);
-
+
if (defaultValue != null) {
Resource assertion = findAssertionWithPO(g, type, relation, object);
if(assertion != null) {
return;
}
}
+ } else {
+ return;
}
}
}
if (tuple == null)
return;
+ if(g.sync(new IsEnumeratedValue(object))) {
+ Resource assertion = findAssertionWithPO(g, type, relation, object);
+ object = g.newResource();
+ g.claim(object, L0.InstanceOf, L0.Literal);
+ if(assertion != null) {
+ g.deny(assertion, L0.HasObject);
+ g.claim(assertion, L0.HasObject, object);
+ }
+ }
+
g.claimLiteral(object, L0.HasDataType, L0.DataType, tuple.get(0), Bindings.getBindingUnchecked(Datatype.class));
g.claimLiteral(object, L0.HasValueType, g.<String>getRelatedValue(relation, L0.RequiresValueType, Bindings.STRING), Bindings.STRING);
g.claimValue(object, tuple.get(1), (Binding)tuple.get(2));
public static void convertInstantiatedValue(WriteGraph g, Resource instance, Resource relation, String newSCLType) throws DatabaseException {
convertInstantiatedValue(g, instance, relation, newSCLType, null);
}
-
+
public static void convertInstantiatedValue(WriteGraph g, Resource instance, Resource relation, String newSCLType, Resource possibleType)
throws DatabaseException {
if(stm != null && !stm.isAsserted(instance)) {
Layer0 L0 = Layer0.getInstance(g);
- Resource object = stm.getObject();
+ Resource object = stm.getObject();
- if(g.sync(new IsEnumeratedValue(object))) {
- if(!g.isInstanceOf(object, possibleType)) {
- g.deny(instance, relation);
- }
- return;
- }
+ if(g.sync(new IsEnumeratedValue(object))) {
+ if(!g.isInstanceOf(object, possibleType)) {
+ g.deny(instance, relation);
+ }
+ return;
+ }
// We can only convert literals
if(!g.isInstanceOf(object, L0.Literal)) return;