|
@@ -46,13 +46,13 @@ import ua.be.wee.model.util.Pair;
|
|
|
public class EnactmentControllerMVC {
|
|
|
|
|
|
@Autowired private EnactmentController controller;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private PTController ptController;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private Environment env;
|
|
|
-
|
|
|
+
|
|
|
@Value("${base_url}")
|
|
|
private String baseUrl;
|
|
|
|
|
@@ -86,7 +86,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);
|
|
@@ -100,8 +100,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"))) {
|
|
@@ -111,7 +111,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);
|
|
@@ -126,17 +126,17 @@ public class EnactmentControllerMVC {
|
|
|
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);
|
|
@@ -147,7 +147,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);
|
|
@@ -156,10 +155,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);
|
|
@@ -170,7 +167,7 @@ public class EnactmentControllerMVC {
|
|
|
return "enact";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
private List<PMTrigger> findStartActs(PT trace) throws Exception {
|
|
|
PM pmEnacted = trace.getPmEnacted();
|
|
@@ -188,10 +185,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 {
|
|
@@ -207,9 +204,9 @@ public class EnactmentControllerMVC {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
result.addAll(findElements(trace.getPmEnacted(), findNextNodes));
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -232,7 +229,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) {
|
|
@@ -240,7 +237,7 @@ public class EnactmentControllerMVC {
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private List<Node> findEndActs(List<Event> events) {
|
|
@@ -297,8 +294,8 @@ public class EnactmentControllerMVC {
|
|
|
return "error";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@PostMapping("/endAct")
|
|
|
public String endActivityWithArtifacts(Model model, @RequestParam String port, @RequestParam String activity, HttpServletRequest request) throws Exception {
|
|
@@ -315,7 +312,7 @@ public class EnactmentControllerMVC {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
List<Artifact> arts = act.getOutputs();
|
|
|
List<TraceArtifact> traceArts = new ArrayList<TraceArtifact>();
|
|
|
for (Artifact artifact : arts) {
|
|
@@ -328,16 +325,16 @@ public class EnactmentControllerMVC {
|
|
|
traceArts.add(tArt);
|
|
|
controller.uploadArtifact(part.getInputStream(),part.getSubmittedFileName());
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
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));
|
|
@@ -348,7 +345,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");
|
|
@@ -357,17 +354,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");
|
|
@@ -398,21 +395,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) {
|
|
@@ -435,7 +432,7 @@ public class EnactmentControllerMVC {
|
|
|
}
|
|
|
return acts;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private PMTrigger findPMTrigger(List<PMTrigger> acts, String iri) {
|
|
|
for (PMTrigger pmTrigger : acts) {
|
|
|
if (pmTrigger.getIri().equals(iri)) {
|
|
@@ -455,5 +452,5 @@ public class EnactmentControllerMVC {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|