List of usage examples for org.apache.commons.lang StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(String str, String searchStr)
Checks if String contains a search String irrespective of case, handling null
.
From source file:adalid.commons.properties.PropertiesHandler.java
private static void log(ExtendedProperties properties, Level level) { Object next;/*from www .ja v a 2 s .co m*/ Set<String> names = new TreeSet<>(); Iterator iterator = properties.getKeys(); if (iterator != null) { while (iterator.hasNext()) { next = iterator.next(); if (next instanceof String) { names.add((String) next); } } } String value; for (String name : names) { value = properties.getString(name); logger.log(level, name + " = " + (StringUtils.containsIgnoreCase(name, "password") ? "***" : value)); } }
From source file:hydrograph.ui.expression.editor.enums.DataTypes.java
public static String getDataTypefromString(String value) { for (DataTypes dataType : DataTypes.values()) { if (StringUtils.equalsIgnoreCase(dataType.reflectionValue, value)) { return dataType.getDataTypeName(); } else if (StringUtils.containsIgnoreCase(value, dataType.toString())) { return dataType.getDataTypeName(); }// w ww. j av a 2 s. co m } return StringUtils.removeStart(value, Constants.DATA_TYPE_PREFIX_FOR_SOUCE_CODE); }
From source file:com.kenai.redminenb.query.RedmineQuery.java
/** * Performs the issue search with the attributes and values provided by the * map./* ww w . j a va 2 s . c o m*/ * <p> * Note: The Redmine REST API does not support full search support for all * fields. So the issues are post filtered here. * * @see http://www.redmine.org/projects/redmine/wiki/Rest_Issues * @see RedmineQueryController#RedmineQueryController * @param searchParameters */ private List<com.taskadapter.redmineapi.bean.Issue> doSearch( Map<String, RedmineQueryParameter> searchParameters) throws IOException, AuthenticationException, NotFoundException, RedmineException { boolean searchSubject = false; boolean searchDescription = false; boolean searchComments = false; RedmineQueryParameter queryStringParameter = searchParameters.remove("query"); Set<RedmineQueryParameter> multiValueParameters = new HashSet<>(); Map<String, String> m = new HashMap<>(); m.put("project_id", String.valueOf(repository.getProject().getId())); for (RedmineQueryParameter p : searchParameters.values()) { if (StringUtils.isNotBlank(p.getValueString())) { ParameterValue[] paramValues = p.getValues(); if (paramValues.length == 1) { if ("is_subject".equals(p.getParameter())) { searchSubject = "1".equals(paramValues[0].getValue()); } else if ("is_description".equals(p.getParameter())) { searchDescription = "1".equals(paramValues[0].getValue()); } else if ("is_comments".equals(p.getParameter())) { searchComments = "1".equals(paramValues[0].getValue()); } else { m.put(p.getParameter(), paramValues[0].getValue()); } } else if (paramValues.length > 1) { multiValueParameters.add(p); } } } // Perform search List<com.taskadapter.redmineapi.bean.Issue> issueArr = repository.getManager().getIssues(m); // Post filtering: Query string if (queryStringParameter != null && !queryStringParameter.isEmpty() && (searchSubject || searchDescription || searchComments)) { String queryStr = queryStringParameter.getValueString(); List<com.taskadapter.redmineapi.bean.Issue> newArr = new ArrayList<>(issueArr.size()); for (com.taskadapter.redmineapi.bean.Issue issue : issueArr) { if ((searchSubject && StringUtils.containsIgnoreCase(issue.getSubject(), queryStr)) || (searchDescription && StringUtils.containsIgnoreCase(issue.getDescription(), queryStr)) /* || (searchComments && StringUtils.containsIgnoreCase(..., queryStr)) */) { newArr.add(issue); } } issueArr = newArr; } // Post filtering: Multi-value parameters if (!multiValueParameters.isEmpty()) { List<com.taskadapter.redmineapi.bean.Issue> newArr = new ArrayList<>(issueArr.size()); for (com.taskadapter.redmineapi.bean.Issue issue : issueArr) { for (RedmineQueryParameter p : multiValueParameters) { // RedmineIssue.getFieldValue(RedmineIssue.FIELD_xxx) // TODO: map FIELD_xxx property to query parameter String paramName = p.getParameter(); if ("tracker_id".equals(paramName)) { for (ParameterValue pv : p.getValues()) { if (String.valueOf(issue.getTracker().getId()).equals(pv.getValue())) { newArr.add(issue); break; } } } else if ("status_id".equals(paramName)) { for (ParameterValue pv : p.getValues()) { if (String.valueOf(issue.getStatusId()).equals(pv.getValue())) { newArr.add(issue); break; } } } else if ("priority_id".equals(paramName)) { for (ParameterValue pv : p.getValues()) { if (String.valueOf(issue.getPriorityId()).equals(pv.getValue())) { newArr.add(issue); break; } } } else if ("assigned_to_id".equals(paramName)) { for (ParameterValue pv : p.getValues()) { if ((pv == ParameterValue.NONE_PARAMETERVALUE && issue.getAssignee() == null) || (issue.getAssignee() != null && String.valueOf(issue.getAssignee().getId()).equals(pv.getValue()))) { newArr.add(issue); break; } } } else if ("category_id".equals(paramName)) { for (ParameterValue pv : p.getValues()) { if ((pv == ParameterValue.NONE_PARAMETERVALUE && issue.getCategory() == null) || (issue.getCategory() != null && String.valueOf(issue.getCategory().getId()).equals(pv.getValue()))) { newArr.add(issue); break; } } } else if ("fixed_version_id".equals(paramName)) { for (ParameterValue pv : p.getValues()) { if ((pv == ParameterValue.NONE_PARAMETERVALUE && issue.getTargetVersion() == null) || (issue.getTargetVersion() != null && String .valueOf(issue.getTargetVersion().getId()).equals(pv.getValue()))) { newArr.add(issue); break; } } } else { Redmine.LOG.log(Level.WARNING, "Unsupported multi-value parameter ''{0}''", paramName); } } } issueArr = newArr; } return issueArr; }
From source file:com.hangum.tadpole.engine.sql.util.resultset.ResultSetUtils.java
public static Map<Integer, String> getColumnLabelName(UserDBDAO userDB, Map<Integer, String> columnTableName, boolean isShowRowNum, ResultSet rs) throws Exception { Map<Integer, String> mapColumnName = getColumnLabelName(isShowRowNum, rs); DBAccessControlDAO dbAccessCtlDao = userDB.getDbAccessCtl(); Map<String, AccessCtlObjectDAO> mapDetailCtl = dbAccessCtlDao.getMapSelectAccessCtl(); if (!mapDetailCtl.isEmpty()) { Map<Integer, String> mapReturnColumnName = new HashMap<Integer, String>(); int intColumnCnt = 0; // ? db access ?? ?. for (int i = 0; i < mapColumnName.size(); i++) { String strTableName = columnTableName.get(i); // Is filter column? if (mapDetailCtl.containsKey(strTableName)) { // is filter table? AccessCtlObjectDAO acDao = mapDetailCtl.get(strTableName); String strTableOfAccessColumns = acDao.getDetail_obj(); String strResultColumn = mapColumnName.get(i); if (StringUtils.containsIgnoreCase(strTableOfAccessColumns, strResultColumn) | acDao.getDontuse_object().equals("YES")) { // if(logger.isDebugEnabled()) logger.debug("This colum is remove stauts " + strResultColumn); } else { // if(logger.isDebugEnabled()) logger.debug("This colum is normal stauts " + strResultColumn); mapReturnColumnName.put(intColumnCnt, mapColumnName.get(i)); intColumnCnt++;//from ww w .jav a2 s . co m } } else { mapReturnColumnName.put(intColumnCnt, mapColumnName.get(i)); intColumnCnt++; } } return mapReturnColumnName; } else { return mapColumnName; } }
From source file:net.ageto.gyrex.persistence.jdbc.pool.internal.PoolRegistry.java
private String getConnectionTestStatement(final ServiceReference<DataSourceFactory> serviceReference) { final String driverClass = (String) serviceReference.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS); final String driverName = (String) serviceReference.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_NAME); if (StringUtils.containsIgnoreCase(driverName, "mysql") || StringUtils.containsIgnoreCase(driverClass, "mysql")) { return "/* ping */ SELECT 1"; }/* ww w . j a va 2 s . c om*/ // none return null; }
From source file:com.hp.alm.ali.idea.content.taskboard.BacklogItemPanel.java
private boolean filterMatches(String filter, Entity entity, String property) { if (filter == null || filter.isEmpty()) { return true; }/* w w w.j av a 2s.c o m*/ if (StringUtils.containsIgnoreCase(entity.getPropertyValue(property), filter)) { return true; } return false; }
From source file:com.microsoft.azure.vmagent.AzureVMAgentCleanUpTask.java
public void cleanLeakedResources(final String resourceGroup, final ServicePrincipal servicePrincipal, final String cloudName, final DeploymentRegistrar deploymentRegistrar) { try {/*from ww w . j av a2s. co m*/ final List<String> validVMs = getValidVMs(cloudName); final Azure azureClient = TokenCache.getInstance(servicePrincipal).getAzureClient(); //can't use listByTag because for some reason that method strips all the tags from the outputted resources (https://github.com/Azure/azure-sdk-for-java/issues/1436) final PagedList<GenericResource> resources = azureClient.genericResources().listByGroup(resourceGroup); if (resources == null || resources.isEmpty()) { return; } final PriorityQueue<GenericResource> resourcesMarkedForDeletion = new PriorityQueue<>(resources.size(), new Comparator<GenericResource>() { @Override public int compare(GenericResource o1, GenericResource o2) { int o1Priority = getPriority(o1); int o2Priority = getPriority(o2); if (o1Priority == o2Priority) { return 0; } return (o1Priority < o2Priority) ? -1 : 1; } private int getPriority(final GenericResource resource) { final String type = resource.type(); if (StringUtils.containsIgnoreCase(type, "virtualMachine")) { return 1; } if (StringUtils.containsIgnoreCase(type, "networkInterface")) { return 2; } if (StringUtils.containsIgnoreCase(type, "IPAddress")) { return 3; } return 4; } }); for (GenericResource resource : resources) { final Map<String, String> tags = resource.tags(); if (!tags.containsKey(Constants.AZURE_RESOURCES_TAG_NAME) || !deploymentRegistrar.getDeploymentTag() .matches(new AzureUtil.DeploymentTag(tags.get(Constants.AZURE_RESOURCES_TAG_NAME)))) { continue; } boolean shouldSkipDeletion = false; for (String validVM : validVMs) { if (resource.name().contains(validVM)) { shouldSkipDeletion = true; break; } } // we're not removing storage accounts of networks - someone else might be using them if (shouldSkipDeletion || StringUtils.containsIgnoreCase(resource.type(), "StorageAccounts") || StringUtils.containsIgnoreCase(resource.type(), "virtualNetworks")) { continue; } resourcesMarkedForDeletion.add(resource); } while (!resourcesMarkedForDeletion.isEmpty()) { try { final GenericResource resource = resourcesMarkedForDeletion.poll(); if (resource == null) continue; URI osDiskURI = null; if (StringUtils.containsIgnoreCase(resource.type(), "virtualMachine")) { osDiskURI = new URI( azureClient.virtualMachines().getById(resource.id()).osUnmanagedDiskVhdUri()); } LOGGER.log(Level.INFO, "cleanLeakedResources: deleting {0} from resource group {1}", new Object[] { resource.name(), resourceGroup }); azureClient.genericResources().deleteById(resource.id()); if (osDiskURI != null) { AzureVMManagementServiceDelegate.removeStorageBlob(azureClient, osDiskURI, resourceGroup); } } catch (Exception e) { LOGGER.log(Level.INFO, "AzureVMAgentCleanUpTask: cleanLeakedResources: failed to clean resource ", e); } } } catch (Exception e) { // No need to throw exception back, just log and move on. LOGGER.log(Level.INFO, "AzureVMAgentCleanUpTask: cleanLeakedResources: failed to clean leaked resources ", e); } }
From source file:com.hiperium.dao.common.generic.GenericDAO.java
/** * /*w ww. ja v a 2 s .c o m*/ * @param criteriaBuilder * @param criteriaQuery * @param root * @param entity */ private <E> void constructQuery(CriteriaBuilder criteriaBuilder, final CriteriaQuery<E> criteriaQuery, Root<E> root, E entity) { Map<String, Object> properties = this.getEntityProperties(entity); CriteriaFieldConditions criteria = new CriteriaFieldConditions(properties); List<Predicate> predicateList = new ArrayList<Predicate>(); // Add equality conditions conditions Set<String> equalityKeys = criteria.equality.keySet(); for (String key : equalityKeys) { predicateList.add(criteriaBuilder.equal(root.get(key), criteria.equality.get(key))); } // Add like conditions Set<String> likeKeys = criteria.like.keySet(); for (String key : likeKeys) { predicateList.add(criteriaBuilder.like(root.<String>get(key), criteria.like.get(key).toString())); } // Add composite conditions, only with equality conditions Set<String> compositeKeys = criteria.composite.keySet(); for (String key : compositeKeys) { Object value = criteria.composite.get(key); try { if (value.toString().startsWith("class java.util")) { continue; } else if (StringUtils.containsIgnoreCase(key, PK_OBJECT_NAME)) { Map<String, Object> propsComposites = this.getEntityProperties(value, key); CriteriaFieldConditions compositeCriteria = new CriteriaFieldConditions(propsComposites); if (!compositeCriteria.equality.isEmpty()) { Set<String> equalityKeysPk = compositeCriteria.equality.keySet(); for (String keyPk : equalityKeysPk) { String pkValueName = keyPk.replace(PK_OBJECT_NAME.concat("."), ""); predicateList.add(criteriaBuilder.equal(root.get(PK_OBJECT_NAME).get(pkValueName), compositeCriteria.equality.get(keyPk))); } } if (!compositeCriteria.like.isEmpty()) { Set<String> likeKeysPK = compositeCriteria.like.keySet(); for (String keyPk : likeKeysPK) { String pkValueName = keyPk.replace(PK_OBJECT_NAME.concat("."), ""); Expression<String> expression = root.<String>get(PK_OBJECT_NAME).get(pkValueName); predicateList.add( criteriaBuilder.like(expression, compositeCriteria.like.get(keyPk).toString())); } } } } catch (RuntimeException e) { continue; } } // Adding where stuff is necessary if (predicateList.size() == 1) { criteriaQuery.where(predicateList.get(0)); } else if (predicateList.size() > 1) { Predicate[] predicateCriteria = new Predicate[predicateList.size()]; predicateCriteria = predicateList.toArray(predicateCriteria); criteriaQuery.where(criteriaBuilder.and(predicateCriteria)); } }
From source file:com.cubusmail.mail.util.MessageUtils.java
/** * Filter the messages./* www . j av a 2 s.c o m*/ * * @param msgs * @param searchFields * @param searchText * @return */ public static Message[] quickFilterMessages(Message[] msgs, String searchFields, String searchText) { if (!StringUtils.isEmpty(searchFields) && !StringUtils.isEmpty(searchText)) { searchFields = StringUtils.remove(searchFields, '['); searchFields = StringUtils.remove(searchFields, ']'); searchFields = StringUtils.remove(searchFields, '\"'); String[] fields = StringUtils.split(searchFields, ','); List<Message> filteredMsgs = new ArrayList<Message>(); Date searchDate = null; try { searchDate = DateUtils.parseDate(searchText, new String[] { "dd.MM.yyyy" }); } catch (Exception e) { // do nothing } try { for (Message message : msgs) { boolean contains = false; for (String searchField : fields) { if (MessageListFields.SUBJECT.name().equals(searchField)) { String subject = message.getSubject(); contains = StringUtils.containsIgnoreCase(subject, searchText); } else if (MessageListFields.FROM.name().equals(searchField)) { String from = MessageUtils.getMailAdressString(message.getFrom(), AddressStringType.COMPLETE); contains = StringUtils.containsIgnoreCase(from, searchText) || contains; } else if (searchDate != null && MessageListFields.DATE.name().equals(searchField)) { Date sendDate = message.getSentDate(); contains = (sendDate != null && DateUtils.isSameDay(searchDate, sendDate)) || contains; } } if (contains) { filteredMsgs.add(message); } } } catch (MessagingException ex) { log.warn(ex.getMessage(), ex); } return filteredMsgs.toArray(new Message[0]); } return msgs; }
From source file:com.hangum.tadpole.rdb.core.dialog.export.sqltoapplication.composites.axisj.AxisjComposite.java
/** * sql to str/*from w w w . j ava2 s . co m*/ */ private void sqlToStr() { StringBuffer sbStr = new StringBuffer(); String[] sqls = parseSQL(); if (StringUtils.isEmpty(textVariable.getText())) { textVariable.setText(textVariable.getText()); } HashMap<String, String> options = new HashMap<String, String>(); options.put("name", textVariable.getText()); options.put("theme", textTheme.getText()); if (StringUtils.isEmpty(spinnerFixedCol.getText())) { options.put("fixedColSeq", "0"); } else { options.put("fixedColSeq", spinnerFixedCol.getText()); } options.put("fitToWidth", btnCheckFit2Width.getSelection() ? "true" : "false"); options.put("colHeadAlign", comboHeadAlign.getText().toLowerCase()); if (StringUtils.containsIgnoreCase(comboMergeCell.getText(), "true")) {// options.put("mergeCells", "true"); } else if (StringUtils.containsIgnoreCase(comboMergeCell.getText(), "false")) {// . options.put("mergeCells", "false"); } else {//? ?? try { String[] array = StringUtils.split(comboMergeCell.getText(), ','); if (array.length > 0) { StringBuffer sb = new StringBuffer(); for (String idx : array) { sb.append(Integer.valueOf(idx) + ","); // ?? ? ?. } options.put("mergeCells", "[" + StringUtils.removeEnd(sb.toString(), ",") + "]"); } else { // ? ?? ?. options.put("mergeCells", "false"); } } catch (Exception e) { options.put("mergeCells", "false"); } } if (StringUtils.containsIgnoreCase(comboHeight.getText(), "auto")) { options.put("height", "\"auto\""); } else { options.put("height", comboHeight.getText()); } options.put("sort", comboSort.getText().toLowerCase()); options.put("colHeadTool", comboHeadTool.getText().toLowerCase()); options.put("viewMode", comboViewMode.getText().toLowerCase()); for (int i = 0; i < sqls.length; i++) { if ("".equals(StringUtils.trimToEmpty(sqls[i]))) //$NON-NLS-1$ continue; if (i == 0) { sbStr.append(slt.sqlToString(sqls[i], options, listAxisjHeader)); } else { options.put("name", textVariable.getText() + "_" + i); sbStr.append(slt.sqlToString(sqls[i], options, listAxisjHeader)); } // ? . sbStr.append("\r\n"); //$NON-NLS-1$ } textConvert.setText(sbStr.toString()); }