use of org.powo.job.dwc.exception.TaxonAlreadyProcessedException in project powop by RBGKew.
the class SkippingProcessor method process.
/**
* @param taxon a taxon object
* @throws Exception if something goes wrong
* @return Taxon a taxon object
*/
public final Annotation process(final Taxon taxon) throws Exception {
logger.debug("Processing " + taxon.getIdentifier());
if (taxon.getIdentifier() == null) {
throw new NoIdentifierException(taxon);
}
Taxon persistedTaxon = taxonService.find(taxon.getIdentifier());
if (persistedTaxon == null) {
throw new CannotFindRecordException(taxon.getIdentifier(), taxon.toString());
}
Annotation annotation = resolveAnnotation(RecordType.Taxon, persistedTaxon.getId(), getStepExecution().getJobExecutionId());
if (annotation == null) {
annotation = this.createAnnotation(persistedTaxon, RecordType.Taxon, AnnotationCode.Skipped, AnnotationType.Info);
bindAnnotation(annotation);
} else {
if (annotation.getCode().equals(AnnotationCode.Skipped)) {
throw new TaxonAlreadyProcessedException(taxon);
}
annotation.setType(AnnotationType.Info);
annotation.setCode(AnnotationCode.Skipped);
logger.debug(persistedTaxon.getIdentifier() + " was skipped");
}
return annotation;
}
use of org.powo.job.dwc.exception.TaxonAlreadyProcessedException in project powop by RBGKew.
the class CheckingProcessor method process.
/**
* @param taxon a taxon object
* @throws Exception if something goes wrong
* @return Taxon a taxon object
*/
public final Annotation process(final Taxon taxon) throws Exception {
logger.info("Processing " + taxon.getIdentifier());
if (taxon.getIdentifier() == null || taxon.getIdentifier().isEmpty()) {
throw new NoIdentifierException(taxon);
}
Taxon persistedTaxon = taxonService.find(taxon.getIdentifier());
if (persistedTaxon == null) {
throw new CannotFindRecordException(taxon.getIdentifier(), taxon.toString());
}
Annotation annotation = annotationService.findAnnotation(RecordType.Taxon, persistedTaxon.getId(), getStepExecution().getJobExecutionId());
if (annotation == null) {
logger.warn(taxon.getIdentifier() + " was not expected");
throw new UnexpectedTaxonException(taxon);
} else {
if (annotation.getCode().equals(AnnotationCode.Present)) {
throw new TaxonAlreadyProcessedException(taxon);
}
annotation.setType(AnnotationType.Info);
annotation.setCode(AnnotationCode.Present);
logger.info(taxon.getIdentifier() + " was expected");
}
return annotation;
}
Aggregations