Search in sources :

Example 1 with AuditLogsBean

use of org.akaza.openclinica.bean.odmbeans.AuditLogsBean 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 2 with AuditLogsBean

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

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

use of org.akaza.openclinica.bean.odmbeans.AuditLogsBean 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 5 with AuditLogsBean

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

Aggregations

AuditLogsBean (org.akaza.openclinica.bean.odmbeans.AuditLogsBean)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 AuditLogBean (org.akaza.openclinica.bean.odmbeans.AuditLogBean)4 ExportSubjectDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ExportFormDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportFormDataBean)1 ExportStudyEventDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportStudyEventDataBean)1 ImportItemDataBean (org.akaza.openclinica.bean.submit.crfdata.ImportItemDataBean)1 SubjectGroupDataBean (org.akaza.openclinica.bean.submit.crfdata.SubjectGroupDataBean)1 AuditLogEvent (org.akaza.openclinica.domain.datamap.AuditLogEvent)1 SubjectGroupMap (org.akaza.openclinica.domain.datamap.SubjectGroupMap)1