Search in sources :

Example 21 with AuditEvent

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

the class ExpressionExperimentDaoImpl method getArrayDesignAuditEvents.

@Override
@Deprecated
public Map<Long, Map<Long, Collection<AuditEvent>>> getArrayDesignAuditEvents(Collection<Long> ids) {
    // language=HQL
    final String queryString = "select ee.id, ad.id, event " + "from ExpressionExperiment ee " + "inner join ee.bioAssays b " + "inner join b.arrayDesignUsed ad " + "inner join ad.auditTrail trail " + "inner join trail.events event " + "where ee.id in (:ids) ";
    List result = this.getSessionFactory().getCurrentSession().createQuery(queryString).setParameterList("ids", ids).list();
    Map<Long, Map<Long, Collection<AuditEvent>>> eventMap = new HashMap<>();
    // process list of expression experiment ids that have events
    for (Object o : result) {
        Object[] row = (Object[]) o;
        Long eeId = (Long) row[0];
        Long adId = (Long) row[1];
        AuditEvent event = (AuditEvent) row[2];
        Map<Long, Collection<AuditEvent>> adEventMap = eventMap.get(eeId);
        if (adEventMap == null) {
            adEventMap = new HashMap<>();
            eventMap.put(eeId, adEventMap);
        }
        Collection<AuditEvent> events = adEventMap.get(adId);
        if (events == null) {
            events = new ArrayList<>();
            adEventMap.put(adId, events);
        }
        events.add(event);
    }
    return eventMap;
}
Also used : AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)

Example 22 with AuditEvent

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

the class ExpressionExperimentDaoImpl method getAuditEvents.

@Override
public Map<Long, Collection<AuditEvent>> getAuditEvents(Collection<Long> ids) {
    // language=HQL
    final String queryString = "select ee.id, auditEvent from ExpressionExperiment ee inner join ee.auditTrail as auditTrail inner join auditTrail.events as auditEvent " + " where ee.id in (:ids) ";
    List result = this.getSessionFactory().getCurrentSession().createQuery(queryString).setParameterList("ids", ids).list();
    Map<Long, Collection<AuditEvent>> eventMap = new HashMap<>();
    for (Object o : result) {
        Object[] row = (Object[]) o;
        Long id = (Long) row[0];
        AuditEvent event = (AuditEvent) row[1];
        this.addEventsToMap(eventMap, id, event);
    }
    // their values to null.
    for (Object object : ids) {
        Long id = (Long) object;
        if (!eventMap.containsKey(id)) {
            eventMap.put(id, null);
        }
    }
    return eventMap;
}
Also used : ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent)

Example 23 with AuditEvent

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

the class ArrayDesignDaoImpl method getAuditEvents.

@Override
public Map<Long, Collection<AuditEvent>> getAuditEvents(Collection<Long> ids) {
    // language=HQL
    final String queryString = "select ad.id, auditEvent from ArrayDesign ad" + " join ad.auditTrail as auditTrail join auditTrail.events as auditEvent join fetch auditEvent.performer " + " where ad.id in (:ids) ";
    // noinspection unchecked
    List<Object[]> list = this.getSessionFactory().getCurrentSession().createQuery(queryString).setParameterList("ids", ids).list();
    Map<Long, Collection<AuditEvent>> eventMap = new HashMap<>();
    for (Object[] o : list) {
        Long id = (Long) o[0];
        AuditEvent event = (AuditEvent) o[1];
        this.addEventsToMap(eventMap, id, event);
    }
    // Set their values to null.
    for (Object object : ids) {
        Long id = (Long) object;
        if (!eventMap.containsKey(id)) {
            eventMap.put(id, null);
        }
    }
    return eventMap;
}
Also used : PersistentCollection(org.hibernate.collection.PersistentCollection) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent)

Example 24 with AuditEvent

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

the class ArrayDesignMergeHelperServiceImpl method audit.

/**
 * Add an ArrayDesignMergeEvent event to the audit trail. Does not persist it.
 *
 * @param arrayDesign array design
 * @param note        note
 */
private void audit(ArrayDesign arrayDesign, String note) {
    AuditEvent auditEvent = AuditEvent.Factory.newInstance(new Date(), AuditAction.UPDATE, note, null, null, new ArrayDesignMergeEvent());
    arrayDesign.getAuditTrail().addEvent(auditEvent);
}
Also used : ArrayDesignMergeEvent(ubic.gemma.model.common.auditAndSecurity.eventType.ArrayDesignMergeEvent) AuditEvent(ubic.gemma.model.common.auditAndSecurity.AuditEvent) Date(java.util.Date)

Example 25 with AuditEvent

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

the class GeoBrowserServiceImpl method formatArrayDetails.

private void formatArrayDetails(NodeList gpls, StringBuilder buf) {
    Set<String> seenGpl = new HashSet<>();
    for (int i = 0; i < gpls.getLength(); i++) {
        String gpl = "GPL" + gpls.item(i).getNodeValue();
        if (gpl.contains(";"))
            continue;
        if (seenGpl.contains(gpl))
            continue;
        seenGpl.add(gpl);
        ArrayDesign arrayDesign = arrayDesignService.findByShortName(gpl);
        if (arrayDesign != null) {
            arrayDesign = arrayDesignService.thawLite(arrayDesign);
            String trouble = "";
            if (arrayDesign.getCurationDetails().getTroubled()) {
                AuditEvent lastTroubleEvent = arrayDesign.getCurationDetails().getLastTroubledEvent();
                if (lastTroubleEvent != null) {
                    trouble = "&nbsp;<img src='" + Settings.getRootContext() + "/images/icons/warning.png' height='16' width='16' alt=\"troubled\" title=\"" + lastTroubleEvent.getNote() + "\"/>";
                }
            }
            buf.append("<p><strong>Platform in Gemma:&nbsp;<a target=\"_blank\" href=\"").append(Settings.getRootContext()).append("/arrays/showArrayDesign.html?id=").append(arrayDesign.getId()).append("\">").append(gpl).append("</a></strong>").append(trouble);
        } else {
            buf.append("<p><strong>").append(gpl).append(" [New to Gemma]</strong>");
        }
    }
}
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