Search in sources :

Example 1 with AuditLogEvent

use of org.akaza.openclinica.domain.datamap.AuditLogEvent in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method fetchODMAuditBean.

private AuditLogsBean fetchODMAuditBean(ArrayList<AuditLogEvent> auditLogEvents, AuditLogsBean auditLogsBean) {
    for (AuditLogEvent auditLogEvent : auditLogEvents) {
        AuditLogBean auditBean = new AuditLogBean();
        auditBean.setOid("AL_" + auditLogEvent.getAuditId());
        auditBean.setDatetimeStamp(auditLogEvent.getAuditDate());
        if (auditLogEvent.getEntityName() != null && auditLogEvent.getEntityName().equals(STATUS)) {
            /*
                 * if(auditLogEvent.getAuditTable().equals(EVENT_CRF)){
                 * auditBean.setNewValue(EventCRFStatus.getByCode(Integer.valueOf(auditLogEvent.getNewValue())).
                 * getDescription());
                 * auditBean.setOldValue(EventCRFStatus.getByCode(Integer.valueOf(auditLogEvent.getOldValue())).
                 * getDescription());
                 * }
                 * else
                 */
            if (auditLogEvent.getAuditTable().equals(STUDY_EVENT)) {
                auditBean.setNewValue(fetchStudyEventStatus(Integer.valueOf(auditLogEvent.getNewValue())));
                auditBean.setOldValue(fetchStudyEventStatus(Integer.valueOf(auditLogEvent.getOldValue())));
            } else if (auditLogEvent.getAuditTable().equals(SUBJECT_GROUP_MAP)) {
                auditBean.setNewValue(auditLogEvent.getNewValue());
                auditBean.setOldValue(auditLogEvent.getOldValue());
            } else {
                auditBean.setNewValue(Status.getByCode(Integer.valueOf(auditLogEvent.getNewValue())).getI18nDescription(getLocale()));
                auditBean.setOldValue(Status.getByCode(Integer.valueOf(auditLogEvent.getOldValue())).getI18nDescription(getLocale()));
            }
        } else {
            auditBean.setNewValue(auditLogEvent.getNewValue() == null ? "" : auditLogEvent.getNewValue());
            auditBean.setOldValue(auditLogEvent.getOldValue() == null ? "" : auditLogEvent.getOldValue());
        }
        auditBean.setReasonForChange(auditLogEvent.getReasonForChange() == null ? "" : auditLogEvent.getReasonForChange());
        String auditEventTypeName = auditLogEvent.getAuditLogEventType().getName();
        auditEventTypeName = auditEventTypeName.replace(' ', '_');
        auditEventTypeName = auditEventTypeName.substring(0, 1).toLowerCase() + auditEventTypeName.substring(1);
        auditLogEvent.getAuditLogEventType().setName(auditEventTypeName);
        auditBean.setType(auditLogEvent.getAuditLogEventType().getI18nName(locale));
        auditBean.setValueType(auditLogEvent.getEntityName() == null ? "" : auditLogEvent.getEntityName());
        if (auditLogEvent.getUserAccount() != null && auditLogEvent.getUserAccount().getUserId() != 0) {
            auditBean.setUserId("USR_" + auditLogEvent.getUserAccount().getUserId());
            auditBean.setUserName(auditLogEvent.getUserAccount().getUserName());
            auditBean.setName(auditLogEvent.getUserAccount().getFirstName() + " " + auditLogEvent.getUserAccount().getLastName());
        } else {
            auditBean.setUserId("");
            auditBean.setUserName("");
            auditBean.setName("");
        }
        auditLogsBean.getAuditLogs().add(auditBean);
    }
    return auditLogsBean;
}
Also used : AuditLogBean(org.akaza.openclinica.bean.odmbeans.AuditLogBean) AuditLogEvent(org.akaza.openclinica.domain.datamap.AuditLogEvent)

Example 2 with AuditLogEvent

use of org.akaza.openclinica.domain.datamap.AuditLogEvent in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method fetchAuditLogs.

private AuditLogsBean fetchAuditLogs(int entityID, String itemDataAuditTable, String entityValue, String anotherAuditLog) {
    AuditLogsBean auditLogsBean = new AuditLogsBean();
    if (isCollectAudits()) {
        AuditLogEvent auditLog = new AuditLogEvent();
        auditLog.setEntityId(new Integer(entityID));
        auditLog.setAuditTable(itemDataAuditTable);
        auditLogsBean.setEntityID(entityValue);
        ArrayList<AuditLogEvent> auditLogEvent = (getAuditEventDAO().findByParam(auditLog, anotherAuditLog));
        auditLogsBean = fetchODMAuditBean(auditLogEvent, auditLogsBean);
    }
    return auditLogsBean;
}
Also used : AuditLogEvent(org.akaza.openclinica.domain.datamap.AuditLogEvent) AuditLogsBean(org.akaza.openclinica.bean.odmbeans.AuditLogsBean)

Example 3 with AuditLogEvent

use of org.akaza.openclinica.domain.datamap.AuditLogEvent in project OpenClinica by OpenClinica.

the class EnketoUrlService method buildQueryElement.

public QueriesBean buildQueryElement(ItemData itemdata) {
    QueriesBean queryElement = new QueriesBean();
    List<QueryBean> queryBeans = new ArrayList<>();
    List<LogBean> logBeans = new ArrayList<LogBean>();
    List<DiscrepancyNote> dns = discrepancyNoteDao.findChildQueriesByItemData(itemdata.getItemDataId());
    int i = 0;
    for (DiscrepancyNote dn : dns) {
        i++;
        QueryBean query = new QueryBean();
        query.setId(String.valueOf(i));
        query.setAssigned_to(dn.getUserAccountByOwnerId().getUserName());
        query.setComment(escapedValue(dn.getDetailedNotes()));
        query.setStatus(dn.getResolutionStatus().getName().toLowerCase());
        DateTime dateTime = new DateTime(dn.getDateCreated());
        query.setDate_time(convertDateFormat(dateTime));
        query.setNotify(false);
        query.setUser(dn.getUserAccountByOwnerId().getUserName());
        query.setType(COMMENT);
        queryBeans.add(query);
    }
    AuditLogEvent auditLog = new AuditLogEvent();
    auditLog.setEntityId(new Integer(itemdata.getItemDataId()));
    auditLog.setAuditTable(ITEMDATA);
    ArrayList<AuditLogEvent> auditLogEvents = auditLogEventDao.findByParam(auditLog, null);
    for (AuditLogEvent audit : auditLogEvents) {
        LogBean logBean = new LogBean();
        String oldValue = audit.getOldValue() != null ? audit.getOldValue() : "";
        String newValue = audit.getNewValue() != null ? audit.getNewValue() : "";
        logBean.setMessage("Value Changed from \"" + escapedValue(oldValue) + "\" to \"" + escapedValue(newValue) + "\"");
        DateTime dateTime = new DateTime(audit.getAuditDate());
        logBean.setDate_time(convertDateFormat(dateTime));
        UserAccount uAccount = userAccountDao.findById(audit.getUserAccount().getUserId());
        logBean.setUser(uAccount.getUserName());
        logBean.setAssigned_to(uAccount.getUserName());
        logBean.setType(AUDIT);
        logBeans.add(logBean);
    }
    queryElement.setQueries(queryBeans);
    queryElement.setLogs(logBeans);
    if (queryElement.getQueries().size() != 0 || queryElement.getLogs().size() != 0)
        return queryElement;
    else
        return null;
}
Also used : ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) QueryBean(org.akaza.openclinica.core.form.xform.QueryBean) AuditLogEvent(org.akaza.openclinica.domain.datamap.AuditLogEvent) DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) QueriesBean(org.akaza.openclinica.core.form.xform.QueriesBean) LogBean(org.akaza.openclinica.core.form.xform.LogBean) UserAccount(org.akaza.openclinica.domain.user.UserAccount)

Aggregations

AuditLogEvent (org.akaza.openclinica.domain.datamap.AuditLogEvent)3 ArrayList (java.util.ArrayList)1 AuditLogBean (org.akaza.openclinica.bean.odmbeans.AuditLogBean)1 AuditLogsBean (org.akaza.openclinica.bean.odmbeans.AuditLogsBean)1 LogBean (org.akaza.openclinica.core.form.xform.LogBean)1 QueriesBean (org.akaza.openclinica.core.form.xform.QueriesBean)1 QueryBean (org.akaza.openclinica.core.form.xform.QueryBean)1 DiscrepancyNote (org.akaza.openclinica.domain.datamap.DiscrepancyNote)1 UserAccount (org.akaza.openclinica.domain.user.UserAccount)1 DateTime (org.joda.time.DateTime)1