Search in sources :

Example 26 with WorkflowException

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

the class RecurringDisbursementVoucherDocumentServiceImpl method autoApproveDisbursementVouchersSpawnedByRecurringDvs.

@Override
public boolean autoApproveDisbursementVouchersSpawnedByRecurringDvs() {
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Entered.");
    int approvalCount = 0;
    int errorCount = 0;
    List<String> dvDocIdsCausingError = new ArrayList<String>();
    Collection<String> dvDocIds = getRecurringDisbursementVoucherSearchDao().findSavedDvIdsSpawnedByRecurringDvForCurrentAndPastFiscalPeriods(getCurrentFiscalPeriodEndDate());
    if (ObjectUtils.isNotNull(dvDocIds) && !(dvDocIds.isEmpty())) {
        for (String dvDocId : dvDocIds) {
            LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Processing start for DV ID:: " + dvDocId);
            CuDisbursementVoucherDocument dv = null;
            try {
                dv = getDisbursementVoucher(dvDocId);
            } catch (WorkflowException e) {
                dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
                errorCount++;
            }
            if (ObjectUtils.isNotNull(dv)) {
                if (isKfsSystemUserDvInitiator(dv)) {
                    try {
                        addNoteToAutoApproveDv(dv, "Batch job Submit and Blanket Approve performed for DV spawned by Recurring DV.");
                        try {
                            blanketApproveDisbursementVoucherDocument(dv);
                            approvalCount++;
                        } catch (WorkflowException e) {
                            dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
                            errorCount++;
                        }
                    } catch (WorkflowException e) {
                        dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
                        errorCount++;
                    }
                } else {
                    LOG.error("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Detected document initiator was not KFS System user. Auto blanket approval was NOT attemtped for document ID: " + dv.getDocumentNumber());
                    dvDocIdsCausingError.add(new String("DocId=" + dvDocId));
                    errorCount++;
                }
            }
        }
    } else {
        LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: No DV's spwned by Recurring DV found. Nothing will be auto approved. ");
    }
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: **************** Batch Job Processing Results ****************");
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Number of Disbursement Vouchers that generated Errors:: " + errorCount);
    for (Iterator iterator = dvDocIdsCausingError.iterator(); iterator.hasNext(); ) {
        LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Erroring " + (String) iterator.next());
    }
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Number of Disbursement Vouchers successfuly Blanket Approved (fully processed):: " + approvalCount);
    LOG.info("autoApproveDisbursementVouchersSpawnedByRecurringDvs: Leaving.");
    return errorCount == 0;
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 27 with WorkflowException

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

the class RecurringDisbursementVoucherDocumentServiceImpl method saveDisbursementVouchers.

private void saveDisbursementVouchers(List<DisbursementVoucherDocument> dvs, RecurringDisbursementVoucherDocument recurringDV) {
    for (DisbursementVoucherDocument dv : dvs) {
        try {
            dv.getDocumentHeader().setDocumentDescription(recurringDV.getDocumentHeader().getDocumentDescription());
            dv.getDocumentHeader().setExplanation(buildDVExplanation(recurringDV));
            getDocumentService().saveDocument(dv);
            getBusinessObjectService().save(recurringDV.getRecurringDisbursementVoucherDetails());
            updateGLPEDatesAndAddRecurringDocumentLinks(dv, recurringDV.getDocumentNumber());
        } catch (WorkflowException e) {
            ;
            LOG.error("saveDisbursementVouchers: There was an error trying to save our route the created Disbursement Voucher documents: ", e);
            throw new RuntimeException(e);
        }
    }
}
Also used : WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)

Example 28 with WorkflowException

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

the class RecurringDisbursementVoucherDocumentServiceImpl method findPdpStatuses.

@Override
public List<RecurringDisbursementVoucherPDPStatus> findPdpStatuses(RecurringDisbursementVoucherDocument recurringDV) {
    List<RecurringDisbursementVoucherPDPStatus> pdpStatuses = new ArrayList<RecurringDisbursementVoucherPDPStatus>();
    for (RecurringDisbursementVoucherDetail detail : recurringDV.getRecurringDisbursementVoucherDetails()) {
        if (StringUtils.isNotEmpty(detail.getDvDocumentNumber())) {
            DisbursementVoucherDocument disbursementVoucherDocument;
            try {
                disbursementVoucherDocument = (DisbursementVoucherDocument) getDocumentService().getByDocumentHeaderId(detail.getDvDocumentNumber());
            } catch (WorkflowException e) {
                LOG.error("findPdpStatuses: There was a problem getting DV from the recurring DV detail: " + e);
                throw new RuntimeException(e);
            }
            pdpStatuses.add(buildRecurringDisbursementVoucherPDPStatus(disbursementVoucherDocument));
        }
    }
    Collections.sort(pdpStatuses);
    return pdpStatuses;
}
Also used : RecurringDisbursementVoucherPDPStatus(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherPDPStatus) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) RecurringDisbursementVoucherDetail(edu.cornell.kfs.fp.businessobject.RecurringDisbursementVoucherDetail) RecurringDisbursementVoucherDocument(edu.cornell.kfs.fp.document.RecurringDisbursementVoucherDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)

Example 29 with WorkflowException

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

the class SecurityRequestDerivedRoleTypeServiceImpl method getRoleMembersFromDerivedRole.

@Override
public List<RoleMembership> getRoleMembersFromDerivedRole(String namespaceCode, String roleName, Map<String, String> qualification) {
    final List<RoleMembership> members = new ArrayList<RoleMembership>();
    LOG.info("getRoleMembersFromDerivedRole() Generating role membership for role: " + roleName + " with qualification " + qualification);
    String documentNumber = qualification.get(AttributeConstants.DOCUMENT_NUMBER);
    SecurityRequestDocument document = null;
    try {
        document = (SecurityRequestDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(documentNumber);
    } catch (WorkflowException e) {
        LOG.error("getRoleMembersFromDerivedRole() Unable to retrieve security request document: " + documentNumber, e);
        throw new RuntimeException("Unable to retrieve security request document: " + documentNumber, e);
    }
    for (final SecurityRequestRole requestRole : document.getSecurityRequestRoles()) {
        members.addAll(getRoleMembersFromDerivedRole(roleName, document, requestRole));
    }
    LOG.info("getRoleMembersFromDerivedRole() Returning " + members.size() + " members");
    return members;
}
Also used : WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) RoleMembership(org.kuali.kfs.kim.api.role.RoleMembership) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 30 with WorkflowException

use of org.kuali.kfs.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.kfs.kew.api.exception.WorkflowException) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Aggregations

WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)52 ArrayList (java.util.ArrayList)12 DocumentService (org.kuali.kfs.krad.service.DocumentService)11 Document (org.kuali.kfs.krad.document.Document)9 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)7 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)7 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)6 RequisitionDocument (org.kuali.kfs.module.purap.document.RequisitionDocument)6 Date (java.sql.Date)5 HashMap (java.util.HashMap)5 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)5 ValidationException (org.kuali.kfs.krad.exception.ValidationException)5 RemoteException (java.rmi.RemoteException)4 ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)4 Person (org.kuali.kfs.kim.api.identity.Person)4 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)4 CuElectronicInvoiceRejectDocument (edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument)3 AccountGlobal (org.kuali.kfs.coa.businessobject.AccountGlobal)3 Note (org.kuali.kfs.krad.bo.Note)3 ContractsGrantsInvoiceDocument (org.kuali.kfs.module.ar.document.ContractsGrantsInvoiceDocument)3