Search in sources :

Example 16 with WorkflowDocument

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

the class CuRequisitionAction 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;
    String docID = "docId";
    if (request.getParameter(docID) == null) {
        forward = super.copy(mapping, form, request, response);
    } else {
        // this is copy document from Procurement Gateway:
        // use this url to call: http://localhost:8080/kfs-dev/purapRequisition.do?methodToCall=copy&docId=xxxx
        String docId = request.getParameter(docID);
        KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
        CuRequisitionDocument document = null;
        document = (CuRequisitionDocument) getDocumentService().getByDocumentHeaderId(docId);
        document.toCopyFromGateway();
        kualiDocumentFormBase.setDocument(document);
        WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
        kualiDocumentFormBase.setDocTypeName(workflowDocument.getDocumentTypeName());
        SpringContext.getBean(SessionDocumentService.class).addDocumentToUserSession(GlobalVariables.getUserSession(), workflowDocument);
        forward = mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
    return forward;
}
Also used : CuRequisitionDocument(edu.cornell.kfs.module.purap.document.CuRequisitionDocument) SessionDocumentService(org.kuali.kfs.krad.service.SessionDocumentService) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) ActionForward(org.apache.struts.action.ActionForward)

Example 17 with WorkflowDocument

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

the class CuFinancialMaintenanceDocumentActionTest method createMockDocumentHeader.

protected DocumentHeader createMockDocumentHeader(DocumentStatus documentStatus) {
    DocumentHeader documentHeader = mock(FinancialSystemDocumentHeader.class);
    WorkflowDocument mockWorkflowDocument = createMockWorkflowDocument(documentStatus);
    when(documentHeader.getWorkflowDocument()).thenReturn(mockWorkflowDocument);
    return documentHeader;
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) DocumentHeader(org.kuali.kfs.krad.bo.DocumentHeader)

Example 18 with WorkflowDocument

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

the class CuDisbursementVoucherEmployeeInformationValidation method validate.

public boolean validate(AttributedDocumentEvent event) {
    LOG.debug("validate start");
    boolean isValid = true;
    CuDisbursementVoucherDocument document = (CuDisbursementVoucherDocument) getAccountingDocumentForValidation();
    DisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
    if (!payeeDetail.isEmployee() || payeeDetail.isVendor() || !(document.getDocumentHeader().getWorkflowDocument().isInitiated() || document.getDocumentHeader().getWorkflowDocument().isSaved())) {
        return true;
    }
    String employeeId = payeeDetail.getDisbVchrPayeeIdNumber();
    Person employee = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(employeeId);
    MessageMap errors = GlobalVariables.getMessageMap();
    errors.addToErrorPath(KFSPropertyConstants.DOCUMENT);
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    boolean stateIsInitiated = workflowDocument.isInitiated() || workflowDocument.isSaved();
    if (ObjectUtils.isNull(employee)) {
        employee = SpringContext.getBean(PersonService.class).getPerson(employeeId);
    } else {
        if (!KFSConstants.EMPLOYEE_ACTIVE_STATUS.equals(employee.getEmployeeStatusCode()) && !CUKFSConstants.EMPLOYEE_RETIRED_STATUS.equals(employee.getEmployeeStatusCode())) {
            // If employee is found, then check that employee is active or retired if the doc has not already been routed.
            if (stateIsInitiated) {
                String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
                errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_INACTIVE, label);
                isValid = false;
            }
        }
    }
    // check existence of employee
    if (employee == null) {
        // If employee is not found, report existence error
        String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(DisbursementVoucherPayeeDetail.class, KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER);
        errors.putError(DV_PAYEE_ID_NUMBER_PROPERTY_PATH, KFSKeyConstants.ERROR_EXISTENCE, label);
        isValid = false;
    }
    errors.removeFromErrorPath(KFSPropertyConstants.DOCUMENT);
    return isValid;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) PersonService(org.kuali.rice.kim.api.identity.PersonService) DisbursementVoucherPayeeDetail(org.kuali.kfs.fp.businessobject.DisbursementVoucherPayeeDetail) Person(org.kuali.rice.kim.api.identity.Person) MessageMap(org.kuali.kfs.krad.util.MessageMap) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Example 19 with WorkflowDocument

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

the class CuProcurementCardAccountingLineAuthorizer method determineEditPermissionByFieldName.

@Override
protected boolean determineEditPermissionByFieldName(AccountingDocument accountingDocument, AccountingLine accountingLine, String fieldName, Person currentUser, Set<String> currentNodes) {
    WorkflowDocument workflowDocument = accountingDocument.getDocumentHeader().getWorkflowDocument();
    List<ActionRequest> actionRequests = workflowDocument.getRootActionRequests();
    Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
    boolean isAddHocRoute = CollectionUtils.isNotEmpty(nodeNames) && nodeNames.contains(PurapWorkflowConstants.DOC_ADHOC_NODE_NAME);
    if (!isAddHocRoute) {
        for (ActionRequest actionRequest : actionRequests) {
            isAddHocRoute = actionRequest.getActionTaken() == null && StringUtils.startsWith(actionRequest.getAnnotation(), "Ad Hoc Routed by") && StringUtils.equals(actionRequest.getPrincipalId(), currentUser.getPrincipalId());
            if (isAddHocRoute) {
                return false;
            }
        }
    } else {
        return false;
    }
    // 2. Check that the document is at AccountFullEdit route node
    if (accountingDocument.getDocumentHeader() != null && accountingDocument.getDocumentHeader().getWorkflowDocument() != null) {
        if (currentNodes != null && currentNodes.contains(RouteLevelNames.ACCOUNT_REVIEW_FULL_EDIT)) {
            // 3. Check that the current user has the permission to edit the document, which means in this case he can edit the accounting line
            if (getDocumentAuthorizer(accountingDocument).canEdit(accountingDocument, currentUser)) {
                // since any user that can edit the accounting lines will be able to add/change it to any other account
                return true;
            }
        }
    }
    return super.determineEditPermissionByFieldName(accountingDocument, accountingLine, fieldName, currentUser, currentNodes);
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) ActionRequest(org.kuali.rice.kew.api.action.ActionRequest)

Example 20 with WorkflowDocument

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

the class CuProcurementCardDocumentPresentationController method canEditDocumentOverview.

@Override
public boolean canEditDocumentOverview(Document document) {
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
    return workflowDocument.isEnroute() && CollectionUtils.isNotEmpty(nodeNames) && nodeNames.contains(KFSConstants.RouteLevelNames.ACCOUNT_REVIEW_FULL_EDIT) && workflowDocument.isApprovalRequested() && !workflowDocument.isAcknowledgeRequested();
}
Also used : WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument)

Aggregations

WorkflowDocument (org.kuali.rice.kew.api.WorkflowDocument)36 ArrayList (java.util.ArrayList)4 FinancialSystemDocumentHeader (org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader)4 Person (org.kuali.rice.kim.api.identity.Person)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 ActionForward (org.apache.struts.action.ActionForward)3 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)3 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)3 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)2 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)2 Iterator (java.util.Iterator)2 List (java.util.List)2 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)2 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)2 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)2 PurchaseOrderItem (org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem)2 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)2 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)2 PurapService (org.kuali.kfs.module.purap.document.service.PurapService)2 FinancialSystemWorkflowHelperService (org.kuali.kfs.sys.service.FinancialSystemWorkflowHelperService)2