use of ubic.gemma.model.common.Auditable in project Gemma by PavlidisLab.
the class SearchServiceImpl method searchForNewlyCreatedUserQueryResults.
@Override
public Map<Class<?>, List<SearchResult>> searchForNewlyCreatedUserQueryResults(UserQuery query) {
Map<Class<?>, List<SearchResult>> searchResults;
Map<Class<?>, List<SearchResult>> finalResults = new HashMap<>();
SearchSettings settings = query.getSearchSettings();
if (StringUtils.isBlank(settings.getTermUri()) && !settings.getQuery().startsWith("http://")) {
// fill objects=true, speedySearch=false
searchResults = this.generalSearch(settings, true, false);
} else {
// we only attempt an ontology search if the uri looks remotely like a url.
searchResults = this.ontologyUriSearch(settings);
}
if (searchResults == null) {
return finalResults;
}
for (Class<?> clazz : searchResults.keySet()) {
List<SearchResult> results = searchResults.get(clazz);
List<SearchResult> updatedResults = new ArrayList<>();
if (results.size() == 0)
continue;
SearchServiceImpl.log.info("Search for newly createdQuery with settings: " + settings + "; result: " + results.size() + " " + clazz.getSimpleName() + "s");
for (SearchResult sr : results) {
// Are SearchResults always auditable? maybe put in some error handling in case they are not or
// enforce searchSettings object to be of a certain form
Auditable auditableResult = (Auditable) sr.getResultObject();
// this list is ordered by date (not descending)
List<AuditEvent> eventList = auditTrailService.getEvents(auditableResult);
if (eventList == null || eventList.isEmpty())
continue;
for (AuditEvent ae : eventList) {
// assuming there is only one create event
if (ae.getAction() == AuditAction.CREATE && ae.getDate().after(query.getLastUsed())) {
updatedResults.add(sr);
break;
}
}
}
if (!updatedResults.isEmpty()) {
finalResults.put(clazz, updatedResults);
}
}
return finalResults;
}
use of ubic.gemma.model.common.Auditable in project Gemma by PavlidisLab.
the class AuditEventDaoImplTest method testHandleGetUpdatedSinceDate.
@Test
public void testHandleGetUpdatedSinceDate() {
Calendar c = Calendar.getInstance();
c.set(2006, Calendar.DECEMBER, 1);
Date d = c.getTime();
Collection<Auditable> objs = auditEventService.getUpdatedSinceDate(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 ExpressionExperimentReportServiceImpl method populateEventInformation.
/**
* Fills in event and security information from the database. This will only retrieve the latest event (if any).
* This is rather slow so should be avoided if the information isn't needed.
*/
@Override
public void populateEventInformation(Collection<ExpressionExperimentDetailsValueObject> vos) {
StopWatch timer = new StopWatch();
timer.start();
Collection<Long> ids = EntityUtils.getIds(vos);
// do this ahead to avoid round trips - this also filters...
Collection<ExpressionExperiment> ees = expressionExperimentService.load(ids);
if (ees.size() == 0) {
return;
}
Map<Long, ExpressionExperiment> eeMap = EntityUtils.getIdMap(ees);
Map<Long, Date> lastArrayDesignUpdates = expressionExperimentService.getLastArrayDesignUpdate(ees);
Collection<Class<? extends AuditEventType>> typesToGet = Arrays.asList(eventTypes);
Map<Class<? extends AuditEventType>, Map<Auditable, AuditEvent>> events = this.getEvents(ees, typesToGet);
Map<Auditable, AuditEvent> linkAnalysisEvents = events.get(LinkAnalysisEvent.class);
Map<Auditable, AuditEvent> missingValueAnalysisEvents = events.get(MissingValueAnalysisEvent.class);
Map<Auditable, AuditEvent> rankComputationEvents = events.get(ProcessedVectorComputationEvent.class);
Map<Auditable, AuditEvent> differentialAnalysisEvents = events.get(DifferentialExpressionAnalysisEvent.class);
Map<Auditable, AuditEvent> batchFetchEvents = events.get(BatchInformationFetchingEvent.class);
Map<Auditable, AuditEvent> pcaAnalysisEvents = events.get(PCAAnalysisEvent.class);
Map<Long, Collection<AuditEvent>> sampleRemovalEvents = this.getSampleRemovalEvents(ees);
/*
* add in the last events of interest for all eeVos This step is remarkably slow.
*/
for (ExpressionExperimentDetailsValueObject eeVo : vos) {
Long id = eeVo.getId();
ExpressionExperiment ee = eeMap.get(id);
if (linkAnalysisEvents.containsKey(ee)) {
AuditEvent event = linkAnalysisEvents.get(ee);
if (event != null) {
Date date = event.getDate();
eeVo.setDateLinkAnalysis(date);
eeVo.setLinkAnalysisEventType(event.getEventType().getClass().getSimpleName());
}
}
if (missingValueAnalysisEvents.containsKey(ee)) {
AuditEvent event = missingValueAnalysisEvents.get(ee);
if (event != null) {
Date date = event.getDate();
eeVo.setDateMissingValueAnalysis(date);
eeVo.setMissingValueAnalysisEventType(event.getEventType().getClass().getSimpleName());
}
}
if (rankComputationEvents.containsKey(ee)) {
AuditEvent event = rankComputationEvents.get(ee);
if (event != null) {
Date date = event.getDate();
eeVo.setDateProcessedDataVectorComputation(date);
eeVo.setProcessedDataVectorComputationEventType(event.getEventType().getClass().getSimpleName());
}
}
if (differentialAnalysisEvents.containsKey(ee)) {
AuditEvent event = differentialAnalysisEvents.get(ee);
if (event != null) {
Date date = event.getDate();
eeVo.setDateDifferentialAnalysis(date);
}
}
if (pcaAnalysisEvents.containsKey(ee)) {
AuditEvent event = pcaAnalysisEvents.get(ee);
if (event != null) {
Date date = event.getDate();
eeVo.setDatePcaAnalysis(date);
eeVo.setPcaAnalysisEventType(event.getEventType().getClass().getSimpleName());
}
}
if (batchFetchEvents.containsKey(ee)) {
AuditEvent event = batchFetchEvents.get(ee);
if (event != null) {
Date date = event.getDate();
eeVo.setDateBatchFetch(date);
eeVo.setBatchFetchEventType(event.getEventType().getClass().getSimpleName());
}
}
if (lastArrayDesignUpdates.containsKey(id)) {
Date date = lastArrayDesignUpdates.get(id);
eeVo.setDateArrayDesignLastUpdated(date);
}
if (sampleRemovalEvents.containsKey(id)) {
Collection<AuditEvent> removalEvents = sampleRemovalEvents.get(id);
// we find we are getting lazy-load exceptions from this guy.
eeVo.auditEvents2SampleRemovedFlags(removalEvents);
}
}
if (timer.getTime() > 1000)
log.info("Retrieving audit events took " + timer.getTime() + "ms");
}
use of ubic.gemma.model.common.Auditable 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.model.common.Auditable in project Gemma by PavlidisLab.
the class ArrayDesignReportServiceImpl method fillEventInformation.
/**
* Fill in event information
*/
@Override
public void fillEventInformation(Collection<ArrayDesignValueObject> adVos) {
if (adVos == null || adVos.size() == 0)
return;
StopWatch watch = new StopWatch();
watch.start();
Collection<Long> ids = new ArrayList<>();
for (Object object : adVos) {
ArrayDesignValueObject adVo = (ArrayDesignValueObject) object;
Long id = adVo.getId();
if (id == null)
continue;
ids.add(id);
}
if (ids.size() == 0)
return;
Collection<Class<? extends AuditEventType>> typesToGet = Arrays.asList(eventTypes);
Collection<ArrayDesign> arrayDesigns = arrayDesignService.load(ids);
Map<Long, ArrayDesign> idMap = EntityUtils.getIdMap(arrayDesigns);
Map<Class<? extends AuditEventType>, Map<Auditable, AuditEvent>> events = auditEventService.getLastEvents(arrayDesigns, typesToGet);
Map<Auditable, AuditEvent> geneMappingEvents = events.get(ArrayDesignGeneMappingEvent.class);
Map<Auditable, AuditEvent> sequenceUpdateEvents = events.get(ArrayDesignSequenceUpdateEvent.class);
Map<Auditable, AuditEvent> sequenceAnalysisEvents = events.get(ArrayDesignSequenceAnalysisEvent.class);
Map<Auditable, AuditEvent> repeatAnalysisEvents = events.get(ArrayDesignRepeatAnalysisEvent.class);
for (ArrayDesignValueObject adVo : adVos) {
Long id = adVo.getId();
ArrayDesign ad = idMap.get(id);
if (geneMappingEvents.containsKey(ad)) {
AuditEvent event = geneMappingEvents.get(ad);
if (event != null) {
adVo.setLastGeneMapping(event.getDate());
}
}
if (sequenceUpdateEvents.containsKey(ad)) {
AuditEvent event = sequenceUpdateEvents.get(ad);
if (event != null) {
adVo.setLastSequenceUpdate(event.getDate());
}
}
if (sequenceAnalysisEvents.containsKey(ad)) {
AuditEvent event = sequenceAnalysisEvents.get(ad);
if (event != null) {
adVo.setLastSequenceAnalysis(event.getDate());
}
}
if (repeatAnalysisEvents.containsKey(ad)) {
AuditEvent event = repeatAnalysisEvents.get(ad);
if (event != null) {
adVo.setLastRepeatMask(event.getDate());
}
}
}
watch.stop();
if (watch.getTime() > 1000)
ArrayDesignReportServiceImpl.log.info("Added event information in " + watch.getTime() + "ms");
}
Aggregations