@Transactional
public boolean invalidate(final Publication aPublication) {
boolean res = false;
- if ((aPublication.value().getProgressState() == ProgressState.inCHECK)
- && getDocumentService().demote(aPublication.value())) {
+ if ((aPublication.value().getProgressState() == ProgressState.inCHECK)) {
DocumentType type = aPublication.value().getType();
Study owner = aPublication.getOwnerStudy();
- if (getDocumentService().isStudyResult(type)
- && owner.getProgressState() == ProgressState.inCHECK) {
- getStudyService().demote(owner);
+
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ owner, type);
+ // Check if the validation cycle allows the review step
+ if (cycle.enables(ValidationStep.REVIEW)) {
+ if (getDocumentService().demote(aPublication.value())
+ && getDocumentService().isStudyResult(type)
+ && owner.getProgressState() == ProgressState.inCHECK) {
+ getStudyService().demote(owner);
+ }
+ res = true;
+ } else { // If the validation cycle has no inDraft step
+ res = demote(aPublication);
}
- res = true;
}
return res;
}
"Cannot save a Publication object refering an undefined Document");
}
if (!aPublication.value().getSourceFile().exists()) {
- throw new FileNotFoundException(aPublication.value().getSourceFile().asFile().getAbsolutePath());
+ throw new FileNotFoundException(aPublication.value()
+ .getSourceFile().asFile().getAbsolutePath());
}
if (state == ProgressState.inWORK || state == ProgressState.EXTERN) {