1
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.bulktag;
|
2
|
|
3
|
import com.google.common.base.Joiner;
|
4
|
import com.googlecode.sarasvati.Arc;
|
5
|
import com.googlecode.sarasvati.NodeToken;
|
6
|
import eu.dnetlib.data.bulktag.CommunityConfigurationFactory;
|
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.util.List;
|
15
|
|
16
|
public class LoadBulkTaggingConfigurationJobNode extends SimpleJobNode {
|
17
|
|
18
|
private static final Log log = LogFactory.getLog(LoadBulkTaggingConfigurationJobNode.class);
|
19
|
|
20
|
@Autowired
|
21
|
private UniqueServiceLocator serviceLocator;
|
22
|
|
23
|
private String xquery;
|
24
|
|
25
|
private String bulkTaggingConfParam;
|
26
|
|
27
|
private String enabledConfParam;
|
28
|
|
29
|
private boolean enabled;
|
30
|
|
31
|
private String mappingProtoParam;
|
32
|
|
33
|
private String mapping;
|
34
|
|
35
|
public String getMappingProtoParam() {
|
36
|
return mappingProtoParam;
|
37
|
}
|
38
|
|
39
|
public LoadBulkTaggingConfigurationJobNode setMappingProtoParam(String mappingProtoParam) {
|
40
|
this.mappingProtoParam = mappingProtoParam;
|
41
|
return this;
|
42
|
}
|
43
|
|
44
|
public String getMapping() {
|
45
|
return mapping;
|
46
|
}
|
47
|
|
48
|
public LoadBulkTaggingConfigurationJobNode setMapping(String mapping) {
|
49
|
this.mapping = mapping;
|
50
|
return this;
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
protected String execute(final NodeToken token) throws Exception {
|
55
|
|
56
|
final List<String> res = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery());
|
57
|
|
58
|
final String xmlConf = "<communities>" + Joiner.on(" ").join(res) + "</communities>";
|
59
|
|
60
|
token.getEnv().setAttribute(getBulkTaggingConfParam(), CommunityConfigurationFactory.newInstance(xmlConf).toJson());
|
61
|
token.getEnv().setAttribute(getEnabledConfParam(),isEnabled());
|
62
|
token.getEnv().setAttribute(getMappingProtoParam(),getMapping());
|
63
|
return Arc.DEFAULT_ARC;
|
64
|
}
|
65
|
|
66
|
public String getXquery() {
|
67
|
log.debug(xquery);
|
68
|
return xquery;
|
69
|
}
|
70
|
|
71
|
public void setXquery(final String xquery) {
|
72
|
this.xquery = xquery;
|
73
|
|
74
|
}
|
75
|
|
76
|
public String getBulkTaggingConfParam() {
|
77
|
return bulkTaggingConfParam;
|
78
|
}
|
79
|
|
80
|
public void setBulkTaggingConfParam(final String bulkTaggingConfParam) {
|
81
|
this.bulkTaggingConfParam = bulkTaggingConfParam;
|
82
|
}
|
83
|
|
84
|
public boolean isEnabled() {
|
85
|
return enabled;
|
86
|
}
|
87
|
|
88
|
public void setEnabled(boolean enabled) {
|
89
|
this.enabled = enabled;
|
90
|
}
|
91
|
|
92
|
public String getEnabledConfParam() {
|
93
|
return enabledConfParam;
|
94
|
}
|
95
|
|
96
|
public void setEnabledConfParam(String enabledConfParam) {
|
97
|
this.enabledConfParam = enabledConfParam;
|
98
|
}
|
99
|
|
100
|
}
|