Search in sources :

Example 16 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class CuPaymentRequestServiceImpl method addHoldOnPaymentRequest.

@Override
@NonTransactional
public PaymentRequestDocument addHoldOnPaymentRequest(PaymentRequestDocument document, String note) throws Exception {
    // save the note
    Note noteObj = documentService.createNoteFromDocument(document, note);
    document.addNote(noteObj);
    noteService.save(noteObj);
    document.setHoldIndicator(true);
    document.setLastActionPerformedByPersonId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    purapService.saveDocumentNoValidation(document);
    // force reindexing
    reIndexDocument(document);
    return document;
}
Also used : Note(org.kuali.kfs.krad.bo.Note) NonTransactional(org.kuali.kfs.sys.service.NonTransactional)

Example 17 with Note

use of org.kuali.kfs.krad.bo.Note 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 18 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class CuReceivingServiceImpl method spawnPoAmendmentForUnorderedItems.

protected void spawnPoAmendmentForUnorderedItems(ReceivingDocument receivingDocument, PurchaseOrderDocument po) {
    // if receiving line document
    if (receivingDocument instanceof LineItemReceivingDocument) {
        LineItemReceivingDocument rlDoc = (LineItemReceivingDocument) receivingDocument;
        // if a new item has been added spawn a purchase order amendment
        if (hasNewUnorderedItem((LineItemReceivingDocument) receivingDocument)) {
            String newSessionUserId = KFSConstants.SYSTEM_USER;
            try {
                LogicContainer logicToRun = new LogicContainer() {

                    @Override
                    public Object runLogic(Object[] objects) throws Exception {
                        LineItemReceivingDocument rlDoc = (LineItemReceivingDocument) objects[0];
                        String poDocNumber = (String) objects[1];
                        // create a PO amendment
                        PurchaseOrderAmendmentDocument amendmentPo = (PurchaseOrderAmendmentDocument) purchaseOrderService.createAndSavePotentialChangeDocument(poDocNumber, PurchaseOrderDocTypes.PURCHASE_ORDER_AMENDMENT_DOCUMENT, PurchaseOrderStatuses.APPDOC_AMENDMENT);
                        // KFSPTS-1769, KFSUPGRADE-339
                        ((CuPurchaseOrderAmendmentDocument) amendmentPo).setSpawnPoa(true);
                        // add new lines to amendement
                        addUnorderedItemsToAmendment(amendmentPo, rlDoc);
                        // route amendment
                        documentService.routeDocument(amendmentPo, null, null);
                        // add note to amendment po document
                        String note = "Purchase Order Amendment " + amendmentPo.getPurapDocumentIdentifier() + " (document id " + amendmentPo.getDocumentNumber() + ") created for new unordered line items due to Receiving (document id " + rlDoc.getDocumentNumber() + ")";
                        Note noteObj = documentService.createNoteFromDocument(amendmentPo, note);
                        amendmentPo.addNote(noteObj);
                        noteService.save(noteObj);
                        return null;
                    }
                };
                purapService.performLogicWithFakedUserSession(newSessionUserId, logicToRun, new Object[] { rlDoc, po.getDocumentNumber() });
            } catch (WorkflowException e) {
                String errorMsg = "Workflow Exception caught: " + e.getLocalizedMessage();
                throw new RuntimeException(errorMsg, e);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
Also used : PurchaseOrderAmendmentDocument(org.kuali.kfs.module.purap.document.PurchaseOrderAmendmentDocument) CuPurchaseOrderAmendmentDocument(edu.cornell.kfs.module.purap.document.CuPurchaseOrderAmendmentDocument) CuPurchaseOrderAmendmentDocument(edu.cornell.kfs.module.purap.document.CuPurchaseOrderAmendmentDocument) LineItemReceivingDocument(org.kuali.kfs.module.purap.document.LineItemReceivingDocument) Note(org.kuali.kfs.krad.bo.Note) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) LogicContainer(org.kuali.kfs.module.purap.document.service.LogicContainer) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException)

Example 19 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderAction method cancel.

// ==== End CU Customization ====
public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    Object question = request.getParameter(KFSConstants.QUESTION_INST_ATTRIBUTE_NAME);
    ActionForward forward = super.cancel(mapping, form, request, response);
    if (question == null) {
        return forward;
    } else {
        Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
        if ((KFSConstants.DOCUMENT_CANCEL_QUESTION.equals(question)) && ConfirmationQuestion.NO.equals(buttonClicked)) {
            // if no button clicked just reload the doc
            return forward;
        }
    // else go to cancel logic below
    }
    // TODO : need to check note length ?
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
    String reason = request.getParameter(KFSConstants.QUESTION_REASON_ATTRIBUTE_NAME);
    if (StringUtils.isNotBlank(reason)) {
        String noteText = "Reason for cancelling PO : " + reason;
        Note newNote = new Note();
        newNote.setNoteText(noteText);
        newNote.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
        kualiDocumentFormBase.setNewNote(newNote);
        try {
            insertBONote(mapping, kualiDocumentFormBase, request, response);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    return forward;
}
Also used : KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) Note(org.kuali.kfs.krad.bo.Note) ActionForward(org.apache.struts.action.ActionForward) AuthorizationException(org.kuali.kfs.krad.exception.AuthorizationException)

Example 20 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderForm method populate.

/**
 * @see org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase#populate(javax.servlet.http.HttpServletRequest)
 */
@Override
public void populate(HttpServletRequest request) {
    PurchaseOrderDocument po = (PurchaseOrderDocument) this.getDocument();
    super.populate(request);
    /*
		 * KFSPTS-794 : for PO & POA.  The notes will be refreshed from DB.  hence, the 'sendtovendor' flag will
		 * be lost. This is to save the notes from from document, and the restore it before doing comparison later in action.
		 */
    if (ObjectUtils.isNotNull(po.getPurapDocumentIdentifier())) {
        if (CollectionUtils.isNotEmpty(po.getNotes())) {
            for (Note note : (List<Note>) po.getNotes()) {
                copiedNotes.add((Note) ObjectUtils.deepCopy(note));
            // po.refreshDocumentBusinessObject();
            }
            for (Note note : (List<Note>) po.getNotes()) {
                note.refreshReferenceObject("attachment");
            }
        }
    }
}
Also used : Note(org.kuali.kfs.krad.bo.Note) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Note (org.kuali.kfs.krad.bo.Note)76 Attachment (org.kuali.kfs.krad.bo.Attachment)14 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)12 IOException (java.io.IOException)9 FileNotFoundException (java.io.FileNotFoundException)7 ArrayList (java.util.ArrayList)7 NoteService (org.kuali.kfs.krad.service.NoteService)7 FileInputStream (java.io.FileInputStream)6 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)6 NonTransactional (org.kuali.kfs.sys.service.NonTransactional)6 File (java.io.File)5 Iterator (java.util.Iterator)5 DocumentService (org.kuali.kfs.krad.service.DocumentService)5 Person (org.kuali.rice.kim.api.identity.Person)5 NoteExtendedAttribute (edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Document (org.kuali.kfs.krad.document.Document)4 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)4 HashMap (java.util.HashMap)3 List (java.util.List)3