|
@@ -46,13 +46,13 @@ import ua.be.wee.service.FileStorageService;
|
|
|
public class EnactmentControllerMVC {
|
|
|
|
|
|
@Autowired private EnactmentController controller;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private PTController ptController;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private Environment env;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
FileStorageService storageService;
|
|
|
|
|
@@ -89,7 +89,7 @@ public class EnactmentControllerMVC {
|
|
|
return "index";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@RequestMapping("/gettraces")
|
|
|
public String getTraces(Model model, @RequestParam String iri, HttpServletRequest request) throws Exception {
|
|
|
List<StartTraceEvent> activeTraces = ptController.getActiveTraces(iri);
|
|
@@ -103,8 +103,8 @@ public class EnactmentControllerMVC {
|
|
|
model.addAttribute("current", iri);
|
|
|
return "pms";
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
@RequestMapping(value="/enactpm", method=RequestMethod.POST, params="action=new")
|
|
|
public String getPMtoEnact(Model model, @RequestParam String pmiri, HttpServletRequest request) throws Exception {
|
|
|
if ((pmiri.equals("select PM"))) {
|
|
@@ -114,7 +114,7 @@ public class EnactmentControllerMVC {
|
|
|
model.addAttribute("current", "1");
|
|
|
return "pms";
|
|
|
} else {
|
|
|
- PM pm = controller.getPM(pmiri);
|
|
|
+ PM pm = controller.getPM(pmiri);
|
|
|
PT trace = controller.createTrace(pm);
|
|
|
List<Pair<String,String>> iris = controller.findNextNodes(pm.getInitial().getIri(), trace.getIri());
|
|
|
List<PMTrigger> acts = findElements(pm, iris);
|
|
@@ -122,23 +122,23 @@ public class EnactmentControllerMVC {
|
|
|
request.getSession().setAttribute("pm", pm);
|
|
|
request.getSession().setAttribute("trace", trace);
|
|
|
request.getSession().setAttribute("acts",acts);
|
|
|
- request.getSession().setAttribute("endacts",new ArrayList<Node>());
|
|
|
+ request.getSession().setAttribute("endacts",new ArrayList<Node>()); // TODO Is this a typo?
|
|
|
model.addAttribute("arts", null);
|
|
|
model.addAttribute("current", "1");
|
|
|
return "enact";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@RequestMapping(value="/enactpm", method=RequestMethod.POST, params="action=continue")
|
|
|
public String continueEnact(Model model, @RequestParam String pmiri, @RequestParam String contTrace, HttpServletRequest request) throws Exception {
|
|
|
- if ((pmiri.equals("select PM")) || contTrace != null && contTrace.equals("Select Trace")) {
|
|
|
- model.addAttribute("error", true);
|
|
|
+ if ((pmiri.equals("select PM")) || contTrace != null && contTrace.equals("Select Trace")) {
|
|
|
+ model.addAttribute("error", true);
|
|
|
model.addAttribute("pms", controller.getAllPMs());
|
|
|
model.addAttribute("traces",null);
|
|
|
model.addAttribute("current", "1");
|
|
|
return "pms";
|
|
|
} else {
|
|
|
- PM pm = controller.getPM(pmiri);
|
|
|
+ PM pm = controller.getPM(pmiri);
|
|
|
List<Event> events = ptController.getEvents(contTrace);
|
|
|
PT trace = new PT();
|
|
|
trace.setEvents(events);
|
|
@@ -149,7 +149,6 @@ public class EnactmentControllerMVC {
|
|
|
List<Pair<String,String>> iris = controller.findNextNodes(pm.getInitial().getIri(), trace.getIri());
|
|
|
List<PMTrigger> acts = findElements(pm, iris);
|
|
|
request.getSession().setAttribute("acts",acts);
|
|
|
-
|
|
|
} else {
|
|
|
endActs = findEndActs(events);
|
|
|
List<PMTrigger> acts = findStartActs(trace);
|
|
@@ -158,10 +157,8 @@ public class EnactmentControllerMVC {
|
|
|
List<Pair<String,String>> iris = controller.findNextNodes(last.getRelatesTo().getIri(), trace.getIri());
|
|
|
acts.addAll(findElements(pm, iris));
|
|
|
}
|
|
|
-
|
|
|
request.getSession().setAttribute("acts",acts);
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
model.addAttribute("error", false);
|
|
|
request.getSession().setAttribute("pm", pm);
|
|
|
request.getSession().setAttribute("trace", trace);
|
|
@@ -171,7 +168,7 @@ public class EnactmentControllerMVC {
|
|
|
return "enact";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
private List<PMTrigger> findStartActs(PT trace) throws Exception {
|
|
|
PM pmEnacted = trace.getPmEnacted();
|
|
@@ -189,10 +186,10 @@ public class EnactmentControllerMVC {
|
|
|
}
|
|
|
}
|
|
|
List<String> consider = checkTrace(trace,actIris);
|
|
|
-
|
|
|
+
|
|
|
for (Iterator<Pair<String,String>> iterator = findNextNodes.iterator(); iterator.hasNext();) {
|
|
|
Pair<String,String> pair = iterator.next();
|
|
|
-
|
|
|
+
|
|
|
if (pair.getSnd() == null) {
|
|
|
findNextNodes.remove(pair);
|
|
|
} else {
|
|
@@ -208,9 +205,9 @@ public class EnactmentControllerMVC {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
result.addAll(findElements(trace.getPmEnacted(), findNextNodes));
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -233,7 +230,7 @@ public class EnactmentControllerMVC {
|
|
|
}
|
|
|
pairs.add(new Pair<String, Integer>(iri, count));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
List<String> result = new ArrayList<String>();
|
|
|
for (Pair<String, Integer> pair : pairs) {
|
|
|
if (pair.getSnd() < max) {
|
|
@@ -241,7 +238,7 @@ public class EnactmentControllerMVC {
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private List<Node> findEndActs(List<Event> events) {
|
|
@@ -289,11 +286,11 @@ public class EnactmentControllerMVC {
|
|
|
} else {
|
|
|
return "error";
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@PostMapping("/endAct")
|
|
|
public String endActivityWithArtifacts(Model model, @RequestParam String port, @RequestParam String activity, HttpServletRequest request) throws Exception {
|
|
@@ -310,7 +307,7 @@ public class EnactmentControllerMVC {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
List<Artifact> arts = act.getOutputs();
|
|
|
List<TraceArtifact> traceArts = new ArrayList<TraceArtifact>();
|
|
|
for (Artifact artifact : arts) {
|
|
@@ -323,16 +320,16 @@ public class EnactmentControllerMVC {
|
|
|
traceArts.add(tArt);
|
|
|
storageService.save(part);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
controller.addEndEvent(pt,traceArts,p);
|
|
|
for (Node activ : endacts) {
|
|
|
if (activ.getIri().equals(act.getIri())) {
|
|
|
endacts.remove(activ);
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
List<Pair<String,String>> iris = controller.findNextNodes(p.getIri(), pt.getIri());
|
|
|
acts.addAll(findElements(pm, iris));
|
|
@@ -343,7 +340,7 @@ public class EnactmentControllerMVC {
|
|
|
model.addAttribute("current", "1");
|
|
|
return "enact";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@RequestMapping("/endselect")
|
|
|
public String selectActivityToEnd(Model model, @RequestParam String iri, HttpServletRequest request) throws Exception {
|
|
|
PM pm = (PM)request.getSession().getAttribute("pm");
|
|
@@ -352,17 +349,17 @@ public class EnactmentControllerMVC {
|
|
|
Activity act = (Activity)pm.getNode(iri);
|
|
|
model.addAttribute("act", pm.getNode(iri));
|
|
|
model.addAttribute("arts", act.getOutputs());
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
model.addAttribute("endBool", true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
model.addAttribute("arts", null);
|
|
|
}
|
|
|
|
|
|
return "enactEnd";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@RequestMapping("/inarts")
|
|
|
public String selectActivity(Model model, @RequestParam String iri, HttpServletRequest request) throws Exception {
|
|
|
PT pt = (PT)request.getSession().getAttribute("trace");
|
|
@@ -393,21 +390,21 @@ public class EnactmentControllerMVC {
|
|
|
//model.addAttribute("arts", arts);
|
|
|
request.getSession().setAttribute("arts", arts);
|
|
|
model.addAttribute("storageURL", env.getProperty("storageURL"));
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
model.addAttribute("endBool", true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
request.getSession().setAttribute("arts", null);
|
|
|
}
|
|
|
model.addAttribute("current", iri);
|
|
|
return "enact";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
// Helper methods
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
private List<PMTrigger> findElements(PM pm, List<Pair<String, String>> iris) {
|
|
|
List<PMTrigger> acts = new ArrayList<PMTrigger>();
|
|
|
for (Pair<String,String> pair : iris) {
|
|
@@ -430,7 +427,7 @@ public class EnactmentControllerMVC {
|
|
|
}
|
|
|
return acts;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private PMTrigger findPMTrigger(List<PMTrigger> acts, String iri) {
|
|
|
for (PMTrigger pmTrigger : acts) {
|
|
|
if (pmTrigger.getIri().equals(iri)) {
|
|
@@ -450,5 +447,5 @@ public class EnactmentControllerMVC {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|