Search in sources :

Example 1 with LogBean

use of org.akaza.openclinica.core.form.xform.LogBean 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

ArrayList (java.util.ArrayList)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 AuditLogEvent (org.akaza.openclinica.domain.datamap.AuditLogEvent)1 DiscrepancyNote (org.akaza.openclinica.domain.datamap.DiscrepancyNote)1 UserAccount (org.akaza.openclinica.domain.user.UserAccount)1 DateTime (org.joda.time.DateTime)1