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:com.sfs.whichdoctor.dao.TagDAOImpl.java

/**
 * Creates the tag bean./*from w  w  w . j av a2 s.c  om*/
 *
 * @param tag the tag
 * @param checkUser the check user
 * @param privileges the privileges
 * @return the int
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final int create(final TagBean tag, final UserBean checkUser, final PrivilegesBean privileges)
        throws WhichDoctorDaoException {

    if (tag.getGUID() == 0) {
        throw new WhichDoctorDaoException("Tag must have a GUID > 0");
    }
    if (StringUtils.isBlank(tag.getTagName())) {
        throw new WhichDoctorDaoException("Tag cannot be an empty string");
    }
    if (StringUtils.isBlank(tag.getSecurity())) {
        throw new WhichDoctorDaoException("A security level must be set for the tag");
    }
    if (!this.uniqueTest(tag)) {
        /* The tag submitted is not unique */
        throw new WhichDoctorDaoException("Sorry a tag of these " + "characteristics already exists");
    }

    boolean allowCreate = privileges.getPrivilege(checkUser, tag.getSecurity(), "modify");
    /* If the tag is of type private default to allow */
    if (StringUtils.equalsIgnoreCase(tag.getTagType(), "Private")) {
        allowCreate = true;
    }
    if (!allowCreate) {
        throw new WhichDoctorDaoException("Sorry, you do not have the required privileges to create this tag");
    }

    int objectTypeId = 0;
    try {
        ObjectTypeBean object = this.getObjectTypeDAO().load("Tag Type", "", tag.getTagType());
        objectTypeId = object.getObjectTypeId();
    } catch (Exception e) {
        dataLogger.error("Error identifying object type for tag: " + e.getMessage());
        throw new WhichDoctorDaoException("Error identifying object type for tag");
    }

    int tagId = 0;

    Timestamp sqlTimeStamp = new Timestamp(Calendar.getInstance().getTimeInMillis());

    int updateCount = 0;

    try {
        updateCount = this.getJdbcTemplateWriter().update(this.getSQL().getValue("tag/create"),
                new Object[] { tag.getGUID(), objectTypeId, DataFilter.capitaliseFirst(tag.getTagName()),
                        sqlTimeStamp, checkUser.getDN() });

    } catch (DataAccessException de) {
        dataLogger.error("Error creating tag: " + de.getMessage());
        throw new WhichDoctorDaoException("Error creating tag: " + de.getMessage());
    }

    if (updateCount > 0) {
        dataLogger.info(checkUser.getDN() + " successfully created tag");

        final String findMaxSQL = getSQL().getValue("tag/findMax");

        tagId = this.getJdbcTemplateWriter().queryForInt(findMaxSQL);
    }

    return tagId;
}

From source file:com.edgenius.wiki.service.impl.TestRenderService.java

/**
 * Mark to HTML, then HTML to markup, markup to HTML, final, go back to Markup
 * @throws IOException/*from   ww w  . java2  s  .c  om*/
 */
@Test
public void testMarkupConversion() throws IOException {
    List<TestItem> cases = readTestcaseFile("MarkupConversion");

    for (TestItem testItem : cases) {
        //to html
        List<RenderPiece> pieces = renderService.renderHTML(RenderContext.RENDER_TARGET_RICH_EDITOR,
                TestDataConstants.spaceUname1, TestDataConstants.pageUuid1, testItem.expected, null);
        String html = renderService.renderRichHTML(TestDataConstants.spaceUname1, TestDataConstants.pageUuid1,
                pieces);
        System.out.println(html);

        //goback to markup
        String markup = renderService.renderHTMLtoMarkup(TestDataConstants.spaceUname1, html);

        //go html again
        pieces = renderService.renderHTML(RenderContext.RENDER_TARGET_RICH_EDITOR,
                TestDataConstants.spaceUname1, TestDataConstants.pageUuid1, markup, null);
        html = renderService.renderRichHTML(TestDataConstants.spaceUname1, TestDataConstants.pageUuid1, pieces);

        //return markup 
        markup = renderService.renderHTMLtoMarkup(TestDataConstants.spaceUname1, html);
        if (testItem.input.startsWith("MIXED") || testItem.input == "") {
            if (testItem.input == "") {
                Assert.assertEquals(testItem.expected, markup);
            } else {
                //MIXED - need parse
                final Map<String, String> expMap = new HashMap<String, String>();
                final Map<String, String> outMap = new HashMap<String, String>();
                //maybe the parameter value is in wrong sequence, so have to parse macro and compare
                singleMacroProvider.replaceByTokenVisitor(testItem.expected, new TokenVisitor<Matcher>() {
                    public void handleMatch(StringBuffer buffer, Matcher result) {
                        expMap.put("MACRO_NAME", result.group(1));
                        BaseMacroParameter mParams = new BaseMacroParameter();
                        mParams.setParams(StringEscapeUtil.unescapeHtml(result.group(2)));
                        expMap.putAll(mParams.getParams());
                    }
                });
                singleMacroProvider.replaceByTokenVisitor(markup, new TokenVisitor<Matcher>() {
                    public void handleMatch(StringBuffer buffer, Matcher result) {
                        outMap.put("MACRO_NAME", result.group(1));
                        BaseMacroParameter mParams = new BaseMacroParameter();
                        mParams.setParams(StringEscapeUtil.unescapeHtml(result.group(2)));
                        outMap.putAll(mParams.getParams());
                    }
                });

                for (Entry<String, String> entry : expMap.entrySet()) {
                    if (!StringUtils.equalsIgnoreCase(outMap.remove(entry.getKey()), entry.getValue())) {
                        //this just for throw readable error message and stop test
                        Assert.assertEquals(testItem.expected, markup);
                    }
                }
                if (outMap.size() != 0)
                    //this just for throw readable error message and stop test
                    Assert.assertEquals(testItem.expected, markup);
            }
        } else {
            Assert.assertEquals(testItem.input, markup);
        }
    }
}

From source file:com.bluexml.xforms.generator.forms.renderable.classes.RenderableAttribute.java

@Override
protected void applyConstraints(ModelElementBindSimple meb) {
    if (getMetaInfoValue("email") != null) {
        setConstraintMail(meb);//from  www. j  a v a2 s.c  om
    } else {
        String regularExpression = getMetaInfoValue("regular-expression");
        if (regularExpression != null) {
            setConstraintRegexp(meb, regularExpression);
        }
    }
    setLength(meb, getMetaInfoValue("min-length"), getMetaInfoValue("max-length"));
    setRequired(meb, StringUtils.equalsIgnoreCase(getMetaInfoValue("required"), "true"));
    setHidden(meb, StringUtils.equalsIgnoreCase(getMetaInfoValue("hidden"), "true"));
}

From source file:gov.nih.nci.cabig.caaers.tools.configuration.Configuration.java

public boolean isAuthenticationModeLocal() {
    return StringUtils.equalsIgnoreCase("local", authenticationMode);
}

From source file:com.sfs.whichdoctor.analysis.AgedDebtorsAnalysisDAOImpl.java

/**
 * Load groupings.// w w w. ja  v a2s  .  c om
 *
 * @param analysis the analysis
 * @return the aged debtors analysis bean
 */
private AgedDebtorsAnalysisBean loadGroupings(final AgedDebtorsAnalysisBean analysis) {

    HashMap<Integer, AgedDebtorsRecord> records = buildRecordMap(analysis);

    HashMap<Integer, ReceiptBean> lastReceipts = loadLastReceipts(analysis);

    TreeMap<String, AgedDebtorsGrouping> groupings = new TreeMap<String, AgedDebtorsGrouping>();

    // If there are no records then there is no need to perform any searches
    if (records.size() > 0) {
        // Loop through these for the different periods and in total
        for (Integer periodId : analysis.getPeriods().keySet()) {

            AgedDebtorsPeriod period = analysis.getPeriods().get(periodId);

            for (String type : types) {

                dataLogger.debug("Performing lookup for " + type);

                Collection<AgedDebtorsRecord> results = performLookup(analysis, period, type);

                for (AgedDebtorsRecord result : results) {

                    int guid = result.getPersonGUID();
                    if (result.getOrganisationGUID() > 0) {
                        guid = result.getOrganisationGUID();
                    }

                    String groupName = analysis.getGroupName(guid);

                    AgedDebtorsGrouping grouping = new AgedDebtorsGrouping();
                    grouping.setName(groupName);
                    if (groupings.containsKey(groupName)) {
                        grouping = groupings.get(groupName);
                    }

                    dataLogger.debug("Processing result for GUID: " + guid + ", "
                            + Formatter.toCurrency(result.getOutstandingDebitValue()));

                    AgedDebtorsRecord record = records.get(guid);

                    AgedDebtorsPeriod periodResult = new AgedDebtorsPeriod(period);
                    if (record.getPeriodBreakdown().containsKey(periodId)) {
                        periodResult = record.getPeriodBreakdown().get(periodId);
                    }

                    if (StringUtils.equalsIgnoreCase(type, "debit")) {
                        periodResult.setOutstandingDebitValue(result.getOutstandingDebitValue());

                        // Update the running total for the record
                        record.setOutstandingDebitValue(
                                record.getOutstandingDebitValue() + result.getOutstandingDebitValue());

                        // Update the running total for the period
                        period.setOutstandingDebitValue(
                                period.getOutstandingDebitValue() + result.getOutstandingDebitValue());
                    }
                    if (StringUtils.equalsIgnoreCase(type, "credit")) {
                        periodResult.setUnallocatedCreditValue(result.getOutstandingDebitValue());

                        // Update the running total for the record
                        record.setUnallocatedCreditValue(
                                record.getUnallocatedCreditValue() + result.getOutstandingDebitValue());

                        // Update the running total for the period
                        period.setUnallocatedCreditValue(
                                period.getUnallocatedCreditValue() + result.getOutstandingDebitValue());
                    }
                    if (StringUtils.equalsIgnoreCase(type, "refund")) {
                        periodResult.setUnallocatedRefundValue(result.getOutstandingDebitValue());

                        // Update the running total for the record
                        record.setUnallocatedRefundValue(
                                record.getUnallocatedRefundValue() + result.getOutstandingDebitValue());

                        // Update the running total for the period
                        period.setUnallocatedRefundValue(
                                period.getUnallocatedRefundValue() + result.getOutstandingDebitValue());
                    }
                    if (StringUtils.equalsIgnoreCase(type, "receipt")) {
                        periodResult.setUnallocatedReceiptValue(result.getOutstandingDebitValue());

                        // Update the running total for the record
                        record.setUnallocatedReceiptValue(
                                record.getUnallocatedReceiptValue() + result.getOutstandingDebitValue());

                        // Update the running total for the period
                        period.setUnallocatedReceiptValue(
                                period.getUnallocatedReceiptValue() + result.getOutstandingDebitValue());
                    }

                    // Set the last receipt if one exists for this record
                    if (lastReceipts.containsKey(guid)) {
                        record.setLastReceipt(lastReceipts.get(guid));
                    }

                    record.getPeriodBreakdown().put(periodId, periodResult);
                    grouping.getRecords().put(analysis.getOrderKey(guid), record);
                    groupings.put(groupName, grouping);
                }
            }
            analysis.getPeriods().put(periodId, period);
        }
    }
    analysis.setGroupings(processGroups(groupings, analysis.getShowZeroBalances()));

    return analysis;
}

From source file:edu.wfu.inotado.impl.SyncResourcesServiceImpl.java

@SuppressWarnings("deprecation")
@Override//www  . j a v  a2 s .c om
public void updateAssignmentWithGrades(ScAssignment scAssignment) {
    String siteId = null;
    String siteName = null;
    String userId = null;
    String name = null;

    try {
        siteId = scAssignment.getcourse().getlms_identifier();
        siteName = scAssignment.getcourse().getname();

        // Skip the process if no site found
        Site site = siteService.getSite(siteId);
        if (site == null) {
            log.warn("Unable to find any site with id: " + siteId);
            log.warn("Skip updating assignment.");
            return;
        }

        // Save rubric
        this.saveRubric(scAssignment.getrubric());

        // Find existing assignment or create a new assignment if not found
        Assignment assignment = getOrMakeAssignment(scAssignment, siteId);
        // Skip the process if assignment was not found from previous step
        if (assignment == null) {
            return;
        }

        boolean isAssignmentUpdated = false;

        List<ScAssignmentSubmitssion> scAssignmentSubmitssions = scAssignment.getassignment_submissions();
        for (ScAssignmentSubmitssion scAssignmentSubmitssion : scAssignmentSubmitssions) {
            ScUser user = scAssignmentSubmitssion.getuser();
            userId = user.getlms_identifier();
            name = user.getfirst_name() + " " + user.getlast_name();
            User sakaiUser = null;
            if (StringUtils.isBlank(userId) || StringUtils.equalsIgnoreCase(userId, "null")) {
                String email = user.getemail();
                List<User> users = (List<User>) userDirectoryService.findUsersByEmail(email);
                // get the first user with matching email
                if (users.size() > 0) {
                    sakaiUser = users.get(0);
                } else {
                    // Skip this user
                    log.warn("No user found with email: " + email);
                    continue;
                }
            } else {
                sakaiUser = userDirectoryService.getUserByEid(userId);
            }
            String sakaiUserId = sakaiUser.getId();
            userId = sakaiUser.getEid();

            double grade = scAssignmentSubmitssion.getgrade().gettotal_score();

            // Skip if user does not exist in the site
            if (site.getMember(sakaiUserId) == null) {
                // User does not exist in this site
                log.warn("User " + userId + " is not a member of site \"" + site.getTitle() + "\"(" + siteId
                        + ")");
                continue;
            }

            String assignmentName = assignment.getName();

            Double exGrade = gradebookService.getAssignmentScore(siteId, assignmentName, sakaiUserId);
            if (exGrade != null && exGrade == grade) {
                log.debug("Exact grade entry already exists for user " + sakaiUserId);
            } else {
                gradebookService.setAssignmentScore(siteId, assignmentName, sakaiUserId, grade,
                        "External Sync");

                // update the assignment to reflect its external properties
                if (!isAssignmentUpdated) {
                    Assignment asm = gradebookService.getAssignment(siteId, assignmentName);
                    // update external app name
                    this.genericSakaiDao.updateAssignment(asm.getId(), Constants.SCHOOL_CHAPTERS);
                    isAssignmentUpdated = true;
                }
            }

            // save to school chapters table
            this.saveAssignmentSubmittion(scAssignmentSubmitssion, siteId, assignmentName, sakaiUserId);
        }
        log.info("Successfully processed site \"" + site.getTitle() + "\"(" + site.getId() + ").");
    } catch (IdUnusedException e) {
        log.warn("Unable to find site \"" + siteName + "\" with lms_identifier " + siteId);
    } catch (UserNotDefinedException e) {
        log.warn("Unalble to find user " + name + " with lms_identifier " + userId);
    } catch (Exception e) {
        log.warn("Unexpected error occurred", e);
    }

}

From source file:com.prowidesoftware.swift.model.MxNode.java

/**
 * Recursive implementation of the find by name
 *//*from  w  w  w  .jav a  2s  . c om*/
private MxNode _findFirstByName(final MxNode node, final String name) {
    if (node == null) {
        return null;
    }
    if (StringUtils.equalsIgnoreCase(node.localName, name)) {
        return node;
    } else if (node.children != null) {
        for (final MxNode child : node.children) {
            final MxNode found = _findFirstByName(child, name);
            if (found != null) {
                return found;
            }
        }
    }
    return null;
}

From source file:com.sammyun.controller.console.MemberController.java

/**
 * ??/* w ww  .  ja v  a2  s.  c o m*/
 */
@RequestMapping(value = "/check_idCard", method = RequestMethod.GET)
public @ResponseBody boolean checkIdCard(String previousIdCard, String idCard) {
    if (StringUtils.equalsIgnoreCase(previousIdCard, idCard)) {
        return true;
    }
    if (memberService.idCardUnique(idCard)) {
        return false;
    } else {
        return true;
    }
}

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

/**
 * Gets the collection./*from  w  w  w .java 2 s  .  c om*/
 *
 * @param revenue the revenue
 * @param section the section
 * @return the collection
 */
public static Collection<Object> getCollection(final RevenueBean revenue, final String section) {

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

    if (StringUtils.equalsIgnoreCase(section, "Payments")) {
        if (revenue.getReceipts() != null) {
            for (Integer key : revenue.getReceipts().keySet()) {
                ReceiptBean receipt = revenue.getReceipts().get(key);
                if (receipt != null) {
                    collection.add(receipt);
                }
            }
        }
    }
    return collection;
}

From source file:io.udvi.amqp.mq.transport.session.CAMQPSessionManager.java

protected static Collection<Integer> getAllAttachedChannels(String amqpContainerId) {
    Collection<Integer> sessionList = new ArrayList<>();
    Set<CAMQPConnectionKey> amqpRemoteConnectionKeys = _sessionManager.mappedSessions.keySet();
    for (CAMQPConnectionKey key : amqpRemoteConnectionKeys) {
        if (StringUtils.equalsIgnoreCase(key.getRemoteContainerId(), amqpContainerId)) {
            List<CAMQPSession> sessions = _sessionManager.mappedSessions.get(key);
            if (sessions != null) {
                synchronized (sessions) {
                    for (CAMQPSession session : sessions) {
                        sessionList.add(session.getOutgoingChannelNumber());
                    }//  w  ww.j  a va  2 s  .  c om
                }
            }
        }
    }
    return sessionList;
}