1
|
package eu.dnetlib.msro.oai.workflows.nodes;
|
2
|
|
3
|
import eu.dnetlib.data.information.oai.utils.OAIParameterNames;
|
4
|
import org.apache.commons.lang.StringUtils;
|
5
|
|
6
|
import com.googlecode.sarasvati.NodeToken;
|
7
|
|
8
|
import eu.dnetlib.data.oai.store.OAIStoreService;
|
9
|
import eu.dnetlib.enabling.resultset.rmi.ResultSetException;
|
10
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
11
|
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
|
12
|
|
13
|
public abstract class AbstractOAIJobNode extends BlackboardJobNode {
|
14
|
|
15
|
private String oaiDbNameParam = OAIParameterNames.OAI_DB;
|
16
|
// overrides the value in the env param oaiDbNameParam
|
17
|
private String oaiDbName;
|
18
|
|
19
|
private String oaiFormatParam = OAIParameterNames.OAI_FORMAT_NAME;
|
20
|
private String oaiFormat;
|
21
|
|
22
|
private String oaiLayoutParam = OAIParameterNames.OAI_FORMAT_LAYOUT;
|
23
|
private String oaiLayout;
|
24
|
|
25
|
private String oaiInterpretationParam = OAIParameterNames.OAI_FORMAT_INTERPRETATION;
|
26
|
private String oaiInterpretation;
|
27
|
|
28
|
private String oaiSourceParam = OAIParameterNames.OAI_SOURCE;
|
29
|
// overrides the value in the env param oaiSourceParam
|
30
|
private String oaiSource;
|
31
|
|
32
|
protected String getTheOAIDBName(final NodeToken token) {
|
33
|
return StringUtils.isNotBlank(oaiDbName)? oaiDbName : token.getEnv().getAttribute(oaiDbNameParam);
|
34
|
}
|
35
|
protected String getTheOAIFormat(final NodeToken token) {
|
36
|
return StringUtils.isNotBlank(oaiFormat)? oaiFormat : token.getEnv().getAttribute(oaiFormatParam);
|
37
|
}
|
38
|
protected String getTheOAILayout(final NodeToken token) {
|
39
|
return StringUtils.isNotBlank(oaiLayout)? oaiLayout : token.getEnv().getAttribute(oaiLayoutParam);
|
40
|
}
|
41
|
protected String getTheOAIInterpretation(final NodeToken token) {
|
42
|
return StringUtils.isNotBlank(oaiInterpretation)? oaiInterpretation : token.getEnv().getAttribute(oaiInterpretationParam);
|
43
|
}
|
44
|
protected String getTheOAISource(final NodeToken token) {
|
45
|
return StringUtils.isNotBlank(oaiSource)? oaiSource : token.getEnv().getAttribute(oaiSourceParam);
|
46
|
}
|
47
|
|
48
|
protected String getTheOAICollection(final NodeToken token) {
|
49
|
return getTheOAIFormat(token) + "-" + getTheOAILayout(token) + "-" + getTheOAIInterpretation(token);
|
50
|
}
|
51
|
|
52
|
|
53
|
@Override
|
54
|
protected String obtainServiceId(final NodeToken token) {
|
55
|
return getServiceLocator().getServiceId(OAIStoreService.class);
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException {
|
60
|
job.getParameters().put(OAIParameterNames.OAI_DB, getTheOAIDBName(token));
|
61
|
job.getParameters().put(OAIParameterNames.OAI_FORMAT_NAME, getTheOAIFormat(token));
|
62
|
job.getParameters().put(OAIParameterNames.OAI_FORMAT_LAYOUT, getTheOAILayout(token));
|
63
|
job.getParameters().put(OAIParameterNames.OAI_FORMAT_INTERPRETATION, getTheOAIInterpretation(token));
|
64
|
job.getParameters().put(OAIParameterNames.OAI_COLLECTON, getTheOAICollection(token));
|
65
|
String theSource = getTheOAISource(token);
|
66
|
if(StringUtils.isNotBlank(theSource)) job.getParameters().put(OAIParameterNames.OAI_SOURCE, getTheOAISource(token));
|
67
|
completePrepareJob(job, token);
|
68
|
}
|
69
|
|
70
|
abstract void completePrepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException;
|
71
|
|
72
|
public String getOaiDbNameParam() {
|
73
|
return oaiDbNameParam;
|
74
|
}
|
75
|
|
76
|
public void setOaiDbNameParam(final String oaiDbNameParam) {
|
77
|
this.oaiDbNameParam = oaiDbNameParam;
|
78
|
}
|
79
|
|
80
|
public String getOaiDbName() {
|
81
|
return oaiDbName;
|
82
|
}
|
83
|
|
84
|
public void setOaiDbName(final String oaiDbName) {
|
85
|
this.oaiDbName = oaiDbName;
|
86
|
}
|
87
|
|
88
|
public String getOaiFormatParam() {
|
89
|
return oaiFormatParam;
|
90
|
}
|
91
|
|
92
|
public void setOaiFormatParam(final String oaiFormatParam) {
|
93
|
this.oaiFormatParam = oaiFormatParam;
|
94
|
}
|
95
|
|
96
|
public String getOaiFormat() {
|
97
|
return oaiFormat;
|
98
|
}
|
99
|
|
100
|
public void setOaiFormat(final String oaiFormat) {
|
101
|
this.oaiFormat = oaiFormat;
|
102
|
}
|
103
|
|
104
|
public String getOaiLayoutParam() {
|
105
|
return oaiLayoutParam;
|
106
|
}
|
107
|
|
108
|
public void setOaiLayoutParam(final String oaiLayoutParam) {
|
109
|
this.oaiLayoutParam = oaiLayoutParam;
|
110
|
}
|
111
|
|
112
|
public String getOaiLayout() {
|
113
|
return oaiLayout;
|
114
|
}
|
115
|
|
116
|
public void setOaiLayout(final String oaiLayout) {
|
117
|
this.oaiLayout = oaiLayout;
|
118
|
}
|
119
|
|
120
|
public String getOaiInterpretationParam() {
|
121
|
return oaiInterpretationParam;
|
122
|
}
|
123
|
|
124
|
public void setOaiInterpretationParam(final String oaiInterpretationParam) {
|
125
|
this.oaiInterpretationParam = oaiInterpretationParam;
|
126
|
}
|
127
|
|
128
|
public String getOaiInterpretation() {
|
129
|
return oaiInterpretation;
|
130
|
}
|
131
|
|
132
|
public void setOaiInterpretation(final String oaiInterpretation) {
|
133
|
this.oaiInterpretation = oaiInterpretation;
|
134
|
}
|
135
|
|
136
|
public String getOaiSourceParam() {
|
137
|
return oaiSourceParam;
|
138
|
}
|
139
|
|
140
|
public void setOaiSourceParam(final String oaiSourceParam) {
|
141
|
this.oaiSourceParam = oaiSourceParam;
|
142
|
}
|
143
|
|
144
|
public String getOaiSource() {
|
145
|
return oaiSource;
|
146
|
}
|
147
|
|
148
|
public void setOaiSource(final String oaiSource) {
|
149
|
this.oaiSource = oaiSource;
|
150
|
}
|
151
|
}
|