1 |
36643
|
claudio.at
|
package eu.dnetlib.msro.workflows.actions;
|
2 |
|
|
|
3 |
|
|
import java.util.List;
|
4 |
|
|
import java.util.Map;
|
5 |
|
|
|
6 |
|
|
import org.apache.commons.logging.Log;
|
7 |
|
|
import org.apache.commons.logging.LogFactory;
|
8 |
|
|
|
9 |
|
|
import com.google.common.collect.Lists;
|
10 |
|
|
import com.google.common.collect.Maps;
|
11 |
|
|
import com.google.gson.Gson;
|
12 |
|
|
import com.googlecode.sarasvati.Arc;
|
13 |
|
|
import com.googlecode.sarasvati.NodeToken;
|
14 |
|
|
|
15 |
|
|
import eu.dnetlib.actionmanager.set.RawSet;
|
16 |
|
|
import eu.dnetlib.miscutils.datetime.DateUtils;
|
17 |
|
|
import eu.dnetlib.msro.workflows.dedup.conf.DedupConfigurationOrchestration;
|
18 |
|
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
|
|
* The Class PrepareConfiguredActionSetJobNode.
|
22 |
|
|
*/
|
23 |
|
|
public class PrepareConfiguredActionSetJobNode extends SimpleJobNode {
|
24 |
|
|
|
25 |
|
|
/**
|
26 |
|
|
* logger.
|
27 |
|
|
*/
|
28 |
|
|
private static final Log log = LogFactory.getLog(PrepareConfiguredActionSetJobNode.class);
|
29 |
|
|
|
30 |
|
|
/** The dedup config sequence param. */
|
31 |
|
|
private String dedupConfigSequenceParam;
|
32 |
|
|
|
33 |
|
|
/** The job property. */
|
34 |
|
|
private String jobProperty;
|
35 |
|
|
|
36 |
|
|
/*
|
37 |
|
|
* (non-Javadoc)
|
38 |
37124
|
claudio.at
|
*
|
39 |
36643
|
claudio.at
|
* @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken)
|
40 |
|
|
*/
|
41 |
|
|
@Override
|
42 |
|
|
protected String execute(final NodeToken token) throws Exception {
|
43 |
|
|
|
44 |
|
|
final List<Map<String, String>> setList = Lists.newArrayList();
|
45 |
|
|
|
46 |
|
|
final Map<String, String> set = Maps.newHashMap();
|
47 |
|
|
|
48 |
|
|
set.put("rawset", RawSet.newInstance().getId());
|
49 |
|
|
set.put("creationDate", DateUtils.now_ISO8601());
|
50 |
|
|
set.put("set", getActionSetId(token));
|
51 |
|
|
set.put("enabled", "true");
|
52 |
|
|
set.put("jobProperty", getJobProperty());
|
53 |
|
|
|
54 |
|
|
token.getEnv().setAttribute(set.get("jobProperty"), set.get("rawset"));
|
55 |
|
|
|
56 |
37124
|
claudio.at
|
setList.add(set);
|
57 |
36643
|
claudio.at
|
final String sets = new Gson().toJson(setList);
|
58 |
|
|
log.debug("built set: " + sets);
|
59 |
|
|
|
60 |
|
|
token.getEnv().setAttribute("sets", sets);
|
61 |
|
|
|
62 |
|
|
return Arc.DEFAULT_ARC;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
/**
|
66 |
|
|
* Gets the action set id.
|
67 |
|
|
*
|
68 |
|
|
* @param token
|
69 |
|
|
* the token
|
70 |
|
|
* @return the action set id
|
71 |
|
|
*/
|
72 |
|
|
private String getActionSetId(final NodeToken token) {
|
73 |
|
|
final String json = token.getEnv().getAttribute(getDedupConfigSequenceParam());
|
74 |
|
|
final DedupConfigurationOrchestration dco = DedupConfigurationOrchestration.fromJSON(json);
|
75 |
|
|
final String actionSetId = dco.getActionSetId();
|
76 |
|
|
log.info("found actionSetId in workflow env: " + actionSetId);
|
77 |
|
|
return actionSetId;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
/**
|
81 |
|
|
* Gets the dedup config sequence param.
|
82 |
|
|
*
|
83 |
|
|
* @return the dedup config sequence param
|
84 |
|
|
*/
|
85 |
|
|
public String getDedupConfigSequenceParam() {
|
86 |
|
|
return dedupConfigSequenceParam;
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
/**
|
90 |
|
|
* Sets the dedup config sequence param.
|
91 |
|
|
*
|
92 |
|
|
* @param dedupConfigSequenceParam
|
93 |
|
|
* the new dedup config sequence param
|
94 |
|
|
*/
|
95 |
|
|
public void setDedupConfigSequenceParam(final String dedupConfigSequenceParam) {
|
96 |
|
|
this.dedupConfigSequenceParam = dedupConfigSequenceParam;
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
/**
|
100 |
|
|
* Gets the job property.
|
101 |
|
|
*
|
102 |
|
|
* @return the job property
|
103 |
|
|
*/
|
104 |
|
|
public String getJobProperty() {
|
105 |
|
|
return jobProperty;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
/**
|
109 |
|
|
* Sets the job property.
|
110 |
|
|
*
|
111 |
|
|
* @param jobProperty
|
112 |
|
|
* the new job property
|
113 |
|
|
*/
|
114 |
|
|
public void setJobProperty(final String jobProperty) {
|
115 |
|
|
this.jobProperty = jobProperty;
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
}
|