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:net.firejack.platform.generate.VelocityGenerator.java

/**
 * @param name//from w ww.ja va  2  s. c o  m
 * @param generate
 * @param model
 * @param file
 * @param prepare
 */
public void compose(String name, Base generate, Map model, File file, boolean prepare) {
    try {
        Map describe = PropertyUtils.describe(generate);

        if (model != null) {
            describe.putAll(model);
        }

        compose(name, describe, file, prepare);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
}

From source file:ei.ne.ke.cassandra.cql3.IdClassEntitySpecification.java

/**
 * {@inheritDoc}/*from  ww w .j  a v a2s . c  om*/
 */
@Override
public Map<String, ByteBuffer> serialize(T entity) {
    Preconditions.checkNotNull(entity);
    Map<String, ByteBuffer> result = Maps.newLinkedHashMap();
    result.putAll(getSerializedKeyValues(entity));
    for (Map.Entry<String, AttributeAccessor> entry : attributeAccessors.entrySet()) {
        result.put(entry.getKey(), EntitySpecificationUtils.serializeAttribute(entry.getValue(), entity));
    }
    return result;
}

From source file:org.activiti.crystalball.simulator.SimulatorProcessMonitorTestWithoutProcess.java

private void reportGraph(String fileName, String processDefinitionKey, List<String> highLightedActivities,
        Map<String, String> counts, RepositoryService repositoryService) throws IOException {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("processDefinitionId", processDefinitionKey);

    Map<String, Object> highlightParams = new HashMap<String, Object>();
    highlightParams.put("processDefinitionId", processDefinitionKey);
    highlightParams.put("highLightedActivities", highLightedActivities);

    Map<String, Object> writeCountParams = new HashMap<String, Object>();
    writeCountParams.put("processDefinitionId", processDefinitionKey);

    writeCountParams.putAll(counts);
    BasicProcessDiagramGenerator basicGenerator = new BasicProcessDiagramGenerator(
            (RepositoryServiceImpl) repositoryService);
    HighlightNodeDiagramLayer highlightGenerator = new HighlightNodeDiagramLayer(
            (RepositoryServiceImpl) repositoryService);
    WriteNodeDescriptionDiagramLayer countGenerator = new WriteNodeDescriptionDiagramLayer(
            (RepositoryServiceImpl) repositoryService);
    MergeLayersGenerator mergeGenerator = new MergeLayersGenerator();

    Map<String, Object> mergeL = new HashMap<String, Object>();
    mergeL.put("1", basicGenerator.generateLayer("png", params));
    mergeL.put("2", highlightGenerator.generateLayer("png", highlightParams));
    mergeL.put("3", countGenerator.generateLayer("png", writeCountParams));

    mergeGenerator.generateLayer("png", mergeL);
    File generatedFile = new File(fileName);
    ImageIO.write(ImageIO.read(mergeGenerator.generateLayer("png", mergeL)), "png", generatedFile);
}

From source file:com.opengamma.analytics.financial.curve.ParameterSensitivity.java

/**
 * Create a copy of the sensitivity and add a given named sensitivity to it.
 * @param nameCcy The name and the currency.
 * @param sensitivity The sensitivity to add.
 * @return The total sensitivity./* w  ww. j  a  va 2 s  . c  o  m*/
 */
public ParameterSensitivity plus(final Pair<String, Currency> nameCcy, final DoubleMatrix1D sensitivity) {
    ArgumentChecker.notNull(nameCcy, "Name/currency");
    ArgumentChecker.notNull(sensitivity, "Matrix");
    final Map<Pair<String, Currency>, DoubleMatrix1D> result = new HashMap<Pair<String, Currency>, DoubleMatrix1D>();
    result.putAll(_sensitivity);
    if (result.containsKey(nameCcy)) {
        result.put(nameCcy, (DoubleMatrix1D) MATRIX.add(result.get(nameCcy), sensitivity));
    } else {
        result.put(nameCcy, sensitivity);
    }
    return new ParameterSensitivity(result);
}

From source file:com.opengamma.analytics.financial.curve.ParameterSensitivity.java

/**
 * Create a copy of the sensitivity and add a given sensitivity to it.
 * @param other The sensitivity to add./*from   w  w  w.  j a v a2  s  .  c  om*/
 * @return The total sensitivity.
 */
public ParameterSensitivity plus(final ParameterSensitivity other) {
    ArgumentChecker.notNull(other, "Sensitivity to add");
    final Map<Pair<String, Currency>, DoubleMatrix1D> result = new HashMap<Pair<String, Currency>, DoubleMatrix1D>();
    result.putAll(_sensitivity);
    for (final Pair<String, Currency> nameCcy : other._sensitivity.keySet()) {
        if (result.containsKey(nameCcy)) {
            result.put(nameCcy,
                    (DoubleMatrix1D) MATRIX.add(result.get(nameCcy), other._sensitivity.get(nameCcy)));
        } else {
            result.put(nameCcy, other._sensitivity.get(nameCcy));
        }
    }
    return new ParameterSensitivity(result);
}

From source file:com.glaf.mail.business.MailProcessBean.java

public Map<String, Object> populate(String mailDefId, String actorId, Map<String, Object> context) {
    Map<String, Object> dataMap = new java.util.HashMap<String, Object>();
    dataMap.putAll(context);
    MailTemplate mail = MailContainer.getContainer().getMailDefinition(mailDefId);
    logger.debug(mail.getMailDefId() + " -> " + mail.getTemplatePath());
    List<MailDataSet> dataSetList = mail.getDataSetList();
    if (dataSetList != null && !dataSetList.isEmpty()) {
        logger.debug("dataSetList size:" + dataSetList.size());
        for (MailDataSet mailDS : dataSetList) {
            try {
                List<MailRowSet> rowSetList = mailDS.getRowSetList();
                logger.debug("rowSetList:" + rowSetList);
                if (rowSetList != null && !rowSetList.isEmpty()) {
                    for (MailRowSet rs : rowSetList) {
                        String dataMgr = rs.getDataMgr();
                        String query = rs.getQuery();
                        String mapping = rs.getMapping();
                        String mailMgrMapping = rs.getMailMgrMapping();
                        IMailDataManager dataManager = null;
                        List<?> rows = null;
                        if ("mybatis".equals(dataMgr)) {
                            dataManager = new MyBatisMailDataManager();
                        } else {
                            String dataMgrClassName = rs.getDataMgrClassName();
                            if (StringUtils.isNotEmpty(dataMgrClassName)) {
                                dataManager = (IMailDataManager) ClassUtils.instantiateObject(dataMgrClassName);
                            } else {
                                String dataMgrBeanId = rs.getDataMgrBeanId();
                                if (StringUtils.isNotEmpty(dataMgrBeanId)) {
                                    Object bean = ContextFactory.getBean(dataMgrBeanId);
                                    if (bean instanceof IMailDataManager) {
                                        dataManager = (IMailDataManager) bean;
                                    }/*  ww  w .j  ava 2s  .  c  o  m*/
                                }
                            }
                        }
                        if (dataManager != null) {
                            if (mailMgrMapping != null) {
                                dataMap.put(mailMgrMapping, dataManager);
                            } else {
                                String clazz = dataManager.getClass().getSimpleName();
                                clazz = clazz.substring(0, 1).toLowerCase() + clazz.substring(1);
                                dataMap.put(clazz, dataManager);
                            }
                            rows = dataManager.getResultList(query, context);
                            logger.debug(rows);
                            boolean singleResult = rs.isSingleResult();
                            if (rows != null && rows.size() > 0) {
                                if (singleResult) {
                                    Object object = rows.get(0);
                                    dataMap.put(mapping, object);
                                    dataMap.put("dataModel_" + mapping, object);
                                } else {
                                    dataMap.put(mapping, rows);
                                    dataMap.put("dataModel_" + mapping, rows);
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                logger.error(ex);
                throw new RuntimeException(ex);
            }
        }
    }

    return dataMap;
}

From source file:springfox.documentation.swagger.readers.operation.SwaggerResponseMessageReader.java

protected Set<ResponseMessage> read(HandlerMethod handlerMethod, OperationContext context) {
    ResolvedType defaultResponse = new HandlerMethodResolver(typeResolver).methodReturnType(handlerMethod);
    Optional<ApiOperation> operationAnnotation = findApiOperationAnnotation(handlerMethod.getMethod());
    Optional<ResolvedType> operationResponse = operationAnnotation
            .transform(resolvedTypeFromOperation(typeResolver, defaultResponse));
    Optional<ResponseHeader[]> defaultResponseHeaders = operationAnnotation.transform(resposeHeaders());
    Map<String, ModelReference> defaultHeaders = newHashMap();
    if (defaultResponseHeaders.isPresent()) {
        defaultHeaders.putAll(headers(defaultResponseHeaders.get()));
    }//  w  w w.  ja  va 2  s  . co m

    Optional<ApiResponses> apiResponses = findApiResponsesAnnotations(handlerMethod.getMethod());
    Set<ResponseMessage> responseMessages = newHashSet();

    if (apiResponses.isPresent()) {
        ApiResponse[] apiResponseAnnotations = apiResponses.get().value();
        for (ApiResponse apiResponse : apiResponseAnnotations) {
            ModelContext modelContext = returnValue(apiResponse.response(), context.getDocumentationType(),
                    context.getAlternateTypeProvider(),
                    context.getDocumentationContext().getGenericsNamingStrategy());
            Optional<ModelReference> responseModel = Optional.absent();
            Optional<ResolvedType> type = resolvedType(null, apiResponse);
            if (isSuccessful(apiResponse.code())) {
                type = type.or(operationResponse);
            }
            if (type.isPresent()) {
                responseModel = Optional.of(modelRefFactory(modelContext, typeNameExtractor)
                        .apply(context.alternateFor(type.get())));
            }
            Map<String, ModelReference> headers = newHashMap(defaultHeaders);
            headers.putAll(headers(apiResponse.responseHeaders()));

            responseMessages
                    .add(new ResponseMessageBuilder().code(apiResponse.code()).message(apiResponse.message())
                            .responseModel(responseModel.orNull()).headers(headers).build());
        }

    }
    if (operationResponse.isPresent()) {
        ModelContext modelContext = returnValue(operationResponse.get(), context.getDocumentationType(),
                context.getAlternateTypeProvider(),
                context.getDocumentationContext().getGenericsNamingStrategy());
        ResolvedType resolvedType = context.alternateFor(operationResponse.get());

        ModelReference responseModel = modelRefFactory(modelContext, typeNameExtractor).apply(resolvedType);
        context.operationBuilder().responseModel(responseModel);
        ResponseMessage defaultMessage = new ResponseMessageBuilder().code(httpStatusCode(handlerMethod))
                .message(message(handlerMethod)).responseModel(responseModel).build();
        if (!responseMessages.contains(defaultMessage) && !"void".equals(responseModel.getType())) {
            responseMessages.add(defaultMessage);
        }
    }
    return responseMessages;
}

From source file:com.celements.payment.service.PayPalScriptService.java

@SuppressWarnings("unchecked")
public void executeCallbackAction(Map parameterMap) {
    Map<String, String[]> data = new HashMap<String, String[]>();
    data.putAll(parameterMap);
    if (parameterMap.containsKey("custom")) {
        String customValue = data.get("custom")[0];
        if ((customValue != null) && (!"".equals(customValue))) {
            //shoppingCartDoc.fullName;$user
            String[] customValueSplit = customValue.split(";");
            if (customValueSplit.length > 1) {
                String cartDocFN = customValueSplit[0];
                String user = customValueSplit[1];
                data.put("cartUser", new String[] { user });
                getContext().setUser(user);
                try {
                    XWikiDocument userDoc = getContext().getWiki()
                            .getDocument(webUtils.resolveDocumentReference(user), getContext());
                    BaseObject userObj = userDoc.getXObject(
                            new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiUsers"));
                    data.put("userEmail", new String[] { userObj.getStringValue("email") });
                } catch (XWikiException exp) {
                    LOGGER.error("Failed to get userdoc for [" + user + "]. Possibly failing to"
                            + " send any callback emails.", exp);
                }/*w  w  w.j  ava2 s.co m*/
                data.put("cartDocFN", new String[] { cartDocFN });
            } else {
                LOGGER.warn("illegal custom value [" + customValue + "] found."
                        + " Failed to reconstruct cart payed.");
            }
        } else {
            LOGGER.warn("no custom value found to reconstruct cart payed.");
        }
    }
    paymentService.executePaymentAction(data);
}

From source file:edu.cornell.mannlib.vitro.webapp.web.widgets.BrowseWidget.java

private WidgetTemplateValues doClassAlphaDisplay(Environment env, Map params, HttpServletRequest request,
        ServletContext context) throws Exception {
    Map<String, Object> body = new HashMap<String, Object>();
    body.putAll(getCommonValues(env, context));
    body.putAll(getClassAlphaValues(env, params, request, context));

    String macroName = Mode.VCLASS_ALPHA.macroName;
    return new WidgetTemplateValues(macroName, body);
}