1
|
package eu.dnetlib.msro.workflows.nodes;
|
2
|
|
3
|
import java.util.List;
|
4
|
import javax.annotation.Resource;
|
5
|
|
6
|
import com.google.gson.Gson;
|
7
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
8
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
9
|
import eu.dnetlib.msro.workflows.procs.Env;
|
10
|
import eu.dnetlib.rmi.enabling.ISLookUpException;
|
11
|
import eu.dnetlib.rmi.enabling.ISLookUpService;
|
12
|
import org.apache.commons.logging.Log;
|
13
|
import org.apache.commons.logging.LogFactory;
|
14
|
|
15
|
public class FetchRelClassesJobNode extends SimpleJobNode {
|
16
|
|
17
|
private static final Log log = LogFactory.getLog(FetchRelClassesJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
18
|
|
19
|
private String xquery;
|
20
|
|
21
|
private String relClassesName;
|
22
|
|
23
|
@Resource
|
24
|
private UniqueServiceLocator serviceLocator;
|
25
|
|
26
|
@Override
|
27
|
protected String execute(final Env env) throws Exception {
|
28
|
|
29
|
final String relClasses = new Gson().toJson(fetchRelClasses());
|
30
|
|
31
|
log.info("loaded relClasses: " + relClasses);
|
32
|
|
33
|
env.setAttribute(getRelClassesName(), relClasses);
|
34
|
|
35
|
return Arc.DEFAULT_ARC;
|
36
|
}
|
37
|
|
38
|
private List<String> fetchRelClasses() throws ISLookUpException {
|
39
|
|
40
|
log.info("Loading relClasses with xquery: " + getXquery());
|
41
|
|
42
|
return serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery());
|
43
|
}
|
44
|
|
45
|
public String getRelClassesName() {
|
46
|
return relClassesName;
|
47
|
}
|
48
|
|
49
|
public void setRelClassesName(final String relClassesName) {
|
50
|
this.relClassesName = relClassesName;
|
51
|
}
|
52
|
|
53
|
public String getXquery() {
|
54
|
return xquery;
|
55
|
}
|
56
|
|
57
|
public void setXquery(final String xquery) {
|
58
|
this.xquery = xquery;
|
59
|
}
|
60
|
}
|