Revision 45457
Added by Alessia Bardi over 7 years ago
AbstractOAIJobNode.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode; |
5 | 5 |
import eu.dnetlib.msro.workflows.procs.Env; |
6 | 6 |
import eu.dnetlib.msro.workflows.procs.Token; |
7 |
import eu.dnetlib.oai.utils.OAIParameterNames; |
|
7 | 8 |
import eu.dnetlib.rmi.common.ResultSetException; |
8 | 9 |
import eu.dnetlib.rmi.provision.OAIStoreService; |
9 | 10 |
import org.apache.commons.lang3.StringUtils; |
10 | 11 |
|
11 | 12 |
public abstract class AbstractOAIJobNode extends BlackboardJobNode { |
12 | 13 |
|
13 |
protected String dbName; |
|
14 |
private String oaiDbNameParam = OAIParameterNames.OAI_DB; |
|
15 |
// overrides the value in the env param oaiDbNameParam |
|
16 |
private String oaiDbName; |
|
14 | 17 |
|
15 |
protected String collectionName; |
|
18 |
private String oaiFormatParam = OAIParameterNames.OAI_FORMAT_NAME; |
|
19 |
private String oaiFormat; |
|
16 | 20 |
|
17 |
protected String format, layout, interpretation; |
|
21 |
private String oaiLayoutParam = OAIParameterNames.OAI_FORMAT_LAYOUT; |
|
22 |
private String oaiLayout; |
|
18 | 23 |
|
24 |
private String oaiInterpretationParam = OAIParameterNames.OAI_FORMAT_INTERPRETATION; |
|
25 |
private String oaiInterpretation; |
|
26 |
|
|
27 |
private String oaiSourceParam = OAIParameterNames.OAI_SOURCE; |
|
28 |
// overrides the value in the env param oaiSourceParam |
|
29 |
private String oaiSource; |
|
30 |
|
|
31 |
protected String getTheOAIDBName(final Token token) { |
|
32 |
return StringUtils.isNotBlank(oaiDbName)? oaiDbName : token.getEnv().getAttribute(oaiDbNameParam, String.class); |
|
33 |
} |
|
34 |
protected String getTheOAIFormat(final Token token) { |
|
35 |
return StringUtils.isNotBlank(oaiFormat)? oaiFormat : token.getEnv().getAttribute(oaiFormatParam, String.class); |
|
36 |
} |
|
37 |
protected String getTheOAILayout(final Token token) { |
|
38 |
return StringUtils.isNotBlank(oaiLayout)? oaiLayout : token.getEnv().getAttribute(oaiLayoutParam, String.class); |
|
39 |
} |
|
40 |
protected String getTheOAIInterpretation(final Token token) { |
|
41 |
return StringUtils.isNotBlank(oaiInterpretation)? oaiInterpretation : token.getEnv().getAttribute(oaiInterpretationParam, String.class); |
|
42 |
} |
|
43 |
protected String getTheOAISource(final Token token) { |
|
44 |
return StringUtils.isNotBlank(oaiSource)? oaiSource : token.getEnv().getAttribute(oaiSourceParam, String.class); |
|
45 |
} |
|
46 |
|
|
47 |
protected String getTheOAICollection(final Token token) { |
|
48 |
return getTheOAIFormat(token) + "-" + getTheOAILayout(token) + "-" + getTheOAIInterpretation(token); |
|
49 |
} |
|
50 |
|
|
51 |
|
|
19 | 52 |
@Override |
20 | 53 |
protected String obtainServiceId(final Env env) { |
21 | 54 |
return getServiceLocator().getServiceId(OAIStoreService.class); |
... | ... | |
23 | 56 |
|
24 | 57 |
@Override |
25 | 58 |
protected void prepareJob(final BlackboardJob job, final Token token) throws ResultSetException { |
26 |
job.getParameters().put("oai_dbName", getDbName()); |
|
27 |
job.getParameters().put("oai_collectionName", getCollectionName()); |
|
59 |
job.getParameters().put(OAIParameterNames.OAI_DB, getTheOAIDBName(token)); |
|
60 |
job.getParameters().put(OAIParameterNames.OAI_FORMAT_NAME, getTheOAIFormat(token)); |
|
61 |
job.getParameters().put(OAIParameterNames.OAI_FORMAT_LAYOUT, getTheOAILayout(token)); |
|
62 |
job.getParameters().put(OAIParameterNames.OAI_FORMAT_INTERPRETATION, getTheOAIInterpretation(token)); |
|
63 |
job.getParameters().put(OAIParameterNames.OAI_COLLECTON, getTheOAICollection(token)); |
|
64 |
String theSource = getTheOAISource(token); |
|
65 |
if(StringUtils.isNotBlank(theSource)) job.getParameters().put(OAIParameterNames.OAI_SOURCE, getTheOAISource(token)); |
|
28 | 66 |
completePrepareJob(job, token); |
29 | 67 |
} |
30 | 68 |
|
31 | 69 |
abstract void completePrepareJob(final BlackboardJob job, final Token token) throws ResultSetException; |
32 | 70 |
|
33 |
public String getDbName() {
|
|
34 |
return this.dbName;
|
|
71 |
public String getOaiDbNameParam() {
|
|
72 |
return oaiDbNameParam;
|
|
35 | 73 |
} |
36 | 74 |
|
37 |
public void setDbName(final String dbName) {
|
|
38 |
this.dbName = dbName;
|
|
75 |
public void setOaiDbNameParam(final String oaiDbNameParam) {
|
|
76 |
this.oaiDbNameParam = oaiDbNameParam;
|
|
39 | 77 |
} |
40 | 78 |
|
41 |
public String getCollectionName() { |
|
79 |
public String getOaiDbName() { |
|
80 |
return oaiDbName; |
|
81 |
} |
|
42 | 82 |
|
43 |
if (!StringUtils.isBlank(collectionName)) |
|
44 |
return collectionName; |
|
45 |
if (!StringUtils.isBlank(format) && !StringUtils.isBlank(layout) && !StringUtils.isBlank(interpretation)) { |
|
46 |
return String.format("%s-%s-%s", format, layout, interpretation); |
|
47 |
} |
|
48 |
return null; |
|
83 |
public void setOaiDbName(final String oaiDbName) { |
|
84 |
this.oaiDbName = oaiDbName; |
|
85 |
} |
|
49 | 86 |
|
87 |
public String getOaiFormatParam() { |
|
88 |
return oaiFormatParam; |
|
50 | 89 |
} |
51 | 90 |
|
52 |
public void setCollectionName(final String collectionName) {
|
|
53 |
this.collectionName = collectionName;
|
|
91 |
public void setOaiFormatParam(final String oaiFormatParam) {
|
|
92 |
this.oaiFormatParam = oaiFormatParam;
|
|
54 | 93 |
} |
55 | 94 |
|
56 |
public String getFormat() { |
|
57 |
return format;
|
|
95 |
public String getOaiFormat() {
|
|
96 |
return oaiFormat;
|
|
58 | 97 |
} |
59 | 98 |
|
60 |
public void setFormat(final String format) {
|
|
61 |
this.format = format;
|
|
99 |
public void setOaiFormat(final String oaiFormat) {
|
|
100 |
this.oaiFormat = oaiFormat;
|
|
62 | 101 |
} |
63 | 102 |
|
64 |
public String getLayout() {
|
|
65 |
return layout;
|
|
103 |
public String getOaiLayoutParam() {
|
|
104 |
return oaiLayoutParam;
|
|
66 | 105 |
} |
67 | 106 |
|
68 |
public void setLayout(final String layout) {
|
|
69 |
this.layout = layout;
|
|
107 |
public void setOaiLayoutParam(final String oaiLayoutParam) {
|
|
108 |
this.oaiLayoutParam = oaiLayoutParam;
|
|
70 | 109 |
} |
71 | 110 |
|
72 |
public String getInterpretation() {
|
|
73 |
return interpretation;
|
|
111 |
public String getOaiLayout() {
|
|
112 |
return oaiLayout;
|
|
74 | 113 |
} |
75 | 114 |
|
76 |
public void setInterpretation(final String interpretation) {
|
|
77 |
this.interpretation = interpretation;
|
|
115 |
public void setOaiLayout(final String oaiLayout) {
|
|
116 |
this.oaiLayout = oaiLayout;
|
|
78 | 117 |
} |
118 |
|
|
119 |
public String getOaiInterpretationParam() { |
|
120 |
return oaiInterpretationParam; |
|
121 |
} |
|
122 |
|
|
123 |
public void setOaiInterpretationParam(final String oaiInterpretationParam) { |
|
124 |
this.oaiInterpretationParam = oaiInterpretationParam; |
|
125 |
} |
|
126 |
|
|
127 |
public String getOaiInterpretation() { |
|
128 |
return oaiInterpretation; |
|
129 |
} |
|
130 |
|
|
131 |
public void setOaiInterpretation(final String oaiInterpretation) { |
|
132 |
this.oaiInterpretation = oaiInterpretation; |
|
133 |
} |
|
134 |
|
|
135 |
public String getOaiSourceParam() { |
|
136 |
return oaiSourceParam; |
|
137 |
} |
|
138 |
|
|
139 |
public void setOaiSourceParam(final String oaiSourceParam) { |
|
140 |
this.oaiSourceParam = oaiSourceParam; |
|
141 |
} |
|
142 |
|
|
143 |
public String getOaiSource() { |
|
144 |
return oaiSource; |
|
145 |
} |
|
146 |
|
|
147 |
public void setOaiSource(final String oaiSource) { |
|
148 |
this.oaiSource = oaiSource; |
|
149 |
} |
|
79 | 150 |
} |
Also available in: Unified diff
OAI job nodes adapted to the latest version on Dnet 40: less mess with parameters