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.github.fge.jsonschema.core.keyword.syntax.checkers.helpers.DependenciesSyntaxChecker.java

@Override
protected final void checkValue(final Collection<JsonPointer> pointers, final MessageBundle bundle,
        final ProcessingReport report, final SchemaTree tree) throws ProcessingException {
    final JsonNode node = getNode(tree);
    final Map<String, JsonNode> map = Maps.newTreeMap();
    map.putAll(JacksonUtils.asMap(node));

    String key;/*from  ww  w  . j  a  va2 s  .co m*/
    JsonNode value;

    for (final Map.Entry<String, JsonNode> entry : map.entrySet()) {
        key = entry.getKey();
        value = entry.getValue();
        if (value.isObject())
            pointers.add(JsonPointer.of(keyword, key));
        else
            checkDependency(report, bundle, entry.getKey(), tree);
    }

}

From source file:io.dockstore.webservice.helpers.Helper.java

@SuppressWarnings("checkstyle:parameternumber")
public static Tool refreshContainer(final long containerId, final long userId, final HttpClient client,
        final ObjectMapper objectMapper, final UserDAO userDAO, final ToolDAO toolDAO, final TokenDAO tokenDAO,
        final TagDAO tagDAO, final FileDAO fileDAO) {
    Tool tool = toolDAO.findById(containerId);
    String gitUrl = tool.getGitUrl();
    Map<String, String> gitMap = SourceCodeRepoFactory.parseGitUrl(gitUrl);

    if (gitMap == null) {
        LOG.info("Could not parse Git URL. Unable to refresh tool!");
        return tool;
    }//from w w  w  . ja va 2s  .  c om

    String gitSource = gitMap.get("Source");
    String gitUsername = gitMap.get("Username");
    String gitRepository = gitMap.get("Repository");

    // Get user's quay and git tokens
    List<Token> tokens = tokenDAO.findByUserId(userId);
    Token quayToken = extractToken(tokens, TokenType.QUAY_IO.toString());
    Token githubToken = extractToken(tokens, TokenType.GITHUB_COM.toString());
    Token bitbucketToken = extractToken(tokens, TokenType.BITBUCKET_ORG.toString());

    // with Docker Hub support it is now possible that there is no quayToken
    if (gitSource.equals("github.com") && githubToken == null) {
        LOG.info("WARNING: GITHUB token not found!");
        throw new CustomWebApplicationException("A valid GitHub token is required to refresh this tool.",
                HttpStatus.SC_CONFLICT);
        //throw new CustomWebApplicationException("A valid GitHub token is required to refresh this tool.", HttpStatus.SC_CONFLICT);
    }
    if (gitSource.equals("bitbucket.org") && bitbucketToken == null) {
        LOG.info("WARNING: BITBUCKET token not found!");
        throw new CustomWebApplicationException("A valid Bitbucket token is required to refresh this tool.",
                HttpStatus.SC_BAD_REQUEST);
    }
    if (tool.getRegistry() == Registry.QUAY_IO && quayToken == null) {
        LOG.info("WARNING: QUAY.IO token not found!");
        throw new CustomWebApplicationException("A valid Quay.io token is required to refresh this tool.",
                HttpStatus.SC_BAD_REQUEST);
    }

    ImageRegistryFactory factory = new ImageRegistryFactory(client, objectMapper, quayToken);
    final ImageRegistryInterface anInterface = factory.createImageRegistry(tool.getRegistry());

    List<Tool> apiTools = new ArrayList<>();

    // Find a tool with the given tool's Path and is not manual
    Tool duplicatePath = null;
    List<Tool> containersList = toolDAO.findByPath(tool.getPath());
    for (Tool c : containersList) {
        if (c.getMode() != ToolMode.MANUAL_IMAGE_PATH) {
            duplicatePath = c;
            break;
        }
    }

    // If exists, check conditions to see if it should be changed to auto (in sync with quay tags and git repo)
    if (tool.getMode() == ToolMode.MANUAL_IMAGE_PATH && duplicatePath != null
            && tool.getRegistry().toString().equals(Registry.QUAY_IO.toString())
            && duplicatePath.getGitUrl().equals(tool.getGitUrl())) {
        tool.setMode(duplicatePath.getMode());
    }

    if (tool.getMode() == ToolMode.MANUAL_IMAGE_PATH) {
        apiTools.add(tool);
    } else {
        List<String> namespaces = new ArrayList<>();
        namespaces.add(tool.getNamespace());
        if (anInterface != null) {
            apiTools.addAll(anInterface.getContainers(namespaces));
        }
    }
    apiTools.removeIf(container1 -> !container1.getPath().equals(tool.getPath()));

    Map<String, ArrayList<?>> mapOfBuilds = new HashMap<>();
    if (anInterface != null) {
        mapOfBuilds.putAll(anInterface.getBuildMap(apiTools));
    }

    List<Tool> dbTools = new ArrayList<>();
    dbTools.add(tool);

    removeContainersThatCannotBeUpdated(dbTools);

    final User dockstoreUser = userDAO.findById(userId);
    // update information on a tool by tool level
    updateContainers(apiTools, dbTools, dockstoreUser, toolDAO);
    userDAO.clearCache();

    final List<Tool> newDBTools = new ArrayList<>();
    newDBTools.add(toolDAO.findById(tool.getId()));

    // update information on a tag by tag level
    final Map<String, List<Tag>> tagMap = getTags(client, newDBTools, objectMapper, quayToken, mapOfBuilds);

    updateTags(newDBTools, client, toolDAO, tagDAO, fileDAO, githubToken, bitbucketToken, tagMap);
    userDAO.clearCache();

    return toolDAO.findById(tool.getId());
}

From source file:com.linkedin.gradle.python.util.internal.pex.ThinPexGenerator.java

@Override
public void buildEntryPoints() throws Exception {
    DeployableExtension deployableExtension = ExtensionUtils.getPythonComponentExtension(project,
            DeployableExtension.class);
    PexExtension pexExtension = ExtensionUtils.getPythonComponentExtension(project, PexExtension.class);

    List<String> dependencies = new PipFreezeAction(project).getDependencies();

    PexExecSpecAction action = PexExecSpecAction.withOutEntryPoint(project, project.getName(), dependencies);

    ExecResult exec = project.exec(action);
    new PexExecOutputParser(action, exec).validatePexBuildSuccessfully();

    for (String it : EntryPointHelpers.collectEntryPoints(project)) {
        logger.lifecycle("Processing entry point: {}", it);
        String[] split = it.split("=");
        String name = split[0].trim();
        String entry = split[1].trim();

        Map<String, String> propertyMap = new HashMap<>();
        propertyMap.putAll(extraProperties);
        propertyMap.put("realPex", project.getName() + ".pex");
        propertyMap.put("entryPoint", entry);

        new EntryPointWriter(project, getTemplate(pexExtension))
                .writeEntryPoint(new File(deployableExtension.getDeployableBinDir(), name), propertyMap);
    }/*from   w  ww.ja  va 2  s  .com*/
}

From source file:com.infinitechaos.vpcviewer.web.rest.dto.VpcDetailDTO.java

public VpcDetailDTO(final Vpc vpc, final List<Subnet> subnets, final List<RouteTable> routeTables) {
    super(vpc);/*  w w  w  . ja  v  a  2s  .c om*/

    final Map<String, SubnetDetailDTO> subnetDetails = new HashMap<>();
    subnetDetails.putAll(subnets.stream().map(SubnetDetailDTO::new)
            .collect(Collectors.toMap(s -> s.getSubnetId(), identity())));

    LOG.trace("Details map: {}", subnetDetails);

    routeTables.stream().map(RouteTableDTO::new).forEach(rt -> rt.getAssociations().forEach(assoc -> {
        SubnetDetailDTO dto = subnetDetails.get(assoc.getSubnetId());

        if (dto == null) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("RT: {}, Assoc.SubnetID: {}, Assocs: {}", rt.getRouteTableId(), assoc.getSubnetId(),
                        rt.getAssociations());
            }

            return;
        }

        dto.setRouteTableId(rt.getRouteTableId());
        dto.getRoutes().addAll(rt.getRoutes());
    }));

    this.subnets.addAll(subnetDetails.values());
}

From source file:io.spring.initializr.web.test.ResponseFieldSnippet.java

@Override
public void document(Operation operation) throws IOException {
    RestDocumentationContext context = (RestDocumentationContext) operation.getAttributes()
            .get(RestDocumentationContext.class.getName());
    WriterResolver writerResolver = (WriterResolver) operation.getAttributes()
            .get(WriterResolver.class.getName());
    try (Writer writer = writerResolver.resolve(operation.getName() + "/" + getSnippetName(), file, context)) {
        Map<String, Object> model = createModel(operation);
        model.putAll(getAttributes());
        TemplateEngine templateEngine = (TemplateEngine) operation.getAttributes()
                .get(TemplateEngine.class.getName());
        writer.append(templateEngine.compileTemplate(getSnippetName()).render(model));
    }//from   ww  w.  j ava2s .  c om
}

From source file:org.envirocar.server.rest.encoding.json.SensorJSONEncoder.java

@Override
public ObjectNode encodeJSON(Sensor t, AccessRights rights, MediaType mediaType) {
    ObjectNode sensor = getJsonFactory().objectNode();
    if (t.hasType()) {
        sensor.put(JSONConstants.TYPE_KEY, t.getType());
    }/*from   w  w  w . j  a  v  a  2  s  .  c  om*/
    Map<String, Object> properties = Maps.newHashMap();

    if (t.hasProperties()) {
        properties.putAll(t.getProperties());
    }
    properties.put(JSONConstants.IDENTIFIER_KEY, t.getIdentifier());
    if (mediaType.equals(MediaTypes.SENSOR_TYPE)) {
        if (t.hasCreationTime()) {
            properties.put(JSONConstants.CREATED_KEY, getDateTimeFormat().print(t.getCreationTime()));
        }
        if (t.hasModificationTime()) {
            properties.put(JSONConstants.MODIFIED_KEY, getDateTimeFormat().print(t.getModificationTime()));
        }
    }

    sensor.putPOJO(JSONConstants.PROPERTIES_KEY, properties);
    return sensor;
}

From source file:au.edu.anu.portal.portlets.basiclti.adapters.StandardAdapter.java

/**
 * Returns the map of params unchanged (except for adding the default params), as per a standard Basic LTI request.
 * /*from  ww w.  j  ava 2 s .  com*/
 * @param params   map of launch data params
 * @return the map, unchanged
 */
@Override
public Map<String, String> processLaunchData(Map<String, String> params) {

    log.debug("StandardAdapter.processLaunchData() called");

    //add defaults
    params.putAll(super.getDefaultParameters());

    return params;
}

From source file:net.seedboxer.mule.processor.notification.EmailNotification.java

/**
 * Return parameters of Message for create Email
 * @param msg/*from w w w . ja v a  2 s.c  om*/
 * @return
 */
private Map<String, Object> getParams(Message msg) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.putAll(msg.getHeaders());
    params.put(net.seedboxer.core.domain.Configuration.END_TIME, new Date());
    return params;
}

From source file:backtype.storm.utils.Utils.java

public static Map readStormConfig() {
    Map ret = readDefaultConfig();
    String confFile = System.getProperty("storm.conf.file");
    Map storm;/*w w  w  . ja  v a2 s .  c  o  m*/
    if (StringUtils.isBlank(confFile) == true) {
        storm = findAndReadConfigFile("storm.yaml", false);
    } else {
        storm = loadDefinedConf(confFile);
    }
    ret.putAll(storm);
    ret.putAll(readCommandLineOpts());

    replaceLocalDir(ret);
    return ret;
}

From source file:com.seedboxer.seedboxer.mule.processor.notification.EmailNotification.java

/**
 * Return parameters of Message for create Email
 * @param msg/*from   w w w.j  a v a 2 s .  com*/
 * @return
 */
private Map<String, Object> getParams(Message msg) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.putAll(msg.getHeaders());
    params.put(com.seedboxer.seedboxer.core.domain.Configuration.END_TIME, new Date());
    return params;
}