use of org.akaza.openclinica.dao.admin.AuditDAO in project OpenClinica by OpenClinica.
the class ViewItemAuditLogServlet method processRequest.
public void processRequest() throws Exception {
AuditDAO adao = new AuditDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
String auditTable = fp.getString("auditTable");
if (auditTable.equalsIgnoreCase("studysub")) {
auditTable = "study_subject";
} else if (auditTable.equalsIgnoreCase("eventcrf")) {
auditTable = "event_crf";
} else if (auditTable.equalsIgnoreCase("studyevent")) {
auditTable = "study_event";
} else if (auditTable.equalsIgnoreCase("itemdata")) {
auditTable = "item_data";
}
int entityId = fp.getInt("entityId");
ArrayList itemAuditEvents = adao.findItemAuditEvents(entityId, auditTable);
request.setAttribute("itemAudits", itemAuditEvents);
forwardPage(Page.AUDIT_LOGS_ITEMS);
}
use of org.akaza.openclinica.dao.admin.AuditDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method setTotals.
/**
* To set the totals of each resolution status on the DisplayItemBean for each item.
* @param dib
* @param notes
* @param ecbId TODO
*/
private DisplayItemBean setTotals(DisplayItemBean dib, int itemDataId, ArrayList<DiscrepancyNoteBean> notes, int ecbId) {
long t = System.currentTimeMillis();
logMe("Method::::::setTotals" + t);
int resolutionStatus;
int totNew = 0, totRes = 0, totClosed = 0, totUpdated = 0, totNA = 0;
boolean hasOtherThread = false;
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(getDataSource());
ArrayList<DiscrepancyNoteBean> existingNotes = dndao.findExistingNotesForToolTip(itemDataId);
dib.setDiscrepancyNotes(existingNotes);
for (DiscrepancyNoteBean obj : dib.getDiscrepancyNotes()) {
DiscrepancyNoteBean note = obj;
if (note.getParentDnId() == 0) {
resolutionStatus = note.getResolutionStatusId();
//using totNew to show the total parent threads
totNew++;
/* if(resolutionStatus==ResolutionStatus.UPDATED.getId())totUpdated++;
else if(resolutionStatus==ResolutionStatus.RESOLVED.getId())totRes++;//Resolution proposed count
else if(resolutionStatus==ResolutionStatus.CLOSED.getId())totClosed++;
else if(resolutionStatus==ResolutionStatus.NOT_APPLICABLE.getId())totNA++;*/
// not needed any more
}
}
ArrayList parentNotes = dndao.findExistingNotesForItemData(itemDataId);
//Adding this to show the value of only parent threads on discrepancy notes tool tip
for (Object obj : parentNotes) {
DiscrepancyNoteBean note = (DiscrepancyNoteBean) obj;
if (note.getParentDnId() == 0) {
if (hasOtherThread) {
totNew++;
}
hasOtherThread = true;
}
}
logMe("time taken thus far, before audit log check" + (System.currentTimeMillis() - t));
long t1 = System.currentTimeMillis();
AuditDAO adao = new AuditDAO(getDataSource());
ArrayList itemAuditEvents = adao.checkItemAuditEventsExist(dib.getItem().getId(), "item_data", ecbId);
if (itemAuditEvents.size() > 0) {
AuditBean itemFirstAudit = (AuditBean) itemAuditEvents.get(0);
String firstRFC = itemFirstAudit.getReasonForChange();
String oldValue = itemFirstAudit.getOldValue();
if (firstRFC != null && "initial value".equalsIgnoreCase(firstRFC) && (oldValue == null || oldValue.isEmpty())) {
dib.getData().setAuditLog(false);
} else {
dib.getData().setAuditLog(true);
}
}
logMe("time taken thus far, after audit log check" + (System.currentTimeMillis() - t));
logMe("Only for audit check::" + (System.currentTimeMillis() - t1));
//totNew is used for parent thread count
dib.setTotNew(totNew);
dib.setTotRes(totRes);
dib.setTotUpdated(totUpdated);
dib.setTotClosed(totClosed);
dib.setTotNA(totNA);
logMe("returning back..time taken" + (System.currentTimeMillis() - t));
return dib;
}
use of org.akaza.openclinica.dao.admin.AuditDAO in project OpenClinica by OpenClinica.
the class ChangeCRFVersionController method changeCRFVersionAction.
@RequestMapping("/managestudy/changeCRFVersion")
public // @RequestMapping("/managestudy/changeCRFVersionAction")
ModelMap changeCRFVersionAction(HttpServletRequest request, HttpServletResponse response, @RequestParam("crfId") int crfId, @RequestParam("crfName") String crfName, @RequestParam("formLayoutId") int formLayoutId, @RequestParam("formLayoutName") String formLayoutName, @RequestParam("studySubjectLabel") String studySubjectLabel, @RequestParam("studySubjectId") int studySubjectId, @RequestParam("eventCRFId") int eventCRFId, @RequestParam("eventDefinitionCRFId") int eventDefinitionCRFId, @RequestParam(value = "newFormLayoutId", required = true) int newFormLayoutId) {
// to be removed for aquamarine
if (!mayProceed(request)) {
if (redirect(request, response, "/MainMenu?message=authentication_failed") == null)
return null;
}
ArrayList<String> pageMessages = initPageMessages(request);
setupResource(request);
// update event_crf_id table
try {
EventCRFDAO event_crf_dao = new EventCRFDAO(dataSource);
StudyEventDAO sedao = new StudyEventDAO(dataSource);
EventCRFBean ev_bean = (EventCRFBean) event_crf_dao.findByPK(eventCRFId);
StudyEventBean st_event_bean = (StudyEventBean) sedao.findByPK(ev_bean.getStudyEventId());
Connection con = dataSource.getConnection();
CoreResources.setSchema(con);
con.setAutoCommit(false);
event_crf_dao.updateFormLayoutID(eventCRFId, newFormLayoutId, getCurrentUser(request).getId(), con);
String status_before_update = null;
SubjectEventStatus eventStatus = null;
Status subjectStatus = null;
AuditDAO auditDao = new AuditDAO(dataSource);
// event signed, check if subject is signed as well
StudySubjectDAO studySubDao = new StudySubjectDAO(dataSource);
StudySubjectBean studySubBean = (StudySubjectBean) studySubDao.findByPK(st_event_bean.getStudySubjectId());
if (studySubBean.getStatus().isSigned()) {
status_before_update = auditDao.findLastStatus("study_subject", studySubBean.getId(), "8");
if (status_before_update != null && status_before_update.length() == 1) {
int subject_status = Integer.parseInt(status_before_update);
subjectStatus = Status.get(subject_status);
studySubBean.setStatus(subjectStatus);
}
studySubBean.setUpdater(getCurrentUser(request));
studySubDao.update(studySubBean, con);
}
st_event_bean.setUpdater(getCurrentUser(request));
st_event_bean.setUpdatedDate(new Date());
status_before_update = auditDao.findLastStatus("study_event", st_event_bean.getId(), "8");
if (status_before_update != null && status_before_update.length() == 1) {
int status = Integer.parseInt(status_before_update);
eventStatus = SubjectEventStatus.get(status);
st_event_bean.setSubjectEventStatus(eventStatus);
}
sedao.update(st_event_bean, con);
con.commit();
con.setAutoCommit(true);
con.close();
pageMessages.add(resword.getString("confirm_crf_version_ms"));
String msg = resword.getString("confirm_crf_version_ms");
redirect(request, response, "/ViewStudySubject?isFromCRFVersionChange=" + msg + "&id=" + studySubjectId);
} catch (Exception e) {
pageMessages.add(resword.getString("error_message_cannot_update_crf_version"));
}
return null;
}
Aggregations