// 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