1
|
package eu.dnetlib.msro.workflows.nodes.stats;
|
2
|
|
3
|
import java.util.List;
|
4
|
import javax.annotation.Resource;
|
5
|
|
6
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
7
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
8
|
import eu.dnetlib.msro.workflows.procs.Env;
|
9
|
import eu.dnetlib.rmi.enabling.ISLookUpException;
|
10
|
import eu.dnetlib.rmi.enabling.ISLookUpService;
|
11
|
import eu.dnetlib.rmi.manager.MSROException;
|
12
|
import org.apache.commons.logging.Log;
|
13
|
import org.apache.commons.logging.LogFactory;
|
14
|
import org.springframework.beans.factory.annotation.Value;
|
15
|
|
16
|
public class FindStatsServiceJobNode extends SimpleJobNode {
|
17
|
|
18
|
/**
|
19
|
* logger.
|
20
|
*/
|
21
|
private static final Log log = LogFactory.getLog(FindStatsServiceJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
22
|
|
23
|
@Resource
|
24
|
private UniqueServiceLocator serviceLocator;
|
25
|
|
26
|
@Value(value = "${dnet.openaire.service.stats.lookup.xquery}")
|
27
|
private String xquery;
|
28
|
|
29
|
private String xqueryForServiceIdParam;
|
30
|
|
31
|
/**
|
32
|
* {@inheritDoc}
|
33
|
*
|
34
|
* @throws ISLookUpException
|
35
|
* @throws MSROException
|
36
|
* @see com.googlecode.sarasvati.mem.MemNode#execute(com.googlecode.sarasvati.Engine, com.googlecode.sarasvati.NodeToken)
|
37
|
*/
|
38
|
@Override
|
39
|
public String execute(final Env env) throws ISLookUpException, MSROException {
|
40
|
|
41
|
log.info("lookup for stats service: " + getXquery());
|
42
|
|
43
|
final List<String> statsServiceIds = this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery());
|
44
|
|
45
|
if (statsServiceIds.size() > 1) { throw new MSROException("too many stats services: " + statsServiceIds); }
|
46
|
|
47
|
if (statsServiceIds.isEmpty()) {
|
48
|
return "notFound";
|
49
|
} else {
|
50
|
env.setAttribute(getXqueryForServiceIdParam(), getXquery());
|
51
|
return "found";
|
52
|
}
|
53
|
}
|
54
|
|
55
|
public String getXquery() {
|
56
|
return this.xquery;
|
57
|
}
|
58
|
|
59
|
public void setXquery(final String xquery) {
|
60
|
this.xquery = xquery;
|
61
|
}
|
62
|
|
63
|
public String getXqueryForServiceIdParam() {
|
64
|
return this.xqueryForServiceIdParam;
|
65
|
}
|
66
|
|
67
|
public void setXqueryForServiceIdParam(final String xqueryForServiceIdParam) {
|
68
|
this.xqueryForServiceIdParam = xqueryForServiceIdParam;
|
69
|
}
|
70
|
|
71
|
}
|