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

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

Introduction

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

Prototype

public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr) 

Source Link

Document

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

Usage

From source file:org.ligoj.app.plugin.vm.azure.VmAzurePluginResource.java

/**
 * Find the virtual machines matching to the given criteria. Look into virtual machine name only.
 *
 * @param node//from   w w  w  .jav a  2s. c om
 *            the node to be tested with given parameters.
 * @param criteria
 *            the search criteria. Case is insensitive.
 * @return virtual machines.
 */
@GET
@Path("{node:service:.+}/{criteria}")
@Consumes(MediaType.APPLICATION_JSON)
public List<AzureVm> findAllByName(@PathParam("node") final String node,
        @PathParam("criteria") final String criteria) throws IOException {
    // Check the node exists
    if (nodeRepository.findOneVisible(node, securityHelper.getLogin()) == null) {
        return Collections.emptyList();
    }

    // Get all VMs and then filter by its name or id
    final Map<String, String> parameters = pvResource.getNodeParameters(node);
    final String vmJson = StringUtils.defaultString(getAzureResource(parameters, FIND_VM_URL),
            "{\"value\":[]}");
    final AzureVmList azure = objectMapper.readValue(vmJson, AzureVmList.class);
    return azure.getValue().stream().filter(vm -> StringUtils.containsIgnoreCase(vm.getName(), criteria))
            .map(v -> toVm(v, null)).sorted().collect(Collectors.toList());
}

From source file:org.molasdin.wbase.hibernate.cursor.BasicHibernateQueryCursor.java

private void populateFilters(StrBuilder builder, String from, Map<String, FilteringMode> matchModes) {
    if (filters().size() > 0) {
        builder.append(' ');
        if (!StringUtils.containsIgnoreCase(from, "where")) {
            builder.append("where").append(" (");
        } else {//from   w  w w .j av a 2  s .com
            builder.append(" and (");
        }
        int pos = 0;
        for (String prop : filters().keySet()) {
            String translated = translateProperty(prop);
            HibernateMatchMode matchMode = HibernateMatchMode.START;
            if (matchModes.containsKey(prop)) {
                matchMode = HibernateMatchMode.fromFilteringMode(matchModes.get(prop));
            }
            String template = matchMode.template();
            builder.appendSeparator(" and ", pos);
            builder.append(String.format(FILTER_PART, translated,
                    String.format(template, filters().get(prop).getRight())));
            pos++;
        }
        builder.append(")");
    }
}

From source file:org.molasdin.wbase.transaction.profiles.ProfilesManager.java

public TransactionProfile profileFor(final String dbName) {
    String key = CollectionUtils.find(profiles.keySet(), new Predicate<String>() {
        @Override//  www .j  a  va  2  s  . co  m
        public boolean evaluate(String object) {
            return StringUtils.containsIgnoreCase(dbName, object);
        }
    });

    if (key == null) {
        return commonTransactionProfile;
    }

    return profiles.get(key);
}

From source file:org.mskcc.cbio.oncokb.util.AlterationUtils.java

private static Boolean isMatch(Boolean exactMatch, String query, String string) {
    if (string != null) {
        if (exactMatch) {
            if (StringUtils.containsIgnoreCase(string, query)) {
                return true;
            }//from  w w w .j  a v  a 2  s .c om
        } else {
            if (StringUtils.containsIgnoreCase(string, query)) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.mskcc.cbio.oncokb.util.AlterationUtils.java

private static boolean stringContainsItemFromSet(String inputString, Set<String> items) {
    for (String item : items) {
        if (StringUtils.containsIgnoreCase(inputString, item)) {
            return true;
        }/*from   w ww.  j  a v  a2  s  .  com*/
    }
    return false;
}

From source file:org.nqcx.generator.service.generate.impl.GenerateServiceImpl.java

/**
 * @param table   table/*from w  w w.  ja  va 2  s  .  co m*/
 * @param columns columns
 * @param fields  fields
 * @param types   types
 */
private void fillPojo(Table table, String[] columns, String[] fields, String[] types) {
    if (table == null || table.getColumns() == null || columns == null
            || table.getColumns().size() != columns.length || fields == null
            || table.getColumns().size() != fields.length || types == null
            || table.getColumns().size() != types.length)
        return;

    Column c;
    for (int i = 0; i < table.getColumns().size(); i++) {
        if ((c = table.getColumns().get(i)) == null || !c.getField().equalsIgnoreCase(columns[i]))
            continue;

        // column type and length
        Matcher matcher = TYPE_LENGTH_PATTERN.matcher(c.getType());
        if (matcher.matches() && matcher.groupCount() == 4) {
            if (matcher.group(1) != null)
                c.setColumnType(matcher.group(1));
            if (matcher.group(3) != null)
                c.setColumnLength(matcher.group(3));
        }

        c.setField_(fields[i]);
        c.setType_(types[i]);
        c.setNull_(true);

        if ("NO".equals(c.getIsNull())) {
            c.setNull_(false);
        }

        if ("PRI".equalsIgnoreCase(c.getKey()) && StringUtils.containsIgnoreCase(c.getField(), "ID")) {
            c.setId_(true);
            c.setIdType_("INT".equalsIgnoreCase(types[i]) ? "Integer" : "Long");

            c.setMybatisValue("NULL");
        }

        if ("DATETIME".equalsIgnoreCase(c.getType())
                && StringUtils.containsIgnoreCase(c.getField(), "_create")) {
            c.setCm_(true);

            c.setMybatisValue("NOW()");
        }

        if ("TIMESTAMP".equalsIgnoreCase(c.getType())
                && StringUtils.containsIgnoreCase(c.getField(), "_modify")) {
            c.setCm_(true);

            c.setMybatisValue("NULL");
        }
    }
}

From source file:org.openbase.bco.ontology.lib.utility.StringModifier.java

/**
 * Method extracts the service type name of the input state method name (e.g. getPowerState to powerStateService).
 *
 * @param stateMethodName is the state method name, which includes the needed service type name.
 * @return the service type name in camel case (first char lower case, e.g. powerStateService)
 * @throws NotAvailableException is thrown in case the input is null or no valid state (name).
 *//*  ww w  .j  a  v  a  2s .co  m*/
static String getServiceTypeNameFromStateMethodName(final String stateMethodName) throws NotAvailableException {
    Preconditions.checkNotNull(stateMethodName, "Couldn't get service type name, cause input string is null.");
    String serviceTypeName = stateMethodName;

    if (StringUtils.containsIgnoreCase(serviceTypeName, MethodRegEx.GET.getName())) {
        final int indexOfGet = StringUtils.indexOfIgnoreCase(serviceTypeName, MethodRegEx.GET.getName());
        final int lengthOfGet = MethodRegEx.GET.getName().length();

        serviceTypeName = serviceTypeName.substring(indexOfGet + lengthOfGet);
        serviceTypeName = firstCharToLowerCase(serviceTypeName);

        if (StringUtils.contains(serviceTypeName, MethodRegEx.STATE.getName())) {
            final int indexOfState = serviceTypeName.indexOf(MethodRegEx.STATE.getName());
            final int lengthOfState = MethodRegEx.STATE.getName().length();

            serviceTypeName = serviceTypeName.substring(0, indexOfState + lengthOfState);
            serviceTypeName += MethodRegEx.SERVICE.getName();
        }
    }

    if (OntConfig.SERVICE_NAME_MAP.keySet().contains(serviceTypeName)) {
        return serviceTypeName;
    } else {
        throw new NotAvailableException("Input string is no state (method) name! " + serviceTypeName);
    }
}

From source file:org.openiot.ui.request.definition.web.scopes.session.context.pages.ApplicationDesignPageContext.java

public void updateAvailableSensors(SensorTypes sensorTypes) {
    List<GraphNode> sensorList = availableNodesByTypeMap.get("SOURCE");
    sensorList.clear();/*from  w  w  w . j  av a  2s .c o m*/
    for (SensorType sensorType : sensorTypes.getSensorType()) {
        GenericSource source = new GenericSource();
        source.setLabel(sensorType.getName());
        source.setType("SOURCE");

        // Copy selected filter params
        source.getPropertyValueMap().put("LAT", filterLocationLat);
        source.getPropertyValueMap().put("LON", filterLocationLon);
        source.getPropertyValueMap().put("RADIUS", filterLocationRadius);

        // Initialize sensor endpoints
        List<GraphNodeEndpoint> endpointList = new ArrayList<GraphNodeEndpoint>();
        source.setEndpointDefinitions(endpointList);

        // Add an additional endpoint for filtering options
        GraphNodeEndpoint endpoint = new DefaultGraphNodeEndpoint();
        endpoint.setAnchor(AnchorType.Left);
        endpoint.setConnectorType(ConnectorType.Dot);
        endpoint.setMaxConnections(1);
        endpoint.setRequired(false);
        endpoint.setType(EndpointType.Input);
        endpoint.setLabel("SEL_FILTER_IN");
        endpoint.setScope("Sensor");
        endpointList.add(endpoint);

        for (MeasurementCapability cap : sensorType.getMeasurementCapability()) {
            if (cap.getUnit() == null || cap.getUnit().isEmpty()) {
                continue;
            }

            endpoint = new DefaultGraphNodeEndpoint();
            endpoint.setAnchor(AnchorType.Right);
            endpoint.setConnectorType(ConnectorType.Rectangle);
            endpoint.setMaxConnections(-1);
            endpoint.setRequired(false);
            endpoint.setType(EndpointType.Output);
            String label = cap.getType();
            if (label.contains("#")) {
                label = label.substring(label.indexOf('#') + 1);
            }
            if (!cap.getUnit().isEmpty() && cap.getUnit().get(0).getName() != null
                    && !cap.getUnit().get(0).getName().equals("null")
                    && !cap.getUnit().get(0).getName().isEmpty()) {
                label += " (" + cap.getUnit().get(0).getName() + ")";
            }
            endpoint.setLabel(label);
            endpoint.setUserData(cap.getType());

            String scope = "Number";
            String capScope = cap.getUnit().get(0).getType();
            if (StringUtils.containsIgnoreCase(capScope, "Int")) {
                scope = "Integer";
            } else if (StringUtils.containsIgnoreCase(capScope, "Long")) {
                scope = "Long";
            } else if (StringUtils.containsIgnoreCase(capScope, "Float")) {
                scope = "Float";
            } else if (StringUtils.containsIgnoreCase(capScope, "Double")) {
                scope = "Double";
            } else if (StringUtils.containsIgnoreCase(capScope, "Decimal")) {
                scope = "Number";
            } else if (StringUtils.containsIgnoreCase(capScope, "Date")) {
                scope = "Date";
            }

            endpoint.setScope("sensor_" + scope);

            // Add to endpoint list
            endpointList.add(endpoint);
        }

        // Add additional endpoint for sensor lat
        endpoint = new DefaultGraphNodeEndpoint();
        endpoint.setAnchor(AnchorType.Right);
        endpoint.setConnectorType(ConnectorType.Rectangle);
        endpoint.setMaxConnections(-1);
        endpoint.setRequired(false);
        endpoint.setType(EndpointType.Output);
        endpoint.setLabel("LAT");
        endpoint.setUserData("geo:lat");
        endpoint.setScope("geo_lat");
        endpointList.add(endpoint);

        // Add additional endpoint for sensor lon
        endpoint = new DefaultGraphNodeEndpoint();
        endpoint.setAnchor(AnchorType.Right);
        endpoint.setConnectorType(ConnectorType.Rectangle);
        endpoint.setMaxConnections(-1);
        endpoint.setRequired(false);
        endpoint.setType(EndpointType.Output);
        endpoint.setLabel("LON");
        endpoint.setUserData("geo:lon");
        endpoint.setScope("geo_lon");
        endpointList.add(endpoint);

        // Add sensor to toolbox
        sensorList.add(source);
    }
}

From source file:org.openmrs.projectbuendia.webservices.rest.UserResource.java

/** Searches for Providers whose names contain the 'q' parameter. */
private SimpleObject searchInner(RequestContext requestContext) throws ResponseException {
    // Partial string query for searches.
    String query = requestContext.getParameter("q");

    // Retrieve all patients and filter the list based on the query.
    List<Provider> filteredProviders = new ArrayList<>();

    // Perform a substring search on username.
    for (Provider provider : providerService.getAllProviders(false)) {
        if (StringUtils.containsIgnoreCase(provider.getName(), query)) {
            filteredProviders.add(provider);
        }/*from www. ja  v a  2  s.c om*/
    }

    addGuestIfNotPresent(filteredProviders);
    return getSimpleObjectWithResults(filteredProviders);
}

From source file:org.opens.tanaguru.rules.elementchecker.helper.RuleCheckHelper.java

/**
 * This methods parses all the elements retrieved from the scope, extracts
 * the ones where the occurrence "captcha" is found among the attribute values
 * and removes these elements from the initial set of elements.
 * // ww  w  .j  a v a  2  s.c  o  m
 * @param elements
 * @return 
 */
public static Elements extractCaptchaElements(Elements elements) {
    Elements captchaElements = new Elements();
    for (Element el : elements) {
        for (Attribute attr : el.attributes()) {
            if (StringUtils.containsIgnoreCase(attr.getValue(), CAPTCHA_KEYWORD)) {
                captchaElements.add(el);
                break;
            }
        }
        for (Element pel : el.parents()) {
            for (Attribute attr : pel.attributes()) {
                if (StringUtils.containsIgnoreCase(attr.getValue(), CAPTCHA_KEYWORD)) {
                    captchaElements.add(el);
                    break;
                }
            }
        }
    }
    elements.removeAll(captchaElements);
    return captchaElements;
}