Project

General

Profile

1
package eu.dnetlib.msro.workflows.nodes.repohi;
2

    
3
import javax.annotation.Resource;
4

    
5
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
6
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
7
import eu.dnetlib.msro.workflows.graph.Arc;
8
import eu.dnetlib.msro.workflows.graph.Env;
9
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
10
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
11
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus;
12

    
13
public class UpdateWfStatusJobNode extends SimpleJobNode {
14

    
15
	@Resource
16
	private UniqueServiceLocator serviceLocator;
17

    
18
	@Override
19
	protected String execute(final Env env) throws Exception {
20
		final String wfId = env.getAttribute("WORKFLOW_ID", String.class);
21
		final String dsId = env.getAttribute(WorkflowsConstants.DATASOURCE_ID, String.class);
22
		final String ifaceId = env.getAttribute(WorkflowsConstants.DATASOURCE_INTERFACE, String.class);
23

    
24
		updateDatasource(dsId, ifaceId);
25

    
26
		if (isReady(wfId)) {
27
			serviceLocator.getService(ISRegistryService.class).updateProfileNode(wfId, "//CONFIGURATION/@status", "'" + WorkflowStatus.EXECUTABLE + "'");
28
		}
29

    
30
		return Arc.DEFAULT_ARC;
31
	}
32

    
33
	protected void updateDatasource(final String dsId, final String ifaceId) throws Exception {
34
		serviceLocator.getService(ISRegistryService.class).updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'true'");
35
	}
36

    
37
	private boolean isReady(final String wfId) throws Exception {
38

    
39
		//TODO: verificare che tutti i workflow figli abbiano non abbiamo nodi "//PARAM[@required='true' and string-length(text()) = 0]"
40

    
41
		return true;
42
	}
43

    
44
}
(4-4/6)