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.mifos.framework.persistence.HardcodedValues.java

public static boolean checkLookupValueLocale(String sql) {
    if (StringUtils.containsIgnoreCase(sql, LOOKUP_VALUE_LOCALE)
            && StringUtils.containsIgnoreCase(sql, LOCALE_ID)) {
        return false;
    }/*  www  . ja v a  2  s . c  o  m*/
    return true;
}

From source file:org.mifosplatform.infrastructure.reportmailingjob.service.ReportMailingJobWritePlatformServiceImpl.java

@Override
@CronTarget(jobName = JobName.EXECUTE_REPORT_MAILING_JOBS)
public void executeReportMailingJobs() throws JobExecutionException {
    if (IPv4Helper.applicationIsNotRunningOnLocalMachine()) {
        final Collection<ReportMailingJob> reportMailingJobCollection = this.reportMailingJobRepository
                .findAll();//www  .j  av  a 2  s .  c  o  m

        for (ReportMailingJob reportMailingJob : reportMailingJobCollection) {
            // get the tenant's date as a DateTime object
            final DateTime localDateTimeOftenant = DateUtils.getLocalDateTimeOfTenant().toDateTime();

            final DateTime nextRunDateTime = reportMailingJob.getNextRunDateTime();

            if (nextRunDateTime != null && reportMailingJob.isActive() && reportMailingJob.isNotDeleted()) {

                if (nextRunDateTime.isBefore(localDateTimeOftenant)
                        || nextRunDateTime.isEqual(localDateTimeOftenant)) {
                    // get the emailAttachmentFileFormat enum object
                    final ReportMailingJobEmailAttachmentFileFormat emailAttachmentFileFormat = ReportMailingJobEmailAttachmentFileFormat
                            .instance(reportMailingJob.getEmailAttachmentFileFormat());

                    if (emailAttachmentFileFormat != null
                            && Arrays.asList(ReportMailingJobEmailAttachmentFileFormat.validValues())
                                    .contains(emailAttachmentFileFormat.getId())) {
                        final Report stretchyReport = reportMailingJob.getStretchyReport();
                        final String reportName = (stretchyReport != null) ? stretchyReport.getReportName()
                                : null;
                        final StringBuilder errorLog = new StringBuilder();
                        final Map<String, String> validateStretchyReportParamMap = this.reportMailingJobValidator
                                .validateStretchyReportParamMap(reportMailingJob.getStretchyReportParamMap());
                        Map<String, String> reportParams = new HashMap<>();

                        if (validateStretchyReportParamMap != null) {
                            Iterator<Map.Entry<String, String>> validateStretchyReportParamMapEntries = validateStretchyReportParamMap
                                    .entrySet().iterator();

                            while (validateStretchyReportParamMapEntries.hasNext()) {
                                Map.Entry<String, String> validateStretchyReportParamMapEntry = validateStretchyReportParamMapEntries
                                        .next();
                                String key = validateStretchyReportParamMapEntry.getKey();
                                String value = validateStretchyReportParamMapEntry.getValue();
                                Object[] stretchyReportParamDateOptionsList = ReportMailingJobStretchyReportParamDateOption
                                        .validValues();

                                if (StringUtils.containsIgnoreCase(key, "date")) {
                                    if (Arrays.asList(stretchyReportParamDateOptionsList).contains(value)) {
                                        ReportMailingJobStretchyReportParamDateOption enumOption = ReportMailingJobStretchyReportParamDateOption
                                                .instance(value);

                                        value = ReportMailingJobStretchyReportDateHelper
                                                .getDateAsString(enumOption);
                                    }
                                }

                                reportParams.put(key, value);
                            }
                        }

                        // generate the pentaho report output stream, method in turn call another that sends the file to the email recipients
                        this.generatePentahoReportOutputStream(reportMailingJob, emailAttachmentFileFormat,
                                reportParams, reportName, errorLog);

                        // TODO - write a helper method to handle the generation of the pentaho report file
                        this.updateReportMailingJobAfterJobExecution(reportMailingJob, errorLog,
                                localDateTimeOftenant);
                    }
                }
            }
        }
    }
}

From source file:org.mule.module.pubsubhubbub.handler.PublisherHandler.java

private String getDistributedContentType(final SyndFeed feed) {
    return StringUtils.containsIgnoreCase(feed.getFeedType(), "rss") ? Constants.RSS_CONTENT_TYPE
            : Constants.ATOM_CONTENT_TYPE;
}

From source file:org.netbeans.jpa.modeler.spec.extend.DataMapping.java

public boolean refractorName(String prevName, String newName) {
    if (CodePanel.isRefractorQuery()) {
        if (StringUtils.containsIgnoreCase(this.getName(), FIND_BY + prevName)) {
            this.setName(this.getName().replaceAll("\\b(?i)" + Pattern.quote(FIND_BY + prevName) + "\\b",
                    FIND_BY + StringHelper.firstUpper(newName)));
            return true;
        } else if (StringUtils.containsIgnoreCase(this.getName(), prevName)) {
            this.setName(this.getName().replaceAll("\\b(?i)" + Pattern.quote(prevName) + "\\b", newName));
            return true;
        }/*from ww w  .j a  v  a  2s . co m*/
    }
    return false;
}

From source file:org.netbeans.jpa.modeler.spec.extend.QueryMapping.java

public boolean refractorQuery(String prevQuery, String newQuery) {
    if (CodePanel.isRefractorQuery() && StringUtils.containsIgnoreCase(this.getQuery(), prevQuery)) {
        this.setQuery(this.getQuery().replaceAll("\\b(?i)" + Pattern.quote(prevQuery) + "\\b", newQuery));
        return true;
    } else {// www  . j  a v a 2s . c om
        return false;
    }
}

From source file:org.ngrinder.agent.service.AgentManagerService.java

@Override
public Map<String, MutableInt> getAvailableAgentCountMap(User user) {
    int availableShareAgents = 0;
    int availableUserOwnAgent = 0;
    String myAgentSuffix = "owned_" + user.getUserId();
    for (AgentInfo agentInfo : getAllActive()) {
        // Skip all agents which are disapproved, inactive or
        // have no region prefix.
        if (!agentInfo.isApproved()) {
            continue;
        }/* w ww  . j ava  2  s .c  om*/
        String fullRegion = agentInfo.getRegion();
        // It's this controller's agent
        if (StringUtils.endsWithIgnoreCase(fullRegion, myAgentSuffix)) {
            availableUserOwnAgent++;
        } else if (!StringUtils.containsIgnoreCase(fullRegion, "owned_")) {
            availableShareAgents++;
        }
    }

    int maxAgentSizePerConsole = getMaxAgentSizePerConsole();
    availableShareAgents = (Math.min(availableShareAgents, maxAgentSizePerConsole));
    Map<String, MutableInt> result = new HashMap<String, MutableInt>(1);
    result.put(Config.NONE_REGION, new MutableInt(availableShareAgents + availableUserOwnAgent));
    return result;
}

From source file:org.ngrinder.recorder.util.NetworkUtil.java

private static InetAddress getFirstNonLoopbackAddress(boolean preferIpv4, boolean preferIPv6)
        throws SocketException {
    Enumeration<?> en = NetworkInterface.getNetworkInterfaces();
    while (en.hasMoreElements()) {
        NetworkInterface i = (NetworkInterface) en.nextElement();
        if (!i.isUp()) {
            continue;
        }//w w  w.  ja v  a2s .  co  m
        if (StringUtils.containsIgnoreCase(i.getDisplayName(), "Host-Only")) {
            continue;
        }
        for (Enumeration<?> en2 = i.getInetAddresses(); en2.hasMoreElements();) {
            InetAddress addr = (InetAddress) en2.nextElement();
            if (!addr.isLoopbackAddress()) {
                if (addr instanceof Inet4Address) {
                    if (preferIPv6) {
                        continue;
                    }
                    return addr;
                }
                if (addr instanceof Inet6Address) {
                    if (preferIpv4) {
                        continue;
                    }
                    return addr;
                }
            }
        }
    }
    return null;
}

From source file:org.ngrinder.script.controller.FileEntryController.java

/**
 * Search files on the query.//w  ww  .j a  v a2 s  .  c o m
 *
 * @param user  current user
 * @param query query string
 * @param model model
 * @return script/list
 */
@RequestMapping(value = "/search/**")
public String search(User user, @RequestParam(required = true, value = "query") final String query,
        ModelMap model) {
    final String trimmedQuery = StringUtils.trimToEmpty(query);
    List<FileEntry> searchResult = newArrayList(
            filter(fileEntryService.getAll(user), new Predicate<FileEntry>() {
                @Override
                public boolean apply(@Nullable FileEntry input) {
                    return input != null && input.getFileType() != FileType.DIR && StringUtils
                            .containsIgnoreCase(new File(input.getPath()).getName(), trimmedQuery);
                }
            }));
    model.addAttribute("query", query);
    model.addAttribute("files", searchResult);
    model.addAttribute("currentPath", "");
    return "script/list";
}

From source file:org.niord.core.aton.AtonDefaultsService.java

/**
 * Returns the name of all node types where the name matches the parameter
 *
 * @param name the substring match/*  w ww.  j a v a 2s .  c o m*/
 * @return the name of all node types where the name matches the parameter
 */
public List<String> getNodeTypeNames(String name) {
    return osmDefaults.getNodeTypes().stream().map(ODNodeType::getName)
            .filter(n -> name == null || StringUtils.containsIgnoreCase(n, name)).distinct().sorted()
            .collect(Collectors.toList());
}

From source file:org.niord.core.aton.AtonDefaultsService.java

/**
 * Computes an auto-complete list for OSM tag keys, based on the current AtoN and key
 *
 * @param aton the current AtoN//from  w  w  w . ja  va 2 s  .co m
 * @param keyStr the currently typed key
 * @param maxKeyNo the max number of keys to return
 * @return the auto-complete list
 */
public List<String> computeKeysForAton(AtonNode aton, String keyStr, int maxKeyNo) {

    // Return empty result for empty key string
    if (StringUtils.isBlank(keyStr)) {
        return Collections.emptyList();
    }

    List<ODNodeType> matchingNodeTypes = computeMatchingNodeTypes(aton);
    Set<String> existingTagKeys = aton.getTags().stream().map(AtonTag::getK).collect(Collectors.toSet());

    // Filter the tag keys of the matching node types, such that
    // 1) There is a substring match with the "key" param
    // 2) The key is not already defined in the AtoN
    List<String> result = matchingNodeTypes.stream().flatMap(nt -> nt.getTags().stream()).map(ODTag::getK)
            .filter(k -> StringUtils.containsIgnoreCase(k, keyStr)).filter(k -> !existingTagKeys.contains(k))
            .distinct().limit(maxKeyNo).collect(Collectors.toList());

    // If there is no match from the matching node types, just look for any matching tag key
    if (result.isEmpty()) {
        result = osmDefaults.getNodeTypes().stream().flatMap(nt -> nt.getTags().stream()).map(ODTag::getK)
                .filter(k -> StringUtils.containsIgnoreCase(k, keyStr)).distinct().limit(maxKeyNo).sorted()
                .collect(Collectors.toList());
    }

    return result;
}