Project

General

Profile

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

    
3
import javax.annotation.Resource;
4

    
5
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
6
import eu.dnetlib.miscutils.datetime.DateUtils;
7
import eu.dnetlib.msro.workflows.graph.Arc;
8
import eu.dnetlib.msro.workflows.procs.Env;
9
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
10
import eu.dnetlib.rmi.enabling.ISLookUpService;
11

    
12
/**
13
 * Created by sandro on 9/23/16.
14
 */
15
public class ObtainISTIDataSourceParamsJobNode extends SimpleJobNode {
16

    
17
	private String providerId;
18

    
19
	@Resource
20
	private UniqueServiceLocator serviceLocator;
21

    
22
	@Override
23
	protected String execute(final Env env) throws Exception {
24
		final String query = "let $x := /*[.//RESOURCE_IDENTIFIER/@value='" + providerId + "']//EXTRA_FIELDS\n"
25
				+ "return concat($x/FIELD[./key='OpenAireDataSourceId']/value, ' @@@ ', $x/FIELD[./key='NamespacePrefix']/value)";
26

    
27
		final String[] arr = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(query).split("@@@");
28

    
29
		final String origId = arr[0].trim();
30
		final String nsPrefix = arr[1].trim();
31
		// this is needed by the mdbuilder
32
		// TODO: update mdbuilder to use the env attributes below, whose names are defined in WorkflowConstants
33
		env.setAttribute("parentDatasourceId", origId);
34
		env.setAttribute("namespacePrefix", nsPrefix);
35
		env.setAttribute("dateOfCollection", DateUtils.now_ISO8601());
36

    
37
		// these are needed for validation and fill hostedby
38
		env.setAttribute(WorkflowsConstants.LOG_DATASOURCE_ID, origId);
39
		env.setAttribute(WorkflowsConstants.DATASOURCE_PREFIX, nsPrefix);
40

    
41
		return Arc.DEFAULT_ARC;
42

    
43
	}
44

    
45
	public String getProviderId() {
46
		return providerId;
47
	}
48

    
49
	public void setProviderId(final String providerId) {
50
		this.providerId = providerId;
51
	}
52

    
53
}
(2-2/3)