1
|
package eu.dnetlib.msro.workflows.nodes.oai;
|
2
|
|
3
|
import eu.dnetlib.enabling.resultset.client.ResultSetClient;
|
4
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
5
|
import eu.dnetlib.miscutils.datetime.DateUtils;
|
6
|
import eu.dnetlib.msro.workflows.procs.Token;
|
7
|
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider;
|
8
|
import eu.dnetlib.oai.utils.OAIParameterNames;
|
9
|
import eu.dnetlib.rmi.common.ResultSet;
|
10
|
import eu.dnetlib.rmi.common.ResultSetException;
|
11
|
import org.apache.commons.logging.Log;
|
12
|
import org.apache.commons.logging.LogFactory;
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
|
15
|
public class SyncOAIStoreJobNode extends AbstractOAIJobNode {
|
16
|
|
17
|
private static final Log log = LogFactory.getLog(SyncOAIStoreJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
18
|
|
19
|
private String eprParam;
|
20
|
|
21
|
@Autowired
|
22
|
private ResultSetClient resultSetClient;
|
23
|
|
24
|
private boolean alwaysNewRecord = false;
|
25
|
private boolean skipDuplicates = false;
|
26
|
private String duplicateXPath;
|
27
|
|
28
|
|
29
|
@Override
|
30
|
void completePrepareJob(final BlackboardJob job, final Token token) throws ResultSetException {
|
31
|
|
32
|
final ResultSet<?> rs = token.getEnv().getAttribute(getEprParam(), ResultSet.class);
|
33
|
|
34
|
token.setProgressProvider(new ResultsetProgressProvider(rs, this.resultSetClient));
|
35
|
|
36
|
job.setAction("SYNC");
|
37
|
job.getParameters().put(OAIParameterNames.OAI_FEED_DATE, DateUtils.now_ISO8601());
|
38
|
job.getParameters().put(OAIParameterNames.OAI_SKIP_DUPLICATES, String.valueOf(skipDuplicates));
|
39
|
if(skipDuplicates) job.getParameters().put(OAIParameterNames.OAI_DUPLICATE_XPATH, duplicateXPath);
|
40
|
//TODO: Why would I need the following? Can I live without?
|
41
|
//job.getParameters().put(OAIParameterNames.OAI_SYNC_EPR, progressProvider.getEpr().toString());
|
42
|
job.getParameters().put(OAIParameterNames.OAI_ALWAYS_NEW_RECORD, String.valueOf(alwaysNewRecord));
|
43
|
log.fatal("OAI Sync Job prepared");
|
44
|
|
45
|
}
|
46
|
|
47
|
public String getEprParam() {
|
48
|
return eprParam;
|
49
|
}
|
50
|
|
51
|
public void setEprParam(final String eprParam) {
|
52
|
this.eprParam = eprParam;
|
53
|
}
|
54
|
|
55
|
public boolean isAlwaysNewRecord() {
|
56
|
return alwaysNewRecord;
|
57
|
}
|
58
|
|
59
|
public void setAlwaysNewRecord(boolean alwaysNewRecord) {
|
60
|
this.alwaysNewRecord = alwaysNewRecord;
|
61
|
}
|
62
|
|
63
|
public boolean isSkipDuplicates() {
|
64
|
return skipDuplicates;
|
65
|
}
|
66
|
|
67
|
public void setSkipDuplicates(final boolean skipDuplicates) {
|
68
|
this.skipDuplicates = skipDuplicates;
|
69
|
}
|
70
|
|
71
|
public String getDuplicateXPath() {
|
72
|
return duplicateXPath;
|
73
|
}
|
74
|
|
75
|
public void setDuplicateXPath(final String duplicateXPath) {
|
76
|
this.duplicateXPath = duplicateXPath;
|
77
|
}
|
78
|
|
79
|
}
|