1 |
26600
|
sandro.lab
|
package eu.dnetlib.msro.workflows.metawf;
|
2 |
|
|
|
3 |
|
|
import java.io.IOException;
|
4 |
|
|
import java.util.Map;
|
5 |
|
|
|
6 |
|
|
import org.antlr.stringtemplate.StringTemplate;
|
7 |
|
|
import org.apache.commons.io.IOUtils;
|
8 |
|
|
import org.springframework.core.io.ClassPathResource;
|
9 |
|
|
import org.springframework.core.io.Resource;
|
10 |
|
|
|
11 |
|
|
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
|
12 |
|
|
|
13 |
|
|
public class WorkflowProfileCreator {
|
14 |
|
|
|
15 |
|
|
private static final Resource wfTemplate = new ClassPathResource("/eu/dnetlib/msro/workflows/templates/workflow.xml.st");
|
16 |
|
|
|
17 |
33199
|
andrea.man
|
public static String generateProfile(final String name,
|
18 |
|
|
final String type,
|
19 |
|
|
final WorkflowStartModeEnum startMode,
|
20 |
|
|
final Map<String, String> params,
|
21 |
|
|
final Resource confTemplate)
|
22 |
|
|
throws IOException {
|
23 |
26600
|
sandro.lab
|
|
24 |
|
|
final StringTemplate conf = new StringTemplate(IOUtils.toString(confTemplate.getInputStream()));
|
25 |
|
|
conf.setAttribute("params", params);
|
26 |
|
|
|
27 |
|
|
final StringTemplate profile = new StringTemplate(IOUtils.toString(wfTemplate.getInputStream()));
|
28 |
|
|
profile.setAttribute("name", name);
|
29 |
|
|
profile.setAttribute("type", type);
|
30 |
|
|
profile.setAttribute("priority", WorkflowsConstants.DEFAULT_WF_PRIORITY);
|
31 |
|
|
profile.setAttribute("conf", conf.toString());
|
32 |
33199
|
andrea.man
|
profile.setAttribute("startMode", startMode);
|
33 |
26600
|
sandro.lab
|
|
34 |
|
|
return profile.toString();
|
35 |
|
|
}
|
36 |
|
|
}
|