Example usage for org.apache.commons.collections MapUtils getString

List of usage examples for org.apache.commons.collections MapUtils getString

Introduction

In this page you can find the example usage for org.apache.commons.collections MapUtils getString.

Prototype

public static String getString(Map map, Object key, String defaultValue) 

Source Link

Document

Looks up the given key in the given map, converting the result into a string, using the default value if the the conversion fails.

Usage

From source file:com.thruzero.common.core.config.AbstractConfig.java

@Override
public String getValue(final String sectionName, final String key) {
    return MapUtils.getString(getSection(sectionName), key, null);
}

From source file:com.thruzero.common.core.config.AbstractConfig.java

@Override
public String getValue(final String sectionName, final String key, final String defaultValue) {
    return MapUtils.getString(getSection(sectionName), key, defaultValue);
}

From source file:com.senseidb.plugin.analyzer.LucenePatternAnalyzerFactory.java

@Override
public Analyzer getBean(Map<String, String> initProperties, String fullPrefix,
        SenseiPluginRegistry pluginRegistry) {
    Version matchVersion = Version.valueOf(MapUtils.getString(initProperties, "matchVersion", "LUCENE_35"));
    Pattern pattern = Pattern.compile(MapUtils.getString(initProperties, "pattern", "\\s+"));
    boolean toLowerCase = MapUtils.getBoolean(initProperties, "toLowerCase", true);
    String stopWordsStr = MapUtils.getString(initProperties, "stopWords", "");
    Set<String> stopWords = new HashSet<String>(Arrays.asList(stopWordsStr.split("\\s*,\\s*")));
    return new PatternAnalyzer(matchVersion, pattern, toLowerCase, stopWords);
}

From source file:com.mirth.connect.model.ncpdp.NCPDPReference.java

public String getTransactionName(String key) {
    return MapUtils.getString(transactionMap, key, key);
}

From source file:com.mirth.connect.model.ncpdp.NCPDPReference.java

public String getSegment(String key, String version) {
    if (StringUtils.equals(version, VERSION_D0)) {
        return MapUtils.getString(segmentD0Map, key, key);
    } else {//  w  w  w. ja v  a2s  .  c o  m
        return MapUtils.getString(segment51Map, key, key);
    }
}

From source file:com.mirth.connect.model.ncpdp.NCPDPReference.java

public String getDescription(String key, String version) {
    if (StringUtils.equals(version, VERSION_D0)) {
        return MapUtils.getString(NCPDPD0map, key, StringUtils.EMPTY);
    } else {/*from   www  . j  a va2  s  .  c  o m*/
        return MapUtils.getString(NCPDP51map, key, StringUtils.EMPTY);
    }
}

From source file:com.senseidb.plugin.analyzer.LucenePerFieldAnalyzerFactory.java

@Override
public Analyzer getBean(Map<String, String> initProperties, String fullPrefix,
        SenseiPluginRegistry pluginRegistry) {
    Analyzer defaultAnalyzer = pluginRegistry.getBeanByFullPrefix(fullPrefix + ".default", Analyzer.class);
    if (defaultAnalyzer == null) {
        defaultAnalyzer = new StandardAnalyzer(Version.LUCENE_35);
    }//from   w  ww . j  a  v  a  2  s . c  om

    String[] fields = MapUtils.getString(initProperties, "fields", "").split("\\s*,\\s*");
    Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>();
    for (String field : fields) {
        String analyzerPrefix = fullPrefix + ".fields." + field;
        Analyzer analyzer = pluginRegistry.getBeanByFullPrefix(analyzerPrefix, Analyzer.class);
        analyzers.put(field, analyzer);
    }

    return new PerFieldAnalyzerWrapper(defaultAnalyzer, analyzers);
}

From source file:gov.nih.nci.cabig.caaers.dao.InvestigationalNewDrugDao.java

/**
 * Get the list of investigational new drugs which match the input parameters.
 * //from w w  w  .  j  av  a 2s.  c om
 * @param paramMap
 *                The input parameters.
 * @return The list of investigational new drugs.
 */
@SuppressWarnings("unchecked")
public List<InvestigationalNewDrug> searchInvestigationalNewDrugs(Map<String, String> paramMap) {
    return getHibernateTemplate().findByNamedParam(SEARCH_IND_QUERY, new String[] { "name", "indNo" },
            new String[] { "%" + MapUtils.getString(paramMap, "sponsorName", "%") + "%",
                    "%" + MapUtils.getString(paramMap, "strINDNumber", "%") + "%" });
}

From source file:com.ctrip.infosec.rule.executor.RulesExecutorService.java

/**
 * ?/*from   ww w  . ja v a  2s.  c  o m*/
 */
void buidFinalResult(RiskFact fact, boolean isAsync) {

    Map<String, Object> finalResult = Constants.defaultResult;
    Map<String, Object> finalResult4Async = Constants.defaultResult;
    if (!isAsync) {
        // finalResult
        for (Map<String, Object> rs : fact.results.values()) {
            finalResult = compareAndReturn(finalResult, rs);
        }
        fact.setFinalResult(Maps.newHashMap(finalResult));

        // originalRiskLevel
        int riskLevel = valueAsInt(finalResult, Constants.riskLevel);
        fact.finalResult.put(Constants.originalRiskLevel, riskLevel);

        fact.finalResult.remove(Constants.async);
        fact.finalResult.remove(Constants.timeUsage);
    } else {
        // finalResult4Async
        for (Map<String, Object> rs : fact.results4Async.values()) {
            finalResult4Async = compareAndReturn(finalResult4Async, rs);
        }
        fact.setFinalResult4Async(Maps.newHashMap(finalResult4Async));
        fact.finalResult4Async.remove(Constants.async);
        fact.finalResult4Async.remove(Constants.timeUsage);
    }

    // ?????
    if (!fact.finalWhitelistResult.isEmpty() && !isAsync) {
        // 0 : ???
        // 95?95???
        // 97??195????97
        int whitelistRiskLevel = valueAsInt(fact.finalWhitelistResult, Constants.riskLevel);
        if (whitelistRiskLevel == 0) {
            fact.setFinalResult(Maps.newHashMap(Constants.defaultResult));
        } else if (whitelistRiskLevel == 95) {
            fact.setFinalResult(Maps.newHashMap(fact.finalWhitelistResult));
        } else if (whitelistRiskLevel == 97) {
            int riskLevel = valueAsInt(finalResult, Constants.riskLevel);
            if (riskLevel < 195) {
                fact.setFinalResult(Maps.newHashMap(fact.finalWhitelistResult));
            }
        }
    }
    fact.finalResult.remove(Constants.async);
    fact.finalResult.remove(Constants.timeUsage);

    // finalResultGroupByScene
    Map<String, Map<String, Object>> finalResultGroupByScene = isAsync ? fact.finalResultGroupByScene4Async
            : fact.finalResultGroupByScene;
    Map<String, Map<String, Object>> resultsGroupByScene = isAsync ? fact.resultsGroupByScene4Async
            : fact.resultsGroupByScene;
    for (Map<String, Object> rs : resultsGroupByScene.values()) {
        List<String> sceneTypeList = valueAsList(rs, Constants.riskScene);
        if (sceneTypeList != null) {
            for (String sceneType : sceneTypeList) {
                int riskLevel = MapUtils.getInteger(rs, Constants.riskLevel, 0);
                String riskMessage = MapUtils.getString(rs, Constants.riskMessage, "");

                // finalResultGroupBySceneput 
                Map<String, Object> sceneResult = finalResultGroupByScene.get(sceneType);
                if (null == sceneResult) {
                    sceneResult = new HashMap<>();
                    sceneResult.put(Constants.riskLevel, riskLevel);
                    sceneResult.put(Constants.riskMessage, riskMessage);
                    finalResultGroupByScene.put(sceneType, sceneResult);
                } else {
                    int lastRiskLevel = MapUtils.getInteger(sceneResult, Constants.riskLevel, 0);
                    if (riskLevel > lastRiskLevel) {
                        sceneResult.put(Constants.riskLevel, riskLevel);
                        sceneResult.put(Constants.riskMessage, riskMessage);
                    }
                }
            }
        }
        Map<String, Map<String, Map<String, String>>> subLevelGroupBySceneType = valueAsMap(rs,
                Constants.subSceneType);
        if (subLevelGroupBySceneType != null) {
            for (String sceneType : subLevelGroupBySceneType.keySet()) {
                Map<String, Map<String, String>> subLevelGroupBySubSceneType = subLevelGroupBySceneType
                        .get(sceneType);

                //?
                Map<String, Object> sceneResult = finalResultGroupByScene.get(sceneType);
                if (null == sceneResult) {
                    sceneResult = new HashMap<>();
                    sceneResult.put(Constants.riskLevel, 0);
                    sceneResult.put(Constants.riskMessage, "PASS");
                    finalResultGroupByScene.put(sceneType, sceneResult);
                }

                int sceneRiskLevel = valueAsInt(sceneResult, Constants.riskLevel);
                Map<String, Map<String, String>> finalSubResults = Maps.newHashMap();

                for (Entry<String, Map<String, String>> entry : subLevelGroupBySubSceneType.entrySet()) {

                    // ????
                    int subSceneRiskLevel = valueAsInt(entry.getValue(), Constants.riskLevel);
                    if (subSceneRiskLevel > sceneRiskLevel) {
                        finalSubResults.put(entry.getKey(), entry.getValue());
                    }

                }

                sceneResult.put(Constants.subSceneType, finalSubResults);
            }
        }
    }
    if (!isAsync) {
        fact.setFinalResultGroupByScene(Maps.newHashMap(finalResultGroupByScene));
        fact.finalResultGroupByScene.remove(Constants.async);
        fact.finalResultGroupByScene.remove(Constants.timeUsage);
    } else {
        fact.setFinalResultGroupByScene4Async(Maps.newHashMap(finalResultGroupByScene));
        fact.finalResultGroupByScene4Async.remove(Constants.async);
        fact.finalResultGroupByScene4Async.remove(Constants.timeUsage);
    }
}

From source file:net.di2e.ecdr.commons.filter.StrictFilterDelegate.java

@Override
public Map<String, String> handlePropertyEqualToString(String propertyName, String literal,
        StringFilterOptions options) {/*from w w  w  .j a  va  2  s . c  o  m*/
    Map<String, String> filterContainer = new HashMap<String, String>();
    if (handleKeyword(propertyName, literal, filterContainer)) {
        if (StringFilterOptions.CASE_SENSITIVE.equals(options)) {
            filterContainer.put(SearchConstants.CASESENSITIVE_PARAMETER, SearchConstants.TRUE_STRING);
        } else if (StringFilterOptions.FUZZY.equals(options)) {
            filterContainer.put(SearchConstants.FUZZY_PARAMETER, SearchConstants.TRUE_STRING);
        }
    } else {
        filterContainer.put(MapUtils.getString(propertyMap, propertyName, propertyName), literal);
    }

    return filterContainer;
}