List of usage examples for org.apache.commons.lang StringUtils containsOnly
public static boolean containsOnly(String str, String validChars)
Checks if the String contains only certain characters.
From source file:org.kuali.ole.coa.document.validation.impl.IndirectCostRecoveryRateRule.java
protected boolean processSubObjectCode(IndirectCostRecoveryRateDetail item) { // chart being a wildcard implies account number being a wildcard, redundant checking? boolean success = true; Map pkMap = new HashMap(); Integer year = indirectCostRecoveryRate.getUniversityFiscalYear(); String chart = item.getChartOfAccountsCode(); String acct = item.getAccountNumber(); String objCd = item.getFinancialObjectCode(); String subObjCd = item.getFinancialSubObjectCode(); if (StringUtils.isNotBlank(subObjCd) && !propertyIsWildcard(subObjCd) && !StringUtils.containsOnly(subObjCd, "-")) { pkMap.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, year); if (!propertyIsWildcard(chart)) { pkMap.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chart); }//from w w w .ja va2s .com if (!propertyIsWildcard(acct)) { pkMap.put(OLEPropertyConstants.ACCOUNT_NUMBER, acct); } if (!propertyIsWildcard(objCd)) { pkMap.put(OLEPropertyConstants.FINANCIAL_OBJECT_CODE, objCd); } pkMap.put(OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, subObjCd); if (!GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY.equals(subObjCd) && !checkExistenceFromTable(SubObjectCode.class, pkMap)) { logErrorUtility(OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, RiceKeyConstants.ERROR_EXISTENCE); success = false; } } return success; }
From source file:org.kuali.ole.coa.document.validation.impl.IndirectCostRecoveryRateRule.java
protected boolean checkAccountNumberWildcardRules(IndirectCostRecoveryRateDetail item) { String accountNumber = item.getAccountNumber(); boolean success = true; if (!accountNumber.equals(item.getChartOfAccountsCode())) { GlobalVariables.getMessageMap().putError(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, OLEKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_WILDCARDS_MUST_MATCH, SpringContext.getBean(DataDictionaryService.class).getAttributeLabel( IndirectCostRecoveryRateDetail.class, OLEPropertyConstants.ACCOUNT_NUMBER), SpringContext.getBean(DataDictionaryService.class).getAttributeLabel( IndirectCostRecoveryRateDetail.class, OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE)); success = false;/*from w ww .j av a 2s .c om*/ } String subAccountNumber = item.getSubAccountNumber(); // If # is entered on account, then # "must" be entered for chart and sub account "must" be dashes. if (GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT.equals(accountNumber)) { if (!GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT .equals(item.getChartOfAccountsCode()) && !StringUtils.containsOnly(subAccountNumber, OLEConstants.DASH)) { GlobalVariables.getMessageMap().putError(OLEPropertyConstants.SUB_ACCOUNT_NUMBER, OLEKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_FIELD_MUST_BE_DASHES, SpringContext.getBean(DataDictionaryService.class).getAttributeLabel( IndirectCostRecoveryRateDetail.class, OLEPropertyConstants.ACCOUNT_NUMBER), GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT, SpringContext.getBean(DataDictionaryService.class).getAttributeLabel( IndirectCostRecoveryRateDetail.class, OLEPropertyConstants.SUB_ACCOUNT_NUMBER)); success = false; } } if (GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY.equals(accountNumber)) { if (!(StringUtils.equals(GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY, subAccountNumber) || !StringUtils.containsOnly(subAccountNumber, OLEConstants.DASH))) { GlobalVariables.getMessageMap().putError(OLEPropertyConstants.SUB_ACCOUNT_NUMBER, OLEKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_ACCOUNT_USE_EXPENDITURE_ENTRY_WILDCARD_RESTRICTION_ON_SUB_ACCOUNT); success = false; } } return success; }
From source file:org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl.java
/** * Helper method to build an inquiry url for a result field. Special implementation to not build an inquiry link if the value is * all dashes./* w w w . j a v a 2s . c om*/ * * @param bo the business object instance to build the urls for * @param propertyName the property which links to an inquirable * @return String url to inquiry */ @Override public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { try { if (PropertyUtils.isReadable(businessObject, attributeName)) { Object objFieldValue = ObjectUtils.getPropertyValue(businessObject, attributeName); String fieldValue = objFieldValue == null ? OLEConstants.EMPTY_STRING : objFieldValue.toString(); if (StringUtils.containsOnly(fieldValue, OLEConstants.DASH)) { return new AnchorHtmlData(); } } return super.getInquiryUrl(businessObject, attributeName, forceInquiry); } catch (Exception ex) { LOG.error("Unable to determine inquiry link for BO Class: " + businessObject.getClass() + " and property " + attributeName); LOG.debug("Unable to determine inquiry link for BO Class: " + businessObject.getClass() + " and property " + attributeName, ex); return new AnchorHtmlData(); } }
From source file:org.kuali.rice.ksb.messaging.dao.impl.MessageQueueDAOOjbImpl.java
@SuppressWarnings("unchecked") public List<PersistedMessageBO> findByValues(Map<String, String> criteriaValues, int maxRows) { Criteria crit = new Criteria(); String value = null;// w w w . j a va 2 s. com for (String key : criteriaValues.keySet()) { value = criteriaValues.get(key); if (StringUtils.isBlank(key) && StringUtils.isBlank(value)) { throw new IllegalArgumentException( "Either the key or value was blank in criteriaValues (" + key + "=" + value + ")"); } // auto-wildcard the statement if (!key.equals("routeQueueId")) { if (value.contains("*")) { value = value.replace("*", "%"); } else { value = value.concat("%"); } } if (!StringUtils.containsOnly(value, "%")) { crit.addLike(key, value); } } QueryByCriteria query = new QueryByCriteria(PersistedMessageBO.class, crit); query.setFetchSize(maxRows); query.setStartAtIndex(0); query.setEndAtIndex(maxRows); return (List<PersistedMessageBO>) getPersistenceBrokerTemplate().getCollectionByQuery(query); }
From source file:org.kuali.student.r2.core.scheduling.util.SchedulingServiceUtil.java
public static boolean isValidDays(String days) { if (StringUtils.isNotBlank(days)) { days = StringUtils.upperCase(days); String validDays = "MTWHFSU"; return StringUtils.containsOnly(days, validDays); }//from w w w .j a v a2s. c o m return false; }
From source file:org.nuxeo.ecm.webapp.security.GroupManagementActions.java
public void validateGroupName(FacesContext context, UIComponent component, Object value) { if (!(value instanceof String) || !StringUtils.containsOnly((String) value, VALID_CHARS)) { FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, ComponentUtils.translate(context, "label.groupManager.wrongGroupName"), null); ((EditableValueHolder) component).setValid(false); context.addMessage(component.getClientId(context), message); // also add global message context.addMessage(null, message); }//from w w w .jav a 2 s . c o m }
From source file:org.nuxeo.ecm.webapp.security.UserManagementActions.java
public void validateUserName(FacesContext context, UIComponent component, Object value) { if (!(value instanceof String) || !StringUtils.containsOnly((String) value, VALID_CHARS)) { FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, ComponentUtils.translate(context, "label.userManager.wrong.username"), null); // also add global message context.addMessage(null, message); throw new ValidatorException(message); }/*from w w w . j a va 2 s .c o m*/ }
From source file:org.onebusaway.nyc.vehicle_tracking.impl.inference.VehicleInferenceInstance.java
/** * This method rechecks the operator assignment and returns either the old * run-results or new ones./* w ww.j a v a 2 s . c om*/ * * @param observation * @param results * @return */ private RunResults updateRunIdMatches(NycRawLocationRecord observation, RunResults results) { final Date obsDate = new Date(observation.getTime()); String opAssignedRunId = null; final String operatorId = observation.getOperatorId(); final boolean noOperatorIdGiven = StringUtils.isEmpty(operatorId) || StringUtils.containsOnly(operatorId, "0"); final Set<AgencyAndId> routeIds = Sets.newHashSet(); if (!noOperatorIdGiven) { try { final OperatorAssignmentItem oai = _operatorAssignmentService .getOperatorAssignmentItemForServiceDate(new ServiceDate(obsDate), new AgencyAndId(observation.getVehicleId().getAgencyId(), operatorId)); if (oai != null) { if (_runService.isValidRunId(oai.getRunId())) { opAssignedRunId = oai.getRunId(); /* * same results; we're done */ if (opAssignedRunId.equals(results.getAssignedRunId())) return results; /* * new assigned run-id; recompute the routes */ routeIds.addAll(_runService.getRoutesForRunId(opAssignedRunId)); for (final String runId : results.getFuzzyMatches()) { routeIds.addAll(_runService.getRoutesForRunId(runId)); } return new RunResults(opAssignedRunId, results.getFuzzyMatches(), results.getBestFuzzyDist(), routeIds); } } } catch (final Exception e) { _log.warn(e.getMessage()); } } /* * if we're here, then the op-assignment call probably failed, so just * return the old results */ return results; }
From source file:org.onebusaway.nyc.vehicle_tracking.impl.inference.VehicleInferenceInstance.java
private RunResults findRunIdMatches(NycRawLocationRecord observation) { final Date obsDate = new Date(observation.getTime()); String opAssignedRunId = null; final String operatorId = observation.getOperatorId(); final boolean noOperatorIdGiven = StringUtils.isEmpty(operatorId) || StringUtils.containsOnly(operatorId, "0"); final Set<AgencyAndId> routeIds = Sets.newHashSet(); if (!noOperatorIdGiven) { try {/*w w w . j av a 2 s .c o m*/ final OperatorAssignmentItem oai = _operatorAssignmentService .getOperatorAssignmentItemForServiceDate(new ServiceDate(obsDate), new AgencyAndId(observation.getVehicleId().getAgencyId(), operatorId)); if (oai != null) { if (_runService.isValidRunId(oai.getRunId())) { opAssignedRunId = oai.getRunId(); routeIds.addAll(_runService.getRoutesForRunId(opAssignedRunId)); } } } catch (final Exception e) { _log.warn(e.getMessage()); } } Set<String> fuzzyMatches = Collections.emptySet(); final String reportedRunId = observation.getRunId(); Integer bestFuzzyDistance = null; if (StringUtils.isEmpty(opAssignedRunId) && !noOperatorIdGiven) { _log.info("no assigned run found for operator=" + operatorId); } if (StringUtils.isNotEmpty(reportedRunId) && !StringUtils.containsOnly(reportedRunId, new char[] { '0', '-' })) { try { final TreeMultimap<Integer, String> fuzzyReportedMatches = _runService .getBestRunIdsForFuzzyId(reportedRunId); if (fuzzyReportedMatches.isEmpty()) { _log.info("couldn't find a fuzzy match for reported runId=" + reportedRunId); } else { bestFuzzyDistance = fuzzyReportedMatches.keySet().first(); if (bestFuzzyDistance <= 0) { fuzzyMatches = fuzzyReportedMatches.get(bestFuzzyDistance); for (final String runId : fuzzyMatches) { routeIds.addAll(_runService.getRoutesForRunId(runId)); } } } } catch (final IllegalArgumentException ex) { _log.warn(ex.getMessage()); } } return new RunResults(opAssignedRunId, fuzzyMatches, bestFuzzyDistance, routeIds); }
From source file:org.openhab.binding.tankerkoenig.handler.StationHandler.java
/*** * Updates the channels of a station item * * @param station/* w w w . ja v a 2 s.com*/ */ public void updateData(LittleStation station) { logger.debug("Update Tankerkoenig data '{}'", getThing().getUID()); if (StringUtils.containsOnly(station.getDiesel(), "01234567890.")) { DecimalType diesel = new DecimalType(station.getDiesel()); updateState(CHANNEL_DIESEL, diesel); } else { updateState(CHANNEL_DIESEL, UnDefType.UNDEF); } if (StringUtils.containsOnly(station.getE10(), "01234567890.")) { DecimalType e10 = new DecimalType(station.getE10()); updateState(CHANNEL_E10, e10); } else { updateState(CHANNEL_E10, UnDefType.UNDEF); } if (StringUtils.containsOnly(station.getE5(), "01234567890.")) { DecimalType e5 = new DecimalType(station.getE5()); updateState(CHANNEL_E5, e5); } else { updateState(CHANNEL_E5, UnDefType.UNDEF); } updateState(CHANNEL_STATION_OPEN, (station.isOpen() ? OpenClosedType.OPEN : OpenClosedType.CLOSED)); updateStatus(ThingStatus.ONLINE); }