Search in sources :

Example 1 with AuditEventService

use of com.infiniteautomation.mango.spring.service.AuditEventService in project ma-core-public by infiniteautomation.

the class PublisherAuditTest method getAuditEvents.

protected List<AuditEventInstanceVO> getAuditEvents(String typeName, int objectId) {
    Audit auditTable = Audit.AUDIT;
    Condition conditions = DSL.and(auditTable.typeName.eq(typeName), auditTable.objectId.eq(objectId));
    ConditionSortLimit c = new ConditionSortLimit(conditions, Collections.singletonList(auditTable.id.asc()), null, null);
    List<AuditEventInstanceVO> events = new ArrayList<>();
    AuditEventService service = Common.getBean(AuditEventService.class);
    // Since these are raised in the background processing thread they may have not yet fired
    int retries = 4;
    while (retries > 0) {
        events.clear();
        service.customizedQuery(c, events::add);
        if (events.size() == 3) {
            break;
        }
        retries--;
        try {
            Thread.sleep(500);
        } catch (InterruptedException ignored) {
        }
    }
    return events;
}
Also used : Condition(org.jooq.Condition) Audit(com.infiniteautomation.mango.db.tables.Audit) ArrayList(java.util.ArrayList) ConditionSortLimit(com.infiniteautomation.mango.db.query.ConditionSortLimit) IDataPoint(com.serotonin.m2m2.vo.IDataPoint) AuditEventInstanceVO(com.serotonin.m2m2.vo.event.audit.AuditEventInstanceVO) AuditEventService(com.infiniteautomation.mango.spring.service.AuditEventService)

Aggregations

ConditionSortLimit (com.infiniteautomation.mango.db.query.ConditionSortLimit)1 Audit (com.infiniteautomation.mango.db.tables.Audit)1 AuditEventService (com.infiniteautomation.mango.spring.service.AuditEventService)1 IDataPoint (com.serotonin.m2m2.vo.IDataPoint)1 AuditEventInstanceVO (com.serotonin.m2m2.vo.event.audit.AuditEventInstanceVO)1 ArrayList (java.util.ArrayList)1 Condition (org.jooq.Condition)1