/** getEntityFromHashMap, the method that gets the object from the database query. */ public Object getEntityFromHashMap(HashMap hm) { DiscrepancyNoteBean eb = new DiscrepancyNoteBean(); Date dateCreated = (Date) hm.get("date_created"); Integer ownerId = (Integer) hm.get("owner_id"); eb.setCreatedDate(dateCreated); eb.setOwnerId(ownerId.intValue()); // discrepancy_note_id serial NOT NULL, // description varchar(255), // discrepancy_note_type_id numeric, // resolution_status_id numeric, // detailed_notes varchar(1000), // date_created date, // owner_id numeric, // parent_dn_id numeric, eb.setId(selectInt(hm, "discrepancy_note_id")); eb.setDescription((String) hm.get("description")); eb.setDiscrepancyNoteTypeId(((Integer) hm.get("discrepancy_note_type_id")).intValue()); eb.setResolutionStatusId(((Integer) hm.get("resolution_status_id")).intValue()); eb.setParentDnId(((Integer) hm.get("parent_dn_id")).intValue()); eb.setDetailedNotes((String) hm.get("detailed_notes")); eb.setEntityType((String) hm.get("entity_type")); eb.setDisType(DiscrepancyNoteType.get(eb.getDiscrepancyNoteTypeId())); eb.setResStatus(ResolutionStatus.get(eb.getResolutionStatusId())); eb.setStudyId(selectInt(hm, "study_id")); return eb; }
public static DiscrepancyNoteBean createDiscrepancyNote( ItemBean itemBean, String message, EventCRFBean eventCrfBean, DisplayItemBean displayItemBean, Integer parentId, UserAccountBean uab, DataSource ds, StudyBean study) { // DisplayItemBean displayItemBean) { DiscrepancyNoteBean note = new DiscrepancyNoteBean(); StudySubjectDAO ssdao = new StudySubjectDAO(ds); note.setDescription(message); note.setDetailedNotes("Failed Validation Check"); note.setOwner(uab); note.setCreatedDate(new Date()); note.setResolutionStatusId(ResolutionStatus.OPEN.getId()); note.setDiscrepancyNoteTypeId(DiscrepancyNoteType.FAILEDVAL.getId()); if (parentId != null) { note.setParentDnId(parentId); } note.setField(itemBean.getName()); note.setStudyId(study.getId()); note.setEntityName(itemBean.getName()); note.setEntityType("ItemData"); note.setEntityValue(displayItemBean.getData().getValue()); note.setEventName(eventCrfBean.getName()); note.setEventStart(eventCrfBean.getCreatedDate()); note.setCrfName(displayItemBean.getEventDefinitionCRF().getCrfName()); StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(eventCrfBean.getStudySubjectId()); note.setSubjectName(ss.getName()); note.setEntityId(displayItemBean.getData().getId()); note.setColumn("value"); DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(ds); note = (DiscrepancyNoteBean) dndao.create(note); // so that the below method works, need to set the entity above // System.out.println("trying to create mapping with " + note.getId() + " " + note.getEntityId() // + " " + note.getColumn() + " " + note.getEntityType()); dndao.createMapping(note); // System.out.println("just created mapping"); return note; }