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);
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
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;
}
Aggregations