Revision 41550
Added by Michele Artini about 8 years ago
LaunchWorkflowTemplateJobNode.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.Map; |
4 | 4 |
|
5 |
import org.apache.commons.lang.math.NumberUtils; |
|
6 | 5 |
import org.apache.commons.logging.Log; |
7 | 6 |
import org.apache.commons.logging.LogFactory; |
8 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
9 | 8 |
|
10 | 9 |
import eu.dnetlib.msro.workflows.graph.Arc; |
10 |
import eu.dnetlib.msro.workflows.procs.ProcessAware; |
|
11 | 11 |
import eu.dnetlib.msro.workflows.procs.Token; |
12 | 12 |
import eu.dnetlib.msro.workflows.procs.WorkflowExecutor; |
13 |
import eu.dnetlib.msro.workflows.procs.WorkflowProcess; |
|
13 | 14 |
import eu.dnetlib.msro.workflows.util.ProcessCallback; |
14 | 15 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
15 | 16 |
|
16 | 17 |
/** |
17 | 18 |
* Created by michele on 12/01/16. |
18 | 19 |
*/ |
19 |
public class LaunchWorkflowTemplateJobNode extends ProcessNode { |
|
20 |
public class LaunchWorkflowTemplateJobNode extends ProcessNode implements ProcessAware {
|
|
20 | 21 |
|
21 | 22 |
private static final Log log = LogFactory.getLog(LaunchWorkflowTemplateJobNode.class); |
22 | 23 |
|
... | ... | |
24 | 25 |
private String name; |
25 | 26 |
private Map<String, String> wfTemplateParams; |
26 | 27 |
|
28 |
private WorkflowProcess process; |
|
29 |
|
|
27 | 30 |
public Map<String, String> getWfTemplateParams() { |
28 | 31 |
return this.wfTemplateParams; |
29 | 32 |
} |
... | ... | |
38 | 41 |
@Override |
39 | 42 |
public final void execute(final Token token) { |
40 | 43 |
try { |
41 |
final String family = (String) token.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_FAMILY); |
|
44 |
final String family = this.process.getFamily(); |
|
45 |
final int priority = this.process.getPriority(); |
|
46 |
final String dsId = token.getEnv().getAttribute(WorkflowsConstants.DATASOURCE_ID, String.class); |
|
47 |
final String iface = token.getEnv().getAttribute(WorkflowsConstants.DATASOURCE_INTERFACE, String.class); |
|
42 | 48 |
|
43 |
final int priority = NumberUtils.toInt((String) token.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_FAMILY), 50); |
|
44 |
|
|
45 | 49 |
final String procId = |
46 |
this.executor.startWorkflowTemplate(getWfTemplateId(), this.name, family, priority, this.wfTemplateParams, new ProcessCallback() { |
|
50 |
this.executor.startWorkflowTemplate(getWfTemplateId(), this.name, family, priority, dsId, iface, this.wfTemplateParams, |
|
51 |
new ProcessCallback() { |
|
47 | 52 |
|
48 |
@Override |
|
49 |
public void onSuccess() { |
|
50 |
log.debug("Child workflow has been completed successfully"); |
|
51 |
token.setNextArc(Arc.DEFAULT_ARC); |
|
52 |
token.release(); |
|
53 |
} |
|
53 |
@Override
|
|
54 |
public void onSuccess() {
|
|
55 |
log.debug("Child workflow has been completed successfully");
|
|
56 |
token.setNextArc(Arc.DEFAULT_ARC);
|
|
57 |
token.release();
|
|
58 |
}
|
|
54 | 59 |
|
55 |
@Override |
|
56 |
public void onFail() { |
|
57 |
log.error("Child workflow is failed"); |
|
58 |
token.releaseAsFailed("Child workflow is failed"); |
|
59 |
} |
|
60 |
}); |
|
60 |
@Override
|
|
61 |
public void onFail() {
|
|
62 |
log.error("Child workflow is failed");
|
|
63 |
token.releaseAsFailed("Child workflow is failed");
|
|
64 |
}
|
|
65 |
});
|
|
61 | 66 |
if (log.isDebugEnabled()) { |
62 | 67 |
log.debug("The child workflow [" + getName() + "] is starting with procId: " + procId); |
63 | 68 |
} |
... | ... | |
83 | 88 |
this.name = name; |
84 | 89 |
} |
85 | 90 |
|
91 |
public WorkflowProcess getProcess() { |
|
92 |
return this.process; |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
public void setProcess(final WorkflowProcess process) { |
|
97 |
this.process = process; |
|
98 |
} |
|
99 |
|
|
86 | 100 |
} |
Also available in: Unified diff
refactoring