Search in sources :

Example 6 with Note

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);
}
Also used : KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) Note(org.kuali.kfs.krad.bo.Note) Attachment(org.kuali.kfs.krad.bo.Attachment) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) Document(org.kuali.kfs.krad.document.Document)

Example 7 with Note

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);
}
Also used : KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) Note(org.kuali.kfs.krad.bo.Note) FormFile(org.apache.struts.upload.FormFile)

Example 8 with Note

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;
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) Note(org.kuali.kfs.krad.bo.Note)

Example 9 with Note

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);
}
Also used : Note(org.kuali.kfs.krad.bo.Note) AdvanceDepositForm(org.kuali.kfs.fp.document.web.struts.AdvanceDepositForm) Document(org.kuali.kfs.krad.document.Document)

Example 10 with Note

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);
}
Also used : 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