use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class CuFinancialMaintenanceDocumentAction method deleteBONote.
/**
* Overridden to include a Rice 2.5.x fix for deleting INITIATED-doc notes and persisting BO note deletions,
* and to delegate the fix's boolean logic to some new shouldSaveBoNoteAfterUpdate()
* and isTargetReadyForNotes() methods so that it can be further limited based on BO class and readiness.
*
* Some other cleanup has also been done to remove certain comments and unused variables,
* but other than that and the changes stated above,
* this method is the same as the one from KualiDocumentActionBase.
*
* @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#deleteBONote(
* org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward deleteBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
Document document = kualiDocumentFormBase.getDocument();
Note note = document.getNote(getLineToDelete(request));
Attachment attachment = note.getAttachment();
String attachmentTypeCode = null;
if (attachment != null) {
attachmentTypeCode = attachment.getAttachmentTypeCode();
}
String authorUniversalIdentifier = note.getAuthorUniversalIdentifier();
if (!WebUtils.canDeleteNoteAttachment(document, attachmentTypeCode, authorUniversalIdentifier)) {
throw buildAuthorizationException("annotate", document);
}
if (attachment != null) {
// so refreshNonUpdateableReferences() should work the same as refresh()
if (note.getNoteIdentifier() != null) {
// KULRICE-2343 don't blow away note reference if the note wasn't persisted
attachment.refreshNonUpdateableReferences();
}
getAttachmentService().deleteAttachmentContents(attachment);
}
// Removed the if check so it no longer checks if the document is initiated before deleting the BO's note per KULRICE- 12327
getNoteService().deleteNote(note);
document.removeNote(note);
if (shouldSaveBoNoteAfterUpdate(document, note)) {
// If this is a maintenance document and we're deleting a BO note then try to save the document so the note is removed from the content
if (!isTargetReadyForNotes(document)) {
getDocumentService().saveDocument(document);
}
}
return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method insertBONote.
@Override
public ActionForward insertBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
// TODO : should use 'addnoteevent' ?
/*
* KFSPTS-794 : add rule check when adding note
*/
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
FormFile attachmentFile = kualiDocumentFormBase.getAttachmentFile();
Note newNote = kualiDocumentFormBase.getNewNote();
if (StringUtils.equals(CUPurapConstants.AttachemntToVendorIndicators.SEND_TO_VENDOR, newNote.getNoteTopicText())) {
if (StringUtils.isBlank(attachmentFile.getFileName())) {
GlobalVariables.getMessageMap().putError(String.format("%s.%s", KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME, KRADConstants.NOTE_TOPIC_TEXT_PROPERTY_NAME), CUPurapKeyConstants.ERROR_ADD_NEW_NOTE_SEND_TO_VENDOR_NO_ATT);
return mapping.findForward(KFSConstants.MAPPING_BASIC);
} else {
if (isAttachmentSizeExceedSqLimit(form, "add")) {
return mapping.findForward(KFSConstants.MAPPING_BASIC);
} else if (attachmentFile.getFileSize() > SIZE_5MB) {
GlobalVariables.getMessageMap().putError(String.format("%s.%s", KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME, KRADConstants.NOTE_TOPIC_TEXT_PROPERTY_NAME), CUPurapKeyConstants.ERROR_ATT_FILE_SIZE_OVER_LIMIT, attachmentFile.getFileName(), "5");
return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
}
}
newNote.setNoteTypeCode(KFSConstants.NoteTypeEnum.DOCUMENT_HEADER_NOTE_TYPE.getCode());
return super.insertBONote(mapping, form, request, response);
}
use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method isAttachmentReqChanged.
/*
* check if the 'send to vendor' flag is changed.
*/
private boolean isAttachmentReqChanged(ActionForm form) {
boolean ischanged = false;
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
List<Note> savedNotes = getPersistedBoNotesNotes(kualiDocumentFormBase.getDocument());
List<Note> boNotes = kualiDocumentFormBase.getDocument().getNotes();
if (!(kualiDocumentFormBase.getDocument() instanceof RequisitionDocument)) {
restoreSendToVendorFlag(boNotes, ((CuPurchaseOrderForm) kualiDocumentFormBase).getCopiedNotes());
}
boolean isChanged = false;
for (Note savedNote : savedNotes) {
for (Note note : boNotes) {
if (note.getNoteIdentifier().equals(savedNote.getNoteIdentifier()) && !StringUtils.equals(note.getNoteTopicText(), savedNote.getNoteTopicText()) && (StringUtils.equalsIgnoreCase(note.getNoteTopicText(), CUPurapConstants.AttachemntToVendorIndicators.SEND_TO_VENDOR) || StringUtils.equalsIgnoreCase(savedNote.getNoteTopicText(), CUPurapConstants.AttachemntToVendorIndicators.SEND_TO_VENDOR))) {
isChanged = true;
break;
}
}
}
return isChanged;
}
use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class CuAdvanceDepositAction method insertBONote.
/**
* Overridden to treat "Confidential" add-attachment authorization failures as validation errors, rather than throwing an authorization exception.
*
* @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#insertBONote(
* org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@SuppressWarnings("deprecation")
@Override
public ActionForward insertBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
AdvanceDepositForm adForm = (AdvanceDepositForm) form;
Note newNote = adForm.getNewNote();
Document document = adForm.getDocument();
if (!ConfidentialAttachmentUtil.attachmentIsNonConfidentialOrCanAddConfAttachment(newNote, document, adForm.getAttachmentFile(), getDocumentHelperService().getDocumentAuthorizer(document))) {
return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
return super.insertBONote(mapping, form, request, response);
}
use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.
the class CuDistributionOfIncomeAndExpenseAction method insertBONote.
/**
* Overridden to treat "Confidential" add-attachment authorization failures as validation errors, rather than throwing an authorization exception.
*
* @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#insertBONote()
*/
@SuppressWarnings("deprecation")
@Override
public ActionForward insertBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
CuDistributionOfIncomeAndExpenseForm diForm = (CuDistributionOfIncomeAndExpenseForm) form;
Note newNote = diForm.getNewNote();
if (!ConfidentialAttachmentUtil.attachmentIsNonConfidentialOrCanAddConfAttachment(newNote, diForm.getDocument(), diForm.getAttachmentFile(), getDocumentHelperService().getDocumentAuthorizer(diForm.getDocument()))) {
return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
return super.insertBONote(mapping, form, request, response);
}
Aggregations