Search in sources :

Example 1 with IWantDocumentService

use of edu.cornell.kfs.module.purap.document.service.IWantDocumentService in project cu-kfs by CU-CommunityApps.

the class IWantDocument method doRouteStatusChange.

/**
 * Override this method to send out an email to the initiator when the document reached the final status.
 *
 * @see org.kuali.kfs.sys.document.FinancialSystemTransactionalDocumentBase#doRouteStatusChange(org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO)
 */
@Override
public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
    super.doRouteStatusChange(statusChangeEvent);
    if (getDocumentHeader().getWorkflowDocument().isFinal()) {
        IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
        iWantDocumentService.sendDocumentFinalizedMessage(this);
    }
}
Also used : IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Example 2 with IWantDocumentService

use of edu.cornell.kfs.module.purap.document.service.IWantDocumentService in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherAction method createDVFromIWantDoc.

/**
 * Creates a DV document based on information on an I Want document.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward createDVFromIWantDoc(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    String iWantDocumentNumber = request.getParameter("docId");
    CuDisbursementVoucherForm disbursementVoucherForm = (CuDisbursementVoucherForm) form;
    IWantDocument iWantDocument = (IWantDocument) getDocumentService().getByDocumentHeaderId(iWantDocumentNumber);
    // Do not allow the DV to be created if the IWNT doc is already associated with another DV.
    if (iWantDocument != null && (StringUtils.isNotBlank(iWantDocument.getReqsDocId()) || StringUtils.isNotBlank(iWantDocument.getDvDocId()))) {
        GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, CUPurapKeyConstants.ERROR_DV_OR_REQ_ALREADY_CREATED_FROM_IWNT, iWantDocumentNumber);
        return mapping.findForward("error");
    }
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    createDocument(disbursementVoucherForm);
    CuDisbursementVoucherDocument disbursementVoucherDocument = (CuDisbursementVoucherDocument) disbursementVoucherForm.getDocument();
    iWantDocumentService.setUpDVDetailsFromIWantDoc(iWantDocument, disbursementVoucherDocument, disbursementVoucherForm);
    // Set the DV doc ID reference on the IWantDocument.
    iWantDocument.setDvDocId(disbursementVoucherDocument.getDocumentNumber());
    SpringContext.getBean(PurapService.class).saveDocumentNoValidation(iWantDocument);
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Example 3 with IWantDocumentService

use of edu.cornell.kfs.module.purap.document.service.IWantDocumentService in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method setCollegeAndDepartmentBasedOnPrimaryDepartment.

/**
 * Sets the College and Department based on the initiator primary department.
 *
 * @param documentForm
 */
private void setCollegeAndDepartmentBasedOnPrimaryDepartment(IWantDocumentForm documentForm) {
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    String primaryDeptOrg = null;
    IWantDocument iWantDocument = null;
    if (documentForm != null && documentForm.getDocument() != null) {
        iWantDocument = (IWantDocument) documentForm.getDocument();
    }
    if (iWantDocument != null && StringUtils.isEmpty(iWantDocument.getCollegeLevelOrganization())) {
        Person currentUser = GlobalVariables.getUserSession().getPerson();
        Entity entityInfo = KimApiServiceLocator.getIdentityService().getEntityByPrincipalId(currentUser.getPrincipalId());
        if (ObjectUtils.isNotNull(entityInfo)) {
            if (ObjectUtils.isNotNull(entityInfo.getEmploymentInformation()) && entityInfo.getEmploymentInformation().size() > 0) {
                EntityEmployment employmentInformation = entityInfo.getEmploymentInformation().get(0);
                String primaryDepartment = employmentInformation.getPrimaryDepartmentCode();
                primaryDeptOrg = primaryDepartment.substring(primaryDepartment.lastIndexOf('-') + 1, primaryDepartment.length());
                String cLevelOrg = iWantDocumentService.getCLevelOrganizationForDLevelOrg(primaryDepartment);
                ((IWantDocument) documentForm.getDocument()).setCollegeLevelOrganization(cLevelOrg);
            }
        }
    }
    if (iWantDocument != null && StringUtils.isNotEmpty(iWantDocument.getCollegeLevelOrganization())) {
        String cLevelOrg = iWantDocument.getCollegeLevelOrganization();
        documentForm.getDeptOrgKeyLabels().clear();
        documentForm.getDeptOrgKeyLabels().add(new ConcreteKeyValue("", "Please Select"));
        List<LevelOrganization> dLevelOrgs = iWantDocumentService.getDLevelOrganizations(cLevelOrg);
        for (LevelOrganization levelOrganization : dLevelOrgs) {
            documentForm.getDeptOrgKeyLabels().add(new ConcreteKeyValue(levelOrganization.getCode(), levelOrganization.getCodeAndDescription()));
        }
        if (primaryDeptOrg != null) {
            iWantDocument.setDepartmentLevelOrganization(primaryDeptOrg);
        }
    }
}
Also used : ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) Entity(org.kuali.rice.kim.api.identity.entity.Entity) LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) EntityEmployment(org.kuali.rice.kim.api.identity.employment.EntityEmployment) Person(org.kuali.rice.kim.api.identity.Person) 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 4 with IWantDocumentService

use of edu.cornell.kfs.module.purap.document.service.IWantDocumentService in project cu-kfs by CU-CommunityApps.

the class IWantDocumentAction method route.

/**
 * @see org.kuali.kfs.kns.web.struts.action.KualiDocumentActionBase#route(org.apache.struts.action.ActionMapping,
 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
 * javax.servlet.http.HttpServletResponse)
 */
@Override
public ActionForward route(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    IWantDocumentForm iWantDocForm = (IWantDocumentForm) form;
    IWantDocument iWantDocument = iWantDocForm.getIWantDocument();
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    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 route if there were failures adding new items or accounts.
    if (!added) {
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    iWantDocument.setExplanation(iWantDocument.getDocumentHeader().getExplanation());
    String step = iWantDocForm.getStep();
    String principalId = iWantDocument.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
    boolean setDefaultCollegeDept = iWantDocument.isUseCollegeAndDepartmentAsDefault();
    if (setDefaultCollegeDept) {
        // set these values in user Options table
        String college = iWantDocument.getCollegeLevelOrganization();
        String department = iWantDocument.getDepartmentLevelOrganization();
        saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_COLLEGE, college);
        saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DEPARTMENT, department);
    }
    if (iWantDocument.isSetDeliverToInfoAsDefault()) {
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToNetID())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NET_ID, iWantDocument.getDeliverToNetID());
        }
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToName())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_NAME, iWantDocument.getDeliverToName());
        }
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToEmailAddress())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_EMAIL_ADDRESS, iWantDocument.getDeliverToEmailAddress());
        }
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToPhoneNumber())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_PHONE_NUMBER, iWantDocument.getDeliverToPhoneNumber());
        }
        if (StringUtils.isNotBlank(iWantDocument.getDeliverToAddress())) {
            saveUserOption(principalId, CUPurapConstants.USER_OPTIONS_DEFAULT_DELIVER_TO_ADDRESS, iWantDocument.getDeliverToAddress());
        }
    }
    iWantDocumentService.setIWantDocumentDescription(iWantDocument);
    // insert adhoc route person first and the route
    if (StringUtils.isNotBlank(iWantDocForm.getNewAdHocRoutePerson().getId())) {
        iWantDocument.setCurrentRouteToNetId(iWantDocForm.getNewAdHocRoutePerson().getId());
        insertAdHocRoutePerson(mapping, iWantDocForm, request, response);
    }
    ActionForward actionForward = super.route(mapping, form, request, response);
    if (CUPurapConstants.IWantDocumentSteps.ROUTING_STEP.equalsIgnoreCase(step)) {
        iWantDocForm.setStep(CUPurapConstants.IWantDocumentSteps.REGULAR);
        iWantDocument.setStep(CUPurapConstants.IWantDocumentSteps.REGULAR);
        return mapping.findForward("finish");
    }
    return actionForward;
}
Also used : IWantAccount(edu.cornell.kfs.module.purap.businessobject.IWantAccount) IWantItem(edu.cornell.kfs.module.purap.businessobject.IWantItem) ActionForward(org.apache.struts.action.ActionForward) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) PurApFavoriteAccountLineBuilderForIWantDocument(edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Example 5 with IWantDocumentService

use of edu.cornell.kfs.module.purap.document.service.IWantDocumentService in project cu-kfs by CU-CommunityApps.

the class CollegeLevelOrganizationValuesFinder method getKeyValues.

public List<KeyValue> getKeyValues() {
    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    List<LevelOrganization> cLevelOrganizations = iWantDocumentService.getCLevelOrganizations();
    keyValues.add(new ConcreteKeyValue("", ""));
    if (cLevelOrganizations != null) {
        for (LevelOrganization cLevelOrganization : cLevelOrganizations) {
            keyValues.add(new ConcreteKeyValue(cLevelOrganization.getCode(), cLevelOrganization.getCodeAndDescription()));
        }
    }
    return keyValues;
}
Also used : ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) KeyValue(org.kuali.rice.core.api.util.KeyValue) ConcreteKeyValue(org.kuali.rice.core.api.util.ConcreteKeyValue) LevelOrganization(edu.cornell.kfs.module.purap.businessobject.LevelOrganization) ArrayList(java.util.ArrayList) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Aggregations

IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)10 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)8 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)6 ActionForward (org.apache.struts.action.ActionForward)5 LevelOrganization (edu.cornell.kfs.module.purap.businessobject.LevelOrganization)3 ConcreteKeyValue (org.kuali.rice.core.api.util.ConcreteKeyValue)3 IWantAccount (edu.cornell.kfs.module.purap.businessobject.IWantAccount)2 IWantItem (edu.cornell.kfs.module.purap.businessobject.IWantItem)2 HashMap (java.util.HashMap)2 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)2 Person (org.kuali.rice.kim.api.identity.Person)2 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)1 IWantDocUserOptions (edu.cornell.kfs.module.purap.businessobject.IWantDocUserOptions)1 CuRequisitionDocument (edu.cornell.kfs.module.purap.document.CuRequisitionDocument)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 TransactionalDocumentAuthorizer (org.kuali.kfs.kns.document.authorization.TransactionalDocumentAuthorizer)1 TransactionalDocumentPresentationController (org.kuali.kfs.kns.document.authorization.TransactionalDocumentPresentationController)1 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)1 AuthorizationException (org.kuali.kfs.krad.exception.AuthorizationException)1