1 |
26600
|
sandro.lab
|
package eu.dnetlib.msro.workflows.metawf;
|
2 |
|
|
|
3 |
|
|
import java.io.IOException;
|
4 |
|
|
import java.io.StringWriter;
|
5 |
|
|
import java.util.List;
|
6 |
|
|
import java.util.Map;
|
7 |
|
|
|
8 |
|
|
import javax.annotation.Resource;
|
9 |
|
|
|
10 |
|
|
import org.apache.commons.lang.StringEscapeUtils;
|
11 |
|
|
import org.springframework.beans.factory.annotation.Required;
|
12 |
|
|
|
13 |
|
|
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
|
14 |
|
|
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
|
15 |
32639
|
michele.ar
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
16 |
26600
|
sandro.lab
|
|
17 |
|
|
public class WorkflowTree {
|
18 |
|
|
|
19 |
|
|
private String id;
|
20 |
|
|
|
21 |
|
|
private String name;
|
22 |
|
|
|
23 |
33199
|
andrea.man
|
private WorkflowStartModeEnum start = WorkflowStartModeEnum.auto;
|
24 |
26600
|
sandro.lab
|
|
25 |
|
|
private List<WorkflowTree> children;
|
26 |
|
|
|
27 |
|
|
private org.springframework.core.io.Resource template;
|
28 |
|
|
|
29 |
32639
|
michele.ar
|
@Resource
|
30 |
|
|
private UniqueServiceLocator serviceLocator;
|
31 |
26600
|
sandro.lab
|
|
32 |
|
|
public void populateMetaWfXml(final StringWriter sw) {
|
33 |
|
|
sw.append("<WORKFLOW id='" + StringEscapeUtils.escapeXml(id) + "' name='" + StringEscapeUtils.escapeXml(name) + "'");
|
34 |
|
|
|
35 |
32639
|
michele.ar
|
if (children == null || children.isEmpty()) {
|
36 |
26600
|
sandro.lab
|
sw.append(" />");
|
37 |
|
|
} else {
|
38 |
|
|
sw.append(">");
|
39 |
|
|
for (WorkflowTree child : children) {
|
40 |
|
|
child.populateMetaWfXml(sw);
|
41 |
|
|
}
|
42 |
|
|
sw.append("</WORKFLOW>");
|
43 |
|
|
}
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
public int registerAllWorkflows(final Map<String, String> params) throws ISRegistryException, IOException {
|
47 |
|
|
int count = 0;
|
48 |
|
|
|
49 |
32639
|
michele.ar
|
if (this.id == null || this.id.isEmpty()) {
|
50 |
33199
|
andrea.man
|
final String profile = WorkflowProfileCreator.generateProfile(name, "aggregator", start, params, template);
|
51 |
32639
|
michele.ar
|
this.id = serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
|
52 |
26600
|
sandro.lab
|
count++;
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
if (children != null) {
|
56 |
|
|
for (WorkflowTree child : children) {
|
57 |
|
|
count += child.registerAllWorkflows(params);
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
return count;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
public String getId() {
|
64 |
|
|
return id;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
public List<WorkflowTree> getChildren() {
|
68 |
|
|
return children;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
public void setChildren(final List<WorkflowTree> children) {
|
72 |
|
|
this.children = children;
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
public String getName() {
|
76 |
|
|
return name;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
@Required
|
80 |
|
|
public void setName(final String name) {
|
81 |
|
|
this.name = name;
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
public org.springframework.core.io.Resource getTemplate() {
|
85 |
|
|
return template;
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
@Required
|
89 |
|
|
public void setTemplate(final org.springframework.core.io.Resource template) {
|
90 |
|
|
this.template = template;
|
91 |
|
|
}
|
92 |
|
|
|
93 |
33199
|
andrea.man
|
public WorkflowStartModeEnum getStart() {
|
94 |
26600
|
sandro.lab
|
return start;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
33199
|
andrea.man
|
public void setStart(final WorkflowStartModeEnum start) {
|
98 |
26600
|
sandro.lab
|
this.start = start;
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
}
|