Search in sources :

Example 16 with KualiDocumentFormBase

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

the class IWantDocumentAction method save.

@Override
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    // Only recreate document description if in INITIATED or SAVED status.
    WorkflowDocument workflowDocument = ((KualiDocumentFormBase) form).getDocument().getDocumentHeader().getWorkflowDocument();
    if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
        iWantDocumentService.setIWantDocumentDescription((IWantDocument) ((KualiDocumentFormBase) form).getDocument());
    }
    ActionForward actionForward = super.save(mapping, form, request, response);
    IWantDocumentForm iWantDocForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantDocForm.getIWantDocument();
    boolean added = true;
    // add new item and new accounting line if not empty
    IWantItem item = iWantDocForm.getNewIWantItemLine();
    if (StringUtils.isNotBlank(item.getItemDescription()) || item.getItemUnitPrice() != null || item.getItemQuantity() != null) {
        added &= addNewItem(iWantDocForm, iWantDocument, item);
    }
    added &= addNewFavoriteAccountIfNecessary(added, iWantDocument);
    if (added) {
        IWantAccount account = iWantDocForm.getNewSourceLine();
        if (StringUtils.isNotBlank(account.getAccountNumber()) || StringUtils.isNotBlank(account.getSubAccountNumber()) || StringUtils.isNotBlank(account.getFinancialObjectCode()) || StringUtils.isNotBlank(account.getFinancialSubObjectCode()) || StringUtils.isNotBlank(account.getProjectCode()) || StringUtils.isNotBlank(account.getOrganizationReferenceId())) {
            added &= addNewAccount(iWantDocForm, iWantDocument, account);
        }
    }
    // Do not save if item or account additions failed.
    if (!added) {
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
    if (StringUtils.isNotBlank(iWantDocForm.getNewAdHocRoutePerson().getId())) {
        iWantDocument.setCurrentRouteToNetId(iWantDocForm.getNewAdHocRoutePerson().getId());
    }
    return actionForward;
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem) ActionForward(org.apache.struts.action.ActionForward) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

Example 17 with KualiDocumentFormBase

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

the class IWantDocumentAction method copy.

/**
 * Overridden to guarantee that form of copied document is set to whatever the entry
 * mode of the document is
 * @see org.kuali.kfs.kns.web.struts.action.KualiTransactionalDocumentActionBase#copy(org.apache.struts.action.ActionMapping,
 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
 * javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    ActionForward forward = null;
    if (request.getParameter(KRADConstants.PARAMETER_DOC_ID) == null) {
        forward = super.copy(mapping, form, request, response);
    } else {
        // this is copy document from Procurement Gateway:
        // use this link to call: http://localhost:8080/kfs-dev/purapIWant.do?methodToCall=copy&docId=xxxx
        String docId = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
        KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
        IWantDocument document = null;
        document = (IWantDocument) getDocumentService().getByDocumentHeaderId(docId);
        document.toCopyFromGateway();
        kualiDocumentFormBase.setDocument(document);
        WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
        kualiDocumentFormBase.setDocTypeName(workflowDocument.getDocumentTypeName());
        UserSessionUtils.addWorkflowDocument(GlobalVariables.getUserSession(), workflowDocument);
        forward = mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    return forward;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) ActionForward(org.apache.struts.action.ActionForward) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)

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