|
@@ -28,7 +28,7 @@ public class NodeRespository {
|
|
|
@Autowired
|
|
|
private PMRepository pmRepo;
|
|
|
|
|
|
- public List<Node> getNodes(String pmIri) {
|
|
|
+ public List<Node> getNodes(String pmIri) throws Exception {
|
|
|
List<Node> nodes = new ArrayList<Node>();
|
|
|
|
|
|
PM pm = pmRepo.getPM(pmIri);
|
|
@@ -237,7 +237,7 @@ public class NodeRespository {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void updateArtifactOfActivities(PM pm) {
|
|
|
+ private void updateArtifactOfActivities(PM pm) throws Exception {
|
|
|
for (Node node : pm.getNodes()) {
|
|
|
if (node instanceof Activity) {
|
|
|
Activity act = (Activity) node;
|
|
@@ -247,13 +247,18 @@ public class NodeRespository {
|
|
|
+ " ?inport owl:sameAs <" + inport.getIri() + "> .\n" + " ?inport pm:dataFrom ?art .\n"
|
|
|
+ "}";
|
|
|
ResultSet results = FusekiWrapper.getInstance().execQuery(query);
|
|
|
- QuerySolution soln = results.nextSolution();
|
|
|
-
|
|
|
- RDFNode art = soln.get("?art");
|
|
|
- if (art != null && !art.toString().isEmpty()) {
|
|
|
- Artifact artifact = (Artifact) pm.getNode(art.toString());
|
|
|
- act.addInputArtifact(artifact);
|
|
|
+ if (results.hasNext()) {
|
|
|
+ QuerySolution soln = results.nextSolution();
|
|
|
+
|
|
|
+ RDFNode art = soln.get("?art");
|
|
|
+ if (art != null && !art.toString().isEmpty()) {
|
|
|
+ Artifact artifact = (Artifact) pm.getNode(art.toString());
|
|
|
+ act.addInputArtifact(artifact);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new Exception("Query did not return any data: \n" + query );
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
for (DataOutputPort outport : act.getDataOutPorts()) {
|
|
@@ -262,19 +267,23 @@ public class NodeRespository {
|
|
|
+ "WHERE { \n" + " ?outport owl:sameAs <" + outport.getIri() + "> .\n"
|
|
|
+ " ?outport pm:dataTo ?art .\n" + "}";
|
|
|
ResultSet results = FusekiWrapper.getInstance().execQuery(query);
|
|
|
- QuerySolution soln = results.nextSolution();
|
|
|
-
|
|
|
- RDFNode art = soln.get("?art");
|
|
|
- if (art != null && !art.toString().isEmpty()) {
|
|
|
- Artifact artifact = (Artifact) pm.getNode(art.toString());
|
|
|
- act.addOutputArtifact(artifact);
|
|
|
+ if (results.hasNext()) {
|
|
|
+ QuerySolution soln = results.nextSolution();
|
|
|
+
|
|
|
+ RDFNode art = soln.get("?art");
|
|
|
+ if (art != null && !art.toString().isEmpty()) {
|
|
|
+ Artifact artifact = (Artifact) pm.getNode(art.toString());
|
|
|
+ act.addOutputArtifact(artifact);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new Exception("Query did not return any data: \n" + query );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Node createNode(RDFNode iri, RDFNode type) {
|
|
|
+ private Node createNode(RDFNode iri, RDFNode type) throws Exception {
|
|
|
Node node = null;
|
|
|
switch (type.toString()) {
|
|
|
case Node.ACTIVITY_IRI:
|
|
@@ -299,7 +308,7 @@ public class NodeRespository {
|
|
|
return node;
|
|
|
}
|
|
|
|
|
|
- private Node createArtifact(String iri) {
|
|
|
+ private Node createArtifact(String iri) throws Exception {
|
|
|
Artifact art = new Artifact();
|
|
|
String query = "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"
|
|
|
+ "PREFIX pm: <http://ua.be/sdo2l/vocabulary/formalisms/pm#>\n"
|
|
@@ -307,17 +316,21 @@ public class NodeRespository {
|
|
|
+ " ?art owl:sameAs <" + iri + "> .\n" + " ?art pm:hasName ?name .\n"
|
|
|
+ " ?art pm:hasType ?type .\n" + " ?type base:hasGUID ?typename .\n" + "}";
|
|
|
ResultSet results = FusekiWrapper.getInstance().execQuery(query);
|
|
|
- QuerySolution soln = results.nextSolution();
|
|
|
- RDFNode name = soln.get("?name");
|
|
|
- RDFNode type = soln.get("?typename");
|
|
|
- art.setIri(iri);
|
|
|
- art.setName(name.toString());
|
|
|
- art.setType(type.toString());
|
|
|
-
|
|
|
- return art;
|
|
|
+ if (results.hasNext()) {
|
|
|
+ QuerySolution soln = results.nextSolution();
|
|
|
+ RDFNode name = soln.get("?name");
|
|
|
+ RDFNode type = soln.get("?typename");
|
|
|
+ art.setIri(iri);
|
|
|
+ art.setName(name.toString());
|
|
|
+ art.setType(type.toString());
|
|
|
+ return art;
|
|
|
+ } else {
|
|
|
+ throw new Exception("Query did not return any data: \n" + query );
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- private Node createActivity(String iri) {
|
|
|
+ private Node createActivity(String iri) throws Exception {
|
|
|
Activity act = new Activity();
|
|
|
String query = "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"
|
|
|
+ "PREFIX ftg: <http://ua.be/sdo2l/vocabulary/formalisms/ftg#>"
|
|
@@ -326,19 +339,24 @@ public class NodeRespository {
|
|
|
+ " ?act owl:sameAs <" + iri + ">;\n" + " pm:isTransformation ?t ; \n"
|
|
|
+ " pm:hasName ?name . \n" + " ?t base:hasGUID ?type . \n" + "}";
|
|
|
ResultSet results = FusekiWrapper.getInstance().execQuery(query);
|
|
|
- QuerySolution soln = results.nextSolution();
|
|
|
- RDFNode name = soln.get("?name");
|
|
|
- RDFNode type = soln.get("?type");
|
|
|
- act.setIri(iri);
|
|
|
- act.setName(name.toString());
|
|
|
- act.setTransformationName(type.toString());
|
|
|
-
|
|
|
- act.setCtrlInPorts(getCtrlInPorts(act));
|
|
|
- act.setCtrlOutPorts(getCtrlOutPorts(act));
|
|
|
- act.setDatalInPorts(getDataInPorts(act));
|
|
|
- act.setDataOutPorts(getDataOutPorts(act));
|
|
|
-
|
|
|
- return act;
|
|
|
+ if (results.hasNext()) {
|
|
|
+ QuerySolution soln = results.nextSolution();
|
|
|
+ RDFNode name = soln.get("?name");
|
|
|
+ RDFNode type = soln.get("?type");
|
|
|
+ act.setIri(iri);
|
|
|
+ act.setName(name.toString());
|
|
|
+ act.setTransformationName(type.toString());
|
|
|
+
|
|
|
+ act.setCtrlInPorts(getCtrlInPorts(act));
|
|
|
+ act.setCtrlOutPorts(getCtrlOutPorts(act));
|
|
|
+ act.setDatalInPorts(getDataInPorts(act));
|
|
|
+ act.setDataOutPorts(getDataOutPorts(act));
|
|
|
+
|
|
|
+ return act;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new Exception("Query did not return any data: \n" + query );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private List<DataOutputPort> getDataOutPorts(Activity act) {
|