Skip to content

Commit 9bb217e

Browse files
committed
Return a list of runids for expandAndRunWorkflow - Will now wait for planning to finish to return
1 parent f9aa3c1 commit 9bb217e

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

portal/.settings/org.eclipse.wst.common.component

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979

8080
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
81-
<dependent-module archiveName="wings-planner-5.3.4.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/wings-planner/wings-planner">
81+
<dependent-module archiveName="wings-planner-5.3.5.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/wings-planner/wings-planner">
8282
<dependency-type>uses</dependency-type>
8383
</dependent-module>
8484
<dependent-module archiveName="ontapi-1.3.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ontapi/ontapi">

portal/src/main/java/edu/isi/wings/portal/classes/util/PlanningAndExecutingThread.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class PlanningAndExecutingThread implements Runnable {
6868
ExecutorService executor;
6969
int max_number_of_executions;
7070
ServletContext context;
71+
ArrayList<String> runids;
7172

7273
public PlanningAndExecutingThread(
7374
String ex_prefix,
@@ -86,6 +87,7 @@ public PlanningAndExecutingThread(
8687
this.ex_prefix = ex_prefix;
8788
this.template_id = template_id;
8889
this.context = context;
90+
this.runids = new ArrayList<String>();
8991
}
9092

9193
private void addTemplateBindings(Template tpl, TemplateBindings tb) {
@@ -226,6 +228,7 @@ public void run() {
226228
rplan.setCallbackUrl(this.template_bindings.getCallbackUrl());
227229
rplan.setCallbackCookies(this.template_bindings.getCallbackCookies());
228230
this.runExecutionPlan(rplan);
231+
this.runids.add(runid);
229232
}
230233
}
231234
if (i >= this.max_number_of_executions) {
@@ -238,4 +241,12 @@ public void run() {
238241
e.printStackTrace();
239242
}
240243
}
244+
245+
public ArrayList<String> getRunids() {
246+
return runids;
247+
}
248+
249+
public void setRunids(ArrayList<String> runids) {
250+
this.runids = runids;
251+
}
241252
}

portal/src/main/java/edu/isi/wings/portal/controllers/DataController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,10 @@ public String runSensorWorkflow(String dataid, HttpServletRequest request, Servl
758758
tbindings.setComponentBindings(new HashMap<String, String>());
759759
tbindings.setTemplateId(tplid);
760760

761-
return this.rc.expandAndRunTemplate(tbindings, context);
761+
ArrayList<String> runids = this.rc.expandAndRunTemplate(tbindings, context);
762+
if(runids != null && runids.size() > 0) {
763+
return runids.get(0);
764+
}
762765
}
763766
catch (Exception e) {
764767
e.printStackTrace();

portal/src/main/java/edu/isi/wings/portal/controllers/RunController.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,11 @@ public boolean stopRun(String runid, ServletContext context) {
336336
- Immediately returns a run id
337337
- Puts the rest of the processing in a Queue to be processed sequentially
338338
*/
339-
public String expandAndRunTemplate(TemplateBindings template_bindings, ServletContext context) {
339+
public ArrayList<String> expandAndRunTemplate(TemplateBindings template_bindings, ServletContext context) {
340340
// Create a runid
341341
String ex_prefix = props.getProperty("domain.executions.dir.url");
342342
String template_id = template_bindings.getTemplateId();
343343

344-
URIEntity tpluri = new URIEntity(template_id);
345-
tpluri.setID(UuidGen.generateURIUuid(tpluri));
346-
String runid = ex_prefix + "/" + tpluri.getName() + ".owl#" + tpluri.getName();
347-
348344
PlanningAPIBindings apis = null;
349345
if(apiBindings.containsKey(ex_prefix)) {
350346
apis = apiBindings.get(ex_prefix);
@@ -355,11 +351,18 @@ public String expandAndRunTemplate(TemplateBindings template_bindings, ServletCo
355351
}
356352

357353
// Submit the planning and execution thread
358-
executor.submit(new PlanningAndExecutingThread(ex_prefix, template_id,
359-
this.config, config.getPlannerConfig().getMaxQueueSize(), template_bindings, apis, executor, context));
360-
361-
// Return the runid
362-
return runid;
354+
try {
355+
PlanningAndExecutingThread thread = new PlanningAndExecutingThread(ex_prefix, template_id,
356+
this.config, config.getPlannerConfig().getMaxQueueSize(), template_bindings, apis, executor, context);
357+
executor.submit(thread).get();
358+
359+
// Return the runids
360+
return thread.getRunids();
361+
}
362+
catch(Exception e) {
363+
e.printStackTrace();
364+
return null;
365+
}
363366
}
364367

365368
public Future<?> runComponent(String cid, HashMap<String, Binding> role_bindings,

portal/src/main/java/edu/isi/wings/portal/resources/RunResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package edu.isi.wings.portal.resources;
22

3+
import java.util.ArrayList;
34
import java.util.Date;
45

56
import javax.annotation.PostConstruct;
@@ -112,7 +113,7 @@ public String getRunPlan(
112113
@POST
113114
@Path("expandAndRunWorkflow")
114115
@Produces(MediaType.APPLICATION_JSON)
115-
public String expandAndRunWorkflow(
116+
public ArrayList<String> expandAndRunWorkflow(
116117
@JsonProperty("template_bindings") final TemplateBindings tbindings) {
117118
if(this.rc != null) {
118119
return rc.expandAndRunTemplate(tbindings, this.context);

0 commit comments

Comments
 (0)