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);
}
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());
}
}
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;
}
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;
}
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;
}
Aggregations