Revision 36623
Added by Claudio Atzori about 9 years ago
PrepareDedupIndexJobNode.java | ||
---|---|---|
5 | 5 |
import org.apache.commons.lang.StringUtils; |
6 | 6 |
import org.apache.commons.logging.Log; |
7 | 7 |
import org.apache.commons.logging.LogFactory; |
8 |
import org.dom4j.DocumentException; |
|
9 |
import org.springframework.beans.factory.annotation.Autowired; |
|
8 | 10 |
import org.springframework.beans.factory.annotation.Required; |
9 | 11 |
|
10 | 12 |
import com.googlecode.sarasvati.Arc; |
11 | 13 |
import com.googlecode.sarasvati.NodeToken; |
12 | 14 |
|
13 |
import eu.dnetlib.data.proto.TypeProtos.Type;
|
|
15 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
|
|
14 | 16 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
15 | 17 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
16 | 18 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
17 | 19 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
18 |
import eu.dnetlib.msro.rmi.MSROException; |
|
20 |
import eu.dnetlib.msro.workflows.dedup.conf.DedupConfigurationOrchestration; |
|
21 |
import eu.dnetlib.msro.workflows.dedup.conf.DedupConfigurationOrchestrationLoader; |
|
19 | 22 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
20 | 23 |
|
21 | 24 |
public class PrepareDedupIndexJobNode extends SimpleJobNode { |
... | ... | |
28 | 31 |
@Resource |
29 | 32 |
private UniqueServiceLocator serviceLocator; |
30 | 33 |
|
34 |
@Autowired |
|
35 |
private DedupConfigurationOrchestrationLoader dedupOrchestrationLoader; |
|
36 |
|
|
31 | 37 |
private String rottenRecordsPathParam; |
32 | 38 |
|
33 | 39 |
private String hbaseTable; |
34 | 40 |
|
35 |
private String entityType;
|
|
41 |
private String dedupConfig;
|
|
36 | 42 |
|
37 | 43 |
@Override |
38 | 44 |
protected String execute(final NodeToken token) throws Exception { |
... | ... | |
55 | 61 |
|
56 | 62 |
token.getEnv().setAttribute("index.feed.timestamp", DateUtils.now_ISO8601()); |
57 | 63 |
|
58 |
if (StringUtils.isBlank(getEntityType())) throw new MSROException("missing parameter 'entityType'"); |
|
59 |
token.getEnv().setAttribute("entityType", getEntityType()); |
|
60 |
token.getEnv().setAttribute("entityTypeId", Type.valueOf(getEntityType()).getNumber()); |
|
64 |
final DedupConfigurationOrchestration conf = dedupConfigurations(token); |
|
61 | 65 |
|
66 |
token.getEnv().setAttribute("actionset", conf.getActionSetId()); |
|
67 |
token.getEnv().setAttribute("entityType", conf.getEntity().getName()); |
|
68 |
token.getEnv().setAttribute("entityTypeId", conf.getEntity().getCode()); |
|
69 |
|
|
62 | 70 |
return Arc.DEFAULT_ARC; |
63 | 71 |
} |
64 | 72 |
|
73 |
private DedupConfigurationOrchestration dedupConfigurations(final NodeToken token) throws ISLookUpDocumentNotFoundException, ISLookUpException, |
|
74 |
DocumentException { |
|
75 |
if ((getDedupConfig() == null) || getDedupConfig().trim().isEmpty()) |
|
76 |
throw new IllegalStateException("Cannot find dedup configurations in workflow env: '" + getDedupConfig() + "'"); |
|
77 |
|
|
78 |
return dedupOrchestrationLoader.load(getDedupConfig()); |
|
79 |
} |
|
80 |
|
|
65 | 81 |
private String getFields(final String format, final String layout) throws ISLookUpException { |
66 |
return isLookup("collection('')//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value = 'MDFormatDSResourceType' and .//NAME='" + format + "']//LAYOUT[@name='" |
|
67 |
+ layout + "']/FIELDS"); |
|
82 |
return isLookup(String |
|
83 |
.format("<FIELDS>{for $x in collection('')//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value = 'MDFormatDSResourceType' and .//NAME='%s']//LAYOUT[@name='%s']/FIELDS/FIELD return $x[string(@path)]}</FIELDS>", |
|
84 |
format, layout)); |
|
68 | 85 |
} |
69 | 86 |
|
70 | 87 |
public String getIndexSolrUrlZk() throws ISLookUpException { |
... | ... | |
124 | 141 |
this.rottenRecordsPathParam = rottenRecordsPathParam; |
125 | 142 |
} |
126 | 143 |
|
127 |
public String getEntityType() {
|
|
128 |
return entityType;
|
|
144 |
public String getDedupConfig() {
|
|
145 |
return dedupConfig;
|
|
129 | 146 |
} |
130 | 147 |
|
131 |
public void setEntityType(final String entityType) {
|
|
132 |
this.entityType = entityType;
|
|
148 |
public void setDedupConfig(final String dedupConfig) {
|
|
149 |
this.dedupConfig = dedupConfig;
|
|
133 | 150 |
} |
134 | 151 |
|
135 | 152 |
} |
Also available in: Unified diff
introduced support for action set ids