Search in sources :

Example 1 with CULegacyTravelService

use of edu.cornell.kfs.fp.document.service.CULegacyTravelService in project cu-kfs by CU-CommunityApps.

the class CuDistributionOfIncomeAndExpenseDocument method doRouteStatusChange.

/**
 * Overridden to interact with the Legacy Travel service
 * @see https://jira.cornell.edu/browse/KFSPTS-2715
 */
@Override
public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
    // If the DI is Cancelled or Disapproved, we need to reopen the trip in the Legacy Travel service.
    if (getDocumentHeader().getWorkflowDocument().isCanceled() || getDocumentHeader().getWorkflowDocument().isDisapproved()) {
        boolean tripReOpened = false;
        boolean isTravelDoc = false;
        List<ActionTaken> actionsTaken = this.getDocumentHeader().getWorkflowDocument().getActionsTaken();
        String disapprovalReason = "";
        if (actionsTaken.size() > 0) {
            String annotation = actionsTaken.get(actionsTaken.size() - 1).getAnnotation();
            if (StringUtils.isNotEmpty(annotation)) {
                disapprovalReason = annotation.substring("Disapproval reason - ".length());
            }
        }
        try {
            CULegacyTravelService cuLegacyTravelService = SpringContext.getBean(CULegacyTravelService.class);
            isTravelDoc = cuLegacyTravelService.isCULegacyTravelIntegrationInterfaceAssociatedWithTrip(this);
            if (isTravelDoc) {
                // This means the DI is a Travel DI
                tripReOpened = cuLegacyTravelService.reopenLegacyTrip(this.getDocumentNumber(), disapprovalReason);
                LOG.info("Trip successfully reopened : " + tripReOpened);
            } else {
                LOG.info("DI is not a travel DI");
            }
        } catch (Exception ex) {
            LOG.error("Exception occurred while trying to cancel a trip.", ex);
        }
    }
    super.doRouteStatusChange(statusChangeEvent);
}
Also used : CULegacyTravelService(edu.cornell.kfs.fp.document.service.CULegacyTravelService) ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException)

Example 2 with CULegacyTravelService

use of edu.cornell.kfs.fp.document.service.CULegacyTravelService in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocument method doRouteStatusChange.

/**
 * Overridden to interact with the Legacy Travel service
 * @see <a href="https://jira.cornell.edu/browse/KFSPTS-2715">https://jira.cornell.edu/browse/KFSPTS-2715</a>
 */
@Override
public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
    // If the DV is Canceled or Disapproved, we need to reopen the trip in the Legacy Travel service.
    if (getDocumentHeader().getWorkflowDocument().isCanceled() || getDocumentHeader().getWorkflowDocument().isDisapproved()) {
        boolean tripReOpened = false;
        boolean isTravelDoc = false;
        List<ActionTaken> actionsTaken = this.getDocumentHeader().getWorkflowDocument().getActionsTaken();
        String disapprovalReason = findDissapprovalReason(actionsTaken);
        try {
            CULegacyTravelService cuLegacyTravelService = SpringContext.getBean(CULegacyTravelService.class);
            isTravelDoc = cuLegacyTravelService.isCULegacyTravelIntegrationInterfaceAssociatedWithTrip(this);
            if (isTravelDoc) {
                // This means the DV is a Travel DV
                tripReOpened = cuLegacyTravelService.reopenLegacyTrip(this.getDocumentNumber(), disapprovalReason);
                LOG.info("Trip successfully reopened : " + tripReOpened);
            } else {
                LOG.info("DV is not a travel DV");
            }
        } catch (Exception ex) {
            LOG.error("Exception occurred while trying to cancel a trip.", ex);
        }
    }
    super.doRouteStatusChange(statusChangeEvent);
}
Also used : CULegacyTravelService(edu.cornell.kfs.fp.document.service.CULegacyTravelService) ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException)

Aggregations

CULegacyTravelService (edu.cornell.kfs.fp.document.service.CULegacyTravelService)2 ActionTaken (org.kuali.kfs.kew.actiontaken.ActionTaken)2 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)2