|
@@ -4,6 +4,7 @@ import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -20,10 +21,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import ua.be.wee.model.EnactmentController;
|
|
|
+import ua.be.wee.model.NamedElement;
|
|
|
import ua.be.wee.model.nodes.Activity;
|
|
|
import ua.be.wee.model.nodes.Artifact;
|
|
|
import ua.be.wee.model.nodes.FinalNode;
|
|
|
import ua.be.wee.model.nodes.Node;
|
|
|
+import ua.be.wee.model.nodes.ports.ControlInputPort;
|
|
|
import ua.be.wee.model.nodes.ports.ControlOutputPort;
|
|
|
import ua.be.wee.model.pm.PM;
|
|
|
import ua.be.wee.model.pt.EndActivityEvent;
|
|
@@ -31,6 +34,7 @@ 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.model.util.Pair;
|
|
|
import ua.be.wee.service.FileStorageService;
|
|
|
|
|
|
@Controller
|
|
@@ -87,11 +91,8 @@ public class EnactementControllerMVC {
|
|
|
} else {
|
|
|
PM pm = controller.getPM(pmiri);
|
|
|
PT trace = controller.createTrace(pm);
|
|
|
- List<String> iris = controller.findNextNodes(pm.getInitial().getIri());
|
|
|
- List<Node> acts = new ArrayList<Node>();
|
|
|
- for (String iri : iris) {
|
|
|
- acts.add(pm.getNode(iri));
|
|
|
- }
|
|
|
+ List<Pair<String,String>> iris = controller.findNextNodes(pm.getInitial().getIri());
|
|
|
+ List<PMTrigger> acts = findElements(pm, iris);
|
|
|
model.addAttribute("error", false);
|
|
|
request.getSession().setAttribute("pm", pm);
|
|
|
request.getSession().setAttribute("trace", trace);
|
|
@@ -103,19 +104,42 @@ public class EnactementControllerMVC {
|
|
|
return "enact";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private List<PMTrigger> findElements(PM pm, List<Pair<String, String>> iris) {
|
|
|
+ List<PMTrigger> acts = new ArrayList<PMTrigger>();
|
|
|
+ for (Pair<String,String> pair : iris) {
|
|
|
+ PMTrigger tr = new PMTrigger();
|
|
|
+ if (pair.getSnd() != null) {
|
|
|
+ List<ControlInputPort> ctrlInPorts = ((Activity)pm.getNode(pair.getSnd())).getCtrlInPorts();
|
|
|
+ ControlInputPort port = null;
|
|
|
+ for (ControlInputPort ctr : ctrlInPorts) {
|
|
|
+ if (ctr.getIri().equals(pair.getFst())) {
|
|
|
+ port = ctr;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tr.setPort(port);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ tr.setNode((FinalNode)pm.getNode(pair.getFst()));
|
|
|
+ }
|
|
|
+ acts.add(tr);
|
|
|
+ }
|
|
|
+ return acts;
|
|
|
+ }
|
|
|
|
|
|
@PostMapping("/startAct")
|
|
|
public String startActivity(Model model, @RequestParam String activity, HttpServletRequest request) throws Exception {
|
|
|
PM pm = (PM)request.getSession().getAttribute("pm");
|
|
|
PT pt = (PT)request.getSession().getAttribute("trace");
|
|
|
- List<Node> acts = (List<Node>) request.getSession().getAttribute("acts");
|
|
|
+ List<PMTrigger> acts = (List<PMTrigger>) 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) {
|
|
|
|
|
|
controller.addStartEvent(pt,(Activity)node,((List<TraceArtifact>)arts));
|
|
|
- acts.remove(node);
|
|
|
+ removeElement(acts,node);
|
|
|
endacts.add(node);
|
|
|
request.getSession().removeAttribute("arts");
|
|
|
return "enact";
|
|
@@ -132,10 +156,20 @@ public class EnactementControllerMVC {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/endAct")
|
|
|
+ private void removeElement(List<PMTrigger> acts, Node node) {
|
|
|
+ for (PMTrigger pmTrigger : acts) {
|
|
|
+ if (pmTrigger.getIri().equals(node.getIri())) {
|
|
|
+ acts.remove(pmTrigger);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/endAct")
|
|
|
public String endActivity(Model model, @RequestParam String port, @RequestParam String activity, HttpServletRequest request) throws Exception {
|
|
|
PM pm = (PM)request.getSession().getAttribute("pm");
|
|
|
- List<Node> acts = (List<Node>)request.getSession().getAttribute("acts");
|
|
|
+ List<PMTrigger> acts = (List<PMTrigger>)request.getSession().getAttribute("acts");
|
|
|
List<Node> endacts = (List<Node>)request.getSession().getAttribute("endacts");
|
|
|
PT pt = (PT)request.getSession().getAttribute("trace");
|
|
|
Activity act = (Activity)pm.getNode(activity);
|
|
@@ -147,13 +181,11 @@ public class EnactementControllerMVC {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- List<String> iris = controller.findNextNodes(p.getIri());
|
|
|
- for (String iri : iris) {
|
|
|
- acts.add(pm.getNode(iri));
|
|
|
- }
|
|
|
+ List<Pair<String,String>> iris = controller.findNextNodes(p.getIri());
|
|
|
+ acts.addAll(findElements(pm, iris));
|
|
|
List<TraceArtifact> arts = new ArrayList<TraceArtifact>();
|
|
|
|
|
|
- controller.addEndEvent(pt,act,arts,p);
|
|
|
+ controller.addEndEvent(pt,arts,p);
|
|
|
endacts.remove(act);
|
|
|
|
|
|
|
|
@@ -167,7 +199,7 @@ public class EnactementControllerMVC {
|
|
|
@PostMapping("/endActArt")
|
|
|
public String endActivityWithArtifacts(Model model, @RequestParam String port, @RequestParam String activity, HttpServletRequest request) throws Exception {
|
|
|
PM pm = (PM)request.getSession().getAttribute("pm");
|
|
|
- List<Node> acts = (List<Node>)request.getSession().getAttribute("acts");
|
|
|
+ List<PMTrigger> acts = (List<PMTrigger>)request.getSession().getAttribute("acts");
|
|
|
List<Node> endacts = (List<Node>)request.getSession().getAttribute("endacts");
|
|
|
PT pt = (PT)request.getSession().getAttribute("trace");
|
|
|
Activity act = (Activity)pm.getNode(activity);
|
|
@@ -188,7 +220,7 @@ public class EnactementControllerMVC {
|
|
|
if (part.getName().equals(artifact.getName())) {
|
|
|
TraceArtifact tArt = new TraceArtifact();
|
|
|
tArt.setLocation(part.getSubmittedFileName());
|
|
|
- tArt.setTag("v1"); //TODO fix the tag generation
|
|
|
+ //tArt.setTag("v1"); //TODO fix the tag generation
|
|
|
tArt.setGUID(part.getSubmittedFileName()+"-" +tArt.getTag());
|
|
|
tArt.setRelatesTo(artifact);
|
|
|
traceArts.add(tArt);
|
|
@@ -198,15 +230,16 @@ public class EnactementControllerMVC {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<String> iris = controller.findNextNodes(p.getIri());
|
|
|
- for (String iri : iris) {
|
|
|
- acts.add(pm.getNode(iri));
|
|
|
- }
|
|
|
-
|
|
|
- controller.addEndEvent(pt,act,traceArts,p);
|
|
|
+ controller.addEndEvent(pt,traceArts,p);
|
|
|
endacts.remove(act);
|
|
|
|
|
|
|
|
|
+ List<Pair<String,String>> iris = controller.findNextNodes(p.getIri());
|
|
|
+ acts.addAll(findElements(pm, iris));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
request.getSession().setAttribute("trace", pt);
|
|
|
request.getSession().setAttribute("previous", p.getIri());
|
|
@@ -259,7 +292,6 @@ public class EnactementControllerMVC {
|
|
|
if (chosen != null) {
|
|
|
arts.add(chosen);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
//model.addAttribute("arts", arts);
|
|
|
request.getSession().setAttribute("arts", arts);
|