|
|
@@ -2,6 +2,7 @@ package ua.be.wee.controller;
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
+import java.sql.Timestamp;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -25,8 +26,10 @@ import ua.be.wee.model.nodes.FinalNode;
|
|
|
import ua.be.wee.model.nodes.Node;
|
|
|
import ua.be.wee.model.nodes.ports.ControlOutputPort;
|
|
|
import ua.be.wee.model.pm.PM;
|
|
|
+import ua.be.wee.model.pt.EndActivityEvent;
|
|
|
import ua.be.wee.model.pt.Event;
|
|
|
import ua.be.wee.model.pt.PT;
|
|
|
+import ua.be.wee.model.pt.TraceArtifact;
|
|
|
import ua.be.wee.model.repository.FusekiWrapper;
|
|
|
import ua.be.wee.service.FileStorageService;
|
|
|
|
|
|
@@ -108,12 +111,13 @@ public class EnactementControllerMVC {
|
|
|
List<Node> acts = (List<Node>) request.getSession().getAttribute("acts");
|
|
|
List<Node> endacts = (List<Node>) request.getSession().getAttribute("endacts");
|
|
|
Node node = pm.getNode(activity);
|
|
|
-
|
|
|
+ Object arts = request.getSession().getAttribute("arts");
|
|
|
if (node instanceof Activity) {
|
|
|
- List<Artifact> arts = new ArrayList<>();
|
|
|
- controller.addStartEvent(pt,(Activity)node,arts);
|
|
|
+
|
|
|
+ controller.addStartEvent(pt,(Activity)node,((List<TraceArtifact>)arts));
|
|
|
acts.remove(node);
|
|
|
endacts.add(node);
|
|
|
+ request.getSession().removeAttribute("arts");
|
|
|
return "enact";
|
|
|
} else if (node instanceof FinalNode) {
|
|
|
String previous = (String)request.getSession().getAttribute("previous");
|
|
|
@@ -147,7 +151,7 @@ public class EnactementControllerMVC {
|
|
|
for (String iri : iris) {
|
|
|
acts.add(pm.getNode(iri));
|
|
|
}
|
|
|
- List<Artifact> arts = new ArrayList<>();
|
|
|
+ List<TraceArtifact> arts = new ArrayList<TraceArtifact>();
|
|
|
|
|
|
controller.addEndEvent(pt,act,arts,p);
|
|
|
endacts.remove(act);
|
|
|
@@ -177,14 +181,19 @@ public class EnactementControllerMVC {
|
|
|
}
|
|
|
|
|
|
List<Artifact> arts = act.getOutputs();
|
|
|
+ List<TraceArtifact> traceArts = new ArrayList<TraceArtifact>();
|
|
|
for (Artifact artifact : arts) {
|
|
|
ArrayList<Part> parts = (ArrayList<Part>)request.getParts();
|
|
|
for (Part part : parts) {
|
|
|
if (part.getName().equals(artifact.getName())) {
|
|
|
- artifact.setLocation(part.getSubmittedFileName());
|
|
|
- artifact.setTag("v1"); //TODO fix the tag generation
|
|
|
- artifact.setGUID(part.getSubmittedFileName()+"-" +artifact.getTag());
|
|
|
+ TraceArtifact tArt = new TraceArtifact();
|
|
|
+ tArt.setLocation(part.getSubmittedFileName());
|
|
|
+ tArt.setTag("v1"); //TODO fix the tag generation
|
|
|
+ tArt.setGUID(part.getSubmittedFileName()+"-" +tArt.getTag());
|
|
|
+ tArt.setRelatesTo(artifact);
|
|
|
+ traceArts.add(tArt);
|
|
|
storageService.save(part);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -194,7 +203,7 @@ public class EnactementControllerMVC {
|
|
|
acts.add(pm.getNode(iri));
|
|
|
}
|
|
|
|
|
|
- controller.addEndEvent(pt,act,arts,p);
|
|
|
+ controller.addEndEvent(pt,act,traceArts,p);
|
|
|
endacts.remove(act);
|
|
|
|
|
|
|
|
|
@@ -228,18 +237,39 @@ public class EnactementControllerMVC {
|
|
|
@RequestMapping("/inarts")
|
|
|
public String selectActivity(Model model, @RequestParam String iri, HttpServletRequest request) throws Exception {
|
|
|
PM pm = (PM)request.getSession().getAttribute("pm");
|
|
|
+ PT pt = (PT)request.getSession().getAttribute("trace");
|
|
|
if (!iri.equals("1")) {
|
|
|
if (pm.getNode(iri) instanceof Activity) {
|
|
|
Activity act = (Activity)pm.getNode(iri);
|
|
|
List<Artifact> inputs = act.getInputs();
|
|
|
- model.addAttribute("arts", act.getInputs());
|
|
|
+ List<TraceArtifact> arts = new ArrayList<TraceArtifact>();
|
|
|
+ for (Artifact artifact : inputs) {
|
|
|
+ Timestamp time = Timestamp.valueOf("1900-01-01 00:00:00");
|
|
|
+ TraceArtifact chosen = null;
|
|
|
+ for (Event ev : pt.getEvents()) {
|
|
|
+ if (ev instanceof EndActivityEvent) {
|
|
|
+ List<TraceArtifact> producedArtifacts = ((EndActivityEvent) ev).getProducedArtifacts();
|
|
|
+ for (TraceArtifact traceArtifact : producedArtifacts) {
|
|
|
+ if (traceArtifact.getRelatesTo().getIri().equals(artifact.getIri()) && traceArtifact.getTimestamp().after(time)) {
|
|
|
+ chosen = traceArtifact;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (chosen != null) {
|
|
|
+ arts.add(chosen);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //model.addAttribute("arts", arts);
|
|
|
+ request.getSession().setAttribute("arts", arts);
|
|
|
model.addAttribute("storageURL", env.getProperty("storageURL"));
|
|
|
} else {
|
|
|
model.addAttribute("endBool", true);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- model.addAttribute("arts", null);
|
|
|
+ request.getSession().setAttribute("arts", null);
|
|
|
}
|
|
|
model.addAttribute("current", iri);
|
|
|
return "enact";
|