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
|
public class ObtainOpenaireDataSourceParamsJobNode extends SimpleJobNode {
|
13
|
|
14
|
private String providerId;
|
15
|
|
16
|
@Resource
|
17
|
private UniqueServiceLocator serviceLocator;
|
18
|
|
19
|
@Override
|
20
|
protected String execute(final Env env) throws Exception {
|
21
|
final String query = "let $x := /*[.//RESOURCE_IDENTIFIER/@value='" + this.providerId + "']//EXTRA_FIELDS\n"
|
22
|
+ "return concat($x/FIELD[./key='OpenAireDataSourceId']/value, ' @@@ ', $x/FIELD[./key='NamespacePrefix']/value)";
|
23
|
|
24
|
final String[] arr = this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(query).split("@@@");
|
25
|
|
26
|
final String origId = arr[0].trim();
|
27
|
final String nsPrefix = arr[1].trim();
|
28
|
// this is needed by the mdbuilder
|
29
|
// TODO: update mdbuilder to use the env attributes below, whose names are defined in WorkflowConstants
|
30
|
env.setAttribute("parentDatasourceId", origId);
|
31
|
env.setAttribute("namespacePrefix", nsPrefix);
|
32
|
env.setAttribute("dateOfCollection", DateUtils.now_ISO8601());
|
33
|
|
34
|
// these are needed for validation and fill hostedby
|
35
|
env.setAttribute(WorkflowsConstants.LOG_DATASOURCE_ID, origId);
|
36
|
env.setAttribute(WorkflowsConstants.DATASOURCE_PREFIX, nsPrefix);
|
37
|
|
38
|
return Arc.DEFAULT_ARC;
|
39
|
|
40
|
}
|
41
|
|
42
|
public String getProviderId() {
|
43
|
return this.providerId;
|
44
|
}
|
45
|
|
46
|
public void setProviderId(final String providerId) {
|
47
|
this.providerId = providerId;
|
48
|
}
|
49
|
|
50
|
}
|