Example usage for java.util Map putAll

List of usage examples for java.util Map putAll

Introduction

In this page you can find the example usage for java.util Map putAll.

Prototype

void putAll(Map<? extends K, ? extends V> m);

Source Link

Document

Copies all of the mappings from the specified map to this map (optional operation).

Usage

From source file:com.netsteadfast.greenstep.bsc.model.BscMeasureDataFrequency.java

public static Map<String, String> getFrequencyMap(boolean pleaseSelect) {
    Map<String, String> dataMap = new LinkedHashMap<String, String>();
    if (pleaseSelect) {
        dataMap.put(Constants.HTML_SELECT_NO_SELECT_ID, Constants.HTML_SELECT_NO_SELECT_NAME);
    }//from   w w  w  .  j  a  v a  2s  .co m
    if (frequencyMap.size() < 1) {
        loadMapData();
    }
    dataMap.putAll(frequencyMap);
    return dataMap;
}

From source file:me.prokopyl.commandtools.migration.UUIDFetcher.java

static public Map<String, UUID> fetch(List<String> names, int limitByRequest)
        throws IOException, InterruptedException {
    Map<String, UUID> UUIDs = new HashMap<String, UUID>();
    int requests = (names.size() / limitByRequest) + 1;

    List<String> tempNames;
    Map<String, UUID> tempUUIDs;

    for (int i = 0; i < requests; i++) {
        tempNames = names.subList(limitByRequest * i, Math.min((limitByRequest * (i + 1)) - 1, names.size()));
        tempUUIDs = fetch(tempNames);//from www  .  j  a  v  a  2 s.c  o m
        UUIDs.putAll(tempUUIDs);
        Thread.sleep(400);
    }

    return UUIDs;
}

From source file:ca.weblite.contacts.webservice.RESTServiceConfiguration.java

private static void loadRuntimeSettings() {
    Properties p = new Properties();
    Map props = new HashMap();
    try {//ww  w. j  a va 2 s. com
        InputStream in = RESTServiceConfiguration.class.getResourceAsStream("/runtime.properties");
        if (in != null) {
            try {
                p.load(in);
                props.putAll(p);
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (Throwable t) {
                    }
                }
            }
        }
        in = RESTServiceConfiguration.class.getResourceAsStream("/runtime.override.properties");
        if (in != null) {
            try {
                p.load(in);
                props.putAll(p);
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (Throwable t) {
                    }
                }
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    System.out.println("In LoadRuntimeSettings");
    System.out.println(p);
    if (p.containsKey("DB_URL")) {
        DB_URL = (String) p.get("DB_URL");
        DB_PASSWORD = (String) p.get("DB_PASSWORD");
        DB_USERNAME = (String) p.get("DB_USERNAME");
    }
    if (p.containsKey("GCM_SERVER_API_KEY")) {
        GCM_SERVER_API_KEY = (String) p.get("GCM_SERVER_API_KEY");
    }
    if (p.containsKey("PUSH_TOKEN")) {
        PUSH_TOKEN = (String) p.get("PUSH_TOKEN");
    }
    if (p.containsKey("IOS_PUSH_CERT_URL")) {
        IOS_PUSH_CERT_URL = (String) p.getProperty("IOS_PUSH_CERT_URL");
    }
    if (p.containsKey("IOS_PUSH_CERT_PASSWORD")) {
        IOS_PUSH_CERT_PASSWORD = (String) p.getProperty("IOS_PUSH_CERT_PASSWORD");
    }

}

From source file:com.borqs.sync.server.contact.MergeUtils.java

/**
 *
 *///from   w ww  .  j av  a  2 s. co  m
public static MergeResult mergeMap(Map mapA, Map mapB) {

    MergeResult result = new MergeResult();

    if (mapA == null && mapB != null) {
        mapA = new HashMap();
        mapA.putAll(mapB);
        result.addPropertyA("MapA", "MapA is null, MapB isn't null");
        return result;
    }

    if (mapA != null && mapB == null) {
        mapB = new HashMap();
        mapB.putAll(mapA);
        result.addPropertyB("MapB", "MapA isn't null, MapB is null");
        return result;
    }

    if (mapA == null && mapB == null) {
        return result;
    }

    Iterator itA = mapA.keySet().iterator();
    String key = null;
    String valueA = null;
    String valueB = null;
    MergeResult tmpResult = null;

    while (itA.hasNext()) {
        key = (String) itA.next();
        valueA = (String) mapA.get(key);
        valueB = (String) mapB.get(key);

        tmpResult = MergeUtils.compareStrings(valueA, valueB);
        if (tmpResult.isSetARequired()) {
            mapA.put(key, valueB);
        } else if (tmpResult.isSetBRequired()) {
            mapB.put(key, valueA);
        }

        result.addMergeResult(tmpResult, key);
    }

    Iterator itB = mapB.keySet().iterator();

    while (itB.hasNext()) {
        key = (String) itB.next();
        valueA = (String) mapA.get(key);

        if (valueA != null) {
            //
            // The property is already in MapA so we can continue
            // (we already have handled this prop in the previous cycle)
            //
            continue;
        }

        valueB = (String) mapB.get(key);

        tmpResult = MergeUtils.compareStrings(valueA, valueB);
        if (tmpResult.isSetARequired()) {
            mapA.put(key, valueB);
        } else if (tmpResult.isSetBRequired()) {
            mapB.put(key, valueA);
        }

        result.addMergeResult(tmpResult, key);
    }

    return result;
}

From source file:com.baidu.rigel.biplatform.tesseract.qsservice.query.QueryContextBuilder.java

public static Map<String, String> getRequestParams(QuestionModel questionModel, Cube cube) {
    Map<String, String> rs = Maps.newHashMap();
    rs.putAll(questionModel.getRequestParams());
    StringBuilder filterDimNames = new StringBuilder();
    if (questionModel.getQueryConditions() != null && questionModel.getQueryConditions().size() > 0) {
        questionModel.getQueryConditions().forEach((k, v) -> {
            Dimension dim = cube.getDimensions().get(k);
            MiniCube miniCube = (MiniCube) cube;
            if (dim != null && miniCube.getSource().equals(dim.getTableName())) {
                DimensionCondition cond = (DimensionCondition) v;
                StringBuilder sb = new StringBuilder();
                List<QueryData> queryDataNodes = cond.getQueryDataNodes();
                int size = queryDataNodes.size();
                String[] strArray = null;
                for (int index = 0; index < size; ++index) {
                    QueryData data = queryDataNodes.get(index);
                    strArray = MetaNameUtil.parseUnique2NameArray(data.getUniqueName());
                    sb.append(strArray[strArray.length - 1]);
                    if (index < size - 1) {
                        sb.append(",");
                    }/*  ww w.  j a v a2 s. c  om*/
                }
                filterDimNames.append(cond.getMetaName());
                rs.put(cond.getMetaName(), sb.toString());
            }
        });
    }
    rs.put(FILTER_DIM_KEY, filterDimNames.toString());
    return rs;
}

From source file:io.cloudslang.lang.tools.build.tester.TriggerTestCaseEventListener.java

public static Map<String, Serializable> extractOutputs(LanguageEventData data) {

    Map<String, Serializable> outputsMap = new HashMap<>();

    boolean thereAreOutputsForRootPath = data.containsKey(LanguageEventData.OUTPUTS)
            && data.containsKey(LanguageEventData.PATH) && data.getPath().equals(EXEC_START_PATH);

    if (thereAreOutputsForRootPath) {
        Map<String, Serializable> outputs = data.getOutputs();
        if (MapUtils.isNotEmpty(outputs)) {
            outputsMap.putAll(outputs);
        }/*  ww  w  .j ava2  s .  co  m*/
    }

    return outputsMap;
}

From source file:com.jhkt.playgroundArena.db.nosql.mongodb.beans.AbstractDocument.java

private final static Object convertBacktoClassInstanceHelper(DBObject dBObject) {

    Object returnValue = null;/*from   w  ww  .j  ava 2s  . co m*/

    try {
        String className = dBObject.get(JPAConstants.CONVERTER_CLASS.CLASS.name()).toString();
        Class<?> classCheck = Class.forName(className);

        if (AbstractDocument.class.isAssignableFrom(classCheck)) {
            Class<? extends AbstractDocument> classToConvertTo = classCheck.asSubclass(AbstractDocument.class);
            AbstractDocument dInstance = classToConvertTo.newInstance();

            for (String key : dBObject.keySet()) {
                Object value = dBObject.get(key);

                char[] propertyChars = key.toCharArray();
                String methodMain = String.valueOf(propertyChars[0]).toUpperCase() + key.substring(1);
                String methodName = "set" + methodMain;
                String getMethodName = "get" + methodMain;

                if (key.equals(JPAConstants.CONVERTER_CLASS.CLASS.name())) {
                    continue;
                }

                if (value instanceof BasicDBObject) {
                    value = convertBacktoClassInstanceHelper(BasicDBObject.class.cast(value));
                }

                try {
                    Method getMethod = classToConvertTo.getMethod(getMethodName);
                    Class<?> getReturnType = getMethod.getReturnType();
                    Method method = classToConvertTo.getMethod(methodName, getReturnType);

                    if (getMethod.isAnnotationPresent(IDocumentKeyValue.class)) {
                        method.invoke(dInstance, value);
                    }
                } catch (NoSuchMethodException nsMe) {
                    _log.warn("Within convertBacktoClassInstance, following method was not found " + methodName,
                            nsMe);
                }

            }

            returnValue = dInstance;

        } else if (Enum.class.isAssignableFrom(classCheck)) {

            List<?> constants = Arrays.asList(classCheck.getEnumConstants());
            String name = String.class.cast(dBObject.get(JPAConstants.CONVERTER_CLASS.CONTENT.name()));
            for (Object constant : constants) {
                if (constant.toString().equals(name)) {
                    returnValue = constant;
                }
            }

        } else if (Collection.class.isAssignableFrom(classCheck)) {

            @SuppressWarnings("unchecked")
            Class<? extends Collection<? super Object>> classToConvertTo = (Class<? extends Collection<? super Object>>) classCheck;
            Collection<? super Object> cInstance = classToConvertTo.newInstance();

            BasicDBList bDBList = (BasicDBList) dBObject.get(JPAConstants.CONVERTER_CLASS.CONTENT.name());
            cInstance.addAll(bDBList);

            returnValue = cInstance;

        } else if (Map.class.isAssignableFrom(classCheck)) {

            @SuppressWarnings("unchecked")
            Class<? extends Map<String, ? super Object>> classToConvertTo = (Class<? extends Map<String, ? super Object>>) classCheck;
            Map<String, ? super Object> mInstance = classToConvertTo.newInstance();

            BasicDBObject mapObject = (BasicDBObject) dBObject.get(JPAConstants.CONVERTER_CLASS.CONTENT.name());
            mInstance.putAll(mapObject);

            returnValue = mInstance;

        }

    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    return returnValue;
}

From source file:com.yahoo.sql4dclient.BeanGenUtil.java

public static void generateBean(String cmd, String beanClassName) {
    Matcher joinSqlMatcher = joinSqlPattern.matcher(cmd);
    if (joinSqlMatcher.matches()) {
        Map<String, String> firstSet = getFields(joinSqlMatcher.group(1));
        Map<String, String> secondSet = null;
        Matcher sqlMatcher = sqlPattern.matcher(joinSqlMatcher.group(4));
        if (sqlMatcher.matches()) {
            secondSet = getFields(sqlMatcher.group(1));
            String joinField = joinSqlMatcher.group(5);
            secondSet.remove(joinField);
            firstSet.putAll(secondSet);
        }//from w ww .j  a v a  2  s .c om
        generate(firstSet, beanClassName);
    } else {
        Matcher sqlMatcher = sqlPattern.matcher(cmd);
        if (sqlMatcher.matches()) {
            generate(getFields(sqlMatcher.group(1)), beanClassName);
        }
    }
}

From source file:com.panet.imeta.core.util.StringUtil.java

/**
 * Substitutes variables in <code>aString</code> with the environment
 * values in the system properties/*from ww w  .  j ava  2 s  .  com*/
 * 
 * @param aString
 *            the string on which to apply the substitution.
 * @param systemProperties
 *            the system properties to use
 * @return the string with the substitution applied.
 */
public static final String environmentSubstitute(String aString, Map<String, String> systemProperties) {
    Map<String, String> sysMap = new HashMap<String, String>();
    sysMap.putAll(systemProperties);

    aString = substituteWindows(aString, sysMap);
    aString = substituteUnix(aString, sysMap);
    aString = substituteHex(aString);
    return aString;
}

From source file:com.baidu.rigel.biplatform.parser.util.ConditionUtil.java

/** 
 * contexCondition??//from w  w  w .ja  v  a2  s . c  o  m
 * simpleMergeContexsCondition
 * @param contexs
 * @return
 */
public static Map<Condition, Set<String>> simpleMergeContexsCondition(Collection<CompileContext> contexs) {

    Map<Condition, Set<String>> result = new HashMap<Condition, Set<String>>();
    if (CollectionUtils.isNotEmpty(contexs)) {
        Map<Condition, Set<String>> condition = null;
        for (CompileContext contex : contexs) {
            // ?????
            condition = new HashMap<Condition, Set<String>>(contex.getConditionVariables());
            if (result.isEmpty()) {
                result.putAll(condition);
            } else if (MapUtils.isNotEmpty(condition)) {
                for (Entry<Condition, Set<String>> entry : result.entrySet()) {
                    if (condition.containsKey(entry.getKey())) {
                        entry.getValue().addAll(condition.get(entry.getKey()));
                        condition.remove(entry.getKey());
                    }
                }
                if (MapUtils.isNotEmpty(condition)) {
                    result.putAll(condition);
                }
            }
        }
    }
    return result;
}