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.apache.ranger.plugin.resourcematcher.RangerAbstractResourceMatcher.java
@Override public boolean isCompleteMatch(String resource, Map<String, Object> evalContext) { if (LOG.isDebugEnabled()) { LOG.debug("==> RangerAbstractResourceMatcher.isCompleteMatch(" + resource + ", " + evalContext + ")"); }//from ww w . j a v a 2 s . c om boolean ret = false; if (CollectionUtils.isEmpty(policyValues)) { ret = StringUtils.isEmpty(resource); } else if (policyValues.size() == 1) { String policyValue = policyValues.get(0); if (isMatchAny) { ret = StringUtils.containsOnly(resource, WILDCARD_ASTERISK); } else { ret = optIgnoreCase ? StringUtils.equalsIgnoreCase(resource, policyValue) : StringUtils.equals(resource, policyValue); } if (policyIsExcludes) { ret = !ret; } } if (LOG.isDebugEnabled()) { LOG.debug("<== RangerAbstractResourceMatcher.isCompleteMatch(" + resource + ", " + evalContext + "): " + ret); } return ret; }
From source file:org.intermine.bio.dataconversion.EnsemblSnpDbConverter.java
/** * Given an allele string read from the database determine the type of variation, e.g. snp, * in-del, etc. This is a re-implementation of code from the Ensembl perl API, see: * http://www.ensembl.org/info/docs/Doxygen/variation-api/ * classBio_1_1EnsEMBL_1_1Variation_1_1Utils_1_1Sequence.html * @param alleleStr the alleles to determine the type for * @return a variation class or null if none can be determined *//*from w ww. ja va 2 s .co m*/ protected String determineType(String alleleStr) { String type = null; final String validBases = "ATUGCYRSWKMBDHVN"; alleleStr = alleleStr.toUpperCase(); if (!StringUtils.isBlank(alleleStr)) { // snp if e.g. A/C or A|C if (alleleStr.matches("^[" + validBases + "]([\\/\\|\\\\][" + validBases + "])+$")) { type = "snp"; } else if ("CNV".equals(alleleStr)) { type = alleleStr.toLowerCase(); } else if ("CNV_PROBE".equals(alleleStr)) { type = "cnv probe"; } else if ("HGMD_MUTATION".equals(alleleStr)) { type = alleleStr.toLowerCase(); } else { String[] alleles = alleleStr.split("[\\|\\/\\\\]"); if (alleles.length == 1) { type = "het"; } else if (alleles.length == 2) { if ((StringUtils.containsOnly(alleles[0], validBases) && "-".equals(alleles[1])) || (StringUtils.containsOnly(alleles[1], validBases) && "-".equals(alleles[0]))) { type = "in-del"; } else if (containsOneOf(alleles[0], "LARGE", "INS", "DEL") || containsOneOf(alleles[1], "LARGE", "INS", "DEL")) { type = "named"; } else if ((StringUtils.containsOnly(alleles[0], validBases) && alleles[0].length() > 1) || (StringUtils.containsOnly(alleles[1], validBases) && alleles[1].length() > 1)) { // AA/GC 2 alleles type = "substitution"; } } else if (alleles.length > 2) { if (containsDigit(alleles[0])) { type = "microsat"; } else if (anyContainChar(alleles, "-")) { type = "mixed"; } } if (type == null) { LOG.warn("Failed to work out allele type for: " + alleleStr); } } } return type; }
From source file:org.intermine.bio.dataconversion.ModEncodeFeatureProcessor.java
private void processExpressionLevels(Connection connection) throws SQLException, ObjectStoreException { ResultSet res = getExpressionLevels(connection); Integer previousId = -1;/*w w w. j ava 2 s. c om*/ Item level = null; while (res.next()) { Integer id = res.getInt("expression_id"); Integer featureId = res.getInt("feature_id"); String name = res.getString("uniquename"); String value = res.getString("value"); String property = res.getString("property"); String propValue = res.getString("propvalue"); LOG.debug("EL: " + id + "|" + previousId + "->" + featureId + ":" + property + "|" + propValue); if (!id.equals(previousId)) { // if not first store prev level if (previousId > 0) { getChadoDBConverter().store(level); } level = createExpressionLevel(featureId, name, value); } // check if dcpm is a decimal number if ("dcpm".equalsIgnoreCase(property) && !StringUtils.containsOnly(propValue, ".0123456789")) { // in some cases (waterston) the value for dcpm is // 'nan' or 'na' or '.na' instead of a decimal number previousId = id; continue; } if (!EL_KNOWN_ATTRIBUTES.contains(property)) { LOG.debug("ExpressionLevel for feature_id = " + featureId + " has unknown attribute " + property); previousId = id; continue; } level.setAttribute(getPropName(property), propValue); previousId = id; } if (res.isAfterLast()) { getChadoDBConverter().store(level); } res.close(); }
From source file:org.kuali.kfs.coa.document.IndirectCostRecoveryRateMaintainableImpl.java
/** * Hook for quantity and setting asset numbers. * @see org.kuali.rice.kns.maintenance.KualiMaintainableImpl#addNewLineToCollection(java.lang.String) *//*from w ww .ja va 2 s . c o m*/ @Override public void addNewLineToCollection(String collectionName) { // create handle for the addline section of the doc IndirectCostRecoveryRateDetail addLine = (IndirectCostRecoveryRateDetail) newCollectionLines .get(collectionName); List<IndirectCostRecoveryRateDetail> maintCollection = (List<IndirectCostRecoveryRateDetail>) ObjectUtils .getPropertyValue(getBusinessObject(), collectionName); if (StringUtils.isBlank(addLine.getSubAccountNumber()) || StringUtils.containsOnly(addLine.getSubAccountNumber(), "-")) { addLine.setSubAccountNumber(KFSConstants.getDashSubAccountNumber()); } if (StringUtils.isBlank(addLine.getFinancialSubObjectCode()) || StringUtils.containsOnly(addLine.getFinancialSubObjectCode(), "-")) { addLine.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode()); } Integer icrEntryNumberMax = 0; for (IndirectCostRecoveryRateDetail item : maintCollection) { if (icrEntryNumberMax < item.getAwardIndrCostRcvyEntryNbr()) { icrEntryNumberMax = item.getAwardIndrCostRcvyEntryNbr(); } } // addLine.setActive(true); // TODO remove after active indicator fixes addLine.setNewCollectionRecord(true); addLine.setAwardIndrCostRcvyEntryNbr(icrEntryNumberMax + 1); maintCollection.add(addLine); initNewCollectionLine(collectionName); }
From source file:org.kuali.kfs.coa.document.validation.impl.IndirectCostRecoveryRateRule.java
protected boolean processSubAccount(IndirectCostRecoveryRateDetail item) { boolean success = true; Map pkMap = new HashMap(); String chart = item.getChartOfAccountsCode(); String acct = item.getAccountNumber(); String subAcct = item.getSubAccountNumber(); if (StringUtils.isNotBlank(subAcct) && !StringUtils.containsOnly(subAcct, "-")) { // if doesn't contain only dashes if (!propertyIsWildcard(chart)) { pkMap.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chart); }//from w ww . ja v a 2s .com if (!propertyIsWildcard(acct)) { pkMap.put(KFSPropertyConstants.ACCOUNT_NUMBER, acct); } if (!propertyIsWildcard(subAcct) && StringUtils.isNotBlank(subAcct) && !StringUtils.containsOnly(subAcct, "-")) { pkMap.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, subAcct); if (!checkExistenceFromTable(SubAccount.class, pkMap)) { logErrorUtility(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, RiceKeyConstants.ERROR_EXISTENCE); success = false; } } } return success; }
From source file:org.kuali.kfs.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(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, year); if (!propertyIsWildcard(chart)) { pkMap.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, chart); }// w w w.ja v a 2 s . c o m if (!propertyIsWildcard(acct)) { pkMap.put(KFSPropertyConstants.ACCOUNT_NUMBER, acct); } if (!propertyIsWildcard(objCd)) { pkMap.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, objCd); } pkMap.put(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, subObjCd); if (!GeneralLedgerConstants.PosterService.SYMBOL_USE_EXPENDITURE_ENTRY.equals(subObjCd) && !checkExistenceFromTable(SubObjectCode.class, pkMap)) { logErrorUtility(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE, RiceKeyConstants.ERROR_EXISTENCE); success = false; } } return success; }
From source file:org.kuali.kfs.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(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_WILDCARDS_MUST_MATCH, SpringContext.getBean(DataDictionaryService.class).getAttributeLabel( IndirectCostRecoveryRateDetail.class, KFSPropertyConstants.ACCOUNT_NUMBER), SpringContext.getBean(DataDictionaryService.class).getAttributeLabel( IndirectCostRecoveryRateDetail.class, KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE)); success = false;// ww w .j av a 2 s. 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, KFSConstants.DASH)) { GlobalVariables.getMessageMap().putError(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_FIELD_MUST_BE_DASHES, SpringContext.getBean(DataDictionaryService.class).getAttributeLabel( IndirectCostRecoveryRateDetail.class, KFSPropertyConstants.ACCOUNT_NUMBER), GeneralLedgerConstants.PosterService.SYMBOL_USE_ICR_FROM_ACCOUNT, SpringContext.getBean(DataDictionaryService.class).getAttributeLabel( IndirectCostRecoveryRateDetail.class, KFSPropertyConstants.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, KFSConstants.DASH))) { GlobalVariables.getMessageMap().putError(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_ACCOUNT_USE_EXPENDITURE_ENTRY_WILDCARD_RESTRICTION_ON_SUB_ACCOUNT); success = false; } } return success; }
From source file:org.kuali.kfs.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 ww .j a v a 2 s .co m * * @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 */ 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 ? KFSConstants.EMPTY_STRING : objFieldValue.toString(); if (StringUtils.containsOnly(fieldValue, KFSConstants.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.ole.coa.document.IndirectCostRecoveryRateMaintainableImpl.java
/** * Hook for quantity and setting asset numbers. * @see org.kuali.rice.kns.maintenance.KualiMaintainableImpl#addNewLineToCollection(java.lang.String) *//*from w w w . j ava2 s . co m*/ @Override public void addNewLineToCollection(String collectionName) { // create handle for the addline section of the doc IndirectCostRecoveryRateDetail addLine = (IndirectCostRecoveryRateDetail) newCollectionLines .get(collectionName); List<IndirectCostRecoveryRateDetail> maintCollection = (List<IndirectCostRecoveryRateDetail>) ObjectUtils .getPropertyValue(getBusinessObject(), collectionName); if (StringUtils.isBlank(addLine.getSubAccountNumber()) || StringUtils.containsOnly(addLine.getSubAccountNumber(), "-")) { addLine.setSubAccountNumber(OLEConstants.getDashSubAccountNumber()); } if (StringUtils.isBlank(addLine.getFinancialSubObjectCode()) || StringUtils.containsOnly(addLine.getFinancialSubObjectCode(), "-")) { addLine.setFinancialSubObjectCode(OLEConstants.getDashFinancialSubObjectCode()); } Integer icrEntryNumberMax = 0; for (IndirectCostRecoveryRateDetail item : maintCollection) { if (icrEntryNumberMax < item.getAwardIndrCostRcvyEntryNbr()) { icrEntryNumberMax = item.getAwardIndrCostRcvyEntryNbr(); } } // addLine.setActive(true); // TODO remove after active indicator fixes addLine.setNewCollectionRecord(true); addLine.setAwardIndrCostRcvyEntryNbr(icrEntryNumberMax + 1); maintCollection.add(addLine); initNewCollectionLine(collectionName); }
From source file:org.kuali.ole.coa.document.validation.impl.IndirectCostRecoveryRateRule.java
protected boolean processSubAccount(IndirectCostRecoveryRateDetail item) { boolean success = true; Map pkMap = new HashMap(); String chart = item.getChartOfAccountsCode(); String acct = item.getAccountNumber(); String subAcct = item.getSubAccountNumber(); if (StringUtils.isNotBlank(subAcct) && !StringUtils.containsOnly(subAcct, "-")) { // if doesn't contain only dashes if (!propertyIsWildcard(chart)) { pkMap.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chart); }/*from w w w .j a v a2 s.co m*/ if (!propertyIsWildcard(acct)) { pkMap.put(OLEPropertyConstants.ACCOUNT_NUMBER, acct); } if (!propertyIsWildcard(subAcct) && StringUtils.isNotBlank(subAcct) && !StringUtils.containsOnly(subAcct, "-")) { pkMap.put(OLEPropertyConstants.SUB_ACCOUNT_NUMBER, subAcct); if (!checkExistenceFromTable(SubAccount.class, pkMap)) { logErrorUtility(OLEPropertyConstants.SUB_ACCOUNT_NUMBER, RiceKeyConstants.ERROR_EXISTENCE); success = false; } } } return success; }