Search in sources :

Example 61 with Note

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

the class CuElectronicInvoiceHelperServiceImpl method attachInvoiceXMLWithRejectDoc.

protected void attachInvoiceXMLWithRejectDoc(ElectronicInvoiceRejectDocument eInvoiceRejectDocument, File attachmentFile, String noteText) {
    Note note = null;
    try {
        note = SpringContext.getBean(DocumentService.class).createNoteFromDocument(eInvoiceRejectDocument, noteText);
        // KFSCNTRB-1369: Can't add note without remoteObjectIdentifier
        note.setRemoteObjectIdentifier(eInvoiceRejectDocument.getNoteTarget().getObjectId());
    } catch (Exception e1) {
        throw new RuntimeException("Unable to create note from document: ", e1);
    }
    String attachmentType = null;
    BufferedInputStream fileStream = null;
    try {
        fileStream = new BufferedInputStream(new FileInputStream(attachmentFile));
    } catch (FileNotFoundException e) {
        LOG.error("Exception opening attachment file", e);
    }
    Attachment attachment = null;
    try {
        attachment = SpringContext.getBean(AttachmentService.class).createAttachment(eInvoiceRejectDocument.getNoteTarget(), attachmentFile.getName(), INVOICE_FILE_MIME_TYPE, (int) attachmentFile.length(), fileStream, attachmentType);
    } catch (Exception e) {
        // it may have more than one kind of Exception
        // if attachment is not created for any reason, then don't include in note and proceed.
        // otherwise it will throw runtimeexception and cause job to stop
        LOG.error("Unable to create attachment", e);
    // throw new RuntimeException("Unable to create attachment", e);
    } finally {
        if (fileStream != null) {
            try {
                fileStream.close();
            } catch (IOException e) {
                LOG.error("Exception closing file", e);
            }
        }
    }
    if (attachment != null) {
        // if attachment is not created for any reason, then don't ininclude in note and proceed.
        // otherwise it will throw runtimeexception and cause job to stop
        note.setAttachment(attachment);
        attachment.setNote(note);
    }
    SpringContext.getBean(NoteService.class).save(note);
}
Also used : BufferedInputStream(java.io.BufferedInputStream) Note(org.kuali.kfs.krad.bo.Note) FileNotFoundException(java.io.FileNotFoundException) NoteService(org.kuali.kfs.krad.service.NoteService) Attachment(org.kuali.kfs.krad.bo.Attachment) IOException(java.io.IOException) ValidationException(org.kuali.kfs.krad.exception.ValidationException) IOException(java.io.IOException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) CxmlParseException(org.kuali.kfs.module.purap.exception.CxmlParseException) FileInputStream(java.io.FileInputStream)

Example 62 with Note

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

the class CuElectronicInvoiceHelperServiceImpl method addRejectReasonsToNote.

protected void addRejectReasonsToNote(String rejectReasons, ElectronicInvoiceRejectDocument eInvoiceRejectDocument) {
    try {
        Note note = SpringContext.getBean(DocumentService.class).createNoteFromDocument(eInvoiceRejectDocument, rejectReasons);
        // KFSCNTRB-1369: Can't add note without remoteObjectIdentifier
        note.setRemoteObjectIdentifier(eInvoiceRejectDocument.getNoteTarget().getObjectId());
        PersistableBusinessObject noteParent = eInvoiceRejectDocument.getNoteTarget();
        SpringContext.getBean(NoteService.class).save(note);
    } catch (Exception e) {
        LOG.error("Error creating reject reason note - " + e.getMessage());
    }
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) Note(org.kuali.kfs.krad.bo.Note) NoteService(org.kuali.kfs.krad.service.NoteService) WorkflowDocumentService(org.kuali.kfs.krad.workflow.service.WorkflowDocumentService) DocumentService(org.kuali.kfs.krad.service.DocumentService) FinancialSystemDocumentService(org.kuali.kfs.sys.document.service.FinancialSystemDocumentService) ValidationException(org.kuali.kfs.krad.exception.ValidationException) IOException(java.io.IOException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) CxmlParseException(org.kuali.kfs.module.purap.exception.CxmlParseException)

Example 63 with Note

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

the class CuAttachmentServiceImplTest method setupMockNoteWithoutRemoteObjectId.

private Note setupMockNoteWithoutRemoteObjectId() {
    Note mockNote = EasyMock.createMock(Note.class);
    EasyMock.expect(mockNote.getRemoteObjectIdentifier()).andStubReturn(null);
    EasyMock.replay(mockNote);
    return mockNote;
}
Also used : Note(org.kuali.kfs.krad.bo.Note)

Example 64 with Note

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

the class CuB2BPurchaseOrderSciquestServiceImpl method getNotesToSendToVendor.

/**
 * KFSPTS-794: This code change was taken from an enhancement provided to Cornell from CSU.
 *
 * Returns list of Note(s) that should be sent to the vendor
 */
private List<Note> getNotesToSendToVendor(PurchaseOrderDocument purchaseOrder) {
    // this may not work for POA because PO note is linked to oldest PO
    List<Note> notesToSend = new ArrayList<Note>();
    List<Note> boNotes = purchaseOrder.getNotes();
    if (CollectionUtils.isEmpty(boNotes)) {
        boNotes = SpringContext.getBean(PurchaseOrderService.class).getPurchaseOrderNotes(purchaseOrder.getPurapDocumentIdentifier());
    }
    for (Note note : boNotes) {
        if (StringUtils.equalsIgnoreCase(note.getNoteTopicText(), CUPurapConstants.AttachemntToVendorIndicators.SEND_TO_VENDOR)) {
            notesToSend.add(note);
        }
    }
    return notesToSend;
}
Also used : Note(org.kuali.kfs.krad.bo.Note) ArrayList(java.util.ArrayList)

Example 65 with Note

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

the class CuCreditMemoServiceImpl method removeHoldOnCreditMemo.

/**
 * @see org.kuali.kfs.module.purap.document.service.CreditMemoService#removeHoldOnCreditMemo(org.kuali.kfs.module.purap.document.CreditMemoDocument,
 *      java.lang.String)
 */
@Override
public VendorCreditMemoDocument removeHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception {
    // save the note
    Note noteObj = documentService.createNoteFromDocument(cmDocument, note);
    cmDocument.addNote(noteObj);
    noteService.save(noteObj);
    // retrieve and save with hold indicator set to false
    VendorCreditMemoDocument cmDoc = getCreditMemoDocumentById(cmDocument.getPurapDocumentIdentifier());
    cmDoc.setHoldIndicator(false);
    cmDoc.setLastActionPerformedByPersonId(null);
    purapService.saveDocumentNoValidation(cmDoc);
    // force reindexing
    reIndexDocument(cmDoc);
    // must also save it on the incoming document
    cmDocument.setHoldIndicator(false);
    cmDocument.setLastActionPerformedByPersonId(null);
    // force reindexing
    reIndexDocument(cmDocument);
    return cmDoc;
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) Note(org.kuali.kfs.krad.bo.Note)

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