@Override protected void processRequest() throws Exception { FormProcessor fp = new FormProcessor(request); DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource()); int noteId = fp.getInt(NOTE_ID, true); DiscrepancyNoteBean note = (DiscrepancyNoteBean) dndao.findByPK(noteId); String entityType = note.getEntityType(); UserAccountDAO udao = new UserAccountDAO(sm.getDataSource()); ArrayList notes = dndao.findAllEntityByPK(note.getEntityType(), noteId); Date lastUpdatedDate = note.getCreatedDate(); UserAccountBean lastUpdator = (UserAccountBean) udao.findByPK(note.getOwnerId()); for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n = (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if (pId == 0) { note = n; note.setLastUpdator((UserAccountBean) udao.findByPK(n.getOwnerId())); note.setLastDateUpdated(n.getCreatedDate()); lastUpdatedDate = note.getLastDateUpdated(); lastUpdator = note.getLastUpdator(); } } for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n = (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if (pId > 0) { note.getChildren().add(n); if (!n.getCreatedDate().before(lastUpdatedDate)) { lastUpdatedDate = n.getCreatedDate(); lastUpdator = (UserAccountBean) udao.findByPK(n.getOwnerId()); note.setLastUpdator(lastUpdator); note.setLastDateUpdated(lastUpdatedDate); note.setResolutionStatusId(n.getResolutionStatusId()); note.setResStatus(ResolutionStatus.get(n.getResolutionStatusId())); } } } note.setNumChildren(note.getChildren().size()); note.setDisType(DiscrepancyNoteType.get(note.getDiscrepancyNoteTypeId())); logger.info("Just set Note: " + note.getCrfName() + " column " + note.getColumn()); request.setAttribute(DIS_NOTE, note); forwardPage(Page.VIEW_SINGLE_NOTE); }
/** Creates a new discrepancy note map */ public void createMapping(DiscrepancyNoteBean eb) { HashMap variables = new HashMap(); variables.put(new Integer(1), new Integer(eb.getEntityId())); variables.put(new Integer(2), new Integer(eb.getId())); variables.put(new Integer(3), eb.getColumn()); String entityType = eb.getEntityType(); if ("subject".equalsIgnoreCase(entityType)) { this.execute(digester.getQuery("createSubjectMap"), variables); } else if ("studySub".equalsIgnoreCase(entityType)) { this.execute(digester.getQuery("createStudySubjectMap"), variables); } else if ("eventCrf".equalsIgnoreCase(entityType)) { this.execute(digester.getQuery("createEventCRFMap"), variables); } else if ("studyEvent".equalsIgnoreCase(entityType)) { this.execute(digester.getQuery("createStudyEventMap"), variables); } else if ("itemData".equalsIgnoreCase(entityType)) { this.execute(digester.getQuery("createItemDataMap"), variables); } }