|
@@ -116,14 +116,14 @@ class ModelverseState(object):
|
|
|
def create_dict(self, source, data, destination):
|
|
|
if not isinstance(source, rdflib.URIRef):
|
|
|
return (None, status.FAIL_CDICT_SOURCE)
|
|
|
- if not isinstance(target, rdflib.URIRef):
|
|
|
+ if not isinstance(destination, rdflib.URIRef):
|
|
|
return (None, status.FAIL_CDICT_TARGET)
|
|
|
if not self.is_valid_datavalue(data):
|
|
|
return (None, status.FAIL_CDICT_OOB)
|
|
|
|
|
|
n = self.create_nodevalue(data)[0]
|
|
|
e = self.create_edge(source, destination)[0]
|
|
|
- t = self.create_edge(e, n)
|
|
|
+ self.create_edge(e, n)
|
|
|
return (None, status.SUCCESS)
|
|
|
|
|
|
def read_value(self, node):
|
|
@@ -148,9 +148,11 @@ class ModelverseState(object):
|
|
|
"""
|
|
|
SELECT ?link
|
|
|
WHERE {
|
|
|
- <%s> MV:hasTarget ?link .
|
|
|
+ ?link MV:hasSource <%s> .
|
|
|
}
|
|
|
""" % elem)
|
|
|
+ print(elem)
|
|
|
+ print("Result: " + str(len(result)))
|
|
|
return ([i[0] for i in result], status.SUCCESS)
|
|
|
|
|
|
def read_incoming(self, elem):
|
|
@@ -160,7 +162,7 @@ class ModelverseState(object):
|
|
|
"""
|
|
|
SELECT ?link
|
|
|
WHERE {
|
|
|
- <%s> MV:hasSource ?link .
|
|
|
+ ?link MV:hasTarget <%s> .
|
|
|
}
|
|
|
""" % elem)
|
|
|
return ([i[0] for i in result], status.SUCCESS)
|
|
@@ -168,7 +170,7 @@ class ModelverseState(object):
|
|
|
def read_edge(self, edge):
|
|
|
result = self.graph.query(
|
|
|
"""
|
|
|
- SELECT ?source, ?target
|
|
|
+ SELECT ?source ?target
|
|
|
WHERE {
|
|
|
<%s> MV:hasSource ?source ;
|
|
|
MV:hasTarget ?target .
|
|
@@ -230,7 +232,7 @@ class ModelverseState(object):
|
|
|
MV:hasTarget ?attr_node .
|
|
|
?attr_node MV:hasValue '%s' .
|
|
|
}
|
|
|
- """ % (node, value))
|
|
|
+ """ % (node, json.dumps(value)))
|
|
|
if len(result) == 0:
|
|
|
return (None, status.FAIL_RDICTE_NOT_FOUND)
|
|
|
return (list(result)[0][0], status.SUCCESS)
|
|
@@ -282,7 +284,7 @@ class ModelverseState(object):
|
|
|
MV:hasTarget ?value_node .
|
|
|
?value_node MV:hasValue '%s' .
|
|
|
}
|
|
|
- """ % (node, value))
|
|
|
+ """ % (node, json.dumps(value)))
|
|
|
|
|
|
return ([i[0] for i in result], status.SUCCESS)
|
|
|
|
|
@@ -311,10 +313,10 @@ class ModelverseState(object):
|
|
|
return (None, status.SUCCESS)
|
|
|
|
|
|
def delete_edge(self, edge):
|
|
|
- if not isinstance(node, rdflib.URIRef):
|
|
|
+ if not isinstance(edge, rdflib.URIRef):
|
|
|
return (None, status.FAIL_DN_UNKNOWN)
|
|
|
# Remove its links
|
|
|
- self.graph.remove((node, None, None))
|
|
|
+ self.graph.remove((edge, None, None))
|
|
|
|
|
|
# Get all edges connecting this
|
|
|
result = self.graph.query(
|