1
|
package eu.dnetlib.msro.workflows.nodes;
|
2
|
|
3
|
import java.util.List;
|
4
|
|
5
|
import org.apache.commons.logging.Log;
|
6
|
import org.apache.commons.logging.LogFactory;
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
|
9
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
10
|
import eu.dnetlib.enabling.resultset.client.ResultSetClient;
|
11
|
import eu.dnetlib.enabling.resultset.factory.ResultSetFactory;
|
12
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
13
|
import eu.dnetlib.msro.workflows.nodes.mdstore.MultipleMdStoreIterable;
|
14
|
import eu.dnetlib.msro.workflows.procs.Env;
|
15
|
import eu.dnetlib.rmi.common.ResultSet;
|
16
|
import eu.dnetlib.rmi.enabling.ISLookUpService;
|
17
|
|
18
|
public class FetchMultipleMDStoresJobNode extends SimpleJobNode {
|
19
|
|
20
|
private String format;
|
21
|
private String layout;
|
22
|
private String interpretation;
|
23
|
private String eprParam;
|
24
|
|
25
|
private static final Log log = LogFactory.getLog(FetchMultipleMDStoresJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
26
|
|
27
|
@Autowired
|
28
|
private UniqueServiceLocator serviceLocator;
|
29
|
|
30
|
@Autowired
|
31
|
private ResultSetFactory resultSetFactory;
|
32
|
|
33
|
@Autowired
|
34
|
private ResultSetClient resultSetClient;
|
35
|
|
36
|
@Override
|
37
|
protected String execute(final Env env) throws Exception {
|
38
|
|
39
|
final String query = String.format(
|
40
|
"collection('/db/DRIVER/MDStoreDSResources/MDStoreDSResourceType')[normalize-space(.//METADATA_FORMAT) = '%s' and normalize-space(.//METADATA_FORMAT_LAYOUT = '%s') and normalize-space(.//METADATA_FORMAT_INTERPRETATION) = '%s']//RESOURCE_IDENTIFIER/@value/string()",
|
41
|
format.trim(), layout.trim(), interpretation.trim());
|
42
|
|
43
|
final List<String> mdIds = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
|
44
|
|
45
|
log.info(String.format("fetching records for %s mdstores", mdIds.size()));
|
46
|
if (log.isDebugEnabled()) {
|
47
|
log.debug(String.format("fetching records for mdstores: %s", mdIds));
|
48
|
}
|
49
|
|
50
|
final MultipleMdStoreIterable iter = new MultipleMdStoreIterable(serviceLocator, mdIds, resultSetClient);
|
51
|
final ResultSet<String> rs = resultSetFactory.createResultSet(iter);
|
52
|
|
53
|
env.setAttribute(eprParam, rs);
|
54
|
|
55
|
return Arc.DEFAULT_ARC;
|
56
|
}
|
57
|
|
58
|
public String getFormat() {
|
59
|
return format;
|
60
|
}
|
61
|
|
62
|
public void setFormat(final String format) {
|
63
|
this.format = format;
|
64
|
}
|
65
|
|
66
|
public String getLayout() {
|
67
|
return layout;
|
68
|
}
|
69
|
|
70
|
public void setLayout(final String layout) {
|
71
|
this.layout = layout;
|
72
|
}
|
73
|
|
74
|
public String getInterpretation() {
|
75
|
return interpretation;
|
76
|
}
|
77
|
|
78
|
public void setInterpretation(final String interpretation) {
|
79
|
this.interpretation = interpretation;
|
80
|
}
|
81
|
|
82
|
public String getEprParam() {
|
83
|
return eprParam;
|
84
|
}
|
85
|
|
86
|
public void setEprParam(final String eprParam) {
|
87
|
this.eprParam = eprParam;
|
88
|
}
|
89
|
|
90
|
}
|