Search in sources :

Example 1 with NoteExtendedAttribute

use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method populateIdentifierOnNoteAndExtension.

private void populateIdentifierOnNoteAndExtension(Note note) {
    Long nextNoteId = getSequenceAccessorService().getNextAvailableSequenceNumber(CUKFSConstants.NOTE_SEQUENCE_NAME);
    NoteExtendedAttribute extension = (NoteExtendedAttribute) note.getExtension();
    note.setNoteIdentifier(nextNoteId);
    extension.setNoteIdentifier(nextNoteId);
}
Also used : NoteExtendedAttribute(edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute)

Example 2 with NoteExtendedAttribute

use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderServiceImpl method copyNotesAndAttachmentsToPO.

// 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) {
                        // new Attachment();
                        Attachment newAttachment = SpringContext.getBean(AttachmentService.class).createAttachment((PersistableBusinessObject) copyingNote, originalAttachment.getAttachmentFileName(), originalAttachment.getAttachmentMimeTypeCode(), originalAttachment.getAttachmentFileSize().intValue(), originalAttachment.getAttachmentContents(), originalAttachment.getAttachmentTypeCode());
                        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;
}
Also used : NoteExtendedAttribute(edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute) Note(org.kuali.kfs.krad.bo.Note) ArrayList(java.util.ArrayList) List(java.util.List) Attachment(org.kuali.kfs.krad.bo.Attachment) DocumentService(org.kuali.kfs.krad.service.DocumentService) AttachmentService(org.kuali.kfs.krad.service.AttachmentService) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException)

Example 3 with NoteExtendedAttribute

use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.

the class CuRequisitionAction method insertBONote.

@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;
}
Also used : NoteExtendedAttribute(edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) Note(org.kuali.kfs.krad.bo.Note) ActionForward(org.apache.struts.action.ActionForward) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 4 with NoteExtendedAttribute

use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.

the class CuRequisitionDocument method prepareForSave.

/**
 * Overridden to also pre-populate note IDs on unsaved notes lacking attachments,
 * to avoid persistence problems with note extended attributes. This is necessary
 * because of the OJB behavior of trying to persist the 1-1 reference object
 * prior to the parent object, which can interfere with saving auto-generated
 * notes (like "copied from document" notes).
 *
 * @see org.kuali.kfs.module.purap.document.PurchasingDocumentBase#prepareForSave(org.kuali.kfs.krad.rules.rule.event.KualiDocumentEvent)
 */
@Override
public void prepareForSave(KualiDocumentEvent event) {
    super.prepareForSave(event);
    SequenceAccessorService sequenceAccessorService = SpringContext.getBean(SequenceAccessorService.class);
    for (Note note : getNotes()) {
        if (note.getNoteIdentifier() == null && ObjectUtils.isNull(note.getAttachment())) {
            // Pre-populate IDs on unsaved notes without attachments, as well as their extended attributes.
            Long newNoteId = sequenceAccessorService.getNextAvailableSequenceNumber(CUKFSConstants.NOTE_SEQUENCE_NAME);
            note.setNoteIdentifier(newNoteId);
            ((NoteExtendedAttribute) note.getExtension()).setNoteIdentifier(newNoteId);
        }
    }
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) NoteExtendedAttribute(edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute) Note(org.kuali.kfs.krad.bo.Note)

Example 5 with NoteExtendedAttribute

use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.

the class IWantDocumentServiceImpl method copyIWantDocAttachments.

/**
 * Copies all attachments from the I Want document to the accounting document
 *
 * NOTE: A true extCopyNoteIndicator value will cause the copied notes to also
 * include an extended attribute with copyNoteIndicator set to true.
 *
 * @param document
 * @param iWantDocument
 * @param copyConfidentialAttachments
 * @param extCopyNoteIndicator
 * @throws Exception
 */
private void copyIWantDocAttachments(AccountingDocument document, IWantDocument iWantDocument, boolean copyConfidentialAttachments, boolean extCopyNoteIndicator) throws Exception {
    purapService.saveDocumentNoValidation(document);
    if (iWantDocument.getNotes() != null && iWantDocument.getNotes().size() > 0) {
        for (Iterator iterator = iWantDocument.getNotes().iterator(); iterator.hasNext(); ) {
            Note note = (Note) iterator.next();
            try {
                Note copyingNote = documentService.createNoteFromDocument(document, note.getNoteText());
                purapService.saveDocumentNoValidation(document);
                copyingNote.setNotePostedTimestamp(note.getNotePostedTimestamp());
                copyingNote.setAuthorUniversalIdentifier(note.getAuthorUniversalIdentifier());
                copyingNote.setNoteTopicText(note.getNoteTopicText());
                Attachment originalAttachment = attachmentService.getAttachmentByNoteId(note.getNoteIdentifier());
                if (originalAttachment != null && (copyConfidentialAttachments || !ConfidentialAttachmentTypeCodes.CONFIDENTIAL_ATTACHMENT_TYPE.equals(originalAttachment.getAttachmentTypeCode()))) {
                    // new Attachment();
                    Attachment newAttachment = attachmentService.createAttachment((PersistableBusinessObject) copyingNote, originalAttachment.getAttachmentFileName(), originalAttachment.getAttachmentMimeTypeCode(), originalAttachment.getAttachmentFileSize().intValue(), originalAttachment.getAttachmentContents(), originalAttachment.getAttachmentTypeCode());
                    if (ObjectUtils.isNotNull(originalAttachment) && ObjectUtils.isNotNull(newAttachment)) {
                        copyingNote.addAttachment(newAttachment);
                    }
                    document.addNote(copyingNote);
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
    purapService.saveDocumentNoValidation(document);
    // If specified, auto-construct extended attributes on the document notes at this point. (Doing so before initial persistence can cause save problems.)
    if (extCopyNoteIndicator && CollectionUtils.isNotEmpty(document.getNotes())) {
        for (Note copiedNote : document.getNotes()) {
            NoteExtendedAttribute noteExtension = (NoteExtendedAttribute) copiedNote.getExtension();
            noteExtension.setNoteIdentifier(copiedNote.getNoteIdentifier());
            noteExtension.setCopyNoteIndicator(true);
        }
        purapService.saveDocumentNoValidation(document);
    }
}
Also used : NoteExtendedAttribute(edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute) Note(org.kuali.kfs.krad.bo.Note) Iterator(java.util.Iterator) Attachment(org.kuali.kfs.krad.bo.Attachment) MessagingException(javax.mail.MessagingException) InvalidAddressException(org.kuali.kfs.krad.exception.InvalidAddressException)

Aggregations

NoteExtendedAttribute (edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute)5 Note (org.kuali.kfs.krad.bo.Note)4 Attachment (org.kuali.kfs.krad.bo.Attachment)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 MessagingException (javax.mail.MessagingException)1 ActionForward (org.apache.struts.action.ActionForward)1 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)1 InvalidAddressException (org.kuali.kfs.krad.exception.InvalidAddressException)1 AttachmentService (org.kuali.kfs.krad.service.AttachmentService)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1 DocumentService (org.kuali.kfs.krad.service.DocumentService)1 SequenceAccessorService (org.kuali.kfs.krad.service.SequenceAccessorService)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1