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

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

Introduction

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

Prototype

public static boolean equalsIgnoreCase(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal ignoring the case.

Usage

From source file:de.hybris.platform.b2bacceleratorservices.jalo.promotions.ProductPriceDiscountPromotionByPaymentType.java

@Override
public List<PromotionResult> evaluate(final SessionContext ctx, final PromotionEvaluationContext promoContext) {
    final List<PromotionResult> promotionResults = new ArrayList<PromotionResult>();
    // Find all valid products in the cart
    final PromotionsManager.RestrictionSetResult restrictionResult = this.findEligibleProductsInBasket(ctx,
            promoContext);// w  w  w.ja  v a 2s. c  o m

    if (restrictionResult.isAllowedToContinue() && !restrictionResult.getAllowedProducts().isEmpty()) {
        final PromotionOrderView view = promoContext.createView(ctx, this,
                restrictionResult.getAllowedProducts());
        final AbstractOrder order = promoContext.getOrder();

        for (final PromotionOrderEntry entry : view.getAllEntries(ctx)) {
            // Get the next order entry
            final long quantityToDiscount = entry.getQuantity(ctx);
            if (quantityToDiscount > 0) {
                final long quantityOfOrderEntry = entry.getBaseOrderEntry().getQuantity(ctx).longValue();

                // The adjustment to the order entry
                final double originalUnitPrice = entry.getBasePrice(ctx).doubleValue();
                final double originalEntryPrice = quantityToDiscount * originalUnitPrice;

                final Currency currency = promoContext.getOrder().getCurrency(ctx);
                Double discountPriceValue;

                final EnumerationValue paymentType = B2BAcceleratorServicesManager.getInstance()
                        .getPaymentType(ctx, order);

                if (paymentType != null
                        && StringUtils.equalsIgnoreCase(paymentType.getCode(), getPaymentType().getCode())) {
                    promoContext.startLoggingConsumed(this);
                    discountPriceValue = this.getPriceForOrder(ctx, this.getProductDiscountPrice(ctx),
                            promoContext.getOrder(),
                            ProductPriceDiscountPromotionByPaymentType.PRODUCTDISCOUNTPRICE);

                    final BigDecimal adjustedEntryPrice = Helper.roundCurrencyValue(ctx, currency,
                            originalEntryPrice - (quantityToDiscount * discountPriceValue.doubleValue()));
                    // Calculate the unit price and round it
                    final BigDecimal adjustedUnitPrice = Helper.roundCurrencyValue(ctx, currency,
                            adjustedEntryPrice.equals(BigDecimal.ZERO) ? BigDecimal.ZERO
                                    : adjustedEntryPrice.divide(BigDecimal.valueOf(quantityToDiscount),
                                            RoundingMode.HALF_EVEN));

                    for (final PromotionOrderEntryConsumed poec : view.consume(ctx, quantityToDiscount)) {
                        poec.setAdjustedUnitPrice(ctx, adjustedUnitPrice.doubleValue());
                    }

                    final PromotionResult result = PromotionsManager.getInstance().createPromotionResult(ctx,
                            this, promoContext.getOrder(), 1.0F);
                    result.setConsumedEntries(ctx, promoContext.finishLoggingAndGetConsumed(this, true));
                    final BigDecimal adjustment = Helper.roundCurrencyValue(ctx, currency,
                            adjustedEntryPrice.subtract(BigDecimal.valueOf(originalEntryPrice)));
                    final PromotionOrderEntryAdjustAction poeac = PromotionsManager.getInstance()
                            .createPromotionOrderEntryAdjustAction(ctx, entry.getBaseOrderEntry(),
                                    quantityOfOrderEntry, adjustment.doubleValue());
                    result.addAction(ctx, poeac);
                    promotionResults.add(result);
                }
            }
        }
        final long remainingCount = view.getTotalQuantity(ctx);
        if (remainingCount > 0) {
            promoContext.startLoggingConsumed(this);
            view.consume(ctx, remainingCount);
            final PromotionResult result = PromotionsManager.getInstance().createPromotionResult(ctx, this,
                    promoContext.getOrder(), 0.5F);
            result.setConsumedEntries(ctx, promoContext.finishLoggingAndGetConsumed(this, false));
            promotionResults.add(result);
        }
    }
    return promotionResults;
}

From source file:com.mmj.app.common.checkcode.CheckCodeManager.java

public boolean checkByMD5(CookieManager cookieManager, String checkcode, CookieNameEnum cookieNameEnum) {
    if (!needCheck) {
        return true;
    }//from w w  w. j ava  2  s  . c o m
    if (initException != null) {// ??
        setup();
    }
    boolean stillInitFailed = initException != null;
    if (stillInitFailed) {
        return true;// 
    }

    // ??(??Cookie)
    if (StringUtils.isBlank(checkcode)) {
        return false;
    }
    String checkCodeInCookie = cookieManager.get(cookieNameEnum);
    if (StringUtils.isEmpty(checkCodeInCookie)) {
        return false;
    }
    checkCodeInCookie = Md5Encrypt.md5(StringUtils.lowerCase(checkCodeInCookie));
    boolean isValid = StringUtils.equalsIgnoreCase(checkCodeInCookie, checkcode);
    if (!isValid) {// ???Cookie?
        cookieManager.set(cookieNameEnum, null);
    }
    return isValid;
}

From source file:gov.nih.nci.cabig.caaers.rules.deploy.MedicalInfoBusinessRulesTest.java

/**
 * RuleName : PAT_BR3_CHK/*from   ww  w  . j  av a  2s  . co  m*/
 * Rule : "'Other Primary Site of Disease'  must not be provided if 'Primary Site of Disease' is provided and vice-versa.
 * Error Code : PAT_BR3B_ERR
 * Error Message :  Either and only PRIMARY_SITE_OF_DISEASE or OTHER_PRIMARY_SITE_OF_DISEASE must be provided.
 */
public void testOtherPrimarySiteOfDisease_NullCodedPrimaryDisease() throws Exception {
    ExpeditedAdverseEventReport aeReport = createAEReport();
    aeReport.getSaeReportPreExistingConditions().clear();

    aeReport.getDiseaseHistory().setCodedPrimaryDiseaseSite(null);
    aeReport.getDiseaseHistory().setOtherPrimaryDiseaseSite("OtherSite");

    System.out.println("b0: "
            + NullSafeFieldExtractor.extractField(aeReport, "diseaseHistory.codedPrimaryDiseaseSite.name"));
    System.out.println("b1" + StringUtils.equalsIgnoreCase(
            NullSafeFieldExtractor.extractStringField(aeReport, "diseaseHistory.codedPrimaryDiseaseSite.name"),
            "Other, specify"));

    System.out.println("a1 :" + "null"
            .equals(NullSafeFieldExtractor.extractField(aeReport, "diseaseHistory.codedPrimaryDiseaseSite")));
    System.out.println("a2 :" + StringUtils.equalsIgnoreCase(
            NullSafeFieldExtractor.extractStringField(aeReport, "diseaseHistory.codedPrimaryDiseaseSite.name"),
            "Other, specify"));

    System.out.println("Condition 2 :"
            + NullSafeFieldExtractor.extractField(aeReport, "diseaseHistory.otherPrimaryDiseaseSite") != null);

    ValidationErrors errors = fireRules(aeReport);

    assertEquals("No Errors when OtherPrimarySiteOfDisease is only present", 0, errors.getErrorCount());
}

From source file:hydrograph.ui.graph.editor.JobDeleteParticipant.java

private boolean deleteCorrospondingJobAndPropertyFileifUserDeleteXmlFile(IProject iProject) {
    if (modifiedResource.getProjectRelativePath() != null && StringUtils.equalsIgnoreCase(
            modifiedResource.getProjectRelativePath().segment(0), CustomMessages.ProjectSupport_JOBS)) {
        IFile propertyFileName = null;//from  w  w w . j  a v  a 2 s.c o m
        IFolder jobsFolder = iProject.getFolder(CustomMessages.ProjectSupport_JOBS);
        IFolder propertiesFolder = iProject.getFolder(Messages.PARAM);

        if (jobsFolder != null) {
            jobIFile = jobsFolder.getFile(modifiedResource.getFullPath().removeFirstSegments(2)
                    .removeFileExtension().addFileExtension(Constants.JOB_EXTENSION_FOR_IPATH));
        }
        if (propertiesFolder != null) {
            propertyFileName = propertiesFolder.getFile(modifiedResource.getFullPath().removeFileExtension()
                    .addFileExtension(Constants.PROPERTIES).toFile().getName());
        }
        String message = getErrorMessageIfUserDeleteXmlRelatedFiles(jobIFile, propertyFileName);
        showErrorMessage(jobIFile, propertyFileName, Messages.bind(message, modifiedResource.getName()));
    } else {
        flag = true;
    }
    return flag;
}

From source file:AIR.Common.DB.DataBaseTable.java

public boolean matchesName(String name) {
    if (_dbType == DATABASE_TYPE.SQLSERVER) {
        // TODO Shiva
        // this first check is a safety precaution. we do not want to drop any
        // permanent table.
        if (_tableName.indexOf("@") > -1 || _tableName.indexOf("#") > -1)
            return StringUtils.equalsIgnoreCase(name, _tableName);
        else//www .  j a va  2 s.  c  o  m
            return false;
    } else if (_dbType == DATABASE_TYPE.MYSQL) {
        return StringUtils.equalsIgnoreCase(_tableName, name);
    } else
        throw new InvalidDataBaseTypeSpecification(
                String.format("Database of type %s is not recognized", _dbType));
}

From source file:com.ewcms.component.util.Struts2Util.java

/**
 * ?contentTypeheaders.//w w  w. ja v  a2  s . co  m
 */
private static HttpServletResponse initResponseHeader(final String contentType, final String... headers) {
    //?headers?
    String encoding = DEFAULT_ENCODING;
    boolean noCache = DEFAULT_NOCACHE;
    for (String header : headers) {
        String headerName = StringUtils.substringBefore(header, ":");
        String headerValue = StringUtils.substringAfter(header, ":");

        if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) {
            encoding = headerValue;
        } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) {
            noCache = Boolean.parseBoolean(headerValue);
        } else {
            throw new IllegalArgumentException(headerName + "??header");
        }
    }

    HttpServletResponse response = ServletActionContext.getResponse();

    //headers?
    String fullContentType = contentType + ";charset=" + encoding;
    response.setContentType(fullContentType);
    if (noCache) {
        ServletUtil.setNoCacheHeader(response);
    }

    return response;
}

From source file:ch.entwine.weblounge.maven.MyGengoI18nImport.java

private void importLanguageFile(String name, InputStream file) {
    String lang = name.substring(0, name.indexOf("/"));
    String filename = name.substring(name.indexOf("/") + 1);
    String path;//w  w  w.j ava2s  . c o  m
    if (filename.startsWith(siteId)) {
        log.info("Importing i18n file " + name);
        if ((siteId + "_site.xml").equals(filename)) {
            if (StringUtils.equalsIgnoreCase(lang, defaultLang))
                path = "/i18n/message.xml";
            else
                path = "/i18n/message_" + lang + ".xml";
        } else {
            String filenameNoSite = filename.substring(filename.indexOf("_") + 1);
            String module = filenameNoSite.substring(filenameNoSite.indexOf("_") + 1,
                    filenameNoSite.indexOf("."));
            if (StringUtils.equalsIgnoreCase(lang, defaultLang))
                path = "/modules/" + module + "/i18n/message.xml";
            else
                path = "/modules/" + module + "/i18n/message_" + lang + ".xml";
        }

        File dest = new File(siteRoot, path);
        try {
            FileUtils.forceMkdir(dest.getParentFile());
            if (!dest.exists())
                dest.createNewFile();
            IOUtils.copy(file, new FileOutputStream(dest));
        } catch (IOException e) {
            log.error("Error importing i18n file " + name);
            return;
        }
    }
}

From source file:com.sfs.whichdoctor.dao.ItemDAOImpl.java

/**
 * Used to get a TreeMap of ItemBean details for a specified GUID number.
 *
 * @param guid the guid//from www . j  av  a 2s.  c o  m
 * @param fullResults the full results
 * @param itemTypeVal the item type value
 * @param groupClassVal the group class value
 * @param object2GUID the object2 guid
 * @param startDate the start date
 * @param endDate the end date
 *
 * @return the tree map< string, item bean>
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final TreeMap<String, ItemBean> load(final int guid, final boolean fullResults, final String itemTypeVal,
        final String groupClassVal, final int object2GUID, final String startDate, final String endDate)
        throws WhichDoctorDaoException {

    TreeMap<String, ItemBean> items = new TreeMap<String, ItemBean>();

    String itemType = "Group";
    String groupClass = "Members";
    if (itemTypeVal != null) {
        itemType = itemTypeVal;
    }
    if (groupClass != null) {
        groupClass = groupClassVal;
    }

    if (StringUtils.equalsIgnoreCase(itemType, "Employer")
            || StringUtils.equalsIgnoreCase(itemType, "Employee")) {
        itemType = "Employment";
    }

    java.util.Date dtStartDate = null;
    java.util.Date dtEndDate = null;
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.UK);
    try {
        dtStartDate = df.parse(startDate);
    } catch (Exception e) {
        dataLogger.debug("Error parsing start date: " + e.getMessage());
    }
    try {
        dtEndDate = df.parse(endDate);
    } catch (Exception e) {
        dataLogger.debug("Error parsing end date: " + e.getMessage());
    }
    if (dtStartDate != null && dtEndDate != null && dtStartDate.compareTo(dtEndDate) > 0) {
        /* Start date is greater than end date, switch around */
        java.util.Date tempStartDate = dtStartDate;
        dtStartDate = dtEndDate;
        dtEndDate = tempStartDate;
    }

    StringBuffer loadItems = new StringBuffer();
    ArrayList<Object> parameters = new ArrayList<Object>();
    parameters.add(guid);
    parameters.add(itemType);

    loadItems.append(getLoadSQL(groupClass));

    if (StringUtils.equalsIgnoreCase(groupClass, "Employers")) {
        loadItems.append(" AND items.Object2GUID = ? AND itemtype.Class = ?");
    } else {
        loadItems.append(" AND items.Object1GUID = ? AND itemtype.Class = ?");
    }
    if (object2GUID > 0) {
        loadItems.append(" AND items.Object2GUID = ?");
        parameters.add(object2GUID);
    }

    dataLogger.info("Items for GUID: " + guid + " requested");

    Collection<ItemBean> itemCollection = new ArrayList<ItemBean>();
    try {
        itemCollection = this.getJdbcTemplateReader().query(loadItems.toString(), parameters.toArray(),
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadItem(rs);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }

    for (ItemBean item : itemCollection) {
        if (item.display(dtStartDate, dtEndDate)) {
            items.put(item.getOrderIndex(), item);
        }
    }

    return items;
}

From source file:com.edgenius.wiki.model.PageLink.java

public boolean equals(Object obj) {
    if (!(obj instanceof PageLink))
        return false;
    PageLink ln = (PageLink) obj;/*from ww w  .  j av  a2s  .  co  m*/

    return StringUtils.equalsIgnoreCase(ln.spaceUname, this.spaceUname)
            && StringUtils.equalsIgnoreCase(ln.link, this.link) && ln.type == this.type;
}

From source file:com.sfs.whichdoctor.formatter.AgedDebtorsAnalysisFormatter.java

/**
 * Gets the collection./*  ww w.j  av a2s  . c om*/
 *
 * @param revenue the revenue
 * @param section the section
 * @return the collection
 */
public static Collection<Object> getCollection(final AgedDebtorsGrouping grouping, final String section) {

    Collection<Object> collection = new ArrayList<Object>();

    if (StringUtils.equalsIgnoreCase(section, "Records")) {
        if (grouping.getRecords() != null) {
            for (String order : grouping.getRecords().keySet()) {
                AgedDebtorsRecord record = grouping.getRecords().get(order);
                if (record != null) {
                    collection.add(record);
                }
            }
        }
    }
    return collection;
}