1
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.index;
|
2
|
|
3
|
import java.util.List;
|
4
|
import java.util.Queue;
|
5
|
import javax.annotation.Resource;
|
6
|
|
7
|
import com.google.common.collect.Queues;
|
8
|
import com.googlecode.sarasvati.NodeToken;
|
9
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
10
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
11
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
12
|
import eu.dnetlib.msro.rmi.MSROException;
|
13
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
14
|
import org.apache.commons.logging.Log;
|
15
|
import org.apache.commons.logging.LogFactory;
|
16
|
import org.springframework.beans.factory.annotation.Value;
|
17
|
|
18
|
/**
|
19
|
* Supercedes eu.dnetlib.msro.openaireplus.workflows.nodes.index.FindSearchServiceJobNode.
|
20
|
* Returns a queue of SearchService ids that match the xquery and saves it in the env with the name 'searchService_ids'.
|
21
|
* Use with eu.dnetlib.msro.openaireplus.workflows.nodes.index.SwitchIndexesJobNode
|
22
|
*
|
23
|
* @author claudio, alessia
|
24
|
*/
|
25
|
public class FindSearchServicesJobNode extends SimpleJobNode {
|
26
|
|
27
|
/**
|
28
|
* logger.
|
29
|
*/
|
30
|
private static final Log log = LogFactory.getLog(FindSearchServicesJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
31
|
|
32
|
@Resource
|
33
|
private UniqueServiceLocator serviceLocator;
|
34
|
|
35
|
@Value(value = "${dnet.openaire.service.search.lookup.xquery}")
|
36
|
private String xquery;
|
37
|
|
38
|
/**
|
39
|
* {@inheritDoc}
|
40
|
*
|
41
|
* @throws ISLookUpException
|
42
|
* @throws MSROException
|
43
|
* @see com.googlecode.sarasvati.mem.MemNode#execute(com.googlecode.sarasvati.Engine, NodeToken)
|
44
|
*/
|
45
|
@Override
|
46
|
public String execute(final NodeToken token) throws ISLookUpException, MSROException {
|
47
|
|
48
|
log.info("lookup for search service: " + getXquery());
|
49
|
|
50
|
List<String> searchServiceIds = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery());
|
51
|
log.info("SearchService found: " + searchServiceIds.size());
|
52
|
Queue<String> q = Queues.newLinkedBlockingQueue(searchServiceIds);
|
53
|
|
54
|
if (searchServiceIds.isEmpty()) {
|
55
|
return "notFound";
|
56
|
} else {
|
57
|
token.getEnv().setTransientAttribute("searchService_ids", q);
|
58
|
return "found";
|
59
|
}
|
60
|
}
|
61
|
|
62
|
public String getXquery() {
|
63
|
return xquery;
|
64
|
}
|
65
|
|
66
|
public void setXquery(final String xquery) {
|
67
|
this.xquery = xquery;
|
68
|
}
|
69
|
}
|