Search in sources :

Example 1 with ActionTaken

use of org.kuali.kfs.kew.actiontaken.ActionTaken 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 ActionTaken

use of org.kuali.kfs.kew.actiontaken.ActionTaken in project cu-kfs by CU-CommunityApps.

the class CuDisbursementVoucherDocument method isCampusReviewRequired.

protected boolean isCampusReviewRequired() {
    List<ActionTaken> actions = RouteContext.getCurrentRouteContext().getDocument().getActionsTaken();
    List<String> people = new ArrayList<String>();
    for (ActionTaken atv : actions) {
        if (!people.contains(atv.getPrincipalId())) {
            people.add(atv.getPrincipalId());
        }
    }
    if (people.size() < 2) {
        return true;
    }
    List<AccountingLine> theList = (List<AccountingLine>) this.sourceAccountingLines;
    for (AccountingLine alb : theList) {
        ParameterEvaluator objectCodes = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator("KFS-FP", "DisbursementVoucher", OBJECT_CODES_REQUIRING_CAMPUS_REVIEW, alb.getFinancialObjectCode());
        if (objectCodes.evaluationSucceeds()) {
            LOG.info("Object Code " + alb.getFinancialObjectCode() + " requires this document to undergo Campus review.");
            return true;
        }
    }
    ParameterEvaluator paymentReasons = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator("KFS-FP", "DisbursementVoucher", PAYMENT_REASONS_REQUIRING_CAMPUS_REVIEW, this.dvPayeeDetail.getDisbVchrPaymentReasonCode());
    if (paymentReasons.evaluationSucceeds()) {
        return true;
    }
    String dollarThreshold = getParameterService().getParameterValueAsString("KFS-FP", "DisbursementVoucher", DOLLAR_THRESHOLD_REQUIRING_CAMPUS_REVIEW);
    KualiDecimal dollarThresholdDecimal = new KualiDecimal(dollarThreshold);
    if (this.disbVchrCheckTotalAmount.isGreaterEqual(dollarThresholdDecimal)) {
        return true;
    }
    return false;
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) List(java.util.List) ArrayList(java.util.ArrayList) ParameterEvaluator(org.kuali.kfs.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.kfs.core.api.parameter.ParameterEvaluatorService) ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken)

Example 3 with ActionTaken

use of org.kuali.kfs.kew.actiontaken.ActionTaken in project cu-kfs by CU-CommunityApps.

the class CuAutoDisapproveDocumentsServiceImpl method buildSuccessMessage.

private String buildSuccessMessage(Document document) throws Exception {
    StringBuilder headerBuilder = new StringBuilder();
    headerBuilder.append(document.getDocumentNumber());
    headerBuilder.append(TAB);
    headerBuilder.append(document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
    headerBuilder.append(TAB);
    headerBuilder.append(document.getDocumentHeader().getDocumentDescription());
    headerBuilder.append(TAB);
    headerBuilder.append(getPersonService().getPerson(document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId()).getPrincipalName());
    headerBuilder.append(TAB);
    headerBuilder.append(getPersonService().getPerson(document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId()).getName());
    headerBuilder.append(TAB);
    headerBuilder.append(document.getDocumentHeader().getWorkflowDocument().getDateCreated());
    headerBuilder.append(TAB);
    ConfigurationService k = KRADServiceLocator.getKualiConfigurationService();
    StringBuilder routeBuilder = new StringBuilder();
    String url = k.getPropertyValueAsString("workflow.url");
    routeBuilder.append(url);
    routeBuilder.append("/RouteLog.do?routeHeaderId=");
    routeBuilder.append(document.getDocumentNumber());
    routeBuilder.append(TAB);
    headerBuilder.append(routeBuilder);
    List<ActionTaken> actions;
    // try {
    // actions = KEWServiceLocator.getActionTakenService().findByDocumentId(document.getDocumentHeader().getWorkflowDocument().getDocumentId());
    actions = KEWServiceLocator.getActionTakenService().findByDocumentIdIgnoreCurrentInd(document.getDocumentNumber());
    ActionTaken max = null;
    for (ActionTaken at : actions) {
        if (ObjectUtils.isNull(max)) {
            max = at;
        } else if (at.getActionDate().compareTo(max.getActionDate()) > 0) {
            max = at;
        }
    }
    headerBuilder.append(getPersonService().getPerson(max.getPrincipalId()).getPrincipalName());
    headerBuilder.append(TAB);
    headerBuilder.append(getPersonService().getPerson(max.getPrincipalId()).getName());
    headerBuilder.append(TAB);
    headerBuilder.append(max.getActionDate());
    headerBuilder.append(TAB);
    headerBuilder.append(max.getActionTakenLabel());
    headerBuilder.append(TAB);
    // } catch (WorkflowException e) {
    // e.printStackTrace();
    // }
    String headerString = headerBuilder.toString();
    StringBuilder builder = new StringBuilder();
    if (document instanceof AccountingDocumentBase) {
        for (Object o : ((AccountingDocumentBase) document).getSourceAccountingLines()) {
            SourceAccountingLine sal = (SourceAccountingLine) o;
            builder.append(headerString);
            builder.append(sal.getChartOfAccountsCode());
            builder.append(TAB);
            builder.append(sal.getAccountNumber());
            builder.append(TAB);
            builder.append(sal.getAmount());
            builder.append(TAB);
            builder.append(sal.getAccount().getOrganizationCode());
            builder.append(TAB);
            builder.append(KFSConstants.NEWLINE);
        }
        for (Object o : ((AccountingDocumentBase) document).getTargetAccountingLines()) {
            TargetAccountingLine tal = (TargetAccountingLine) o;
            builder.append(headerString);
            builder.append(tal.getChartOfAccountsCode());
            builder.append(TAB);
            builder.append(tal.getAccountNumber());
            builder.append(TAB);
            builder.append(tal.getAmount());
            builder.append(TAB);
            builder.append(tal.getAccount().getOrganizationCode());
            builder.append(TAB);
            builder.append(KFSConstants.NEWLINE);
        }
    }
    return builder.toString();
}
Also used : TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) ConfigurationService(org.kuali.kfs.core.api.config.property.ConfigurationService) AccountingDocumentBase(org.kuali.kfs.sys.document.AccountingDocumentBase) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken)

Example 4 with ActionTaken

use of org.kuali.kfs.kew.actiontaken.ActionTaken in project cu-kfs by CU-CommunityApps.

the class ExcludeInitiatorAndSubmitterSeparationOfDutiesRoleTypeService method getSubmitter.

private String getSubmitter(String documentId) {
    String submitterPrincipalId = null;
    String principalId = workflowDocumentService.getRoutedByPrincipalIdByDocumentId(documentId);
    List<ActionTaken> actionTakenDTOs = workflowDocumentService.getActionsTaken(documentId);
    for (ActionTaken actionTaken : actionTakenDTOs) {
        if (StringUtils.equals(principalId, actionTaken.getPrincipalId())) {
            submitterPrincipalId = principalId;
        }
    }
    return submitterPrincipalId;
}
Also used : ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken)

Example 5 with ActionTaken

use of org.kuali.kfs.kew.actiontaken.ActionTaken in project cu-kfs by CU-CommunityApps.

the class ActionTakenDAOOjbImpl method findByActionTakenId.

public ActionTaken findByActionTakenId(String actionTakenId) {
    LOG.debug("finding Action Taken by actionTakenId " + actionTakenId);
    Criteria criteria = new Criteria();
    criteria.addEqualTo("actionTakenId", actionTakenId);
    criteria.addEqualTo("currentIndicator", Boolean.TRUE);
    return (ActionTaken) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(ActionTaken.class, criteria));
}
Also used : QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria) ActionTaken(org.kuali.kfs.kew.actiontaken.ActionTaken)

Aggregations

ActionTaken (org.kuali.kfs.kew.actiontaken.ActionTaken)12 ArrayList (java.util.ArrayList)3 CULegacyTravelService (edu.cornell.kfs.fp.document.service.CULegacyTravelService)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Criteria (org.apache.ojb.broker.query.Criteria)2 QueryByCriteria (org.apache.ojb.broker.query.QueryByCriteria)2 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)2 Person (org.kuali.kfs.kim.api.identity.Person)2 PersonService (org.kuali.kfs.kim.api.identity.PersonService)2 Timestamp (java.sql.Timestamp)1 ParseException (java.text.ParseException)1 Iterator (java.util.Iterator)1 StringTokenizer (java.util.StringTokenizer)1 ActionMessage (org.apache.struts.action.ActionMessage)1 ActionMessages (org.apache.struts.action.ActionMessages)1 ConfigurationService (org.kuali.kfs.core.api.config.property.ConfigurationService)1 ParameterEvaluator (org.kuali.kfs.core.api.parameter.ParameterEvaluator)1 ParameterEvaluatorService (org.kuali.kfs.core.api.parameter.ParameterEvaluatorService)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1