Search in sources :

Example 1 with AuditLogBean

use of org.akaza.openclinica.bean.odmbeans.AuditLogBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setOCItemDataAuditLogs.

protected void setOCItemDataAuditLogs(StudyBean study, OdmClinicalDataBean data, String idataIds, HashMap<Integer, String> idataOidPoses) {
    this.setOCItemDataAuditsTypesExpected();
    logger.debug("Begin to execute GetOCItemDataAuditsSql");
    logger.debug("getOCItemDataAuditsSql= " + this.getOCItemDataAuditsSql(idataIds));
    ArrayList rows = select(this.getOCItemDataAuditsSql(idataIds));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        Integer idataId = (Integer) row.get("item_data_id");
        Integer auditId = (Integer) row.get("audit_id");
        String type = (String) row.get("name");
        Integer userId = (Integer) row.get("user_id");
        Date auditDate = (Date) row.get("audit_date");
        String auditReason = (String) row.get("reason_for_change");
        String oldValue = (String) row.get("old_value");
        String newValue = (String) row.get("new_value");
        Integer typeId = (Integer) row.get("audit_log_event_type_id");
        if (idataOidPoses.containsKey(idataId)) {
            String[] poses = idataOidPoses.get(idataId).split("---");
            ImportItemDataBean idata = data.getExportSubjectData().get(Integer.parseInt(poses[0])).getExportStudyEventData().get(Integer.parseInt(poses[1])).getExportFormData().get(Integer.parseInt(poses[2])).getItemGroupData().get(Integer.parseInt(poses[3])).getItemData().get(Integer.parseInt(poses[4]));
            AuditLogBean auditLog = new AuditLogBean();
            auditLog.setOid("AL_" + auditId);
            auditLog.setUserId("USR_" + userId);
            auditLog.setDatetimeStamp(auditDate);
            auditLog.setType(type);
            auditLog.setReasonForChange(auditReason);
            if (typeId == 12) {
                if ("0".equals(newValue)) {
                    auditLog.setOldValue(Status.INVALID.getName());
                } else {
                    auditLog.setNewValue(Status.getFromMap(Integer.parseInt(newValue)).getName());
                }
                if ("0".equals(oldValue)) {
                    auditLog.setOldValue(Status.INVALID.getName());
                } else {
                    auditLog.setOldValue(Status.getFromMap(Integer.parseInt(oldValue)).getName());
                }
            } else {
                auditLog.setNewValue(newValue);
                auditLog.setOldValue(oldValue);
            }
            AuditLogsBean logs = idata.getAuditLogs();
            if (logs.getEntityID() == null || logs.getEntityID().length() <= 0) {
                logs.setEntityID(idata.getItemOID());
            }
            logs.getAuditLogs().add(auditLog);
            idata.setAuditLogs(logs);
        }
    }
}
Also used : AuditLogBean(org.akaza.openclinica.bean.odmbeans.AuditLogBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) AuditLogsBean(org.akaza.openclinica.bean.odmbeans.AuditLogsBean) ImportItemDataBean(org.akaza.openclinica.bean.submit.crfdata.ImportItemDataBean) Date(java.util.Date)

Example 2 with AuditLogBean

use of org.akaza.openclinica.bean.odmbeans.AuditLogBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setOCEventDataAuditLogs.

protected void setOCEventDataAuditLogs(StudyBean study, OdmClinicalDataBean data, String studySubjectOids, HashMap<String, String> evnOidPoses) {
    this.setOCEventDataAuditsTypesExpected();
    logger.debug("Begin to execute GetOCEventDataAuditsSql");
    logger.debug("getOCEventDataAuditsSql= " + this.getOCEventDataAuditsSql(studySubjectOids));
    ArrayList rows = select(this.getOCEventDataAuditsSql(studySubjectOids));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        String studySubjectLabel = (String) row.get("study_subject_oid");
        String sedOid = (String) row.get("definition_oid");
        Integer auditId = (Integer) row.get("audit_id");
        String type = (String) row.get("name");
        Integer userId = (Integer) row.get("user_id");
        Date auditDate = (Date) row.get("audit_date");
        String auditReason = (String) row.get("reason_for_change");
        String oldValue = (String) row.get("old_value");
        String newValue = (String) row.get("new_value");
        Integer typeId = (Integer) row.get("audit_log_event_type_id");
        if (evnOidPoses.containsKey(studySubjectLabel + sedOid)) {
            String[] poses = evnOidPoses.get(studySubjectLabel + sedOid).split("---");
            ExportStudyEventDataBean se = data.getExportSubjectData().get(Integer.parseInt(poses[0])).getExportStudyEventData().get(Integer.parseInt(poses[1]));
            AuditLogBean auditLog = new AuditLogBean();
            auditLog.setOid("AL_" + auditId);
            auditLog.setUserId("USR_" + userId);
            auditLog.setDatetimeStamp(auditDate);
            auditLog.setType(type);
            auditLog.setReasonForChange(auditReason);
            if (typeId == 17 || typeId == 18 || typeId == 19 || typeId == 20 || typeId == 21 || typeId == 22 || typeId == 23 || typeId == 31) {
                if ("0".equals(newValue)) {
                    auditLog.setOldValue(SubjectEventStatus.INVALID.getName());
                } else {
                    auditLog.setNewValue(SubjectEventStatus.getFromMap(Integer.parseInt(newValue)).getName());
                }
                if ("0".equals(oldValue)) {
                    auditLog.setOldValue(SubjectEventStatus.INVALID.getName());
                } else {
                    auditLog.setOldValue(SubjectEventStatus.getFromMap(Integer.parseInt(oldValue)).getName());
                }
            } else {
                auditLog.setNewValue(newValue);
                auditLog.setOldValue(oldValue);
            }
            AuditLogsBean logs = se.getAuditLogs();
            if (logs.getEntityID() == null || logs.getEntityID().length() <= 0) {
                logs.setEntityID(se.getStudyEventOID());
            }
            logs.getAuditLogs().add(auditLog);
            se.setAuditLogs(logs);
        }
    }
}
Also used : AuditLogBean(org.akaza.openclinica.bean.odmbeans.AuditLogBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) AuditLogsBean(org.akaza.openclinica.bean.odmbeans.AuditLogsBean) Date(java.util.Date) ExportStudyEventDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportStudyEventDataBean)

Example 3 with AuditLogBean

use of org.akaza.openclinica.bean.odmbeans.AuditLogBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setOCFormDataAuditLogs.

protected void setOCFormDataAuditLogs(StudyBean study, OdmClinicalDataBean data, String studySubjectOids, String ecIds, HashMap<Integer, String> formOidPoses) {
    this.setOCFormDataAuditsTypesExpected();
    String dbName = CoreResources.getDBName();
    logger.debug("Begin to execute GetOCFormDataAuditsSql");
    logger.debug("getOCFormDataAuditsSql= " + this.getOCFormDataAuditsSql(studySubjectOids, ecIds));
    ArrayList rows = select(this.getOCFormDataAuditsSql(studySubjectOids, ecIds));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        Integer ecId = (Integer) row.get("event_crf_id");
        Integer auditId = (Integer) row.get("audit_id");
        String type = (String) row.get("name");
        Integer userId = (Integer) row.get("user_id");
        Date auditDate = (Date) row.get("audit_date");
        String auditReason = (String) row.get("reason_for_change");
        String oldValue = (String) row.get("old_value");
        String newValue = (String) row.get("new_value");
        Integer typeId = (Integer) row.get("audit_log_event_type_id");
        if (formOidPoses.containsKey(ecId)) {
            String[] poses = formOidPoses.get(ecId).split("---");
            ExportFormDataBean form = data.getExportSubjectData().get(Integer.parseInt(poses[0])).getExportStudyEventData().get(Integer.parseInt(poses[1])).getExportFormData().get(Integer.parseInt(poses[2]));
            AuditLogBean auditLog = new AuditLogBean();
            auditLog.setOid("AL_" + auditId);
            auditLog.setUserId("USR_" + userId);
            auditLog.setDatetimeStamp(auditDate);
            auditLog.setType(type);
            auditLog.setReasonForChange(auditReason);
            if (typeId == 8 || typeId == 10 || typeId == 11 || typeId == 14 || typeId == 15 || typeId == 16) {
                if ("0".equals(newValue)) {
                    auditLog.setNewValue(Status.INVALID.getName());
                } else {
                    auditLog.setNewValue(Status.getFromMap(Integer.parseInt(newValue)).getName());
                }
                if ("0".equals(oldValue)) {
                    auditLog.setOldValue(Status.INVALID.getName());
                } else {
                    auditLog.setOldValue(Status.getFromMap(Integer.parseInt(oldValue)).getName());
                }
            } else if ((typeId == 32) && ("oracle".equalsIgnoreCase(dbName))) {
                if ("1".equals(newValue)) {
                    auditLog.setNewValue("TRUE");
                } else {
                    auditLog.setNewValue("FALSE");
                }
                if ("1".equals(oldValue)) {
                    auditLog.setOldValue("TRUE");
                } else {
                    auditLog.setOldValue("FALSE");
                }
            } else {
                auditLog.setNewValue(newValue);
                auditLog.setOldValue(oldValue);
            }
            AuditLogsBean logs = form.getAuditLogs();
            if (logs.getEntityID() == null || logs.getEntityID().length() <= 0) {
                logs.setEntityID(form.getFormOID());
            }
            logs.getAuditLogs().add(auditLog);
            form.setAuditLogs(logs);
        }
    }
}
Also used : ExportFormDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportFormDataBean) AuditLogBean(org.akaza.openclinica.bean.odmbeans.AuditLogBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) AuditLogsBean(org.akaza.openclinica.bean.odmbeans.AuditLogsBean) Date(java.util.Date)

Example 4 with AuditLogBean

use of org.akaza.openclinica.bean.odmbeans.AuditLogBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setOCSubjectDataAuditLogs.

protected void setOCSubjectDataAuditLogs(StudyBean study, OdmClinicalDataBean data, String studySubjectOids, HashMap<String, String> subOidPoses) {
    this.setOCSubjectDataAuditsTypesExpected();
    logger.debug("Begin to execute GetOCSubjectDataAuditsSql");
    logger.debug("getOCSubjectDataAuditsSql= " + this.getOCSubjectDataAuditsSql(studySubjectOids));
    ArrayList rows = select(this.getOCSubjectDataAuditsSql(studySubjectOids));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        String studySubjectLabel = (String) row.get("study_subject_oid");
        Integer auditId = (Integer) row.get("audit_id");
        String type = (String) row.get("name");
        Integer userId = (Integer) row.get("user_id");
        Date auditDate = (Date) row.get("audit_date");
        String auditReason = (String) row.get("reason_for_change");
        String oldValue = (String) row.get("old_value");
        String newValue = (String) row.get("new_value");
        Integer typeId = (Integer) row.get("audit_log_event_type_id");
        if (subOidPoses.containsKey(studySubjectLabel)) {
            ExportSubjectDataBean sub = data.getExportSubjectData().get(Integer.parseInt(subOidPoses.get(studySubjectLabel)));
            AuditLogBean auditLog = new AuditLogBean();
            auditLog.setOid("AL_" + auditId);
            auditLog.setUserId("USR_" + userId);
            logger.debug("datatime=" + auditDate + " or " + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(auditDate));
            auditLog.setDatetimeStamp(auditDate);
            auditLog.setType(type);
            auditLog.setReasonForChange(auditReason);
            if (typeId == 3 || typeId == 6) {
                if ("0".equals(newValue)) {
                    auditLog.setOldValue(Status.INVALID.getName());
                } else {
                    auditLog.setNewValue(Status.getFromMap(Integer.parseInt(newValue)).getName());
                }
                if ("0".equals(oldValue)) {
                    auditLog.setOldValue(Status.INVALID.getName());
                } else {
                    auditLog.setOldValue(Status.getFromMap(Integer.parseInt(oldValue)).getName());
                }
            } else {
                auditLog.setNewValue(newValue);
                auditLog.setOldValue(oldValue);
            }
            AuditLogsBean logs = sub.getAuditLogs();
            if (logs.getEntityID() == null || logs.getEntityID().length() <= 0) {
                logs.setEntityID(sub.getSubjectOID());
            }
            logs.getAuditLogs().add(auditLog);
            sub.setAuditLogs(logs);
        }
    }
}
Also used : AuditLogBean(org.akaza.openclinica.bean.odmbeans.AuditLogBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) AuditLogsBean(org.akaza.openclinica.bean.odmbeans.AuditLogsBean) ExportSubjectDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 5 with AuditLogBean

use of org.akaza.openclinica.bean.odmbeans.AuditLogBean 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)

Aggregations

AuditLogBean (org.akaza.openclinica.bean.odmbeans.AuditLogBean)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 LinkedHashMap (java.util.LinkedHashMap)4 AuditLogsBean (org.akaza.openclinica.bean.odmbeans.AuditLogsBean)4 SimpleDateFormat (java.text.SimpleDateFormat)1 ExportFormDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportFormDataBean)1 ExportStudyEventDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportStudyEventDataBean)1 ExportSubjectDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean)1 ImportItemDataBean (org.akaza.openclinica.bean.submit.crfdata.ImportItemDataBean)1 AuditLogEvent (org.akaza.openclinica.domain.datamap.AuditLogEvent)1