@Override public ActionForward insertBONote( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; Note newNote = kualiDocumentFormBase.getNewNote(); NoteExtendedAttribute extendedAttribute = (NoteExtendedAttribute) newNote.getExtension(); ActionForward forward = super.insertBONote(mapping, form, request, response); if (newNote != kualiDocumentFormBase.getNewNote()) { Note addedNote = kualiDocumentFormBase .getDocument() .getNotes() .get(kualiDocumentFormBase.getDocument().getNotes().size() - 1); extendedAttribute.setNoteIdentifier(addedNote.getNoteIdentifier()); addedNote.setExtension(extendedAttribute); SpringContext.getBean(BusinessObjectService.class).save(extendedAttribute); addedNote.refreshReferenceObject("extension"); } return forward; }
// mjmc // ************************************************************************************************* private PurchaseOrderDocument copyNotesAndAttachmentsToPO( RequisitionDocument reqDoc, PurchaseOrderDocument poDoc) { purapService.saveDocumentNoValidation(poDoc); List<Note> notes = (List<Note>) reqDoc.getNotes(); int noteLength = notes.size(); if (noteLength > 0) { for (Note note : notes) { try { Note copyingNote = SpringContext.getBean(DocumentService.class) .createNoteFromDocument(poDoc, note.getNoteText()); purapService.saveDocumentNoValidation(poDoc); copyingNote.setNotePostedTimestamp(note.getNotePostedTimestamp()); copyingNote.setAuthorUniversalIdentifier(note.getAuthorUniversalIdentifier()); copyingNote.setNoteTopicText(note.getNoteTopicText()); Attachment originalAttachment = SpringContext.getBean(AttachmentService.class) .getAttachmentByNoteId(note.getNoteIdentifier()); NoteExtendedAttribute noteExtendedAttribute = (NoteExtendedAttribute) note.getExtension(); if (originalAttachment != null || (ObjectUtils.isNotNull(noteExtendedAttribute) && noteExtendedAttribute.isCopyNoteIndicator())) { if (originalAttachment != null) { Attachment newAttachment = SpringContext.getBean(AttachmentService.class) .createAttachment( (PersistableBusinessObject) copyingNote, originalAttachment.getAttachmentFileName(), originalAttachment.getAttachmentMimeTypeCode(), originalAttachment.getAttachmentFileSize().intValue(), originalAttachment.getAttachmentContents(), originalAttachment.getAttachmentTypeCode()); // new Attachment(); if (ObjectUtils.isNotNull(originalAttachment) && ObjectUtils.isNotNull(newAttachment)) { copyingNote.addAttachment(newAttachment); } } poDoc.addNote(copyingNote); } } catch (Exception e) { throw new RuntimeException(e); } } } purapService.saveDocumentNoValidation(poDoc); return poDoc; } // mjmc end