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.ikanow.aleph2.harvest.script.utils.ScriptUtils.java

/**
 * Just a helper function that calls stopScriptProcess then startScriptProcess
 * @param bucket//from   w  w w  .  j a va2 s .c  o  m
 */
public static BasicMessageBean restartScriptProcess(final DataBucketBean bucket, final IHarvestContext context,
        final String aleph_local_root_path, final String aleph_global_root_path,
        final ScriptHarvesterBucketConfigBean config, final String message, final String working_dir,
        Optional<Long> requested_num_objects, Optional<Long> max_run_time_secs) {
    final BasicMessageBean stop_result = stopScriptProcess(bucket, config, message, working_dir,
            aleph_local_root_path);
    final BasicMessageBean start_result = startScriptProcess(bucket, context, aleph_local_root_path,
            aleph_global_root_path, config, message, working_dir, requested_num_objects, max_run_time_secs);
    //merge the results and return that bean
    final Map<String, Object> details = new HashMap<String, Object>();
    if (stop_result.details() != null)
        details.putAll(stop_result.details());
    if (start_result.details() != null)
        details.putAll(start_result.details());
    return new BasicMessageBean(new Date(), stop_result.success() && start_result.success(),
            ScriptHarvestService.class.getSimpleName(), "restartScriptProcess", 0,
            "STOP: " + stop_result.message() + " START: " + start_result.message(), details);
}

From source file:com.glaf.core.util.QueryUtils.java

public static Map<String, Object> lowerKeyMap(Map<String, Object> paramMap) {
    Map<String, Object> dataMap = new LowerLinkedMap();
    dataMap.putAll(paramMap);
    return dataMap;
}

From source file:ch.cyberduck.ui.cocoa.odb.EditorFactory.java

/**
 * @return All statically registered and installed editors
 *///  w ww  .  j av a2 s. com
public static Map<String, String> getInstalledEditors() {
    if (log.isTraceEnabled()) {
        log.trace("getInstalledEditors");
    }
    Map<String, String> installed = new HashMap<String, String>();
    if (Preferences.instance().getBoolean("editor.odb.enable")) {
        installed.putAll(ODBEditor.getInstalledEditors());
    }
    if (Preferences.instance().getBoolean("editor.kqueue.enable")) {
        installed.putAll(WatchEditor.getInstalledEditors());
    }
    return installed;
}

From source file:com.opentok.test.Helpers.java

public static Map<String, String> decodeToken(String token) throws UnsupportedEncodingException {
    Map<String, String> tokenData = new HashMap<String, String>();
    token = token.substring(4);//from w w  w.j  av a 2 s. c o m
    byte[] buffer = Base64.decodeBase64(token);
    String decoded = new String(buffer, "UTF-8");
    String[] decodedParts = decoded.split(":");
    for (String part : decodedParts) {
        tokenData.putAll(decodeFormData(part));
    }
    return tokenData;
}

From source file:ch.cyberduck.ui.cocoa.odb.EditorFactory.java

/**
 * @return All statically registered but possibly not installed editors
 *//*ww  w.  j  av a  2  s .c o m*/
public static Map<String, String> getSupportedEditors() {
    if (log.isTraceEnabled()) {
        log.trace("getSupportedEditors");
    }
    Map<String, String> supported = new HashMap<String, String>();
    if (Preferences.instance().getBoolean("editor.odb.enable")) {
        supported.putAll(ODBEditor.getSupportedEditors());
    }
    if (Preferences.instance().getBoolean("editor.kqueue.enable")) {
        supported.putAll(WatchEditor.getSupportedEditors());
    }
    final String defaultEditor = defaultEditor();
    if (null == defaultEditor) {
        return supported;
    }
    if (!supported.values().contains(defaultEditor)) {
        supported.put(EditorFactory.getApplicationName(defaultEditor), defaultEditor);
    }
    return supported;
}

From source file:cern.enice.jira.listeners.pvss_license_request_listener.PvssLicenseRequestListener.java

@SuppressWarnings("unchecked")
static LicenseRequestData prepareLicenseRequestData(Map<String, Object> webhookData, Map<String, Object> issue,
        Map<String, Object> issueExtendedData) throws ParseException {
    LicenseRequestData licenseRequestData = new LicenseRequestData();
    Map<String, Object> fields = new HashMap<String, Object>();
    if (issue.containsKey("fields")) {
        fields.putAll((Map<String, Object>) issue.get("fields"));
    }//from ww w. j av a 2s .co  m
    String issueKey = (String) issue.get("key");
    licenseRequestData.setIssueKey(issueKey);
    licenseRequestData.setCustomFields(PvssLicenseRequestListener.getCustomFields(issueExtendedData));
    if (fields.containsKey("created")) {
        licenseRequestData.setCreationDate(ListenerUtils.formatCreationDate((String) fields.get("created")));
    }
    licenseRequestData.setMessageId(DigestUtils.md5Hex(issueKey + "PVSSLic"));
    Map<String, Object> assignee = (Map<String, Object>) fields.get("assignee");
    licenseRequestData.setAssigneeEmail(assignee == null ? "" : (String) assignee.get("emailAddress"));
    licenseRequestData.setReporterDetails(ListenerUtils.getReporterDetails(fields));
    String comment = (String) webhookData.get("comment");
    licenseRequestData.setComment(comment == null ? "" : comment);
    String description = (String) fields.get("description");
    licenseRequestData.setDescription(description == null ? "" : description);
    List<Map<String, Object>> components = (List<Map<String, Object>>) fields.get("components");
    licenseRequestData.setComponents(components);
    return licenseRequestData;
}

From source file:de.tudarmstadt.ukp.dkpro.tc.core.util.SaveModelUtils.java

public static void writeModelParameters(TaskContext aContext, File aOutputFolder, List<String> aFeatureSet,
        List<Object> aFeatureParameters) throws Exception {
    // write meta collector data
    // automatically determine the required metaCollector classes from the
    // provided feature
    // extractors
    Set<Class<? extends MetaCollector>> metaCollectorClasses;
    try {/*from   w w  w .ja v a2 s .  co m*/
        metaCollectorClasses = TaskUtils.getMetaCollectorsFromFeatureExtractors(aFeatureSet);
    } catch (ClassNotFoundException e) {
        throw new ResourceInitializationException(e);
    } catch (InstantiationException e) {
        throw new ResourceInitializationException(e);
    } catch (IllegalAccessException e) {
        throw new ResourceInitializationException(e);
    }

    // collect parameter/key pairs that need to be set
    Map<String, String> metaParameterKeyPairs = new HashMap<String, String>();
    for (Class<? extends MetaCollector> metaCollectorClass : metaCollectorClasses) {
        try {
            metaParameterKeyPairs.putAll(metaCollectorClass.newInstance().getParameterKeyPairs());
        } catch (InstantiationException e) {
            throw new ResourceInitializationException(e);
        } catch (IllegalAccessException e) {
            throw new ResourceInitializationException(e);
        }
    }

    Properties parameterProperties = new Properties();
    for (Entry<String, String> entry : metaParameterKeyPairs.entrySet()) {
        File file = new File(aContext.getStorageLocation(META_KEY, AccessMode.READWRITE), entry.getValue());

        String name = file.getName();
        String subFolder = aOutputFolder.getAbsoluteFile() + "/" + name;
        File targetFolder = new File(subFolder);
        copyToTargetLocation(file, targetFolder);
        parameterProperties.put(entry.getKey(), name);

        // should never be reached
    }

    for (int i = 0; i < aFeatureParameters.size(); i = i + 2) {

        String key = (String) aFeatureParameters.get(i).toString();
        String value = aFeatureParameters.get(i + 1).toString();

        if (valueExistAsFileOrFolderInTheFileSystem(value)) {
            String name = new File(value).getName();
            String destination = aOutputFolder + "/" + name;
            copyToTargetLocation(new File(value), new File(destination));
            parameterProperties.put(key, name);
            continue;
        }
        parameterProperties.put(key, value);
    }

    FileWriter writer = new FileWriter(new File(aOutputFolder, MODEL_PARAMETERS));
    parameterProperties.store(writer, "");
    writer.close();
}

From source file:com.ctrip.infosec.rule.resource.DataProxy.java

/**
 * ?DataProxyResponseresultMap/* w  w  w .  j  a va  2  s  .  co m*/
 */
private static Map parseProfileResult(Map result) {
    if (result != null) {
        if (result.get("tagName") != null) {
            return parseResult(result);
        } else if (result.get("tagNames") != null) {
            Object tagValues = result.get("tagNames");
            List oldResults = JSON.parseObject(JSON.toJSONString(tagValues), List.class);
            Map newResults = new HashMap();
            Iterator iterator = oldResults.iterator();
            while (iterator.hasNext()) {
                Map oneResult = (Map) iterator.next();
                newResults.putAll(parseResult(oneResult));
            }
            return newResults;
        } else {
            return result;
        }
    }
    return Collections.EMPTY_MAP;
}

From source file:gov.va.chir.tagline.dao.DatasetUtil.java

@SuppressWarnings("unchecked")
public static Instances createDataset(final Instances header, final Collection<Document> documents)
        throws Exception {

    // Update header to include all docIDs from the passed in documents
    // (Weka requires all values for nominal features)
    final Set<String> docIds = new TreeSet<String>();

    for (Document document : documents) {
        docIds.add(document.getName());//from   w w  w  .j a v  a 2  s .c  o  m
    }

    final AddValues avf = new AddValues();
    avf.setLabels(StringUtils.join(docIds, ","));

    // Have to add 1 because SingleIndex.setValue() has a bug, expecting
    // the passed in index to be 1-based rather than 0-based. Why? I have 
    // no idea.
    // Calling path: AddValues.setInputFormat() -->
    //               SingleIndex.setUpper() -->
    //               SingleIndex.setValue()
    avf.setAttributeIndex(String.valueOf(header.attribute(DOC_ID).index() + 1));

    avf.setInputFormat(header);
    final Instances newHeader = Filter.useFilter(header, avf);

    final Instances instances = new Instances(newHeader, documents.size());

    // Map attributes
    final Map<String, Attribute> attrMap = new HashMap<String, Attribute>();

    final Enumeration<Attribute> en = newHeader.enumerateAttributes();

    while (en.hasMoreElements()) {
        final Attribute attr = en.nextElement();

        attrMap.put(attr.name(), attr);
    }

    attrMap.put(newHeader.classAttribute().name(), newHeader.classAttribute());

    final Attribute docId = attrMap.get(DOC_ID);
    final Attribute lineId = attrMap.get(LINE_ID);
    final Attribute classAttr = attrMap.get(LABEL);

    // Add data
    for (Document document : documents) {
        final Map<String, Object> docFeatures = document.getFeatures();

        for (Line line : document.getLines()) {
            final Instance instance = new DenseInstance(attrMap.size());

            final Map<String, Object> lineFeatures = line.getFeatures();
            lineFeatures.putAll(docFeatures);

            instance.setValue(docId, document.getName());
            instance.setValue(lineId, line.getLineId());

            if (line.getLabel() == null) {
                instance.setMissing(classAttr);
            } else {
                instance.setValue(classAttr, line.getLabel());
            }

            for (Attribute attribute : attrMap.values()) {
                if (!attribute.equals(docId) && !attribute.equals(lineId) && !attribute.equals(classAttr)) {
                    final String name = attribute.name();
                    final Object obj = lineFeatures.get(name);

                    if (obj instanceof Double) {
                        instance.setValue(attribute, ((Double) obj).doubleValue());
                    } else if (obj instanceof Integer) {
                        instance.setValue(attribute, ((Integer) obj).doubleValue());
                    } else {
                        instance.setValue(attribute, obj.toString());
                    }
                }
            }

            instances.add(instance);
        }
    }

    // Set last attribute as class
    instances.setClassIndex(attrMap.size() - 1);

    return instances;
}

From source file:io.cloudslang.maven.compiler.CloudSlangMavenCompiler.java

private static Map<String, byte[]> getDependenciesSourceFiles(CompilerConfiguration config)
        throws CompilerException {
    if (config.getClasspathEntries().isEmpty()) {
        return Collections.emptyMap();
    }// ww w  .  ja  va2s  . c  om

    Map<String, byte[]> sources = new HashMap<>();
    for (String dependency : config.getClasspathEntries()) {
        try {
            sources.putAll(getSourceFilesForDependencies(dependency));
        } catch (IOException e) {
            throw new CompilerException("Cannot load sources from: " + dependency + ". " + e.getMessage());
        }
    }

    return sources;
}