Revision 56355
Added by Miriam Baglioni over 4 years ago
modules/dnet-openaireplus-workflows/branches/dnet-hadoop/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/propagation/communitytoresult/LoadCommunityIdsListJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.openaireplus.workflows.nodes.propagation.communitytoresult; |
|
2 |
|
|
3 |
import com.google.common.reflect.TypeToken; |
|
4 |
import com.google.gson.Gson; |
|
5 |
import com.googlecode.sarasvati.Arc; |
|
6 |
import com.googlecode.sarasvati.NodeToken; |
|
7 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
8 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
9 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
10 |
import org.apache.commons.logging.Log; |
|
11 |
import org.apache.commons.logging.LogFactory; |
|
12 |
import org.springframework.beans.factory.annotation.Autowired; |
|
13 |
|
|
14 |
import java.lang.reflect.Type; |
|
15 |
import java.util.List; |
|
16 |
|
|
17 |
public class LoadCommunityIdsListJobNode extends SimpleJobNode { |
|
18 |
|
|
19 |
private static final Log log = LogFactory.getLog(LoadCommunityIdsListJobNode.class); |
|
20 |
|
|
21 |
@Autowired |
|
22 |
private UniqueServiceLocator serviceLocator; |
|
23 |
|
|
24 |
private String xquery; |
|
25 |
|
|
26 |
private String communityIdParam; |
|
27 |
|
|
28 |
public String getCommunityIdParam() { |
|
29 |
return communityIdParam; |
|
30 |
} |
|
31 |
|
|
32 |
public void setCommunityIdParam(String communityIdParam) { |
|
33 |
this.communityIdParam = communityIdParam; |
|
34 |
} |
|
35 |
|
|
36 |
public UniqueServiceLocator getServiceLocator() { |
|
37 |
return serviceLocator; |
|
38 |
} |
|
39 |
|
|
40 |
public void setServiceLocator(UniqueServiceLocator serviceLocator) { |
|
41 |
this.serviceLocator = serviceLocator; |
|
42 |
} |
|
43 |
|
|
44 |
|
|
45 |
@Override |
|
46 |
protected String execute(final NodeToken token) throws Exception { |
|
47 |
|
|
48 |
final List<String> res = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery()); |
|
49 |
Type listType = new TypeToken<List<String>>() {}.getType(); |
|
50 |
|
|
51 |
token.getEnv().setAttribute(getCommunityIdParam(),new Gson().toJson(res,listType)); |
|
52 |
|
|
53 |
return Arc.DEFAULT_ARC; |
|
54 |
} |
|
55 |
|
|
56 |
public String getXquery() { |
|
57 |
log.debug(xquery); |
|
58 |
return xquery; |
|
59 |
} |
|
60 |
|
|
61 |
public void setXquery(final String xquery) { |
|
62 |
this.xquery = xquery; |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
} |
Also available in: Unified diff
new node for loading the community id list