Search in sources :

Example 11 with AuditEvent

use of ubic.gemma.model.common.auditAndSecurity.AuditEvent in project Gemma by PavlidisLab.

the class ExpressionExperimentDetailsValueObject method auditEvents2SampleRemovedFlags.

public void auditEvents2SampleRemovedFlags(Collection<AuditEvent> s) {
    Collection<AuditEventValueObject> converted = new HashSet<>();
    for (AuditEvent ae : s) {
        converted.add(new AuditEventValueObject(ae));
    }
    this.sampleRemovedFlags = converted;
}
Also used : AuditEventValueObject(ubic.gemma.model.common.auditAndSecurity.AuditEventValueObject) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent) HashSet(java.util.HashSet)

Example 12 with AuditEvent

use of ubic.gemma.model.common.auditAndSecurity.AuditEvent in project Gemma by PavlidisLab.

the class ArrayDesignReportServiceImpl method getLastEvent.

private String getLastEvent(Long id, Class<? extends AuditEventType> eventType) {
    ArrayDesign ad = arrayDesignService.load(id);
    if (ad == null)
        return "";
    List<AuditEvent> events2 = auditEventService.getEvents(ad);
    String analysisEventString;
    List<AuditEvent> events = new ArrayList<>();
    for (AuditEvent event : events2) {
        if (event == null)
            // legacy of ordered-list which could end up with gaps; should not be needed
            continue;
        // any more
        if (event.getEventType() != null && eventType.isAssignableFrom(event.getEventType().getClass())) {
            events.add(event);
        }
    }
    if (events.size() == 0) {
        return "[None]";
    }
    // add the most recent events to the report. There should always be at least one creation event.
    AuditEvent lastEvent = events.get(events.size() - 1);
    analysisEventString = DateFormatUtils.format(lastEvent.getDate(), "yyyy.MMM.dd hh:mm aa");
    return analysisEventString;
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent)

Example 13 with AuditEvent

use of ubic.gemma.model.common.auditAndSecurity.AuditEvent 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");
}
Also used : Auditable(ubic.gemma.model.common.Auditable) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) StopWatch(org.apache.commons.lang3.time.StopWatch) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent)

Example 14 with AuditEvent

use of ubic.gemma.model.common.auditAndSecurity.AuditEvent in project Gemma by PavlidisLab.

the class BatchInfoPopulationServiceImpl method needToRun.

/**
 * @param ee ee
 * @return true if it needs processing
 */
private boolean needToRun(ExpressionExperiment ee) {
    ExpressionExperimentValueObject eevo = expressionExperimentService.loadValueObject(ee);
    assert eevo != null;
    if (StringUtils.isBlank(eevo.getAccession())) {
        BatchInfoPopulationServiceImpl.log.info(ee + " lacks an external accession to use for fetching, will not attempt to fetch raw data files.");
        return false;
    }
    if (eevo.getTechnologyType().equals("NONE")) {
        BatchInfoPopulationServiceImpl.log.info(ee + " has technology type 'NONE', will not attempt to fetch raw data files");
        return false;
    }
    AuditEvent e = auditEventService.getLastEvent(ee, BatchInformationFetchingEvent.class);
    if (e == null)
        return true;
    if (FailedBatchInformationFetchingEvent.class.isAssignableFrom(e.getClass()))
        // worth trying
        return true;
    // on occasions the files appear or were missed the first time ...? GSE20842
    if (FailedBatchInformationMissingEvent.class.isAssignableFrom(e.getClass())) {
        RawDataFetcher fetcher = new RawDataFetcher();
        return fetcher.checkForFile(ee.getAccession().getAccession());
    }
    // already did it.
    return false;
}
Also used : ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent) RawDataFetcher(ubic.gemma.core.loader.expression.geo.fetcher.RawDataFetcher)

Example 15 with AuditEvent

use of ubic.gemma.model.common.auditAndSecurity.AuditEvent in project Gemma by PavlidisLab.

the class ArrayDesignSequenceManipulatingCli method needToRun.

/**
 * @param eventClass e.g., ArrayDesignSequenceAnalysisEvent.class
 * @return true if skipIfLastRunLaterThan is null, or there is no record of a previous analysis, or if the last
 * analysis was run before skipIfLastRunLaterThan. false otherwise.
 */
boolean needToRun(Date skipIfLastRunLaterThan, ArrayDesign arrayDesign, Class<? extends ArrayDesignAnalysisEvent> eventClass) {
    if (skipIfLastRunLaterThan == null)
        return true;
    if (!autoSeek)
        return true;
    ArrayDesign subsumingArrayDesign = arrayDesign.getSubsumingArrayDesign();
    if (subsumingArrayDesign != null) {
        boolean needToRunSubsumer = this.needToRun(skipIfLastRunLaterThan, subsumingArrayDesign, eventClass);
        if (!needToRunSubsumer) {
            AbstractCLI.log.info("Subsumer  " + subsumingArrayDesign + " was run more recently than " + skipIfLastRunLaterThan);
            return false;
        }
    }
    if (autoSeek) {
        return this.needToAutoRun(arrayDesign, eventClass);
    }
    List<AuditEvent> events = this.getEvents(arrayDesign, eventClass);
    if (events.size() == 0) {
        // always do it, it's never been done.
        return true;
    }
    // return true if the last time was older than the limit time.
    AuditEvent lastEvent = events.get(events.size() - 1);
    return lastEvent.getDate().before(skipIfLastRunLaterThan);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent)

Aggregations

AuditEvent (ubic.gemma.model.common.auditAndSecurity.AuditEvent)34 Auditable (ubic.gemma.model.common.Auditable)9 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)7 AuditEventValueObject (ubic.gemma.model.common.auditAndSecurity.AuditEventValueObject)6 StopWatch (org.apache.commons.lang3.time.StopWatch)5 AuditTrail (ubic.gemma.model.common.auditAndSecurity.AuditTrail)5 ArrayDesignValueObject (ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)5 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)5 Date (java.util.Date)4 Test (org.junit.Test)4 Query (org.hibernate.Query)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 AuditEventType (ubic.gemma.model.common.auditAndSecurity.eventType.AuditEventType)3 HashSet (java.util.HashSet)2 Predicate (org.apache.commons.collections.Predicate)2 Transactional (org.springframework.transaction.annotation.Transactional)2 AbstractAuditable (ubic.gemma.model.common.AbstractAuditable)2 Curatable (ubic.gemma.model.common.auditAndSecurity.curation.Curatable)2 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)2 UserDetailsImpl (gemma.gsec.authentication.UserDetailsImpl)1