Search in sources :

Example 11 with WorkflowDocument

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

the class IWantDocumentPresentationController method canEditDocumentOverview.

/*
     * CU Customization (KFSPTS-2270): Added the ability to edit the document overview/description
     * for enroute IWNT docs; we'll use KIM permissions to restrict this to select users.
     * 
     * We restrict the editing of the doc overview to IWNT docs in enroute status at the
     * OrganizationHierarchy node, and further restrict it to non-ad-hoc users.
     */
@Override
public boolean canEditDocumentOverview(Document document) {
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    Set<String> nodeNames = workflowDocument.getCurrentNodeNames();
    return workflowDocument.isEnroute() && CollectionUtils.isNotEmpty(nodeNames) && nodeNames.contains("OrganizationHierarchy") && !SpringContext.getBean(FinancialSystemWorkflowHelperService.class).isAdhocApprovalRequestedForPrincipal(workflowDocument, GlobalVariables.getUserSession().getPrincipalId());
}
Also used : WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) FinancialSystemWorkflowHelperService(org.kuali.kfs.sys.service.FinancialSystemWorkflowHelperService)

Example 12 with WorkflowDocument

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

the class IWantDocumentPresentationController method getEditModes.

@Override
public Set<String> getEditModes(Document document) {
    Set<String> editModes = super.getEditModes(document);
    WorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
    IWantDocument iWantDocument = (IWantDocument) document;
    if (SpringContext.getBean(FinancialSystemWorkflowHelperService.class).isAdhocApprovalRequestedForPrincipal(workflowDocument, GlobalVariables.getUserSession().getPrincipalId())) {
        editModes.add("completeOrder");
    }
    if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
        editModes.add("wizard");
    }
    if (CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP.equalsIgnoreCase(iWantDocument.getStep())) {
        editModes.add(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
        // remove all others
        editModes.remove(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
        editModes.remove(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
        editModes.remove(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
    }
    if (CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP.equalsIgnoreCase(iWantDocument.getStep())) {
        editModes.add(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
        // remove all others
        editModes.remove(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
        editModes.remove(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
        editModes.remove(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
    }
    if (CUPurapConstants.IWantDocumentSteps.VENDOR_STEP.equalsIgnoreCase(iWantDocument.getStep())) {
        editModes.add(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
        // remove all others
        editModes.remove(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
        editModes.remove(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
        editModes.remove(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
    }
    if (CUPurapConstants.IWantDocumentSteps.ROUTING_STEP.equalsIgnoreCase(iWantDocument.getStep())) {
        editModes.add(CUPurapConstants.IWantDocumentSteps.ROUTING_STEP);
        // remove all others
        editModes.remove(CUPurapConstants.IWantDocumentSteps.CUSTOMER_DATA_STEP);
        editModes.remove(CUPurapConstants.IWantDocumentSteps.ITEMS_AND_ACCT_DATA_STEP);
        editModes.remove(CUPurapConstants.IWantDocumentSteps.VENDOR_STEP);
    }
    // KFSPTS-2527 only display create req and create DV buttons if neither REQ not DV has been created from I Want doc
    if ((StringUtils.isBlank(iWantDocument.getReqsDocId()) && StringUtils.isBlank(iWantDocument.getDvDocId())) && !workflowDocument.isInitiated() && !workflowDocument.isSaved()) {
        editModes.add(CUPurapConstants.IWNT_DOC_CREATE_REQ);
        editModes.add(CUPurapConstants.IWNT_DOC_CREATE_DV);
    }
    editModes.add(CUPurapConstants.IWNT_DOC_USE_LOOKUPS);
    return editModes;
}
Also used : WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) FinancialSystemWorkflowHelperService(org.kuali.kfs.sys.service.FinancialSystemWorkflowHelperService) IWantDocument(edu.cornell.kfs.module.purap.document.IWantDocument)

Example 13 with WorkflowDocument

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

the class GeneralLedgerTransferDocument method doRouteStatusChange.

@Override
public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
    super.doRouteStatusChange(statusChangeEvent);
    WorkflowDocument workflowDocument = getDocumentHeader().getWorkflowDocument();
    if (statusChangeRequiringGeneralLedgerEntryDocumentNumberRemoval(workflowDocument, statusChangeEvent)) {
        getGeneralLedgerTransferService().updateGeneralLedgerTransferEntry(getSourceAccountingLines(), null);
    }
}
Also used : WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument)

Example 14 with WorkflowDocument

use of org.kuali.kfs.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.kfs.kew.api.WorkflowDocument) FinancialSystemDocumentHeader(org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader) DocumentHeader(org.kuali.kfs.krad.bo.DocumentHeader)

Example 15 with WorkflowDocument

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

the class MaintenanceUtils method checkDocumentBlockingDocumentId.

public static void checkDocumentBlockingDocumentId(String blockingDocId, boolean throwExceptionIfLocked) {
    // if we got nothing, then no docs are blocking, and we're done
    if (StringUtils.isBlank(blockingDocId)) {
        return;
    }
    if (MaintenanceUtils.LOG.isInfoEnabled()) {
        MaintenanceUtils.LOG.info("Locking document found:  docId = " + blockingDocId + ".");
    }
    // load the blocking locked document
    WorkflowDocument lockedDocument = null;
    try {
        // occur, even though the exception would be caught here
        if (KewApiServiceLocator.getWorkflowDocumentService().doesDocumentExist(blockingDocId)) {
            /*
                 * CU Customization KFSPTS-23120 investigate NPE
                 * Moved the getPerson to a variable to more clearly see what aspect is causing the NPE
                 */
            try {
                Person person = GlobalVariables.getUserSession().getPerson();
                lockedDocument = KewApiServiceLocator.getWorkflowDocumentService().loadWorkflowDocument(blockingDocId, person);
            } catch (NullPointerException npe) {
                LOG.error("checkDocumentBlockingDocumentId, caught an NPE getting the locked document with blockingDocId: " + blockingDocId, npe);
                throw npe;
            }
        }
    } catch (Exception ex) {
        // clean up the lock and notify the admins
        MaintenanceUtils.LOG.error("Unable to retrieve locking document specified in the maintenance lock " + "table: " + blockingDocId, ex);
        cleanOrphanLocks(blockingDocId, ex);
        return;
    }
    if (lockedDocument == null) {
        MaintenanceUtils.LOG.warn("Locking document header for " + blockingDocId + "came back null.");
        cleanOrphanLocks(blockingDocId, null);
    }
    // if we can ignore the lock (see method notes), then exit cause we're done
    if (lockCanBeIgnored(lockedDocument)) {
        return;
    }
    // build the link URL for the blocking document
    Map<String, String> parameters = new HashMap<>();
    parameters.put(KRADConstants.PARAMETER_DOC_ID, blockingDocId);
    parameters.put(KRADConstants.PARAMETER_COMMAND, KRADConstants.METHOD_DISPLAY_DOC_SEARCH_VIEW);
    String blockingUrl = UrlFactory.parameterizeUrl(KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString(KFSConstants.APPLICATION_URL_KEY) + "/" + KRADConstants.DOC_HANDLER_ACTION, parameters);
    if (MaintenanceUtils.LOG.isDebugEnabled()) {
        MaintenanceUtils.LOG.debug("blockingUrl = '" + blockingUrl + "'");
        MaintenanceUtils.LOG.debug("Maintenance record: " + lockedDocument.getApplicationDocumentId() + "is locked.");
    }
    String[] errorParameters = { blockingUrl, blockingDocId };
    // ErrorMap instead.
    if (throwExceptionIfLocked) {
        // post an error about the locked document
        GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_MAINTENANCE_LOCKED, errorParameters);
        throw new ValidationException("Maintenance Record is locked by another document.");
    } else {
        // Post a warning about the locked document.
        GlobalVariables.getMessageMap().putWarning(KRADConstants.GLOBAL_MESSAGES, WARNING_MAINTENANCE_LOCKED, errorParameters);
    }
}
Also used : ValidationException(org.kuali.kfs.krad.exception.ValidationException) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) HashMap(java.util.HashMap) Person(org.kuali.kfs.kim.api.identity.Person) ValidationException(org.kuali.kfs.krad.exception.ValidationException)

Aggregations

WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)36 Person (org.kuali.kfs.kim.api.identity.Person)5 ArrayList (java.util.ArrayList)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 Iterator (java.util.Iterator)3 List (java.util.List)3 ActionForward (org.apache.struts.action.ActionForward)3 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)3 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)2 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)2 HashMap (java.util.HashMap)2 ActionRequest (org.kuali.kfs.kew.actionrequest.ActionRequest)2 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)2 PurApItem (org.kuali.kfs.module.purap.businessobject.PurApItem)2 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)2 PurchasingAccountsPayableDocument (org.kuali.kfs.module.purap.document.PurchasingAccountsPayableDocument)2 FinancialSystemWorkflowHelperService (org.kuali.kfs.sys.service.FinancialSystemWorkflowHelperService)2 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)1 RecurringDisbursementVoucherDocument (edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument)1 CULegacyTravelService (edu.cornell.kfs.fp.document.service.CULegacyTravelService)1