Example usage for org.apache.commons.lang StringUtils containsIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils containsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils containsIgnoreCase.

Prototype

public static boolean containsIgnoreCase(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String irrespective of case, handling null.

Usage

From source file:org.kuali.kfs.sys.context.SpringConfigurationConsistencyCheckTest.java

public void testServicesShouldHaveParentBeans() {
    List<String> failingBeanNames = new ArrayList<String>();
    for (String beanName : SpringContext.applicationContext.getBeanDefinitionNames()) {
        // skip testing mock beans
        if (StringUtils.containsIgnoreCase(beanName, "mock")) {
            continue;
        }/*from w w w. j  ava 2s .c  o m*/
        BeanDefinition beanDef = SpringContext.applicationContext.getBeanFactory().getBeanDefinition(beanName);
        // skip entries in the rice import files or in testing files
        if (StringUtils.contains(beanDef.getResourceDescription(), "spring-kfs-imported-rice-beans.xml")
                || StringUtils.contains(beanDef.getResourceDescription(), "-test.xml")) {
            continue;
        }
        String serviceClass = beanDef.getBeanClassName();
        if (StringUtils.contains(serviceClass, "service.impl") && //should be a service
                !StringUtils.startsWith(serviceClass, "org.kuali.rice") && //let rice test their code
                !beanDef.isAbstract()) { //abstract = parent

            try {
                BeanDefinition parentBean = SpringContext.applicationContext.getBeanFactory()
                        .getBeanDefinition(beanName + "-parentBean");
                String parentClass = parentBean.getBeanClassName();
            } catch (NoSuchBeanDefinitionException ex) {
                failingBeanNames.add(beanName + " : " + beanDef.getResourceDescription() + "\n");
            }
        }
    }
    assertEquals("The following service beans do not have \"-parentBean\"s:\n" + failingBeanNames, 0,
            failingBeanNames.size());
}

From source file:org.kuali.kra.budget.web.struts.action.BudgetActionsAction.java

protected boolean isFinancialIntegrationOn(AwardBudgetDocument awardBudgetDocument) {
    String parameterValue = getParameterService().getParameterValue(Constants.MODULE_NAMESPACE_AWARD,
            Constants.PARAMETER_COMPONENT_DOCUMENT, Constants.FIN_SYSTEM_INTEGRATION_ON_OFF_PARAMETER);
    if (StringUtils.containsIgnoreCase(parameterValue, Constants.FIN_SYSTEM_INTEGRATION_ON)) {
        return true;
    }/*from  w  ww  .  ja va 2 s.  c o  m*/
    return false;
}

From source file:org.kuali.kra.proposaldevelopment.service.impl.PropDevJavaFunctionKrmsTermServiceImpl.java

@Override
public String attachmentFileNameRule(DevelopmentProposal developmentProposal) {
    for (Narrative narr : developmentProposal.getNarratives()) {
        for (String character : restrictedElements) {
            if (StringUtils.containsIgnoreCase(narr.getFileName(), character)) {
                return FALSE;
            }/*from w w w  .  j  a v  a 2 s.c  o m*/
        }
    }
    return TRUE;
}

From source file:org.kuali.kra.questionnaire.answer.QuestionnaireAnswerServiceImpl.java

protected boolean isAnswerMatched(String condition, String parentAnswer, String conditionValue) {
    boolean valid = false;
    if (ConditionType.CONTAINS_TEXT.getCondition().equals(condition)) {
        valid = StringUtils.containsIgnoreCase(parentAnswer, conditionValue);
    } else if (ConditionType.BEGINS_WITH_TEXT.getCondition().equals(condition)) {
        valid = (StringUtils.startsWithIgnoreCase(parentAnswer, conditionValue));
    } else if (ConditionType.ENDS_WITH_TEXT.getCondition().equals(condition)) {
        valid = (StringUtils.endsWithIgnoreCase(parentAnswer, conditionValue));
    } else if (ConditionType.MATCH_TEXT.getCondition().equals(condition)) {
        valid = parentAnswer.equalsIgnoreCase(conditionValue);
    } else if (Integer.parseInt(condition) >= 5 && Integer.parseInt(condition) <= 10) {
        valid = (ConditionType.LESS_THAN_NUMBER.getCondition().equals(condition)
                && (Integer.parseInt(parentAnswer) < Integer.parseInt(conditionValue)))
                || (ConditionType.LESS_THAN_OR_EQUALS_NUMBER.getCondition().equals(condition)
                        && (Integer.parseInt(parentAnswer) <= Integer.parseInt(conditionValue)))
                || (ConditionType.EQUALS_NUMBER.getCondition().equals(condition)
                        && (Integer.parseInt(parentAnswer) == Integer.parseInt(conditionValue)))
                || (ConditionType.NOT_EQUAL_TO_NUMBER.getCondition().equals(condition)
                        && (Integer.parseInt(parentAnswer) != Integer.parseInt(conditionValue)))
                || (ConditionType.GREATER_THAN_OR_EQUALS_NUMBER.getCondition().equals(condition)
                        && (Integer.parseInt(parentAnswer) >= Integer.parseInt(conditionValue)))
                || (ConditionType.GREATER_THAN_NUMBER.getCondition().equals(condition)
                        && (Integer.parseInt(parentAnswer) > Integer.parseInt(conditionValue)));
    } else if (Integer.parseInt(condition) >= 11) {
        final DateFormat dateFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT_PATTERN);
        try {//  w w w  . ja  va 2  s .  c  om
            Date date1 = new Date(dateFormat.parse(parentAnswer).getTime());
            Date date2 = new Date(dateFormat.parse(conditionValue).getTime());
            valid = (ConditionType.BEFORE_DATE.getCondition().equals(condition) && (date1.before(date2)))
                    || (ConditionType.AFTER_DATE.getCondition().equals(condition) && (date1.after(date2)));
        } catch (Exception e) {

        }

    }
    return valid;
}

From source file:org.kuali.ole.coa.document.validation.impl.AccountRule.java

/**
 * the income stream account is required if account's sub fund group code's fund group code is either GF or CG.
 *
 * @param newAccount/*  w w w .j  av a  2 s.  co  m*/
 * @return true if fund group code (obtained through sub fund group) is in the system parameter INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS (values GF;CG)
 * else return false.
 */
protected boolean checkIncomeStreamAccountRule() {
    // KFSMI-4877: if fund group is in system parameter values then income stream account number must exist.
    if (ObjectUtils.isNotNull(newAccount.getSubFundGroup())
            && StringUtils.isNotBlank(newAccount.getSubFundGroup().getFundGroupCode())) {
        if (ObjectUtils.isNull(newAccount.getIncomeStreamAccount())) {
            String incomeStreamRequiringFundGroupCode = SpringContext.getBean(ParameterService.class)
                    .getParameterValueAsString(Account.class,
                            OLEConstants.ChartApcParms.INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS);
            if (StringUtils.containsIgnoreCase(newAccount.getSubFundGroup().getFundGroupCode(),
                    incomeStreamRequiringFundGroupCode)) {
                GlobalVariables.getMessageMap().putError(OLEPropertyConstants.ACCOUNT_NUMBER,
                        OLEKeyConstants.ERROR_DOCUMENT_BA_NO_INCOME_STREAM_ACCOUNT,
                        newAccount.getAccountNumber());
                return false;
            }
        }
    }
    return true;
}

From source file:org.kuali.ole.fp.document.service.impl.CashReceiptCoverSheetServiceImpl.java

/**
 * Use iText <code>{@link PdfStamper}</code> to stamp information from <code>{@link CashReceiptDocument}</code> into field
 * values on a PDF Form Template.//  w ww.  j  a  v a 2  s  . c om
 * 
 * @param document The cash receipt document the values will be pulled from.
 * @param searchPath The directory path of the template to be used to generate the cover sheet.
 * @param returnStream The output stream the cover sheet will be written to.
 */
protected void stampPdfFormValues(CashReceiptDocument document, String searchPath, OutputStream returnStream)
        throws Exception {
    String templateName = CR_COVERSHEET_TEMPLATE_NM;

    try {
        // populate form with document values

        //KFSMI-7303
        //The PDF template is retrieve through web static URL rather than file path, so the File separator is unnecessary
        final boolean isWebResourcePath = StringUtils.containsIgnoreCase(searchPath, "HTTP");

        //skip the File.separator if reference by web resource
        PdfStamper stamper = new PdfStamper(
                new PdfReader(searchPath + (isWebResourcePath ? "" : File.separator) + templateName),
                returnStream);
        AcroFields populatedCoverSheet = stamper.getAcroFields();

        populatedCoverSheet.setField(DOCUMENT_NUMBER_FIELD, document.getDocumentNumber());
        populatedCoverSheet.setField(INITIATOR_FIELD,
                document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId());
        populatedCoverSheet.setField(CREATED_DATE_FIELD,
                document.getDocumentHeader().getWorkflowDocument().getDateCreated().toString());
        populatedCoverSheet.setField(AMOUNT_FIELD, document.getTotalDollarAmount().toString());
        populatedCoverSheet.setField(ORG_DOC_NUMBER_FIELD,
                document.getDocumentHeader().getOrganizationDocumentNumber());
        populatedCoverSheet.setField(CAMPUS_FIELD, document.getCampusLocationCode());
        if (document.getDepositDate() != null) {
            // This value won't be set until the CR document is
            // deposited. A CR document is deposited only when it has
            // been associated with a Cash Management Document (CMD)
            // and with a Deposit within that CMD. And only when the
            // CMD is submitted and FINAL, will the CR documents
            // associated with it, be "deposited." So this value will
            // fill in at an arbitrarily later point in time. So your
            // code shouldn't expect it, but if it's there, then
            // display it.
            populatedCoverSheet.setField(DEPOSIT_DATE_FIELD, document.getDepositDate().toString());
        }
        populatedCoverSheet.setField(DESCRIPTION_FIELD, document.getDocumentHeader().getDocumentDescription());
        populatedCoverSheet.setField(EXPLANATION_FIELD, document.getDocumentHeader().getExplanation());
        populatedCoverSheet.setField(CHECKS_FIELD, document.getTotalCheckAmount().toString());
        populatedCoverSheet.setField(CURRENCY_FIELD, document.getTotalCashAmount().toString());
        populatedCoverSheet.setField(COIN_FIELD, document.getTotalCoinAmount().toString());
        populatedCoverSheet.setField(CHANGE_OUT_FIELD, document.getTotalChangeAmount().toString());

        populatedCoverSheet.setField(TOTAL_RECONCILIATION_FIELD, document.getTotalDollarAmount().toString());

        stamper.setFormFlattening(true);
        stamper.close();
    } catch (Exception e) {
        LOG.error("Error creating coversheet for: " + document.getDocumentNumber() + ". ::" + e);
        throw e;
    }
}

From source file:org.kuali.ole.fp.document.validation.impl.BudgetAdjustmentAccountingLineAccountIncomeStreamValidation.java

/**
 * Validate that, if current adjustment amount is non zero, account has an associated income stream chart and account
 * @see org.kuali.ole.sys.document.validation.Validation#validate(org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent)
 *//*from  w  ww  . j ava 2 s  . co  m*/
public boolean validate(AttributedDocumentEvent event) {
    boolean accountNumberAllowed = true;
    if (getAccountingLineForValidation().getCurrentBudgetAdjustmentAmount().isNonZero()) {
        getAccountingLineForValidation().refreshReferenceObject("account");

        if (!ObjectUtils.isNull(getAccountingLineForValidation().getAccount())) {
            //KFSMI-4877: if fund group is in system parameter values then income stream account number must exist.
            String fundGroupCode = getAccountingLineForValidation().getAccount().getSubFundGroup()
                    .getFundGroupCode();
            String incomeStreamRequiringFundGroupCode = SpringContext.getBean(ParameterService.class)
                    .getParameterValueAsString(Account.class,
                            OLEConstants.ChartApcParms.INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS);
            if (StringUtils.containsIgnoreCase(fundGroupCode, incomeStreamRequiringFundGroupCode)) {
                if (ObjectUtils
                        .isNull(getAccountingLineForValidation().getAccount().getIncomeStreamAccount())) {
                    GlobalVariables.getMessageMap().putError(OLEPropertyConstants.ACCOUNT_NUMBER,
                            OLEKeyConstants.ERROR_DOCUMENT_BA_NO_INCOME_STREAM_ACCOUNT,
                            getAccountingLineForValidation().getAccountNumber());
                    accountNumberAllowed = false;
                }
            }
        }
    }

    return accountNumberAllowed;
}

From source file:org.kuali.ole.gl.batch.service.impl.CollectorReportServiceImpl.java

/**
 * Sends email message to batch mailing list notifying of email send failures during the collector processing
 * /*from   w  w w. j  av a  2s . c  o  m*/
 * @param collectorReportData - data from collector run
 */
protected void sendEmailSendFailureNotice(CollectorReportData collectorReportData) {
    MailMessage message = new MailMessage();

    String returnAddress = parameterService.getParameterValueAsString(OLEConstants.ParameterNamespaces.GL,
            "Batch", OLEConstants.FROM_EMAIL_ADDRESS_PARM_NM);
    if (StringUtils.isEmpty(returnAddress)) {
        returnAddress = mailService.getBatchMailingList();
    }
    message.setFromAddress(returnAddress);

    String subject = configurationService
            .getPropertyValueAsString(OLEKeyConstants.ERROR_COLLECTOR_EMAILSEND_NOTIFICATION_SUBJECT);
    String productionEnvironmentCode = configurationService
            .getPropertyValueAsString(OLEConstants.PROD_ENVIRONMENT_CODE_KEY);
    String environmentCode = configurationService.getPropertyValueAsString(OLEConstants.ENVIRONMENT_KEY);
    if (!StringUtils.equals(productionEnvironmentCode, environmentCode)) {
        subject = environmentCode + ": " + subject;
    }
    message.setSubject(subject);

    boolean hasEmailSendErrors = false;

    String body = configurationService
            .getPropertyValueAsString(OLEKeyConstants.ERROR_COLLECTOR_EMAILSEND_NOTIFICATION_BODY);
    for (String batchId : collectorReportData.getEmailSendingStatus().keySet()) {
        String emailStatus = collectorReportData.getEmailSendingStatus().get(batchId);
        if (StringUtils.containsIgnoreCase(emailStatus, "error")) {
            body += "Batch: " + batchId + " - " + emailStatus + "\n";
            hasEmailSendErrors = true;
        }
    }
    message.setMessage(body);

    message.addToAddress(mailService.getBatchMailingList());

    try {
        if (hasEmailSendErrors) {
            mailService.sendMessage(message);
            LOG.info("Email failure notice has been sent to : " + message.getToAddresses());
        }
    } catch (Exception e) {
        LOG.error("sendErrorEmail() Invalid email address. Message not sent", e);
    }
}

From source file:org.kuali.ole.module.purap.document.web.struts.PurchasingActionBase.java

/**
 * @see org.kuali.ole.sys.web.struts.KualiAccountingDocumentActionBase#refresh(org.apache.struts.action.ActionMapping,
 *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from w  w  w  .  j  a va 2s .  c  o m*/
@Override
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    PurchasingAccountsPayableFormBase baseForm = (PurchasingAccountsPayableFormBase) form;

    PurchasingDocument document = (PurchasingDocument) baseForm.getDocument();
    String refreshCaller = baseForm.getRefreshCaller();
    BusinessObjectService businessObjectService = SpringContext.getBean(BusinessObjectService.class);
    PhoneNumberService phoneNumberService = SpringContext.getBean(PhoneNumberService.class);

    // Format phone numbers
    document.setInstitutionContactPhoneNumber(
            phoneNumberService.formatNumberIfPossible(document.getInstitutionContactPhoneNumber()));
    document.setRequestorPersonPhoneNumber(
            phoneNumberService.formatNumberIfPossible(document.getRequestorPersonPhoneNumber()));
    document.setDeliveryToPhoneNumber(
            phoneNumberService.formatNumberIfPossible(document.getDeliveryToPhoneNumber()));

    //names in KIM are longer than what we store these names at; truncate them to match our data dictionary maxlengths
    if (StringUtils.equals(refreshCaller, "kimPersonLookupable")) {
        Integer deliveryToNameMaxLength = SpringContext.getBean(DataDictionaryService.class)
                .getAttributeMaxLength(document.getClass(), PurapPropertyConstants.DELIVERY_TO_NAME);
        if (StringUtils.isNotEmpty(document.getDeliveryToName())
                && ObjectUtils.isNotNull(deliveryToNameMaxLength)
                && document.getDeliveryToName().length() > deliveryToNameMaxLength.intValue()) {
            document.setDeliveryToName(document.getDeliveryToName().substring(0, deliveryToNameMaxLength));
            GlobalVariables.getMessageMap().clearErrorPath();
            GlobalVariables.getMessageMap().addToErrorPath(PurapConstants.DELIVERY_TAB_ERRORS);
            GlobalVariables.getMessageMap().putWarning(PurapPropertyConstants.DELIVERY_TO_NAME,
                    PurapKeyConstants.WARNING_DELIVERY_TO_NAME_TRUNCATED);
            GlobalVariables.getMessageMap().removeFromErrorPath(PurapConstants.DELIVERY_TAB_ERRORS);
        }

        Integer requestorNameMaxLength = SpringContext.getBean(DataDictionaryService.class)
                .getAttributeMaxLength(document.getClass(), PurapPropertyConstants.REQUESTOR_PERSON_NAME);
        if (StringUtils.isNotEmpty(document.getRequestorPersonName())
                && ObjectUtils.isNotNull(requestorNameMaxLength)
                && document.getRequestorPersonName().length() > requestorNameMaxLength.intValue()) {
            document.setRequestorPersonName(
                    document.getRequestorPersonName().substring(0, requestorNameMaxLength));
            GlobalVariables.getMessageMap().clearErrorPath();
            GlobalVariables.getMessageMap().addToErrorPath(PurapConstants.ADDITIONAL_TAB_ERRORS);
            GlobalVariables.getMessageMap().putWarning(PurapPropertyConstants.REQUESTOR_PERSON_NAME,
                    PurapKeyConstants.WARNING_REQUESTOR_NAME_TRUNCATED);
            GlobalVariables.getMessageMap().removeFromErrorPath(PurapConstants.ADDITIONAL_TAB_ERRORS);
        }
    }

    // Refreshing the fields after returning from a vendor lookup in the vendor tab
    if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_LOOKUPABLE_IMPL)
            && document.getVendorDetailAssignedIdentifier() != null
            && document.getVendorHeaderGeneratedIdentifier() != null) {
        document.setVendorContractGeneratedIdentifier(null);
        document.refreshReferenceObject("vendorContract");

        // retrieve vendor based on selection from vendor lookup
        document.refreshReferenceObject("vendorDetail");
        document.templateVendorDetail(document.getVendorDetail());

        // populate default address based on selected vendor
        VendorAddress defaultAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(
                document.getVendorDetail().getVendorAddresses(), document.getVendorDetail().getVendorHeader()
                        .getVendorType().getAddressType().getVendorAddressTypeCode(),
                document.getDeliveryCampusCode());
        document.templateVendorAddress(defaultAddress);

    }

    // Refreshing the fields after returning from a contract lookup in the vendor tab
    if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_CONTRACT_LOOKUPABLE_IMPL)) {
        if (StringUtils.isNotEmpty(request.getParameter(
                OLEPropertyConstants.DOCUMENT + "." + PurapPropertyConstants.VENDOR_CONTRACT_ID))) {
            // retrieve Contract based on selection from contract lookup
            VendorContract refreshVendorContract = new VendorContract();
            refreshVendorContract
                    .setVendorContractGeneratedIdentifier(document.getVendorContractGeneratedIdentifier());
            refreshVendorContract = (VendorContract) businessObjectService.retrieve(refreshVendorContract);

            // retrieve Vendor based on selected contract
            document.setVendorHeaderGeneratedIdentifier(
                    refreshVendorContract.getVendorHeaderGeneratedIdentifier());
            document.setVendorDetailAssignedIdentifier(
                    refreshVendorContract.getVendorDetailAssignedIdentifier());
            document.refreshReferenceObject("vendorDetail");
            document.templateVendorDetail(document.getVendorDetail());

            // always template contract after vendor to keep contract defaults last
            document.templateVendorContract(refreshVendorContract);

            // populate default address from selected vendor
            VendorAddress defaultAddress = SpringContext.getBean(VendorService.class).getVendorDefaultAddress(
                    document.getVendorDetail().getVendorAddresses(), document.getVendorDetail()
                            .getVendorHeader().getVendorType().getAddressType().getVendorAddressTypeCode(),
                    "");
            document.templateVendorAddress(defaultAddress);

            // update internal dollar limit for PO since the contract might affect this value
            if (document instanceof PurchaseOrderDocument) {
                PurchaseOrderDocument poDoc = (PurchaseOrderDocument) document;
                KualiDecimal limit = SpringContext.getBean(PurchaseOrderService.class)
                        .getInternalPurchasingDollarLimit(poDoc);
                poDoc.setInternalPurchasingLimit(limit);
            }
        }
    }

    // Refreshing the fields after returning from an address lookup in the vendor tab
    if (StringUtils.equals(refreshCaller, VendorConstants.VENDOR_ADDRESS_LOOKUPABLE_IMPL)) {
        if (StringUtils.isNotEmpty(request.getParameter(
                OLEPropertyConstants.DOCUMENT + "." + PurapPropertyConstants.VENDOR_ADDRESS_ID))) {
            // retrieve address based on selection from address lookup
            VendorAddress refreshVendorAddress = new VendorAddress();
            refreshVendorAddress
                    .setVendorAddressGeneratedIdentifier(document.getVendorAddressGeneratedIdentifier());
            refreshVendorAddress = (VendorAddress) businessObjectService.retrieve(refreshVendorAddress);
            document.templateVendorAddress(refreshVendorAddress);
        }
    }

    // Refreshing corresponding fields after returning from various kuali lookups
    if (StringUtils.equals(refreshCaller, OLEConstants.KUALI_LOOKUPABLE_IMPL)) {
        if (request.getParameter("document.deliveryCampusCode") != null) {
            // returning from a building or campus lookup on the delivery tab (update billing address)
            BillingAddress billingAddress = new BillingAddress();
            billingAddress.setBillingCampusCode(document.getDeliveryCampusCode());
            Map keys = SpringContext.getBean(PersistenceService.class).getPrimaryKeyFieldValues(billingAddress);
            billingAddress = SpringContext.getBean(BusinessObjectService.class)
                    .findByPrimaryKey(BillingAddress.class, keys);
            document.templateBillingAddress(billingAddress);

            if (request.getParameter("document.deliveryBuildingName") == null) {
                // came from campus lookup not building, so clear building
                document.setDeliveryBuildingCode("");
                document.setDeliveryBuildingName("");
                document.setDeliveryBuildingLine1Address("");
                document.setDeliveryBuildingLine2Address("");
                document.setDeliveryBuildingRoomNumber("");
                document.setDeliveryCityName("");
                document.setDeliveryStateCode("");
                document.setDeliveryPostalCode("");
                document.setDeliveryCountryCode("");
            } else {
                // came from building lookup then turn off "OTHER" and clear room and line2address
                document.setDeliveryBuildingOtherIndicator(false);
                document.setDeliveryBuildingRoomNumber("");
                document.setDeliveryBuildingLine2Address("");
            }
        } else if (request.getParameter("document.chartOfAccountsCode") != null) {
            // returning from a chart/org lookup on the document detail tab (update receiving address)
            document.loadReceivingAddress();
        } else {
            String buildingCodeParam = findBuildingCodeFromCapitalAssetBuildingLookup(request);
            if (!StringUtils.isEmpty(buildingCodeParam)) {
                // returning from a building lookup in a capital asset tab location (update location address)
                PurchasingFormBase purchasingForm = (PurchasingFormBase) form;
                CapitalAssetLocation location = null;

                // get building code
                String buildingCode = request.getParameterValues(buildingCodeParam)[0];
                // get campus code
                String campusCodeParam = buildingCodeParam.replace("buildingCode", "campusCode");
                String campusCode = request.getParameterValues(campusCodeParam)[0];
                // lookup building
                Building locationBuilding = new Building();
                locationBuilding.setCampusCode(campusCode);
                locationBuilding.setBuildingCode(buildingCode);
                Map<String, String> keys = SpringContext.getBean(PersistenceService.class)
                        .getPrimaryKeyFieldValues(locationBuilding);
                locationBuilding = SpringContext.getBean(BusinessObjectService.class)
                        .findByPrimaryKey(Building.class, keys);

                Map<String, String> parameters = request.getParameterMap();
                Set<String> parameterKeys = parameters.keySet();
                String locationCapitalAssetLocationNumber = "";
                String locationCapitalAssetItemNumber = "";
                for (String parameterKey : parameterKeys) {
                    if (StringUtils.containsIgnoreCase(parameterKey, "newPurchasingCapitalAssetLocationLine")) {
                        // its the new line
                        if (document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode()
                                .equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
                            // get the item number
                            locationCapitalAssetItemNumber = getCaptialAssetItemNumberFromParameter(
                                    parameterKey);
                            PurchasingCapitalAssetItem capitalAssetItem = document
                                    .getPurchasingCapitalAssetItems()
                                    .get(Integer.parseInt(locationCapitalAssetItemNumber));
                            location = capitalAssetItem.getPurchasingCapitalAssetSystem()
                                    .getNewPurchasingCapitalAssetLocationLine();
                        } else {
                            // no item number
                            location = purchasingForm.getNewPurchasingCapitalAssetLocationLine();
                        }
                        break;
                    } else if (StringUtils.containsIgnoreCase(parameterKey,
                            "purchasingCapitalAssetLocationLine")) {
                        // its one of the numbered lines, lets
                        locationCapitalAssetLocationNumber = getCaptialAssetLocationNumberFromParameter(
                                parameterKey);

                        if (document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode()
                                .equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
                            // get the item number
                            locationCapitalAssetItemNumber = getCaptialAssetItemNumberFromParameter(
                                    parameterKey);
                            PurchasingCapitalAssetItem capitalAssetItem = document
                                    .getPurchasingCapitalAssetItems()
                                    .get(Integer.parseInt(locationCapitalAssetItemNumber));
                            location = capitalAssetItem.getPurchasingCapitalAssetSystem()
                                    .getCapitalAssetLocations()
                                    .get(Integer.parseInt(locationCapitalAssetLocationNumber));
                        }
                        break;
                    } else if (StringUtils.containsIgnoreCase(parameterKey, "purchasingCapitalAssetSystems")) {
                        // its one of the numbered lines, lets
                        locationCapitalAssetLocationNumber = getCaptialAssetLocationNumberFromParameter(
                                parameterKey);

                        if (!document.getCapitalAssetSystemType().getCapitalAssetSystemTypeCode()
                                .equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
                            CapitalAssetSystem capitalAssetSystem = document.getPurchasingCapitalAssetSystems()
                                    .get(0);
                            location = capitalAssetSystem.getCapitalAssetLocations()
                                    .get(Integer.parseInt(locationCapitalAssetLocationNumber));
                        }
                        break;
                    }
                }

                if ((location != null) && (locationBuilding != null)) {
                    location.templateBuilding(locationBuilding);
                }
            }
        }
    }
    return super.refresh(mapping, form, request, response);
}

From source file:org.kuali.ole.sys.batch.service.impl.SchedulerServiceImpl.java

protected boolean isPastScheduleCutoffTime(Calendar dateTime, boolean log) {
    try {/* w ww  .  j a v a  2  s .  co  m*/
        Date scheduleCutoffTimeTemp = scheduler.getTriggersOfJob(SCHEDULE_JOB_NAME, SCHEDULED_GROUP)[0]
                .getPreviousFireTime();
        Calendar scheduleCutoffTime;
        if (scheduleCutoffTimeTemp == null) {
            scheduleCutoffTime = dateTimeService.getCurrentCalendar();
        } else {
            scheduleCutoffTime = dateTimeService.getCalendar(scheduleCutoffTimeTemp);
        }
        String cutoffParameter = parameterService.getParameterValueAsString(ScheduleStep.class,
                OLEConstants.SystemGroupParameterNames.BATCH_SCHEDULE_CUTOFF_TIME);
        String[] scheduleStepCutoffTime = StringUtils.split(cutoffParameter, ":");
        if (scheduleStepCutoffTime.length != 3 && scheduleStepCutoffTime.length != 4) {
            throw new IllegalArgumentException(
                    "Error! The " + OLEConstants.SystemGroupParameterNames.BATCH_SCHEDULE_CUTOFF_TIME
                            + " parameter had an invalid value: " + cutoffParameter);
        }
        // if there are 4 components, then we have an AM/PM delimiter
        // otherwise, assume 24-hour time
        if (scheduleStepCutoffTime.length == 4) {
            int hour = Integer.parseInt(scheduleStepCutoffTime[0]);
            // need to adjust for meaning of hour
            if (hour == 12) {
                hour = 0;
            } else {
                hour--;
            }
            scheduleCutoffTime.set(Calendar.HOUR, hour);
            if (StringUtils.containsIgnoreCase(scheduleStepCutoffTime[3], "AM")) {
                scheduleCutoffTime.set(Calendar.AM_PM, Calendar.AM);
            } else {
                scheduleCutoffTime.set(Calendar.AM_PM, Calendar.PM);
            }
        } else {
            scheduleCutoffTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(scheduleStepCutoffTime[0]));
        }
        scheduleCutoffTime.set(Calendar.MINUTE, Integer.parseInt(scheduleStepCutoffTime[1]));
        scheduleCutoffTime.set(Calendar.SECOND, Integer.parseInt(scheduleStepCutoffTime[2]));
        if (parameterService.getParameterValueAsBoolean(ScheduleStep.class,
                OLEConstants.SystemGroupParameterNames.BATCH_SCHEDULE_CUTOFF_TIME_IS_NEXT_DAY)) {
            scheduleCutoffTime.add(Calendar.DAY_OF_YEAR, 1);
        }
        boolean isPastScheduleCutoffTime = dateTime.after(scheduleCutoffTime);
        if (log) {
            LOG.info(new StringBuilder("isPastScheduleCutoffTime=").append(isPastScheduleCutoffTime)
                    .append(" : ").append(dateTimeService.toDateTimeString(dateTime.getTime())).append(" / ")
                    .append(dateTimeService.toDateTimeString(scheduleCutoffTime.getTime())));
        }
        return isPastScheduleCutoffTime;
    } catch (NumberFormatException e) {
        throw new RuntimeException(
                "Caught exception while checking whether we've exceeded the schedule cutoff time", e);
    } catch (SchedulerException e) {
        throw new RuntimeException(
                "Caught exception while checking whether we've exceeded the schedule cutoff time", e);
    }
}