Revision 54712
Added by Claudio Atzori almost 5 years ago
modules/dnet-validator-workflows/trunk/src/main/java/eu/dnetlib/msro/workflows/nodes/validation/ValidatorServiceBlackboardJobNode.java | ||
---|---|---|
197 | 197 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) { |
198 | 198 |
return new BlackboardWorkflowJobListener(engine, token) { |
199 | 199 |
|
200 |
boolean done = false;
|
|
200 |
boolean eprFound = false;
|
|
201 | 201 |
|
202 | 202 |
@Override |
203 | 203 |
protected void onDone(final BlackboardJob job) { |
204 |
if (!isShouldOutputRecords()) { |
|
205 |
log.debug("If you see this log you are not asking to get the validated EPR..."); |
|
206 | 204 |
|
207 |
final String jobId = job.getParameters().get("jobId");
|
|
205 |
log.debug("If you see this log you are not asking to get the validated EPR...");
|
|
208 | 206 |
|
209 |
token.getEnv().setAttribute("validatorJobId", jobId); |
|
210 |
final String error = job.getParameters().get("error"); |
|
211 |
if (StringUtils.isNotBlank(error)) { |
|
212 |
token.getEnv().setAttribute("validatorError", error); |
|
213 |
} |
|
207 |
final String jobId = job.getParameters().get("jobId"); |
|
214 | 208 |
|
215 |
try { |
|
216 |
final String dsId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ORIGINALID); |
|
217 |
final String ifaceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE); |
|
209 |
token.getEnv().setAttribute("validatorJobId", jobId); |
|
210 |
final String error = job.getParameters().get("error"); |
|
211 |
if (StringUtils.isNotBlank(error)) { |
|
212 |
token.getEnv().setAttribute("validatorError", error); |
|
213 |
} |
|
218 | 214 |
|
219 |
dsManager.setLastValidationJob(dsId, ifaceId, jobId); |
|
215 |
try { |
|
216 |
final String dsId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ORIGINALID); |
|
217 |
final String ifaceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE); |
|
220 | 218 |
|
221 |
} catch (final DsmException e) { |
|
222 |
log.error("Error setting last_validation_job field"); |
|
223 |
throw new RuntimeException("Error setting last_validation_job field", e); |
|
224 |
} |
|
219 |
dsManager.setLastValidationJob(dsId, ifaceId, jobId); |
|
225 | 220 |
|
226 |
super.onDone(job); |
|
221 |
} catch (final DsmException e) { |
|
222 |
log.error("Error setting last_validation_job field"); |
|
223 |
throw new RuntimeException("Error setting last_validation_job field", e); |
|
227 | 224 |
} |
225 |
|
|
226 |
super.onDone(job); |
|
228 | 227 |
} |
229 | 228 |
|
230 | 229 |
@Override |
231 | 230 |
protected void onOngoing(final BlackboardJob job) { |
232 | 231 |
currentlyValidated = Integer.parseInt(job.getParameters().get(currentlyValidatedParam)); |
233 |
if (isShouldOutputRecords()) { |
|
234 |
onGoingWithEPRResults(job); |
|
235 |
} else { |
|
236 |
onGoingWithoutEPRResults(job); |
|
237 |
} |
|
238 |
} |
|
239 |
|
|
240 |
private void onGoingWithEPRResults(final BlackboardJob job) { |
|
241 |
if (!done) { |
|
232 |
if (isShouldOutputRecords() & !eprFound) { |
|
242 | 233 |
final String epr = job.getParameters().get(VALIDATOR_EPR_PARAM_NAME); |
243 | 234 |
log.fatal(VALIDATOR_EPR_PARAM_NAME + "= " + epr); |
244 | 235 |
token.getEnv().setAttribute(outputEprName, epr); |
245 |
done = true; |
|
246 |
//super.onDone(job); |
|
236 |
eprFound = true; |
|
247 | 237 |
} |
238 |
super.onOngoing(job); |
|
248 | 239 |
} |
249 | 240 |
|
250 |
private void onGoingWithoutEPRResults(final BlackboardJob job) { |
|
251 |
super.onOngoing(job); |
|
252 |
} |
|
253 | 241 |
}; |
254 | 242 |
|
255 | 243 |
} |
Also available in: Unified diff
simplify the onDone behaviour