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