Search in sources :

Example 41 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class CuRequisitionDocument method isB2BTotalAmountForAutoPO.

protected boolean isB2BTotalAmountForAutoPO() {
    boolean returnValue = false;
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    String autoPOAmountString = new String(parameterService.getParameterValueAsString(RequisitionDocument.class, CUPurapParameterConstants.B2B_TOTAL_AMOUNT_FOR_AUTO_PO));
    KualiDecimal autoPOAmount = new KualiDecimal(autoPOAmountString);
    // KFSPTS-1625
    String routedBy = getRoutedByPrincipalId();
    if (StringUtils.isBlank(routedBy)) {
        routedBy = this.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
    }
    if (KimApiServiceLocator.getPermissionService().hasPermission(routedBy, CUKFSConstants.ParameterNamespaces.PURCHASING, CUPurapConstants.B2B_HIGHER_LIMIT_PERMISSION)) {
        String paramVal = parameterService.getParameterValueAsString(RequisitionDocument.class, CUPurapParameterConstants.B2B_TOTAL_AMOUNT_FOR_SUPER_USER_AUTO_PO);
        if (StringUtils.isNotBlank(paramVal)) {
            autoPOAmount = new KualiDecimal(paramVal);
        }
    }
    RequisitionDocument document = null;
    try {
        document = (RequisitionDocument) (SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(this.getDocumentNumber()));
    } catch (WorkflowException we) {
    }
    KualiDecimal totalAmount = document.getFinancialSystemDocumentHeader().getFinancialDocumentTotalAmount();
    if (ObjectUtils.isNotNull(autoPOAmount) && ObjectUtils.isNotNull(totalAmount) && (autoPOAmount.compareTo(totalAmount) >= 0)) {
        returnValue = true;
    } else {
        returnValue = false;
    }
    return returnValue;
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal)

Example 42 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class CuRequisitionDocument method getRoutedByPrincipalId.

public String getRoutedByPrincipalId() {
    DocumentService documentService = SpringContext.getBean(DocumentService.class);
    RequisitionDocument document = null;
    String principalId = null;
    try {
        document = (RequisitionDocument) documentService.getByDocumentHeaderId(this.getDocumentNumber());
        principalId = document.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId();
    } catch (WorkflowException we) {
    }
    return principalId;
}
Also used : RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Example 43 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class CuRequisitionAction method createReqFromIWantDoc.

/**
 * Creates a requisition document based on information from an I Want document.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
@SuppressWarnings("deprecation")
public ActionForward createReqFromIWantDoc(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    String iWantDocumentNumber = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
    RequisitionForm requisitionForm = (RequisitionForm) form;
    IWantDocument iWantDocument = (IWantDocument) getDocumentService().getByDocumentHeaderId(iWantDocumentNumber);
    if (iWantDocument == null) {
        throw new WorkflowException("Could not find IWantDocument with ID '" + iWantDocumentNumber + "'");
    }
    // Make sure the user is authorized to create the req in this manner.
    TransactionalDocumentPresentationController pControl = (TransactionalDocumentPresentationController) getDocumentHelperService().getDocumentPresentationController(iWantDocument);
    TransactionalDocumentAuthorizer authorizer = (TransactionalDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(iWantDocument);
    Set<String> iwntEditModes = authorizer.getEditModes(iWantDocument, GlobalVariables.getUserSession().getPerson(), pControl.getEditModes(iWantDocument));
    if (!iwntEditModes.contains(CUPurapConstants.IWNT_DOC_CREATE_REQ)) {
        throw new AuthorizationException(GlobalVariables.getUserSession().getPrincipalId(), CUPurapConstants.IWNT_DOC_CREATE_REQ, CuRequisitionDocument.class.getSimpleName(), "user is not authorized to create requisitions from IWantDocument '" + iWantDocumentNumber + "'", Collections.<String, Object>emptyMap());
    }
    // Do not allow the req to be created if the IWNT doc is already associated with another req.
    if (iWantDocument != null && (StringUtils.isNotBlank(iWantDocument.getReqsDocId()) || StringUtils.isNotBlank(iWantDocument.getDvDocId()))) {
        throw new WorkflowException("Cannot create requisition from IWantDocument '" + iWantDocumentNumber + "' because a DV or Requisition has already been created from that document");
    }
    IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
    createDocument(requisitionForm);
    RequisitionDocument requisitionDocument = requisitionForm.getRequisitionDocument();
    iWantDocumentService.setUpRequisitionDetailsFromIWantDoc(iWantDocument, requisitionDocument, requisitionForm);
    // Set the requisition doc ID reference on the IWantDocument.
    iWantDocument.setReqsDocId(requisitionDocument.getDocumentNumber());
    SpringContext.getBean(PurapService.class).saveDocumentNoValidation(iWantDocument);
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
Also used : CuRequisitionDocument(edu.cornell.kfs.module.purap.document.CuRequisitionDocument) RequisitionDocument(org.kuali.kfs.module.purap.document.RequisitionDocument) CuRequisitionDocument(edu.cornell.kfs.module.purap.document.CuRequisitionDocument) PurapService(org.kuali.kfs.module.purap.document.service.PurapService) AuthorizationException(org.kuali.kfs.krad.exception.AuthorizationException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) RequisitionForm(org.kuali.kfs.module.purap.document.web.struts.RequisitionForm) TransactionalDocumentPresentationController(org.kuali.kfs.kns.document.authorization.TransactionalDocumentPresentationController) TransactionalDocumentAuthorizer(org.kuali.kfs.kns.document.authorization.TransactionalDocumentAuthorizer) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument) IWantDocumentService(edu.cornell.kfs.module.purap.document.service.IWantDocumentService)

Example 44 with WorkflowException

use of org.kuali.rice.kew.api.exception.WorkflowException in project cu-kfs by CU-CommunityApps.

the class CuRelatedDocumentDerivedRoleTypeServiceImpl method getRoleMembersFromDerivedRole.

@Override
public List<RoleMembership> getRoleMembersFromDerivedRole(String namespaceCode, String roleName, Map<String, String> qualification) {
    List<RoleMembership> members = new ArrayList<RoleMembership>();
    if (qualification != null && !qualification.isEmpty()) {
        if (SOURCE_DOCUMENT_ROUTER_ROLE_NAME.equals(roleName)) {
            try {
                PurchasingAccountsPayableDocument document = (PurchasingAccountsPayableDocument) getDocumentService().getByDocumentHeaderId(qualification.get(KFSPropertyConstants.DOCUMENT_NUMBER));
                if (document != null) {
                    PurchasingAccountsPayableDocument sourceDocument = document.getPurApSourceDocumentIfPossible();
                    if (sourceDocument != null && StringUtils.isNotBlank(sourceDocument.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId())) {
                        Map<String, String> roleQualifier = new HashMap<String, String>(1);
                        roleQualifier.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, sourceDocument.getDocumentNumber());
                        Builder roleMember = RoleMembership.Builder.create(null, null, sourceDocument.getDocumentHeader().getWorkflowDocument().getRoutedByPrincipalId(), KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, roleQualifier);
                        members.add(roleMember.build());
                    }
                }
            } catch (WorkflowException e) {
                throw new RuntimeException("Unable to load document in getPrincipalIdsFromApplicationRole", e);
            }
        } else if (SENSITIVE_RELATED_DOCUMENT_INITATOR_OR_REVIEWER_ROLE_NAME.equals(roleName)) {
            // KFSUPGRADE-346
            if (!qualification.containsKey(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER)) {
                Map<String, String> tempQualification = new HashMap<String, String>(1);
                tempQualification.put(KFSPropertyConstants.DOCUMENT_NUMBER, qualification.get("documentNumber"));
                for (String principalId : getRoleService().getRoleMemberPrincipalIds(KRADConstants.KUALI_RICE_WORKFLOW_NAMESPACE, RouteLogDerivedRoleTypeServiceImpl.INITIATOR_OR_REVIEWER_ROLE_NAME, tempQualification)) {
                    Builder roleMember = RoleMembership.Builder.create(null, null, principalId, KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, tempQualification);
                    members.add(roleMember.build());
                }
            } else {
                for (String documentId : getPurapService().getRelatedDocumentIds(new Integer(qualification.get(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER)))) {
                    Map<String, String> tempQualification = new HashMap<String, String>(1);
                    tempQualification.put(KFSPropertyConstants.DOCUMENT_NUMBER, documentId);
                    for (String principalId : getRoleService().getRoleMemberPrincipalIds(KRADConstants.KUALI_RICE_WORKFLOW_NAMESPACE, RouteLogDerivedRoleTypeServiceImpl.INITIATOR_OR_REVIEWER_ROLE_NAME, tempQualification)) {
                        Builder roleMember = RoleMembership.Builder.create(null, null, principalId, KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE, tempQualification);
                        members.add(roleMember.build());
                    }
                }
            }
        }
    }
    return members;
}
Also used : HashMap(java.util.HashMap) Builder(org.kuali.rice.kim.api.role.RoleMembership.Builder) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) RoleMembership(org.kuali.rice.kim.api.role.RoleMembership) PurchasingAccountsPayableDocument(org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)44 DocumentService (org.kuali.kfs.krad.service.DocumentService)14 ArrayList (java.util.ArrayList)8 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)7 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)7 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)7 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)6 UserSession (org.kuali.kfs.krad.UserSession)6 FinancialSystemDocumentService (org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)6 Date (java.sql.Date)5 RemoteException (java.rmi.RemoteException)4 ValidationException (org.kuali.kfs.krad.exception.ValidationException)4 WorkflowDocumentService (org.kuali.kfs.krad.workflow.service.WorkflowDocumentService)4 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)4 CuElectronicInvoiceRejectDocument (edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument)3 HashMap (java.util.HashMap)3 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)3 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)3 Note (org.kuali.kfs.krad.bo.Note)3 Document (org.kuali.kfs.krad.document.Document)3