1
|
package eu.dnetlib.msro.workflows.nodes.oai;
|
2
|
|
3
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
4
|
import eu.dnetlib.miscutils.datetime.DateUtils;
|
5
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
6
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
7
|
import eu.dnetlib.msro.workflows.procs.Env;
|
8
|
import eu.dnetlib.rmi.enabling.ISLookUpService;
|
9
|
import eu.dnetlib.rmi.manager.MSROException;
|
10
|
import org.apache.commons.logging.Log;
|
11
|
import org.apache.commons.logging.LogFactory;
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
13
|
|
14
|
/**
|
15
|
* The Class PrepareOaiDataJobNode.
|
16
|
*/
|
17
|
public class PrepareOaiDataJobNode extends SimpleJobNode {
|
18
|
|
19
|
/** The Constant log. */
|
20
|
private static final Log log = LogFactory.getLog(PrepareOaiDataJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
21
|
|
22
|
/** The service locator. */
|
23
|
@Autowired
|
24
|
private UniqueServiceLocator serviceLocator;
|
25
|
|
26
|
/** Target mongo oai store collection name. **/
|
27
|
private String oaiStoreCollectionParam;
|
28
|
|
29
|
/** Target mongo database name. **/
|
30
|
private String oaiDBName;
|
31
|
/** Name of the env property where to put the value of oaiDBName. **/
|
32
|
private String oaiDBNameParam;
|
33
|
|
34
|
private String formatParam = "oai_format";
|
35
|
|
36
|
private String layoutParam = "oai_layout";
|
37
|
|
38
|
private String interpretationParam = "oai_interpretation";
|
39
|
|
40
|
private boolean skipDuplicates = false;
|
41
|
private String duplicateXPath;
|
42
|
|
43
|
/*
|
44
|
* (non-Javadoc)
|
45
|
*
|
46
|
* @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken)
|
47
|
*/
|
48
|
@Override
|
49
|
protected String execute(final Env env) throws Exception {
|
50
|
|
51
|
log.info("start preparing job");
|
52
|
|
53
|
// set the target mongo collection name
|
54
|
final String format = env.getAttribute(getFormatParam(), String.class);
|
55
|
final String interpretation = env.getAttribute(getInterpretationParam(), String.class);
|
56
|
final String layout = env.getAttribute(getLayoutParam(), String.class);
|
57
|
env.setAttribute(getOaiStoreCollectionParam(), format + "-" + layout + "-" + interpretation);
|
58
|
|
59
|
final String configurationProfile = getConfigurationProfile();
|
60
|
env.setAttribute("oaiConfiguration", configurationProfile);
|
61
|
env.setAttribute("oai.feed.date", DateUtils.now_ISO8601());
|
62
|
|
63
|
env.setAttribute(getOaiDBNameParam(), getOaiDBName());
|
64
|
|
65
|
// services.publisher.oai.
|
66
|
// duplicates
|
67
|
env.setAttribute("services.publisher.oai.skipDuplicates", this.skipDuplicates);
|
68
|
env.setAttribute("services.publisher.oai.duplicateXPath", this.duplicateXPath);
|
69
|
|
70
|
return Arc.DEFAULT_ARC;
|
71
|
}
|
72
|
|
73
|
/**
|
74
|
* Gets the configuration profile.
|
75
|
*
|
76
|
* @return the configuration profile
|
77
|
* @throws MSROException
|
78
|
* the MSRO exception
|
79
|
*/
|
80
|
private String getConfigurationProfile() throws MSROException {
|
81
|
try {
|
82
|
return this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
|
83
|
"//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value = 'OAIPublisherConfigurationDSResourceType']");
|
84
|
} catch (final Exception e) {
|
85
|
throw new MSROException("Cannot find OAI configuration profile", e);
|
86
|
}
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* Gets the oai store collection param.
|
91
|
*
|
92
|
* @return the oai store collection param
|
93
|
*/
|
94
|
public String getOaiStoreCollectionParam() {
|
95
|
return this.oaiStoreCollectionParam;
|
96
|
}
|
97
|
|
98
|
/**
|
99
|
* Sets the oai store collection param.
|
100
|
*
|
101
|
* @param oaiStoreCollectionParam
|
102
|
* the new oai store collection param
|
103
|
*/
|
104
|
public void setOaiStoreCollectionParam(final String oaiStoreCollectionParam) {
|
105
|
this.oaiStoreCollectionParam = oaiStoreCollectionParam;
|
106
|
}
|
107
|
|
108
|
public String getOaiDBName() {
|
109
|
return this.oaiDBName;
|
110
|
}
|
111
|
|
112
|
public void setOaiDBName(final String oaiDBName) {
|
113
|
this.oaiDBName = oaiDBName;
|
114
|
}
|
115
|
|
116
|
public String getOaiDBNameParam() {
|
117
|
return this.oaiDBNameParam;
|
118
|
}
|
119
|
|
120
|
public void setOaiDBNameParam(final String oaiDBNameParam) {
|
121
|
this.oaiDBNameParam = oaiDBNameParam;
|
122
|
}
|
123
|
|
124
|
public String getFormatParam() {
|
125
|
return this.formatParam;
|
126
|
}
|
127
|
|
128
|
public void setFormatParam(final String formatParam) {
|
129
|
this.formatParam = formatParam;
|
130
|
}
|
131
|
|
132
|
public String getLayoutParam() {
|
133
|
return this.layoutParam;
|
134
|
}
|
135
|
|
136
|
public void setLayoutParam(final String layoutParam) {
|
137
|
this.layoutParam = layoutParam;
|
138
|
}
|
139
|
|
140
|
public String getInterpretationParam() {
|
141
|
return this.interpretationParam;
|
142
|
}
|
143
|
|
144
|
public void setInterpretationParam(final String interpretationParam) {
|
145
|
this.interpretationParam = interpretationParam;
|
146
|
}
|
147
|
|
148
|
public boolean isSkipDuplicates() {
|
149
|
return this.skipDuplicates;
|
150
|
}
|
151
|
|
152
|
public void setSkipDuplicates(final boolean skipDuplicates) {
|
153
|
this.skipDuplicates = skipDuplicates;
|
154
|
}
|
155
|
|
156
|
public String getDuplicateXPath() {
|
157
|
return this.duplicateXPath;
|
158
|
}
|
159
|
|
160
|
public void setDuplicateXPath(final String duplicateXPath) {
|
161
|
this.duplicateXPath = duplicateXPath;
|
162
|
}
|
163
|
|
164
|
}
|