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.ole.sys.businessobject.lookup.ModuleLookupableHelperServiceImpl.java

@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
    super.setBackLocation((String) fieldValues.get(OLEConstants.BACK_LOCATION));
    super.setDocFormKey((String) fieldValues.get(OLEConstants.DOC_FORM_KEY));
    List<ModuleService> modules = SpringContext.getBean(KualiModuleService.class).getInstalledModuleServices();
    String codeValue = fieldValues.get("moduleCode");
    String nameValue = fieldValues.get("moduleName");
    List<KualiModuleBO> boModules = new ArrayList();
    String tempNamespaceName;//from www. j  a  va  2s . c  o m
    for (ModuleService mod : modules) {
        if (!StringUtils.isEmpty(nameValue) && !StringUtils
                .containsIgnoreCase(mod.getModuleConfiguration().getNamespaceCode(), nameValue)) {
            continue;
        }
        tempNamespaceName = SpringContext.getBean(KualiModuleService.class)
                .getNamespaceName(mod.getModuleConfiguration().getNamespaceCode());
        if (!StringUtils.isEmpty(codeValue) && !StringUtils.containsIgnoreCase(tempNamespaceName, codeValue)) {
            continue;
        }
        boModules.add(new KualiModuleBO(mod.getModuleConfiguration().getNamespaceCode(),
                mod.getModuleConfiguration().getNamespaceCode(), tempNamespaceName));
    }
    return boModules;
}

From source file:org.kuali.rice.krad.dao.impl.LookupDaoJpa.java

private void addCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive,
        boolean treatWildcardsAndOperatorsAsLiteral, Criteria criteria) {
    String alias = "";
    String[] keySplit = propertyName.split("\\.");
    if (keySplit.length > 1) {
        alias = keySplit[keySplit.length - 2];
        String variableKey = keySplit[keySplit.length - 1];
        for (int j = 0; j < keySplit.length - 1; j++) {
            if (StringUtils.contains(keySplit[j], Criteria.JPA_ALIAS_PREFIX)) {
                String tempKey = keySplit[j].substring(
                        keySplit[j].indexOf('\'', keySplit[j].indexOf(Criteria.JPA_ALIAS_PREFIX)) + 1,
                        keySplit[j].lastIndexOf('\'', keySplit[j].indexOf(Criteria.JPA_ALIAS_SUFFIX)));
                if (criteria.getAliasIndex(tempKey) == -1) {
                    criteria.join(tempKey, tempKey, false, true);
                }// w ww. j a v  a 2 s.c  o m
            } else {
                if (criteria.getAliasIndex(keySplit[j]) == -1) {
                    criteria.join(keySplit[j], keySplit[j], false, true);
                }
            }
        }
        if (!StringUtils.contains(propertyName, "__JPA_ALIAS[[")) {
            propertyName = "__JPA_ALIAS[['" + alias + "']]__." + variableKey;
        }
    }
    if (!treatWildcardsAndOperatorsAsLiteral && StringUtils.contains(propertyValue, SearchOperator.OR.op())) {
        addOrCriteria(propertyName, propertyValue, propertyType, caseInsensitive, criteria);
        return;
    }

    if (!treatWildcardsAndOperatorsAsLiteral && StringUtils.contains(propertyValue, SearchOperator.AND.op())) {
        addAndCriteria(propertyName, propertyValue, propertyType, caseInsensitive, criteria);
        return;
    }

    if (StringUtils.containsIgnoreCase(propertyValue, SearchOperator.NULL.op())) {
        if (StringUtils.contains(propertyValue, SearchOperator.NOT.op())) {
            criteria.notNull(propertyName);
        } else {
            criteria.isNull(propertyName);
        }
    } else if (TypeUtils.isStringClass(propertyType)) {
        // KULRICE-85 : made string searches case insensitive - used new
        // DBPlatform function to force strings to upper case
        if (caseInsensitive) {
            // TODO: What to do here now that the JPA version does not extend platform aware?
            //propertyName = getDbPlatform().getUpperCaseFunction() + "(__JPA_ALIAS[[0]]__." + propertyName + ")";
            if (StringUtils.contains(propertyName, "__JPA_ALIAS[[")) {
                propertyName = "UPPER(" + propertyName + ")";
            } else {
                propertyName = "UPPER(__JPA_ALIAS[[0]]__." + propertyName + ")";
            }
            propertyValue = propertyValue.toUpperCase();
        }
        if (!treatWildcardsAndOperatorsAsLiteral
                && StringUtils.contains(propertyValue, SearchOperator.NOT.op())) {
            addNotCriteria(propertyName, propertyValue, propertyType, caseInsensitive, criteria);
        } else if (!treatWildcardsAndOperatorsAsLiteral && propertyValue != null
                && (StringUtils.contains(propertyValue, SearchOperator.BETWEEN.op())
                        || propertyValue.startsWith(">") || propertyValue.startsWith("<"))) {
            addStringRangeCriteria(propertyName, propertyValue, criteria);
        } else {
            if (treatWildcardsAndOperatorsAsLiteral) {
                propertyValue = StringUtils.replace(propertyValue, "*", "\\*");
            }
            criteria.like(propertyName, propertyValue);
        }
    } else if (TypeUtils.isIntegralClass(propertyType) || TypeUtils.isDecimalClass(propertyType)) {
        addNumericRangeCriteria(propertyName, propertyValue, criteria);
    } else if (TypeUtils.isTemporalClass(propertyType)) {
        addDateRangeCriteria(propertyName, propertyValue, criteria);
    } else if (TypeUtils.isBooleanClass(propertyType)) {
        String temp = ObjectUtils.clean(propertyValue);
        criteria.eq(propertyName, ("Y".equalsIgnoreCase(temp) || "T".equalsIgnoreCase(temp)
                || "1".equalsIgnoreCase(temp) || "true".equalsIgnoreCase(temp)) ? true : false);
    } else {
        LOG.error("not adding criterion for: " + propertyName + "," + propertyType + "," + propertyValue);
    }
}

From source file:org.kuali.rice.krad.data.jpa.eclipselink.EclipseLinkJpaMetadataProviderImpl.java

/**
 * {@inheritDoc}// w  ww  .  ja v  a  2  s  .co m
 */
@Override
protected void populateImplementationSpecificAttributeLevelMetadata(DataObjectAttributeImpl attribute,
        SingularAttribute<?, ?> attr) {

    if (attr instanceof SingularAttributeImpl) {
        DatabaseMapping mapping = ((SingularAttributeImpl<?, ?>) attr).getMapping();
        if (mapping != null && mapping.getField() != null) {
            attribute.setReadOnly(mapping.isReadOnly());
            attribute.setBackingObjectName(mapping.getField().getName());
            if (mapping.getField().getLength() != 0) {
                attribute.setMaxLength((long) mapping.getField().getLength());
            }

            // Special check on the converters to attempt to default secure attributes from being shown on the UI
            // We check for a converter which has "encrypt" in its name and auto-set the attribute security
            // to mask the attribute.
            if (mapping instanceof DirectToFieldMapping) {
                Converter converter = ((DirectToFieldMapping) mapping).getConverter();
                // ConverterClass is the internal wrapper EclipseLink uses to wrap the JPA AttributeConverter
                // classes
                // and make them conform to the EclipseLink internal API
                if (converter != null && converter instanceof ConverterClass) {
                    // Unfortunately, there is no access to the actual converter class, so we have to hack it
                    try {
                        Field f = ConverterClass.class.getDeclaredField("attributeConverterClassName");
                        f.setAccessible(true);
                        String attributeConverterClassName = (String) f.get(converter);
                        if (StringUtils.containsIgnoreCase(attributeConverterClassName, "encrypt")) {
                            attribute.setSensitive(true);
                        }
                    } catch (Exception e) {
                        LOG.warn("Unable to access the converter name for attribute: "
                                + attribute.getOwningType().getName() + "." + attribute.getName()
                                + "  Skipping attempt to detect converter.");
                    }
                }
            }

        }
    }
}

From source file:org.kuali.rice.krad.data.jpa.eclipselink.EclipseLinkJpaMetadataProviderImpl.java

/**
 * {@inheritDoc}/*  ww w. j  a v  a  2 s. co  m*/
 */
@Override
protected void populateImplementationSpecificCollectionLevelMetadata(DataObjectCollectionImpl collection,
        PluralAttribute<?, ?, ?> cd) {
    // OJB stores the related class object name. We need to go into the repository and grab the table name.
    Class<?> collectionElementClass = cd.getElementType().getJavaType();
    EntityType<?> elementEntityType = entityManager.getMetamodel().entity(collectionElementClass);
    // get table name behind element
    if (elementEntityType instanceof EntityTypeImpl) {
        collection.setBackingObjectName(((EntityTypeImpl<?>) elementEntityType).getDescriptor().getTableName());
    }

    // Set to read only if store (save) operations should not be pushed through
    PersistentAttributeType persistentAttributeType = cd.getPersistentAttributeType();

    if (cd instanceof PluralAttributeImpl) {
        PluralAttributeImpl<?, ?, ?> coll = (PluralAttributeImpl<?, ?, ?>) cd;
        CollectionMapping collectionMapping = coll.getCollectionMapping();

        if (collectionMapping instanceof OneToManyMapping) {
            OneToManyMapping otm = (OneToManyMapping) collectionMapping;
            populateInverseRelationship(otm, collection);
            Map<DatabaseField, DatabaseField> keyMap = otm.getSourceKeysToTargetForeignKeys();
            List<DataObjectAttributeRelationship> attributeRelationships = new ArrayList<DataObjectAttributeRelationship>();
            for (Map.Entry<DatabaseField, DatabaseField> keyRel : keyMap.entrySet()) {
                attributeRelationships.add(new DataObjectAttributeRelationshipImpl(
                        getPropertyNameFromDatabaseColumnName(cd.getDeclaringType(), keyRel.getKey().getName()),
                        getPropertyNameFromDatabaseColumnName(elementEntityType, keyRel.getValue().getName())));
            }
            collection.setAttributeRelationships(attributeRelationships);
        }

        collection.setReadOnly(collectionMapping.isReadOnly());
        collection.setSavedWithParent(collectionMapping.isCascadePersist());
        collection.setDeletedWithParent(collectionMapping.isCascadeRemove());
        collection
                .setLoadedAtParentLoadTime(collectionMapping.isCascadeRefresh() && !collectionMapping.isLazy());
        collection.setLoadedDynamicallyUponUse(
                collectionMapping.isCascadeRefresh() && collectionMapping.isLazy());
    } else {
        // get what we can based on JPA values (note that we just set some to have values here)
        collection.setReadOnly(false);
        collection.setSavedWithParent(persistentAttributeType == PersistentAttributeType.ONE_TO_MANY);
        collection.setDeletedWithParent(persistentAttributeType == PersistentAttributeType.ONE_TO_MANY);
        collection.setLoadedAtParentLoadTime(true);
        collection.setLoadedDynamicallyUponUse(false);
    }

    // We need to detect the case of a intermediate mapping table. These tables are not directly mapped
    // in OJB, but are referenced by their table and column names.
    // The attributes referenced are assumed to be in the order of the PK fields of the parent and child objects
    // as there is no way to identify the attributes/columns on the linked classes.

    // Extract the default sort order for the collection
    List<DataObjectCollectionSortAttribute> sortAttributes = new ArrayList<DataObjectCollectionSortAttribute>();
    if (cd instanceof PluralAttributeImpl) {
        PluralAttributeImpl<?, ?, ?> coll = (PluralAttributeImpl<?, ?, ?>) cd;
        CollectionMapping collectionMapping = coll.getCollectionMapping();
        if (collectionMapping.getSelectionQuery() instanceof ObjectLevelReadQuery) {
            ObjectLevelReadQuery readQuery = (ObjectLevelReadQuery) collectionMapping.getSelectionQuery();
            List<Expression> orderByExpressions = readQuery.getOrderByExpressions();
            for (Expression expression : orderByExpressions) {
                if (expression instanceof FunctionExpression) {
                    String attributeName = ((FunctionExpression) expression).getBaseExpression().getName();
                    SortDirection direction = SortDirection.ASCENDING;
                    if (expression.getOperator().isOrderOperator()) {
                        if (StringUtils.containsIgnoreCase(expression.getOperator().getDatabaseStrings()[0],
                                "DESC")) {
                            direction = SortDirection.DESCENDING;
                        }
                    }
                    sortAttributes.add(new DataObjectCollectionSortAttributeImpl(attributeName, direction));
                }
            }
        }

    }
    collection.setDefaultCollectionOrderingAttributeNames(sortAttributes);
}

From source file:org.kuali.student.lum.kim.role.type.KSActionRequestDerivedRoleTypeServiceImpl.java

protected boolean containsActivatedRequest(String roleName, List<ActionRequest> actionRequests) {
    if (StringUtils.containsIgnoreCase(roleName, APPROVE_REQUEST_RECIPIENT_ROLE_CONTENT)) {
        for (ActionRequest ar : actionRequests) {
            if (ar.isApprovalRequest() && verifyActionRequest(ar)) {
                return true;
            }//from   ww  w.j  a  v a  2 s.com
        }
    } else if (StringUtils.containsIgnoreCase(roleName, ACKNOWLEDGE_REQUEST_RECIPIENT_ROLE_CONTENT)) {
        for (ActionRequest ar : actionRequests) {
            if (ar.isAcknowledgeRequest() && verifyActionRequest(ar)) {
                return true;
            }
        }
    } else if (StringUtils.containsIgnoreCase(roleName, FYI_REQUEST_RECIPIENT_ROLE_CONTENT)) {
        for (ActionRequest ar : actionRequests) {
            if (ar.isFyiRequest() && verifyActionRequest(ar)) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.kuali.student.r2.core.scheduling.util.SchedulingServiceUtil.java

private static void checkStringForDayCode(String codeInString, Integer integerDayCode, List<Integer> result,
        String testString) {//w  w  w .  j av  a2  s  . c om
    if (StringUtils.containsIgnoreCase(testString, codeInString)) {
        result.add(integerDayCode);
    }
}

From source file:org.LexGrid.LexBIG.distributed.test.services.SearchExtensionTest.java

public void testSimpleSearchWithCodingSchemeRestriction() throws LBException {
    CodingSchemeReference ref = new CodingSchemeReference();
    ref.setCodingScheme(SNOMED_SCHEME);/*  w  w w .j a  v  a2  s.com*/

    Set<CodingSchemeReference> codingSchemes = new HashSet<CodingSchemeReference>();
    codingSchemes.add(ref);

    ResolvedConceptReferencesIterator itr = searchExtension.search("boxing", codingSchemes,
            MatchAlgorithm.LUCENE);
    assertTrue(itr.hasNext());
    ResolvedConceptReference entity = itr.next();
    assertTrue(StringUtils.containsIgnoreCase(entity.getEntityDescription().getContent(), "boxing"));
}

From source file:org.lockss.plugin.ingenta.IngentaBooksUrlNormalizer.java

public String normalizeUrl(String url, ArchivalUnit au) throws PluginException {

    /*//from   w ww  .  ja v a  2  s. c om
     * An Ingenta URL may have a jsessionid in it, 
     */
    if (url.contains(";jsessionid=")) {
        url = url.replaceFirst(";jsessionid=[^?]+", "");
    }

    /* 
     * It's not clear if this is a temporary (error) or if it's in transition
     * but across all of ingenta all article landing pages are now at 
     * contentone instead of content (though both pages still exist).
     * In order not to collect duplicates, we will normalize
     * /contentone/ to /content/
     * 
     */
    if (url.contains("/contentone/")) {
        url = url.replace("/contentone/", "/content/");
    }

    /*
     * The IngentaConnect platform is organized somewhat like an
     * interactive process, whereby one must click through to articles
     * and obtain one-time or short-lived URLs on the way. An
     * alternate access mechanism is in place for robots and
     * crawlers; see the HTML link extractor for that. Now the URL
     * normalizer needs to intercept requests for the gateway URLs
     * that lead to one-time or short-lived URLs and translate them
     * into the URL that is actually extracted and preserved.
     */

    String baseUrl = au.getConfiguration().get(ConfigParamDescr.BASE_URL.getKey());
    final String INFOBIKE_PATH = "search/download?pub=infobike%3a%2f%2f";
    String baseUrlPrefix = baseUrl + INFOBIKE_PATH;
    if (StringUtils.containsIgnoreCase(url, INFOBIKE_PATH)) {
        // First remove the exitTargetId
        if (url.contains("&exitTargetId=")) {
            url = url.replaceFirst("&exitTargetId=[^&]+", "");
        }

        String path = url.substring(baseUrlPrefix.length());
        path = path.replaceAll("%2[Ff]", "/");
        // replace &mimetype= with ?crawler=true&mimetype=
        path = path.replaceFirst("&mimetype=", "?crawler=true&mimetype=");

        // Now construct the URL
        url = baseUrl + "content/" + path;
    }
    return url;
}

From source file:org.lockss.plugin.ingenta.IngentaUrlNormalizer.java

public String normalizeUrl(String url, ArchivalUnit au) throws PluginException {

    /*/*from   www .  ja v  a2  s. c  om*/
     * An Ingenta URL may have a jsessionid in it, which begins with
     * ";jesessionid=" and ends at the question mark for the URL query
     * or at the end of the URL if there is none.
     */

    if (url.contains(";jsessionid=")) {
        url = url.replaceFirst(";jsessionid=[^?]+", "");
    }

    /*
     * The IngentaConnect platform is organized somewhat like an
     * interactive process, whereby one must click through to articles
     * and obtain one-time or short-lived URLs on the way. An
     * alternate access mechanism is in place for robots and
     * crawlers; see the HTML link extractor for that. Now the URL
     * normalizer needs to intercept requests for the gateway URLs
     * that lead to one-time or short-lived URLs and translate them
     * into the URL that is actually extracted and preserved.
     */

    String baseUrl = au.getConfiguration().get(ConfigParamDescr.BASE_URL.getKey());
    final String INFOBIKE_PATH = "search/download?pub=infobike%3a%2f%2f";
    String baseUrlPrefix = baseUrl + INFOBIKE_PATH;
    if (StringUtils.containsIgnoreCase(url, INFOBIKE_PATH)) {
        // First remove the exitTargetId
        if (url.contains("&exitTargetId=")) {
            url = url.replaceFirst("&exitTargetId=[^&]+", "");
        }

        // Then massage the path to include slashes and "?crawler=true"
        // replace &mimetype=application/pdf (assumed default) see IngentaHtmlLinkRewriterFactory
        // with ?crawler=true, otherwise add ?crawler=true to mimetype param
        String path = url.substring(baseUrlPrefix.length());
        path = path.replaceAll("%2[Ff]", "/");
        path = path.replaceFirst("&mimetype=application/pdf", "?crawler=true");
        path = path.replaceFirst("&mimetype=", "?crawler=true&mimetype=");

        // Now construct the URL
        String apiUrl = au.getConfiguration().get(KEY_API_URL);
        url = apiUrl + "content/" + path;
    }

    return url;
}

From source file:org.mifos.framework.persistence.HardcodedValues.java

public static boolean checkLookupValue(String sql) {
    if (StringUtils.containsIgnoreCase(sql, LOOKUP_VALUE) && StringUtils.containsIgnoreCase(sql, LOOKUP_ID)) {
        return false;
    }/*from  ww w . j a v  a2 s . c  o m*/
    return true;
}