use of ubic.gemma.persistence.model.Gene2CsStatus in project Gemma by PavlidisLab.
the class TableMaintenanceUtilImpl method updateGene2CsEntries.
@Override
@Transactional
public synchronized void updateGene2CsEntries() {
if (TableMaintenanceUtilImpl.running.get())
return;
TableMaintenanceUtilImpl.log.debug("Running Gene2CS status check");
String annotation = "";
try {
TableMaintenanceUtilImpl.running.set(true);
Gene2CsStatus status = this.getLastGene2CsUpdateStatus();
boolean needToRefresh = false;
if (status == null) {
needToRefresh = true;
}
if (!needToRefresh) {
Collection<Auditable> newObj = auditEventService.getNewSinceDate(status.getLastUpdate());
for (Auditable a : newObj) {
if (a instanceof ArrayDesign) {
needToRefresh = true;
annotation = a + " is new since " + status.getLastUpdate();
TableMaintenanceUtilImpl.log.debug(annotation);
break;
}
}
}
if (!needToRefresh) {
Collection<Auditable> updatedObj = auditEventService.getUpdatedSinceDate(status.getLastUpdate());
for (Auditable a : updatedObj) {
if (a instanceof ArrayDesign) {
for (AuditEvent ae : auditEventService.getEvents(a)) {
if (ae == null)
// legacy of ordered-list which could end up with gaps; should
continue;
// not be needed any more
if (ae.getEventType() != null && ae.getEventType() instanceof ArrayDesignGeneMappingEvent && ae.getDate().after(status.getLastUpdate())) {
needToRefresh = true;
annotation = a + " had probe mapping done since: " + status.getLastUpdate();
TableMaintenanceUtilImpl.log.debug(annotation);
break;
}
}
}
if (needToRefresh)
break;
}
}
if (needToRefresh) {
TableMaintenanceUtilImpl.log.debug("Update of GENE2CS initiated");
this.generateGene2CsEntries();
Gene2CsStatus updatedStatus = this.writeUpdateStatus(annotation, null);
this.sendEmail(updatedStatus);
} else {
TableMaintenanceUtilImpl.log.debug("No update of GENE2CS needed");
}
} catch (Exception e) {
try {
TableMaintenanceUtilImpl.log.info("Error during attempt to check status or update GENE2CS", e);
Gene2CsStatus updatedStatus = this.writeUpdateStatus(annotation, e);
this.sendEmail(updatedStatus);
} catch (IOException e1) {
throw new RuntimeException(e1);
}
} finally {
TableMaintenanceUtilImpl.running.set(false);
}
}
use of ubic.gemma.persistence.model.Gene2CsStatus in project Gemma by PavlidisLab.
the class TableMaintenanceUtilImpl method writeUpdateStatus.
/**
* @param annotation extra text that describes the status
*/
private Gene2CsStatus writeUpdateStatus(String annotation, Exception e) throws IOException {
this.initDirectories();
Gene2CsStatus status = new Gene2CsStatus();
Calendar c = Calendar.getInstance();
Date date = c.getTime();
status.setLastUpdate(date);
status.setError(e);
status.setAnnotation(annotation);
try (FileOutputStream fos = new FileOutputStream(this.getGene2CsInfopath());
ObjectOutputStream oos = new ObjectOutputStream(fos)) {
oos.writeObject(status);
}
return status;
}
Aggregations