Revision 36651
Added by Michele Artini about 9 years ago
RegisterMetaWfJobNode.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.msro.worker.nodes.repohi; |
2 | 2 |
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringWriter; |
|
3 |
import java.util.UUID; |
|
5 | 4 |
|
6 |
import javax.annotation.Resource;
|
|
5 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
7 | 6 |
|
8 |
import org.antlr.stringtemplate.StringTemplate; |
|
9 |
import org.apache.commons.io.IOUtils; |
|
10 |
|
|
11 | 7 |
import com.googlecode.sarasvati.Arc; |
12 | 8 |
import com.googlecode.sarasvati.NodeToken; |
13 | 9 |
|
14 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
|
15 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
16 |
|
|
10 |
import eu.dnetlib.enabling.datastructures.MetaWorkflow; |
|
11 |
import eu.dnetlib.enabling.datastructures.MetaWorkflow.Status; |
|
12 |
import eu.dnetlib.enabling.utils.DnetResourceFactory; |
|
13 |
import eu.dnetlib.msro.worker.WorkflowConstants; |
|
14 |
import eu.dnetlib.msro.worker.WorkflowConstants.WorkflowStatus; |
|
17 | 15 |
import eu.dnetlib.msro.worker.nodes.SimpleJobNode; |
18 |
import eu.dnetlib.msro.workflows.util.WorkflowConstants; |
|
19 |
import eu.dnetlib.msro.workflows.util.WorkflowConstants.WorkflowStatus; |
|
16 |
import eu.dnetlib.rmi.objects.is.DnetDataStructure; |
|
17 |
import eu.dnetlib.rmi.soap.InformationService; |
|
18 |
import eu.dnetlib.rmi.soap.exceptions.InformationServiceException; |
|
20 | 19 |
|
21 | 20 |
public class RegisterMetaWfJobNode extends SimpleJobNode { |
22 | 21 |
|
23 |
@Resource
|
|
24 |
private DnetServiceLocator serviceLocator;
|
|
22 |
@Autowired
|
|
23 |
private InformationService informationService;
|
|
25 | 24 |
|
26 | 25 |
private String wfName; |
27 | 26 |
|
... | ... | |
39 | 38 |
return Arc.DEFAULT_ARC; |
40 | 39 |
} |
41 | 40 |
|
42 |
public String registerDatasourceWorkflow(final String dsId, final String dsName, final String ifaceId) throws ISRegistryException, IOException { |
|
43 |
final StringWriter sw = new StringWriter(); |
|
44 |
IOUtils.copy(getClass().getResourceAsStream("/eu/dnetlib/msro/workflows/templates/meta-workflow.xml.st"), sw); |
|
41 |
public String registerDatasourceWorkflow(final String dsId, final String dsName, final String ifaceId) throws InformationServiceException { |
|
42 |
final MetaWorkflow metaWf = new MetaWorkflow(wfName, wfName, "dataproviders"); |
|
43 |
metaWf.setDatasourceId(dsId); |
|
44 |
metaWf.setDatasourceName(dsName); |
|
45 |
metaWf.setDatasourceInterfaceId(ifaceId); |
|
46 |
metaWf.setStatus(Status.ASSIGNED); |
|
45 | 47 |
|
46 |
final StringTemplate st = new StringTemplate(sw.toString()); |
|
47 |
st.setAttribute("dsId", dsId); |
|
48 |
st.setAttribute("ifaceId", ifaceId); |
|
49 |
st.setAttribute("dsName", dsName); |
|
50 |
st.setAttribute("section", "dataproviders"); |
|
51 |
st.setAttribute("wfName", getWfName()); |
|
52 |
st.setAttribute("wfFamily", getWfName()); |
|
53 |
st.setAttribute("status", WorkflowStatus.ASSIGNED.toString()); |
|
48 |
final String code = "metawf-" + UUID.randomUUID(); |
|
54 | 49 |
|
55 |
return serviceLocator.getService(ISRegistryService.class).registerProfile(st.toString()); |
|
50 |
final DnetDataStructure ds = DnetResourceFactory.createDatastructure(code, "MetaWorkflow for Aggregation", metaWf); |
|
51 |
|
|
52 |
informationService.registerDs(ds); |
|
53 |
|
|
54 |
return code; |
|
56 | 55 |
} |
57 | 56 |
|
58 | 57 |
public String getWfName() { |
Also available in: Unified diff
MetaWf nodes