Revision 46596
Added by Alessia Bardi about 7 years ago
SyncOAIStoreJobNode.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.msro.oai.workflows.nodes; |
2 | 2 |
|
3 |
import org.apache.commons.logging.Log; |
|
4 |
import org.apache.commons.logging.LogFactory; |
|
5 |
import org.springframework.beans.factory.annotation.Required; |
|
6 |
|
|
7 | 3 |
import com.googlecode.sarasvati.NodeToken; |
8 |
|
|
4 |
import eu.dnetlib.data.information.oai.utils.OAIParameterNames; |
|
9 | 5 |
import eu.dnetlib.enabling.resultset.rmi.ResultSetException; |
10 | 6 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
7 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
11 | 8 |
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode; |
12 | 9 |
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory; |
13 | 10 |
import eu.dnetlib.msro.workflows.util.ProgressProvider; |
14 | 11 |
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider; |
12 |
import org.apache.commons.logging.Log; |
|
13 |
import org.apache.commons.logging.LogFactory; |
|
14 |
import org.springframework.beans.factory.annotation.Required; |
|
15 | 15 |
|
16 | 16 |
public class SyncOAIStoreJobNode extends AbstractOAIJobNode implements ProgressJobNode { |
17 | 17 |
|
18 | 18 |
private static final Log log = LogFactory.getLog(SyncOAIStoreJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM |
19 | 19 |
|
20 |
private String eprParam; |
|
21 |
|
|
22 | 20 |
private ProcessCountingResultSetFactory processCountingResultSetFactory; |
23 | 21 |
|
24 | 22 |
private ResultsetProgressProvider progressProvider; |
25 | 23 |
|
26 |
private String formatParam, layoutParam, interpretationParam, oai_dbName; |
|
27 |
|
|
24 |
private String eprParam; |
|
28 | 25 |
private boolean alwaysNewRecord = false; |
26 |
private boolean skipDuplicates = false; |
|
27 |
private String duplicateXPath; |
|
29 | 28 |
|
30 | 29 |
@Override |
31 | 30 |
void completePrepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException { |
... | ... | |
33 | 32 |
final String eprS = token.getEnv().getAttribute(getEprParam()); |
34 | 33 |
this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), eprS); |
35 | 34 |
job.setAction("SYNC"); |
36 |
job.getParameters().put("oai_syncEpr", progressProvider.getEpr().toString()); |
|
37 |
job.getParameters().put("oai_recordSource", token.getEnv().getAttribute("oai_recordSource")); |
|
38 |
job.getParameters().put("oai_formatName", token.getEnv().getAttribute(formatParam)); |
|
39 |
job.getParameters().put("oai_formatLayout", token.getEnv().getAttribute(layoutParam)); |
|
40 |
job.getParameters().put("oai_formatInterpretation", token.getEnv().getAttribute(interpretationParam)); |
|
41 |
job.getParameters().put("oai_dbName", getOai_dbName()); |
|
42 |
job.getParameters().put("oai_alwaysNewRecord", String.valueOf(alwaysNewRecord)); |
|
43 |
token.getEnv().setAttribute("oai_dbName", getOai_dbName()); |
|
44 |
log.fatal("Job prepared"); |
|
45 |
|
|
35 |
job.getParameters().put(OAIParameterNames.OAI_FEED_DATE, DateUtils.now_ISO8601()); |
|
36 |
job.getParameters().put(OAIParameterNames.OAI_SKIP_DUPLICATES, String.valueOf(skipDuplicates)); |
|
37 |
if(skipDuplicates) job.getParameters().put(OAIParameterNames.OAI_DUPLICATE_XPATH, duplicateXPath); |
|
38 |
job.getParameters().put(OAIParameterNames.OAI_SYNC_EPR, progressProvider.getEpr().toString()); |
|
39 |
job.getParameters().put(OAIParameterNames.OAI_ALWAYS_NEW_RECORD, String.valueOf(alwaysNewRecord)); |
|
40 |
log.fatal("OAI Sync Job prepared"); |
|
46 | 41 |
} |
47 | 42 |
|
48 |
public String getEprParam() { |
|
49 |
return eprParam; |
|
50 |
} |
|
51 |
|
|
52 |
public void setEprParam(final String eprParam) { |
|
53 |
this.eprParam = eprParam; |
|
54 |
} |
|
55 |
|
|
56 | 43 |
public ProcessCountingResultSetFactory getProcessCountingResultSetFactory() { |
57 | 44 |
return processCountingResultSetFactory; |
58 | 45 |
} |
... | ... | |
62 | 49 |
this.processCountingResultSetFactory = processCountingResultSetFactory; |
63 | 50 |
} |
64 | 51 |
|
65 |
public String getFormatParam() { |
|
66 |
return formatParam; |
|
52 |
@Override |
|
53 |
public ProgressProvider getProgressProvider() { |
|
54 |
return this.progressProvider; |
|
67 | 55 |
} |
68 | 56 |
|
69 |
public void setFormatParam(final String formatParam) { |
|
70 |
this.formatParam = formatParam; |
|
71 |
} |
|
72 | 57 |
|
73 |
public String getLayoutParam() {
|
|
74 |
return layoutParam;
|
|
58 |
public String getEprParam() {
|
|
59 |
return eprParam;
|
|
75 | 60 |
} |
76 | 61 |
|
77 |
public void setLayoutParam(final String layoutParam) {
|
|
78 |
this.layoutParam = layoutParam;
|
|
62 |
public void setEprParam(final String eprParam) {
|
|
63 |
this.eprParam = eprParam;
|
|
79 | 64 |
} |
80 | 65 |
|
81 |
public String getInterpretationParam() {
|
|
82 |
return interpretationParam;
|
|
66 |
public boolean isAlwaysNewRecord() {
|
|
67 |
return alwaysNewRecord;
|
|
83 | 68 |
} |
84 | 69 |
|
85 |
public void setInterpretationParam(final String interpretationParam) {
|
|
86 |
this.interpretationParam = interpretationParam;
|
|
70 |
public void setAlwaysNewRecord(boolean alwaysNewRecord) {
|
|
71 |
this.alwaysNewRecord = alwaysNewRecord;
|
|
87 | 72 |
} |
88 | 73 |
|
89 |
public String getOai_dbName() {
|
|
90 |
return oai_dbName;
|
|
74 |
public boolean isSkipDuplicates() {
|
|
75 |
return skipDuplicates;
|
|
91 | 76 |
} |
92 | 77 |
|
93 |
public void setOai_dbName(final String oai_dbName) {
|
|
94 |
this.oai_dbName = oai_dbName;
|
|
78 |
public void setSkipDuplicates(final boolean skipDuplicates) {
|
|
79 |
this.skipDuplicates = skipDuplicates;
|
|
95 | 80 |
} |
96 | 81 |
|
97 |
@Override |
|
98 |
public ProgressProvider getProgressProvider() { |
|
99 |
return this.progressProvider; |
|
82 |
public String getDuplicateXPath() { |
|
83 |
return duplicateXPath; |
|
100 | 84 |
} |
101 | 85 |
|
102 |
public boolean isAlwaysNewRecord() {
|
|
103 |
return alwaysNewRecord;
|
|
86 |
public void setDuplicateXPath(final String duplicateXPath) {
|
|
87 |
this.duplicateXPath = duplicateXPath;
|
|
104 | 88 |
} |
105 | 89 |
|
106 |
public void setAlwaysNewRecord(boolean alwaysNewRecord) { |
|
107 |
this.alwaysNewRecord = alwaysNewRecord; |
|
108 |
} |
|
109 |
|
|
110 | 90 |
} |
Also available in: Unified diff
integrated changes from 'refactoring' branch