Search in sources :

Example 11 with KualiDocumentFormBase

use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.

the class WebUtils method isFormSessionDocument.

public static boolean isFormSessionDocument(PojoFormBase form) {
    Document document = null;
    if (KualiDocumentFormBase.class.isAssignableFrom(form.getClass())) {
        KualiDocumentFormBase docForm = (KualiDocumentFormBase) form;
        document = docForm.getDocument();
    }
    return isDocumentSession(document, form);
}
Also used : KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) Document(org.kuali.kfs.krad.document.Document) SessionDocument(org.kuali.kfs.krad.document.SessionDocument)

Example 12 with KualiDocumentFormBase

use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase 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);
    }
}
Also used : KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) Note(org.kuali.kfs.krad.bo.Note) DocumentService(org.kuali.kfs.krad.service.DocumentService) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ItemParserException(org.kuali.kfs.module.purap.exception.ItemParserException)

Example 13 with KualiDocumentFormBase

use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method save.

@Override
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (isAttachmentSizeExceedSqLimit(form, "save") || isReasonToChangeRequired(form)) {
        return mapping.findForward(KFSConstants.MAPPING_BASIC);
    }
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
    // save this flag before notes is saved during route
    boolean isCreatingReasonNote = isCreatingReasonNote(form);
    // else if (!(kualiDocumentFormBase.getDocument() instanceof RequisitionDocument)) {
    // restoreSendToVendorFlag(kualiDocumentFormBase.getDocument().getDocumentBusinessObject().getBoNotes(), ((PurchaseOrderForm)kualiDocumentFormBase).getCopiedNotes());
    // }
    ActionForward forward = super.save(mapping, form, request, response);
    if (GlobalVariables.getMessageMap().hasNoErrors() && isCreatingReasonNote) {
        createReasonNote(form);
    }
    return forward;
}
Also used : KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) ActionForward(org.apache.struts.action.ActionForward)

Example 14 with KualiDocumentFormBase

use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.

the class PurchasingActionBase method isAttachmentSizeExceedSqLimit.

/*
     * check if number of attachments, that are sent to SQ, is over the limit.
     * default to 10, and also use a system param to make it flexible.
     */
private boolean isAttachmentSizeExceedSqLimit(ActionForm form, String action) {
    boolean isExceed = false;
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
    String attachmentSize = "10";
    int addOne = StringUtils.equals("add", action) ? 1 : 0;
    try {
        attachmentSize = SpringContext.getBean(ParameterService.class).getParameterValueAsString(PurapConstants.PURAP_NAMESPACE, KRADConstants.DetailTypes.ALL_DETAIL_TYPE, CUPurapConstants.MAX_SQ_NO_ATTACHMENTS);
    } catch (Exception e) {
        // param not found
        LOG.info("Parameter MAX_SQ_NO_ATTACHMENTS not found");
    }
    if (StringUtils.isNotBlank(attachmentSize) && Integer.parseInt(attachmentSize) < (getNumberOfNotesToSendToVendor(kualiDocumentFormBase.getDocument()) + addOne)) {
        GlobalVariables.getMessageMap().putError(String.format("%s.%s", KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME, KRADConstants.NOTE_TOPIC_TEXT_PROPERTY_NAME), CUPurapKeyConstants.ERROR_EXCEED_SQ_NUMBER_OF_ATT_LIMIT, action, attachmentSize);
        isExceed = true;
    }
    return isExceed;
}
Also used : KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ItemParserException(org.kuali.kfs.module.purap.exception.ItemParserException)

Example 15 with KualiDocumentFormBase

use of org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase in project cu-kfs by CU-CommunityApps.

the class CuPurchaseOrderAction method movePoCxer.

protected ActionForward movePoCxer(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String newStatus, String newStatusLabel) throws Exception {
    KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
    PurchaseOrderDocument po = (PurchaseOrderDocument) kualiDocumentFormBase.getDocument();
    Object question = request.getParameter(KFSConstants.QUESTION_INST_ATTRIBUTE_NAME);
    // If the user has not received the question screen yet, then perform the PO status update.
    if (ObjectUtils.isNull(question)) {
        // Check authorization.
        checkMovePoCxerAuthorization(po);
        // Use logic similar to the executeManualStatusChange() method to override the document's status.
        try {
            PurapService purapService = SpringContext.getBean(PurapService.class);
            po.updateAndSaveAppDocStatus(newStatus);
            purapService.saveDocumentNoValidation(po);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        // Add a message to the route log.
        po.getDocumentHeader().getWorkflowDocument().logAnnotation("Moved PO document from 'Error occurred sending cxml' status to '" + newStatusLabel + "' status.");
        // Present a success message to the user.
        String message = "PO document " + po.getDocumentNumber() + " was successfully moved to '" + newStatusLabel + "' status.";
        return this.performQuestionWithoutInput(mapping, form, request, response, MOVE_CXML_ERROR_PO_SUCCESS, message, STATUS_OVERRIDE_QUESTION, MOVE_CXML_ERROR_PO_SUCCESS, "");
    }
    return returnToSender(request, mapping, kualiDocumentFormBase);
}
Also used : PurapService(org.kuali.kfs.module.purap.document.service.PurapService) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) AuthorizationException(org.kuali.kfs.krad.exception.AuthorizationException)

Aggregations

KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)17 ActionForward (org.apache.struts.action.ActionForward)8 Note (org.kuali.kfs.krad.bo.Note)7 Document (org.kuali.kfs.krad.document.Document)3 WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)3 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)2 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)2 FormFile (org.apache.struts.upload.FormFile)2 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)2 Attachment (org.kuali.kfs.krad.bo.Attachment)2 AuthorizationException (org.kuali.kfs.krad.exception.AuthorizationException)2 ItemParserException (org.kuali.kfs.module.purap.exception.ItemParserException)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)1 IWantItem (edu.cornell.kfs.module.purap.businessobject.IWantItem)1 CuRequisitionDocument (edu.cornell.kfs.module.purap.document.CuRequisitionDocument)1 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)1 NoteExtendedAttribute (edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute)1 ArrayList (java.util.ArrayList)1 CapitalAccountingLines (org.kuali.kfs.fp.businessobject.CapitalAccountingLines)1