use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class IWantDocumentFeedServiceImpl method addNotes.
/**
* Adds notes to the I Want document.
* @param document
* @param batchIWantDocument
*/
private void addNotes(IWantDocument document, BatchIWantDocument batchIWantDocument) {
// set notes
for (Iterator iterator = batchIWantDocument.getNotes().iterator(); iterator.hasNext(); ) {
Note note = (Note) iterator.next();
note.setRemoteObjectIdentifier(document.getObjectId());
note.setAuthorUniversalIdentifier(document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId());
note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
note.setNotePostedTimestampToCurrent();
note.setNoteText("Note: " + note.getNoteText());
document.addNote(note);
}
}
use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class IWantDocumentFeedServiceImpl method loadDocumentAttachments.
/**
* Adds attachments to the I Want document.
* @param document
* @param attachments
*/
private void loadDocumentAttachments(IWantDocument document, List<BatchIWantAttachment> attachments, String incomingFileName) {
String attachmentsPath = new File(iWantDocumentInputFileType.getDirectoryPath()).toString() + "/attachment/";
for (BatchIWantAttachment attachment : attachments) {
Note note = new Note();
note.setNoteText(attachment.getAttachmentType());
note.setRemoteObjectIdentifier(document.getObjectId());
note.setAuthorUniversalIdentifier(document.getDocumentHeader().getWorkflowDocument().getPrincipalId());
note.setNoteTypeCode(KFSConstants.NoteTypeEnum.DOCUMENT_HEADER_NOTE_TYPE.getCode());
note.setNotePostedTimestampToCurrent();
// attempt to load file
String fileName = attachmentsPath + "/" + attachment.getAttachmentFileName();
File attachmentFile = new File(fileName);
if (!attachmentFile.exists()) {
continue;
}
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(fileName);
Integer fileSize = Integer.parseInt(Long.toString(attachmentFile.length()));
String mimeTypeCode = attachment.getAttachmentMimeTypeCode();
String fileExtension = "." + StringUtils.substringAfterLast(fileName, ".");
if (StringUtils.isNotBlank(fileExtension) && mimeTypeProperties.containsKey(fileExtension)) {
if (StringUtils.isBlank(mimeTypeCode)) {
mimeTypeCode = mimeTypeProperties.getProperty(fileExtension);
}
} else {
LOG.error("Mime type error" + fileName + " " + mimeTypeCode);
}
LOG.info("Mime type " + fileName + " " + mimeTypeCode);
String attachType = KFSConstants.EMPTY_STRING;
Attachment noteAttachment = attachmentService.createAttachment(document.getDocumentHeader(), attachment.getAttachmentFileName(), mimeTypeCode, fileSize, fileInputStream, attachType);
note.addAttachment(noteAttachment);
document.addNote(note);
} catch (FileNotFoundException e) {
continue;
} catch (IOException e1) {
throw new RuntimeException("Unable to create attachment for File: " + fileName, e1);
} finally {
IOUtils.closeQuietly(fileInputStream);
}
}
}
use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method createReasonNote.
/*
* creating the change to vendor reason note.
*/
private void createReasonNote(ActionForm form) {
// TODO : move to service ?
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
try {
Note noteObj = SpringContext.getBean(DocumentService.class).createNoteFromDocument(kualiDocumentFormBase.getDocument(), ((PurchasingFormBase) kualiDocumentFormBase).getReasonToChange());
populateIdentifierOnNoteAndExtension(noteObj);
kualiDocumentFormBase.getDocument().addNote(noteObj);
if (doesDocumentAllowImmediateSaveOfNewNote(kualiDocumentFormBase.getDocument(), noteObj)) {
getNoteService().save(noteObj);
}
((PurchasingFormBase) kualiDocumentFormBase).setReasonToChange(KFSConstants.EMPTY_STRING);
} catch (Exception e) {
String errorMessage = "Error creating and saving close note for reason change requirement with document service";
LOG.error("createReasonNote " + errorMessage, e);
throw new RuntimeException(errorMessage, e);
}
}
use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method changeSystem.
public ActionForward changeSystem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PurchasingAccountsPayableFormBase purchasingForm = (PurchasingAccountsPayableFormBase) form;
PurchasingDocument document = (PurchasingDocument) purchasingForm.getDocument();
Object question = request.getParameter(PurapConstants.QUESTION_INDEX);
Object buttonClicked = request.getParameter(KFSConstants.QUESTION_CLICKED_BUTTON);
if (question == null) {
String questionText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapKeyConstants.PURCHASING_QUESTION_CONFIRM_CHANGE_SYSTEM);
return this.performQuestionWithoutInput(mapping, form, request, response, PurapConstants.CapitalAssetTabStrings.SYSTEM_SWITCHING_QUESTION, questionText, KFSConstants.CONFIRMATION_QUESTION, KFSConstants.ROUTE_METHOD, "0");
} else if (ConfirmationQuestion.YES.equals(buttonClicked)) {
// Add a note if system change occurs when the document is a PO that is being amended.
if ((document instanceof PurchaseOrderDocument) && (PurapConstants.PurchaseOrderStatuses.APPDOC_CHANGE_IN_PROCESS.equals(document.getApplicationDocumentStatus()))) {
Integer poId = document.getPurapDocumentIdentifier();
PurchaseOrderDocument currentPO = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(poId);
String oldSystemTypeCode = "";
if (currentPO != null) {
oldSystemTypeCode = currentPO.getCapitalAssetSystemTypeCode();
}
CapitalAssetSystemType oldSystemType = new CapitalAssetSystemType();
oldSystemType.setCapitalAssetSystemTypeCode(oldSystemTypeCode);
Map<String, String> keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(oldSystemType);
oldSystemType = SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(CapitalAssetSystemType.class, keys);
String description = ((oldSystemType == null) ? "(NONE)" : oldSystemType.getCapitalAssetSystemTypeDescription());
if (document instanceof PurchaseOrderAmendmentDocument) {
String noteText = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(PurapKeyConstants.PURCHASE_ORDER_AMEND_MESSAGE_CHANGE_SYSTEM_TYPE);
noteText = StringUtils.replace(noteText, "{0}", description);
try {
Note systemTypeChangeNote = getDocumentService().createNoteFromDocument(document, noteText);
purchasingForm.setNewNote(systemTypeChangeNote);
insertBONote(mapping, purchasingForm, request, response);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
if (form instanceof RequisitionForm) {
((RequisitionForm) form).resetNewPurchasingCapitalAssetLocationLine();
}
// remove capital assets from db
if (document instanceof PurchaseOrderAmendmentDocument) {
for (PurchasingCapitalAssetItem assetItem : document.getPurchasingCapitalAssetItems()) {
SpringContext.getBean(BusinessObjectService.class).delete((PersistableBusinessObject) assetItem);
}
}
document.clearCapitalAssetFields();
SpringContext.getBean(PurapService.class).saveDocumentNoValidation(document);
KNSGlobalVariables.getMessageList().add(PurapKeyConstants.PURCHASING_MESSAGE_SYSTEM_CHANGED);
}
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method getNumberOfNotesToSendToVendor.
private int getNumberOfNotesToSendToVendor(Document purchaseOrder) {
int numberOfNotesToSendToVendor = 0;
// for POA purchaseOrder.getBoNotes() is empty, but purchaseOrder.getDocumentBusinessObject().getBoNotes() is not.
List<Note> notesToSend = purchaseOrder.getNotes();
if (CollectionUtils.isNotEmpty(notesToSend)) {
for (Note note : notesToSend) {
if (StringUtils.equalsIgnoreCase(note.getNoteTopicText(), CUPurapConstants.AttachemntToVendorIndicators.SEND_TO_VENDOR)) {
numberOfNotesToSendToVendor++;
}
}
}
return numberOfNotesToSendToVendor;
}
Aggregations