Revision 46596
Added by Alessia Bardi about 7 years ago
AbstractOAIJobNode.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.msro.oai.workflows.nodes; |
2 | 2 |
|
3 |
import eu.dnetlib.data.information.oai.utils.OAIParameterNames; |
|
3 | 4 |
import org.apache.commons.lang.StringUtils; |
4 | 5 |
|
5 | 6 |
import com.googlecode.sarasvati.NodeToken; |
... | ... | |
11 | 12 |
|
12 | 13 |
public abstract class AbstractOAIJobNode extends BlackboardJobNode { |
13 | 14 |
|
14 |
private String dbNameParam;
|
|
15 |
// overrides the value in the env param dbNameParam
|
|
16 |
private String dbName;
|
|
15 |
private String oaiDbNameParam = OAIParameterNames.OAI_DB;
|
|
16 |
// overrides the value in the env param oaiDbNameParam
|
|
17 |
private String oaiDbName;
|
|
17 | 18 |
|
18 |
protected String getTheDBName(final NodeToken token) { |
|
19 |
if (StringUtils.isNotBlank(dbName)) { |
|
20 |
return dbName; |
|
21 |
} else { |
|
22 |
return token.getEnv().getAttribute(getDbNameParam()); |
|
23 |
} |
|
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); |
|
24 | 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 |
} |
|
25 | 47 |
|
48 |
protected String getTheOAICollection(final NodeToken token) { |
|
49 |
return getTheOAIFormat(token) + "-" + getTheOAILayout(token) + "-" + getTheOAIInterpretation(token); |
|
50 |
} |
|
51 |
|
|
52 |
|
|
26 | 53 |
@Override |
27 | 54 |
protected String obtainServiceId(final NodeToken token) { |
28 | 55 |
return getServiceLocator().getServiceId(OAIStoreService.class); |
... | ... | |
30 | 57 |
|
31 | 58 |
@Override |
32 | 59 |
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException { |
33 |
job.getParameters().put("oai_dbName", getTheDBName(token)); |
|
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)); |
|
34 | 67 |
completePrepareJob(job, token); |
35 | 68 |
} |
36 | 69 |
|
37 | 70 |
abstract void completePrepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException; |
38 | 71 |
|
39 |
public String getDbNameParam() { |
|
40 |
return dbNameParam;
|
|
72 |
public String getOaiDbNameParam() {
|
|
73 |
return oaiDbNameParam;
|
|
41 | 74 |
} |
42 | 75 |
|
43 |
public void setDbNameParam(final String dbNameParam) {
|
|
44 |
this.dbNameParam = dbNameParam;
|
|
76 |
public void setOaiDbNameParam(final String oaiDbNameParam) {
|
|
77 |
this.oaiDbNameParam = oaiDbNameParam;
|
|
45 | 78 |
} |
46 | 79 |
|
47 |
public String getDbName() { |
|
48 |
return dbName;
|
|
80 |
public String getOaiDbName() {
|
|
81 |
return oaiDbName;
|
|
49 | 82 |
} |
50 | 83 |
|
51 |
public void setDbName(final String dbName) {
|
|
52 |
this.dbName = dbName;
|
|
84 |
public void setOaiDbName(final String oaiDbName) {
|
|
85 |
this.oaiDbName = oaiDbName;
|
|
53 | 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 |
} |
|
54 | 151 |
} |
Also available in: Unified diff
integrated changes from 'refactoring' branch