1
|
package eu.dnetlib.msro.workflows.nodes;
|
2
|
|
3
|
import java.util.List;
|
4
|
import java.util.Map;
|
5
|
import javax.annotation.Resource;
|
6
|
|
7
|
import com.google.common.collect.Maps;
|
8
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
9
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
10
|
import eu.dnetlib.msro.workflows.procs.Env;
|
11
|
import eu.dnetlib.rmi.enabling.ISLookUpService;
|
12
|
|
13
|
public class FindExistingRepositoriesJobNode extends SimpleJobNode {
|
14
|
|
15
|
@Resource
|
16
|
private UniqueServiceLocator serviceLocator;
|
17
|
|
18
|
private String existingReposParam = "existingRepos";
|
19
|
|
20
|
@Override
|
21
|
protected String execute(final Env env) throws Exception {
|
22
|
final String xquery =
|
23
|
"for $x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType') " +
|
24
|
"return concat (" +
|
25
|
"$x//RESOURCE_IDENTIFIER/@value, " +
|
26
|
"'@@@', " +
|
27
|
"$x//EXTRA_FIELDS/FIELD[./key='OpenAireDataSourceId']/value)";
|
28
|
final List<String> list = this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
|
29
|
|
30
|
final Map<String, String> map = Maps.newHashMap();
|
31
|
for (final String s : list) {
|
32
|
final String[] arr = s.split("@@@");
|
33
|
if (arr.length == 2) {
|
34
|
map.put(arr[1], arr[0]);
|
35
|
}
|
36
|
}
|
37
|
env.setAttribute(getExistingReposParam(), map);
|
38
|
|
39
|
return Arc.DEFAULT_ARC;
|
40
|
}
|
41
|
|
42
|
public String getExistingReposParam() {
|
43
|
return this.existingReposParam;
|
44
|
}
|
45
|
|
46
|
public void setExistingReposParam(final String existingReposParam) {
|
47
|
this.existingReposParam = existingReposParam;
|
48
|
}
|
49
|
|
50
|
}
|