List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceImpl.java
@Override public String renderShortView(Individual individual, ShortViewContext context, Map<String, Object> modelMap, VitroRequest vreq) {/*from w w w .j a v a 2s. c o m*/ TemplateAndSupplementalData tsd = getShortViewInfo(individual, context, vreq); String templateName = tsd.getTemplateName(); Map<String, Object> supplementalData = tsd.getSupplementalData(); try { Map<String, Object> fullModelMap = new HashMap<String, Object>(modelMap); fullModelMap.putAll(supplementalData); FreemarkerProcessingService fps = FreemarkerProcessingServiceSetup .getService(vreq.getSession().getServletContext()); if (!fps.isTemplateAvailable(templateName, vreq)) { return "<p>Can't find the short view template '" + templateName + "' for " + individual.getName() + "</p>"; } return fps.renderTemplate(templateName, fullModelMap, vreq); } catch (TemplateParsingException e) { log.error(e, e); return "<p>Can't parse the short view template '" + templateName + "' for " + individual.getName() + "</p>"; } catch (TemplateProcessingException e) { if (e.getCause() instanceof FileNotFoundException) { log.error(e); return "<p>Can't find the short view template '" + templateName + "' for " + individual.getName() + "</p>"; } else { log.error(e, e); return "<p>Can't process the short view template '" + templateName + "' for " + individual.getName() + "</p>"; } } catch (Exception e) { log.error(e, e); return "<p>Failed to render the short view for " + individual.getName() + "</p>"; } }
From source file:edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceImpl.java
/** Build a data map from the combined results of all data getters. */ private Map<String, Object> runDataGetters(Set<DataGetter> dataGetters, Individual individual) { Map<String, Object> valueMap = new HashMap<String, Object>(); valueMap.put("individualUri", individual.getURI()); Map<String, Object> gotData = new HashMap<String, Object>(); for (DataGetter dg : dataGetters) { gotData.putAll(dg.getData(valueMap)); }// w w w . j av a2s . c o m return gotData; }
From source file:eu.supersede.fe.multitenant.MultiJpaProvider.java
@PostConstruct private void load() { Map<String, DataSource> datasources = dataSourceBasedMultiTenantConnectionProviderImpl.getDataSources(); repositoriesFactory = new HashMap<>(); for (String n : datasources.keySet()) { try {/*from www.jav a 2 s . c om*/ log.info("Loading database: " + datasources.get(n).getConnection().getMetaData().getURL()); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } Map<String, Object> hibernateProps = new LinkedHashMap<>(); hibernateProps.putAll(jpaProperties.getHibernateProperties(datasources.get(n))); hibernateProps.put(Environment.DIALECT, "org.hibernate.dialect.PostgreSQLDialect"); Set<String> packages = new HashSet<>(); String[] tmp = MODELS_PACKAGES.split(","); for (String t : tmp) { packages.add(t.trim()); } LocalContainerEntityManagerFactoryBean emfb = builder.dataSource(datasources.get(n)) .packages(packages.toArray(new String[packages.size()])).properties(hibernateProps).jta(false) .build(); emfb.afterPropertiesSet(); EntityManagerFactory emf = emfb.getObject(); EntityManager em = emf.createEntityManager(); final JpaTransactionManager jpaTranMan = new JpaTransactionManager(emf); JpaRepositoryFactory jpaFactory = new JpaRepositoryFactory(em); jpaFactory.addRepositoryProxyPostProcessor(new MultiJpaRepositoryProxyPostProcessor(jpaTranMan)); repositoriesFactory.put(n, new ContainerUtil(jpaFactory, emf, em)); } }
From source file:au.edu.anu.portal.portlets.basiclti.adapters.PeoplesoftAdapter.java
/** * Modify the map of params to uppercase the user_id and replace it * /*from w ww . java2 s . c o m*/ * @param params map of launch data params * @return the map, modified */ @Override public Map<String, String> processLaunchData(Map<String, String> params) { log.debug("PeoplesoftAdapter.processLaunchData() called"); params.put("user_id", StringUtils.upperCase(params.get("user_id"))); //add defaults params.putAll(super.getDefaultParameters()); return params; }
From source file:com.ineunet.knife.persist.dao.support.PaginationDaoSupport.java
/** * {@link #prepareQuery(ICriteria, QueryParameters)} ??? * @param queryParameters//from ww w .j a v a 2 s . com * @param paramValues * @return jql or named parameters hql */ protected String prepareQuery(QueryParameters queryParameters, Map<String, Object> paramValues) { ICriteria c = new Criteria(entityClass, "o", true); this.prepareQuery(c, queryParameters); paramValues.putAll(c.getNamedValues()); return c.getQueryString(); }
From source file:grails.plugin.searchable.internal.compass.spring.DefaultSearchableCompassFactoryBean.java
private Map getBeans() { Map beans = new HashMap(); if (isRegisterAnalyzerBeans()) { beans.putAll(getApplicationContext().getBeansOfType(Analyzer.class)); }/*from w w w .j a v a 2s. c o m*/ if (isRegisterConverterBeans()) { beans.putAll(getApplicationContext().getBeansOfType(Converter.class)); } return beans; }
From source file:CopyOnWriteMap.java
/** * Inserts all the keys and values contained in the * provided map to this map./*from w ww. ja va2s . c o m*/ * * @see java.util.Map#putAll(java.util.Map) */ public void putAll(Map<? extends K, ? extends V> newData) { synchronized (this) { Map<K, V> newMap = new HashMap<K, V>(internalMap); newMap.putAll(newData); internalMap = newMap; } }
From source file:com.googlecode.janrain4j.api.engage.AbstractService.java
protected String apiCall(String method, Map<String, String> partialParams) throws EngageFailureException, ErrorResponeException { Map<String, String> params = new HashMap<String, String>(); if (partialParams != null) { params.putAll(partialParams); }//from w ww.ja v a 2s .com params.put(FORMAT_PARAM, JSON); String url = getBaseUrl() + method; if (log.isInfoEnabled()) { StringBuilder sb = new StringBuilder(); sb.append("Janrain Engage request: ").append(method).append("\n"); sb.append("url: ").append(url).append("\n"); sb.append("parameters: [\n"); for (Iterator<String> iterator = params.keySet().iterator(); iterator.hasNext();) { String key = iterator.next(); String value = params.get(key); sb.append(" ").append(key).append(": ").append(value).append("\n"); } sb.append("]"); log.debug(sb.toString()); } String jsonResponse = null; try { HttpResponse response = HttpClientFactory.getHttpClient(getConfig()).post(url, params); jsonResponse = response.getContent(); JSONObject rsp = new JSONObject(jsonResponse); if (log.isDebugEnabled()) { log.debug("Janrain Engage response:\n" + jsonResponse); } String stat = rsp.getString("stat"); if (!stat.equals("ok")) { if (stat.equals("fail")) { JSONObject err = rsp.getJSONObject("err"); int code = err.getInt("code"); String msg = err.getString("msg"); throw new ErrorResponeException(code, msg, jsonResponse); } else { throw new EngageFailureException("Unexpected status in response: " + stat, jsonResponse); } } return jsonResponse; } catch (HttpFailureException e) { throw new EngageFailureException("Unexpected HTTP error", jsonResponse, e); } catch (JSONException e) { throw new EngageFailureException("Unexpected JSON error", jsonResponse, e); } }
From source file:com.frank.search.solr.core.convert.SolrJConverter.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override/*from ww w . j a va2s . c o m*/ public void write(Object source, Map sink) { if (source == null) { return; } SolrInputDocument convertedDocument = convert(source, SolrInputDocument.class); sink.putAll(convertedDocument); }