use of ubic.gemma.model.common.auditAndSecurity.curation.Curatable in project Gemma by PavlidisLab.
the class AbstractSpringAwareCLI method noNeedToRun.
/**
* @param auditable auditable
* @param eventClass can be null
* @return boolean
*/
protected boolean noNeedToRun(Auditable auditable, Class<? extends AuditEventType> eventClass) {
boolean needToRun = true;
Date skipIfLastRunLaterThan = this.getLimitingDate();
List<AuditEvent> events = this.auditEventService.getEvents(auditable);
// assume okay unless indicated otherwise
boolean okToRun = true;
// count.
for (int j = events.size() - 1; j >= 0; j--) {
AuditEvent event = events.get(j);
if (event == null) {
// legacy of ordered-list which could end up with gaps; should not be needed any more
continue;
}
AuditEventType eventType = event.getEventType();
if (eventType != null && eventClass != null && eventClass.isAssignableFrom(eventType.getClass()) && !eventType.getClass().getSimpleName().startsWith("Fail")) {
if (skipIfLastRunLaterThan != null) {
if (event.getDate().after(skipIfLastRunLaterThan)) {
AbstractCLI.log.info(auditable + ": " + " run more recently than " + skipIfLastRunLaterThan);
errorObjects.add(auditable + ": " + " run more recently than " + skipIfLastRunLaterThan);
needToRun = false;
}
} else {
// it has been run already at some point
needToRun = false;
}
}
}
/*
* Always skip if the object is curatable and troubled
*/
if (auditable instanceof Curatable) {
Curatable curatable = (Curatable) auditable;
// not ok if troubled
okToRun = !curatable.getCurationDetails().getTroubled();
// special case for expression experiments - check associated ADs.
if (okToRun && curatable instanceof ExpressionExperiment) {
ExpressionExperimentService ees = this.getBean(ExpressionExperimentService.class);
for (ArrayDesign ad : ees.getArrayDesignsUsed((ExpressionExperiment) auditable)) {
if (ad.getCurationDetails().getTroubled()) {
// not ok if even one parent AD is troubled, no need to check the remaining ones.
okToRun = false;
break;
}
}
}
if (!okToRun) {
AbstractCLI.log.info(auditable + ": has an active 'trouble' flag");
errorObjects.add(auditable + ": has an active 'trouble' flag");
}
}
return !needToRun || !okToRun;
}
use of ubic.gemma.model.common.auditAndSecurity.curation.Curatable in project Gemma by PavlidisLab.
the class AuditTrailServiceImpl method addUpdateEvent.
/**
* This method creates a new event in the audit trail of the passed Auditable object. If this object also implements
* the {@link Curatable} interface, and the passed auditEventType is one of the extensions of
* {@link CurationDetailsEvent} AuditEventType, this method will pass its result to
* {@link CurationDetailsService#update(Curatable, AuditEvent)}, to update the curatable objects curation details,
* before returning it.
*
* @param auditable the auditable object to whose audit trail should a new event be added.
* @param auditEventType the type of the event that should be created.
* @param note string displayed as a note for the event
* @param detail detailed description of the event.
* @return the new AuditEvent that was created in the audit trail of the given auditable object.
* @see AuditTrailService#addUpdateEvent(Auditable, AuditEventType, String, String)
*/
@Override
@Transactional
public AuditEvent addUpdateEvent(final Auditable auditable, final AuditEventType auditEventType, final String note, final String detail) {
// Create new audit event
AuditEvent auditEvent = AuditEvent.Factory.newInstance(new Date(), AuditAction.UPDATE, note, detail, null, auditEventType);
auditEvent = this.auditTrailDao.addEvent(auditable, auditEvent);
// If object is curatable, update curation details
if (auditable instanceof Curatable && auditEvent != null && auditEvent.getEventType() != null) {
curationDetailsService.update((Curatable) auditable, auditEvent);
}
// return the newly created event
return auditEvent;
}
Aggregations