1
|
package eu.dnetlib.msro.workflows.nodes.index;
|
2
|
|
3
|
import java.util.Map;
|
4
|
|
5
|
import org.apache.commons.logging.Log;
|
6
|
import org.apache.commons.logging.LogFactory;
|
7
|
import org.springframework.beans.factory.annotation.Required;
|
8
|
|
9
|
import com.googlecode.sarasvati.Engine;
|
10
|
import com.googlecode.sarasvati.NodeToken;
|
11
|
import com.googlecode.sarasvati.env.Env;
|
12
|
|
13
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
14
|
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
|
15
|
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener;
|
16
|
|
17
|
// TODO: Auto-generated Javadoc
|
18
|
/**
|
19
|
* The Class CreateIndexJobNode.
|
20
|
*/
|
21
|
public class CreateIndexJobNode extends BlackboardJobNode {
|
22
|
|
23
|
/** The Constant log. */
|
24
|
private static final Log log = LogFactory.getLog(CreateIndexJobNode.class);
|
25
|
|
26
|
/** The output prefix. */
|
27
|
private String outputPrefix = "index_";
|
28
|
|
29
|
/** The default backend id. */
|
30
|
private String defaultBackendId;
|
31
|
|
32
|
/** The format. */
|
33
|
private String format;
|
34
|
|
35
|
|
36
|
/** The layout. */
|
37
|
private String layout;
|
38
|
|
39
|
/** The interpretation. */
|
40
|
private String interpretation;
|
41
|
|
42
|
|
43
|
|
44
|
|
45
|
/* (non-Javadoc)
|
46
|
* @see eu.dnetlib.msro.workflows.nodes.BlackboardJobNode#getXqueryForServiceId(com.googlecode.sarasvati.NodeToken)
|
47
|
*/
|
48
|
@Override
|
49
|
protected String getXqueryForServiceId(final NodeToken token) {
|
50
|
return "collection('/db/DRIVER/ServiceResources/IndexServiceResourceType')//RESOURCE_IDENTIFIER/@value/string()";
|
51
|
}
|
52
|
|
53
|
/* (non-Javadoc)
|
54
|
* @see eu.dnetlib.msro.workflows.nodes.BlackboardJobNode#prepareJob(eu.dnetlib.enabling.tools.blackboard.BlackboardJob, com.googlecode.sarasvati.NodeToken)
|
55
|
*/
|
56
|
@Override
|
57
|
protected void prepareJob(final BlackboardJob job, final NodeToken token) {
|
58
|
final String env_format = token.getFullEnv().getAttribute("format");
|
59
|
final String env_layout = token.getFullEnv().getAttribute("layout");
|
60
|
final String env_interp = token.getFullEnv().getAttribute("interpretation");
|
61
|
|
62
|
if ((env_format != null)&& (!env_format.isEmpty())){
|
63
|
this.format = env_format;
|
64
|
}
|
65
|
if ((env_layout != null)&& (!env_layout.isEmpty())) {
|
66
|
this.layout = env_layout;
|
67
|
}
|
68
|
if ((env_interp != null)&& (!env_interp.isEmpty())) {
|
69
|
this.interpretation = env_interp;
|
70
|
}
|
71
|
|
72
|
|
73
|
log.info("preparing CREATE blackboard job: " + format + "-" + layout + "-" + interpretation);
|
74
|
|
75
|
job.setAction("CREATE");
|
76
|
job.getParameters().put("format", format);
|
77
|
job.getParameters().put("layout", layout);
|
78
|
job.getParameters().put("interpretation", interpretation);
|
79
|
job.getParameters().put("backend_Id", defaultBackendId);
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* Gets the output prefix.
|
84
|
*
|
85
|
* @return the output prefix
|
86
|
*/
|
87
|
public String getOutputPrefix() {
|
88
|
return outputPrefix;
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
* Sets the output prefix.
|
93
|
*
|
94
|
* @param outputPrefix the output prefix
|
95
|
*/
|
96
|
public void setOutputPrefix(final String outputPrefix) {
|
97
|
this.outputPrefix = outputPrefix;
|
98
|
}
|
99
|
|
100
|
/* (non-Javadoc)
|
101
|
* @see eu.dnetlib.msro.workflows.nodes.BlackboardJobNode#generateBlackboardListener(com.googlecode.sarasvati.Engine, com.googlecode.sarasvati.NodeToken)
|
102
|
*/
|
103
|
@Override
|
104
|
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) {
|
105
|
return new BlackboardWorkflowJobListener(engine, token) {
|
106
|
|
107
|
@Override
|
108
|
protected void populateEnv(final Env env, final Map<String, String> responseParams) {
|
109
|
env.setAttribute(getOutputPrefix() + "format", getFormat());
|
110
|
env.setAttribute(getOutputPrefix() + "layout", getLayout());
|
111
|
env.setAttribute(getOutputPrefix() + "interpretation", getInterpretation());
|
112
|
env.setAttribute(getOutputPrefix() + "id", responseParams.get("id"));
|
113
|
}
|
114
|
};
|
115
|
}
|
116
|
|
117
|
/**
|
118
|
* Gets the default backend id.
|
119
|
*
|
120
|
* @return the default backend id
|
121
|
*/
|
122
|
public String getDefaultBackendId() {
|
123
|
return defaultBackendId;
|
124
|
}
|
125
|
|
126
|
/**
|
127
|
* Sets the default backend id.
|
128
|
*
|
129
|
* @param defaultBackendId the default backend id
|
130
|
*/
|
131
|
@Required
|
132
|
public void setDefaultBackendId(String defaultBackendId) {
|
133
|
this.defaultBackendId = defaultBackendId;
|
134
|
}
|
135
|
|
136
|
/**
|
137
|
* Gets the format.
|
138
|
*
|
139
|
* @return the format
|
140
|
*/
|
141
|
public String getFormat() {
|
142
|
return format;
|
143
|
}
|
144
|
|
145
|
/**
|
146
|
* Sets the format.
|
147
|
*
|
148
|
* @param format the format
|
149
|
*/
|
150
|
public void setFormat(String format) {
|
151
|
this.format = format;
|
152
|
}
|
153
|
|
154
|
/**
|
155
|
* Gets the layout.
|
156
|
*
|
157
|
* @return the layout
|
158
|
*/
|
159
|
public String getLayout() {
|
160
|
return layout;
|
161
|
}
|
162
|
|
163
|
/**
|
164
|
* Sets the layout.
|
165
|
*
|
166
|
* @param layout the layout
|
167
|
*/
|
168
|
public void setLayout(String layout) {
|
169
|
this.layout = layout;
|
170
|
}
|
171
|
|
172
|
/**
|
173
|
* Gets the interpretation.
|
174
|
*
|
175
|
* @return the interpretation
|
176
|
*/
|
177
|
public String getInterpretation() {
|
178
|
return interpretation;
|
179
|
}
|
180
|
|
181
|
/**
|
182
|
* Sets the interpretation.
|
183
|
*
|
184
|
* @param interpretation the interpretation
|
185
|
*/
|
186
|
public void setInterpretation(String interpretation) {
|
187
|
this.interpretation = interpretation;
|
188
|
}
|
189
|
|
190
|
|
191
|
|
192
|
}
|