use of ubic.gemma.model.common.Auditable in project Gemma by PavlidisLab.
the class AuditEventDaoImplTest method testHandleGetNewSinceDate.
@Test
public void testHandleGetNewSinceDate() {
Calendar c = Calendar.getInstance();
c.set(2006, Calendar.DECEMBER, 1);
Date d = c.getTime();
Collection<Auditable> objs = auditEventService.getNewSinceDate(d);
assertTrue(objs.size() > 0);
// for ( AbstractAuditable auditable : objs ) {
// if ( objs instanceof ArrayDesign ) {
// }
// }
}
use of ubic.gemma.model.common.Auditable in project Gemma by PavlidisLab.
the class WhatsNewServiceImpl method retrieveReport.
/**
* Retrieve the latest WhatsNew report.
*
* @return WhatsNew the latest WhatsNew report cache.
*/
@Override
public WhatsNew retrieveReport() {
WhatsNew wn = new WhatsNew();
try {
File newObjects = new File(HOME_DIR + File.separatorChar + WhatsNewServiceImpl.WHATS_NEW_DIR + File.separatorChar + WhatsNewServiceImpl.WHATS_NEW_FILE + ".new");
File updatedObjects = new File(HOME_DIR + File.separatorChar + WhatsNewServiceImpl.WHATS_NEW_DIR + File.separatorChar + WhatsNewServiceImpl.WHATS_NEW_FILE + ".updated");
if (!newObjects.exists() && !updatedObjects.exists()) {
return null;
}
// load up all new objects
if (newObjects.exists()) {
Collection<AuditableObject> aos = this.loadAuditableObjects(newObjects);
for (AuditableObject object : aos) {
Auditable auditable = this.fetch(object);
if (auditable == null)
continue;
wn.addNewObjects(auditable);
this.updateDate(wn, object);
}
}
// load up all updated objects
if (updatedObjects.exists()) {
Collection<AuditableObject> aos = this.loadAuditableObjects(updatedObjects);
for (AuditableObject object : aos) {
/*
* This call takes ~ 15-20 ms but it can be called many times if there are a lot of updated
* experiments, meaning this loop can take >8500 ms (over tunnel for ~450 experiments).
*
* Loading objects could be avoided since we only need ids on the front end, but we would need to
* refactor the cache, because object-type is used to calculate counts for updated array design
* objects vs updated experiments
*
* This is probably not necessary because usually the number of updated or new experiments will be
* much lower than 450.
*/
Auditable auditable = this.fetch(object);
if (auditable == null)
continue;
wn.addUpdatedObjects(auditable);
this.updateDate(wn, object);
}
}
// build total, new and updated counts by taxon to display in data summary widget on front page
wn.setNewEEIdsPerTaxon(this.getExpressionExperimentIdsByTaxon(wn.getNewExpressionExperiments()));
wn.setUpdatedEEIdsPerTaxon(this.getExpressionExperimentIdsByTaxon(wn.getUpdatedExpressionExperiments()));
} catch (Throwable e) {
WhatsNewServiceImpl.log.error(e, e);
return null;
}
return wn;
}
use of ubic.gemma.model.common.Auditable in project Gemma by PavlidisLab.
the class WhatsNewServiceImpl method fetch.
private Auditable fetch(AuditableObject object) {
if (object == null)
return null;
Auditable auditable = null;
Element element = this.whatsNewCache.get(object);
if (object.type.equalsIgnoreCase("ArrayDesign")) {
if (element != null) {
auditable = (Auditable) element.getObjectValue();
} else {
try {
auditable = arrayDesignService.load(object.getId());
} catch (AccessDeniedException e) {
return null;
}
whatsNewCache.put(new Element(object, auditable));
}
} else if (object.type.equalsIgnoreCase("ExpressionExperiment")) {
if (element != null) {
auditable = (Auditable) element.getObjectValue();
} else {
try {
auditable = expressionExperimentService.load(object.getId());
} catch (AccessDeniedException e) {
return null;
}
if (auditable == null) {
return null;
}
whatsNewCache.put(new Element(object, auditable));
}
}
return auditable;
}
use of ubic.gemma.model.common.Auditable in project Gemma by PavlidisLab.
the class PersisterHelper method persist.
@Override
@Transactional
public Object persist(Object entity) {
try {
this.getSessionFactory().getCurrentSession().setFlushMode(FlushMode.COMMIT);
if (entity instanceof Auditable) {
Auditable auditable = (Auditable) entity;
if (auditable.getAuditTrail() == null) {
auditable.setAuditTrail(AuditTrail.Factory.newInstance());
}
auditable.setAuditTrail(persistAuditTrail(auditable.getAuditTrail()));
}
return super.persist(entity);
} finally {
this.getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO);
}
}
use of ubic.gemma.model.common.Auditable in project Gemma by PavlidisLab.
the class AuditEventDaoImpl method retainLackingEvent.
@Override
public void retainLackingEvent(final Collection<? extends Auditable> a, final Class<? extends AuditEventType> type) {
StopWatch timer = new StopWatch();
timer.start();
final Map<Auditable, AuditEvent> events = this.getLastEvent(a, type);
AbstractDao.log.info("Phase I: " + timer.getTime() + "ms");
CollectionUtils.filter(a, new Predicate() {
@Override
public boolean evaluate(Object arg0) {
// noinspection SuspiciousMethodCalls // this is perfectly fine since we are passing this directly into the filter
return !events.containsKey(arg0);
}
});
}
Aggregations