Project

General

Profile

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

    
3
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
4
import eu.dnetlib.msro.workflows.graph.Arc;
5
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
6
import eu.dnetlib.msro.workflows.procs.Env;
7
import eu.dnetlib.msro.workflows.procs.ProcessAware;
8
import eu.dnetlib.msro.workflows.procs.WorkflowProcess;
9
import eu.dnetlib.rmi.enabling.ISRegistryException;
10
import eu.dnetlib.rmi.enabling.ISRegistryService;
11
import org.apache.commons.logging.Log;
12
import org.apache.commons.logging.LogFactory;
13
import org.springframework.beans.factory.annotation.Autowired;
14

    
15
public class ValidateDatasourceJobNode extends SimpleJobNode implements ProcessAware {
16

    
17
	private static final Log log = LogFactory.getLog(ValidateDatasourceJobNode.class);
18
	@Autowired
19
	private UniqueServiceLocator serviceLocator;
20

    
21
	private WorkflowProcess process;
22

    
23
	@Override
24
	protected String execute(final Env env) throws Exception {
25
		final String oldId = this.process.getDsId();
26
		final String newId = registerDatasourceWorkflow(oldId);
27
		this.process.setDsId(newId);
28

    
29
		log.info("Validated datasource - OLD ID: " + oldId);
30
		log.info("Validated datasource - NEW ID: " + newId);
31

    
32
		return Arc.DEFAULT_ARC;
33
	}
34

    
35
	public String registerDatasourceWorkflow(final String oldId) throws ISRegistryException {
36
		return this.serviceLocator.getService(ISRegistryService.class).validateProfile(oldId);
37
	}
38

    
39
	public WorkflowProcess getProcess() {
40
		return this.process;
41
	}
42

    
43
	@Override
44
	public void setProcess(final WorkflowProcess process) {
45
		this.process = process;
46
	}
47
}
(4-4/5)