Browse Source

Adding the support for running remote automated activities.

Lucas Albertins 1 year ago
parent
commit
b5421ffc4a

+ 5 - 3
src/main/java/ua/be/wee/controller/EnactmentControllerMVC.java

@@ -299,7 +299,6 @@ public class EnactmentControllerMVC {
     	PT pt = (PT)request.getSession().getAttribute("trace");
     	List<PMTrigger> acts = (List<PMTrigger>) request.getSession().getAttribute("acts");
     	List<Node> endacts = (List<Node>) request.getSession().getAttribute("endacts");
-    	List<AutomatedActivity> automated = (List<AutomatedActivity>) request.getSession().getAttribute("automated");
     	PMTrigger element = findPMTrigger(acts,iri);
     	List<TraceArtifact> arts = (List<TraceArtifact>)request.getSession().getAttribute("arts");
     	if (element.getPort() != null) {
@@ -309,18 +308,19 @@ public class EnactmentControllerMVC {
 				AutomatedActivity aut = (AutomatedActivity)activity;
 				controller.callAutomatedActivity(pt,aut, arts);
 				aut.setAutomatedStatus(AutomatedStatus.IN_PROGRESS);
-				automated.add(aut);
 			} else {
 				endacts.add(port.getActivity());
 			}
         	controller.addStartEvent(pt,port, port.getActivity(),arts);
         	removeElement(acts,iri);
+        	request.getSession().setAttribute("automated",controller.getAutomatedActivities(pt));
         	request.getSession().removeAttribute("arts");
         	return "enact";
 		} else if (element.getNode() != null) {
 			Event endTraceEvent = controller.addEndTraceEvent(pt.getIri(), pt.getLastEvent().getIri(), pm.getIri());
 			pt.addEvent(endTraceEvent);
 			controller.updatePT(pt);
+			request.getSession().setAttribute("automated",controller.getAutomatedActivities(pt));
 			return "endEnactment";
 		} else {
 			return "error";
@@ -372,6 +372,7 @@ public class EnactmentControllerMVC {
         acts.addAll(findElements(pm, iris));
 
     	request.getSession().setAttribute("trace", pt);
+    	request.getSession().setAttribute("automated",controller.getAutomatedActivities(pt));
     	//request.getSession().setAttribute("previous", p.getIri());
 		model.addAttribute("arts", null);
 		model.addAttribute("current", "1");
@@ -393,7 +394,7 @@ public class EnactmentControllerMVC {
 		} else {
 			model.addAttribute("arts", null);
 		}
-
+    	
     	return "enactEnd";
     }
 
@@ -434,6 +435,7 @@ public class EnactmentControllerMVC {
 		} else {
 			request.getSession().setAttribute("arts", null);
 		}
+    	request.getSession().setAttribute("automated",controller.getAutomatedActivities(pt));
     	model.addAttribute("current", iri);
     	return "enact";
     }

+ 40 - 5
src/main/java/ua/be/wee/model/util/AsyncHttpClientService.java

@@ -65,8 +65,8 @@ public class AsyncHttpClientService {
 					
 					JSONObject outputs = res.getJSONObject("output");
 					List<TraceArtifact> traceArts = new ArrayList<TraceArtifact>();
-					for (Iterator iterator = outputs.keys(); iterator.hasNext();) {
-						String outDataName = (String) iterator.next();
+					for (Iterator<String> iterator = outputs.keys(); iterator.hasNext();) {
+						String outDataName = iterator.next();
 						List<DataOutputPort> dataOutPorts = act.getDataOutPorts();
 						
 						for (DataOutputPort dataOutputPort : dataOutPorts) {
@@ -102,10 +102,45 @@ public class AsyncHttpClientService {
 			@Override
 		    public void onThrowable(Throwable t) {
 				if (t instanceof TimeoutException) {
-					System.err.println("Timeout occurred!");
+					List<ControlOutputPort> ctrlOutPorts = act.getCtrlOutPorts();
+					ControlOutputPort ctrlOutPort = null;
+					for (ControlOutputPort controlOutputPort : ctrlOutPorts) {
+						if (controlOutputPort.getName().equals("error")) {
+							ctrlOutPort = controlOutputPort;
+							break;
+						}
+					}
+					try {
+						if (ctrlOutPort != null) {
+							control.addEndEvent(pt, new ArrayList<>(), ctrlOutPort);
+						} else {
+							System.err.println("Missing 'error' control port!");
+						}
+						
+					} catch (Exception e) {
+						System.err.println("Error happened when adding timeout end event in the trace!");
+						e.printStackTrace();
+					}
+					
 				} else {
-					t.printStackTrace();
-					System.err.println("Another error occurred!");
+					List<ControlOutputPort> ctrlOutPorts = act.getCtrlOutPorts();
+					ControlOutputPort ctrlOutPort = null;
+					for (ControlOutputPort controlOutputPort : ctrlOutPorts) {
+						if (controlOutputPort.getName().equals("error")) {
+							ctrlOutPort = controlOutputPort;
+							break;
+						}
+					}
+					try {
+						if (ctrlOutPort != null) {
+							control.addEndEvent(pt, new ArrayList<>(), ctrlOutPort);
+						} else {
+							System.err.println("Missing 'error' control port!");
+						}
+					} catch (Exception e) {
+						System.err.println("Error happened when adding error end event in the trace!");
+						e.printStackTrace();
+					}
 				}
 		    }
 		});

+ 4 - 4
src/main/resources/templates/enact.html

@@ -9,16 +9,16 @@
     <p class="panel-heading">Automated Activities</p>
     
     <th:block th:each="aut : ${session.automated}">
-            <p th:if="${aut.automatedStatus == T(ua.be.wee.model.nodes.AutomatedStatus).COMPLETED'}">
+            <p th:if="${aut.automatedStatus == T(ua.be.wee.model.nodes.AutomatedStatus).COMPLETED}">
     	    	<a class="panel-block automated-activity">
       			<progress class="progress is-medium is-success activity" value= "100" max="100"></progress>
-      			<span th:text="${aut.name}" >Example Completed Activity 1</span>
+      			<span th:text="${aut.name} + ': Completed'" >Example Completed Activity 1</span>
     			</a>    
             </p>
-            <p th:if="${auto.automatedStatus == T(ua.be.wee.model.nodes.AutomatedStatus).IN_PROGRESS'}">
+            <p th:if="${aut.automatedStatus == T(ua.be.wee.model.nodes.AutomatedStatus).IN_PROGRESS}">
             	<a class="panel-block automated-activity">
       			<progress class="progress is-medium is-info activity" max="100"></progress>
-      			<span th:text="${aut.name}">Example In Progress Activity 2</span>
+      			<span th:text="${aut.name} + ': In Progress'">Example In Progress Activity 2</span>
     			</a>
             </p>
     

+ 22 - 12
src/main/resources/templates/enactEnd.html

@@ -7,20 +7,30 @@
 <main>
   <article class="panel is-primary automated-activities">
     <p class="panel-heading">Automated Activities</p>
-    <a class="panel-block automated-activity">
-      <progress class="progress is-medium is-success activity" value= "100" max="100"></progress>
-      <span>Example Completed Activity 1</span>
-    </a>
-
-    <a class="panel-block automated-activity">
-      <progress class="progress is-medium is-info activity" max="100"></progress>
-      <span>Example In Progress Activity 2</span>
-    </a>
-
-    <a class="panel-block">
-      <button class="button is-primary"><img class="refresh" width="32" height="32" th:src="@{/img/refresh.svg}" alt="Circular arrow"></button>
+     <th:block th:each="aut : ${session.automated}">
+            <p th:if="${aut.automatedStatus == T(ua.be.wee.model.nodes.AutomatedStatus).COMPLETED}">
+    	    	<a class="panel-block automated-activity">
+      			<progress class="progress is-medium is-success activity" value= "100" max="100"></progress>
+      			<span th:text="${aut.name} + ': Completed'" >Example Completed Activity 1</span>
+    			</a>    
+            </p>
+            <p th:if="${aut.automatedStatus == T(ua.be.wee.model.nodes.AutomatedStatus).IN_PROGRESS}">
+            	<a class="panel-block automated-activity">
+      			<progress class="progress is-medium is-info activity" max="100"></progress>
+      			<span th:text="${aut.name} + ': In Progress'">Example In Progress Activity 2</span>
+    			</a>
+            </p>
+    
+    </th:block>
+    <form class="form" th:action="@{/reload}" method="post">
+    
+   <a class="panel-block">
+      <button id="reloadButton" class="button is-primary" type="submit"><img class="refresh" width="32" height="32" th:src="@{/img/refresh.svg}" alt="Circular arrow"></button>
     </a>
   </article>
+  
+  </form>
+  </article>
 
   <section class="pt-6 pb-6 pl-5 pr-5">
     <div class="columns">

+ 18 - 13
src/main/resources/templates/endEnactment.html

@@ -7,20 +7,25 @@
 <main>
   <article class="panel is-primary automated-activities">
     <p class="panel-heading">Automated Activities</p>
-    <a class="panel-block automated-activity">
-      <progress class="progress is-medium is-success activity" value= "100" max="100"></progress>
-      <span>Example Completed Activity 1</span>
-    </a>
-
-    <a class="panel-block automated-activity">
-      <progress class="progress is-medium is-info activity" max="100"></progress>
-      <span>Example In Progress Activity 2</span>
-    </a>
-
-    <a class="panel-block">
-      <button class="button is-primary"><img class="refresh" width="32" height="32" th:src="@{/img/refresh.svg}" alt="Circular arrow"></button>
-    </a>
+    <th:block th:each="aut : ${session.automated}">
+            <p th:if="${aut.automatedStatus == T(ua.be.wee.model.nodes.AutomatedStatus).COMPLETED}">
+    	    	<a class="panel-block automated-activity">
+      			<progress class="progress is-medium is-success activity" value= "100" max="100"></progress>
+      			<span th:text="${aut.name} + ': Completed'" >Example Completed Activity 1</span>
+    			</a>    
+            </p>
+            <p th:if="${aut.automatedStatus == T(ua.be.wee.model.nodes.AutomatedStatus).IN_PROGRESS}">
+            	<a class="panel-block automated-activity">
+      			<progress class="progress is-medium is-info activity" max="100"></progress>
+      			<span th:text="${aut.name} + ': In Progress'">Example In Progress Activity 2</span>
+    			</a>
+            </p>
+    
+    </th:block>
+   
   </article>
+  
+
 
   <section class="pt-6 pb-6 pl-5 pr-5">
     <p th:inline="text">Enactment of the Process Model: <span class="accent">[[${session.pm.name}]]</span> has ended!</p>

+ 1 - 1
src/main/resources/templates/index.html

@@ -6,7 +6,7 @@
 <body>
 <main>
   <section class="pt-6 pb-6 pl-5 pr-5">
-    <h2 class="is-size-3 is-capitalized">Welcome to Wee!</h2>
+    <h2 class="is-size-3 is-capitalized">Welcome to WEE!</h2>
     <audio id="audio" src="/audio/Wee.mp3"></audio>
     <img id="img" value="PLAY" onclick="play()" class="wee-meme-image" src="../static/img/wee.png" th:src="@{/img/wee.png}" alt="Logo of person slipping"><!--  https://thenounproject.com/icon/slipping-11426/  -->
     <p>If you want to see wee memes click <a href="https://www.instagram.com/weee.memes/">here!</a></p>

+ 2 - 2
src/main/resources/templates/pms.html

@@ -5,7 +5,7 @@
 </head>
 <body>
 <main>
-  <article class="panel is-primary automated-activities">
+<!--  <article class="panel is-primary automated-activities">
     <p class="panel-heading">Automated Activities</p>
     <a class="panel-block automated-activity">
       <progress class="progress is-medium is-success activity" value= "100" max="100"></progress>
@@ -21,7 +21,7 @@
       <button class="button is-primary"><img class="refresh" width="32" height="32" th:src="@{/img/refresh.svg}" alt="Circular arrow"></button>
     </a>
   </article>
-
+-->
   <section class="pt-6 pb-6 pl-5 pr-5">
     <form class="pt-3" th:action="@{/enactpm}" method="post">
       <p class="is-size-4">Choose the Process Model to be enacted</p>