List of usage examples for java.util HashMap putAll
public void putAll(Map<? extends K, ? extends V> m)
From source file:org.openhab.binding.sunnywebbox.internal.SunnyWebBoxBinding.java
/** * @{inheritDoc//from w ww .j ava 2s . c om */ @Override protected void execute() { // the frequently executed code (polling) goes here ... logger.debug("execute() method of sunnywebbox is called!"); Gson gson = new GsonBuilder().create(); if (deviceIds.isEmpty()) { GetDevicesRequest getDevicesRequest = new GetDevicesRequest(); List<Object> _deviceIds = new ArrayList<Object>(); Iterator<String> keyIterator = URLs.keySet().iterator(); while (keyIterator.hasNext()) { String urlID = keyIterator.next(); String urlValue = URLs.get(urlID); List<Object> deviceIds1 = getDevicesRequest.getDevices(urlValue); if (deviceIds1 != null) { _deviceIds.addAll(deviceIds1); urlToDevicesMap.put(urlID, deviceIds1); } } deviceIds = _deviceIds; logger.info("devices are {}", deviceIds.toString()); } GetPlantOverviewRequest getPlantOverviewRequest = new GetPlantOverviewRequest(); List<String> urlValues = new ArrayList<String>(URLs.values()); HashMap<String, HashMap<String, Object>> localPlantOverviewValues = new HashMap<String, HashMap<String, Object>>(); Iterator<String> keyIterator0 = URLs.keySet().iterator(); while (keyIterator0.hasNext()) { String urlID = keyIterator0.next(); String urlValue = URLs.get(urlID); /* logger.info("URL iterated {}", url); */ localPlantOverviewValues.put(urlID, getPlantOverviewRequest.getValues(urlValue)); } plantOverviewValues = localPlantOverviewValues; String json = gson.toJson(plantOverviewValues); logger.info("plants overview {}", json); // if (plantOverviewValues != null) { // Gson gson = new GsonBuilder().create(); // String json = gson.toJson(plantOverviewValues); // // DBCollection plantOverviewCol = db.getCollection("plantoverview"); // plantOverviewCol.insert(new BasicDBObject(plantOverviewValues)); // // logger.info("plants overview {}", json); // } GetProcessDataRequest getProcessDataRequest = new GetProcessDataRequest(); HashMap<String, HashMap<String, Object>> localProcessDataPerDevice = new HashMap<String, HashMap<String, Object>>(); Iterator<String> keyIterator = URLs.keySet().iterator(); while (keyIterator.hasNext()) { String urlID = keyIterator.next(); String urlValue = URLs.get(urlID); if (urlToDevicesMap.get(urlID) == null) continue; getProcessDataRequest.setDeviceIds(urlToDevicesMap.get(urlID)); localProcessDataPerDevice.putAll(getProcessDataRequest.getProcessDataPerDevice(urlValue)); } processDataPerDevice = localProcessDataPerDevice; String json1 = gson.toJson(processDataPerDevice); logger.info("data per device {}", json1); // for(String url : urlValues) // { // localPlantOverviewValues.putAll(getPlantOverviewRequest.getValues(url)); // } // // getProcessDataRequest.setDeviceIds(deviceIds); // processDataPerDevice = getProcessDataRequest // .getProcessDataPerDevice(URL); // if (processDataPerDevice != null) { // Gson gson = new GsonBuilder().create(); // String json = gson.toJson(processDataPerDevice); // // DBCollection processDataCol = db.getCollection("processdata"); // processDataCol.insert(new BasicDBObject(processDataPerDevice)); // // logger.info("data per device {}", json); // } GetParameterRequest getParameterRequest = new GetParameterRequest(); HashMap<String, HashMap<String, Object>> localParametersPerDevice = new HashMap<String, HashMap<String, Object>>(); Iterator<String> keyIterator1 = URLs.keySet().iterator(); while (keyIterator1.hasNext()) { String urlID = keyIterator1.next(); String urlValue = URLs.get(urlID); if (urlToDevicesMap.get(urlID) == null) continue; getParameterRequest.setDeviceIds(urlToDevicesMap.get(urlID)); localParametersPerDevice.putAll(getParameterRequest.getParametersDevice(urlValue)); } parametersPerDevice = localParametersPerDevice; String json2 = gson.toJson(parametersPerDevice); logger.info("parameters per device {}", json2); // getParameterRequest.setDeviceIds(deviceIds); // parametersPerDevice = getParameterRequest.getParametersDevice(URL); // if (parametersPerDevice != null) { // Gson gson = new GsonBuilder().create(); // String json = gson.toJson(parametersPerDevice); // // DBCollection parametersCol = db.getCollection("parameters"); // parametersCol.insert(new BasicDBObject(parametersPerDevice)); // // logger.info("parameters per device {}", json); // } for (SunnyWebBoxBindingProvider provider : providers) { for (String itemName : provider.getItemNames()) { String deviceId = provider.getDeviceId(itemName); String meta = provider.getMeta(itemName); String urlId = provider.getUrlKey(itemName); logger.info("device id {}", deviceId); logger.info("meta {}", meta); Object value; value = getValueForDevice(deviceId, meta, urlId); if (value != null) { if (NumberUtils.isNumber(value.toString())) { logger.debug("value isNumber:{}", value); eventPublisher.postUpdate(itemName, DecimalType.valueOf(value.toString())); } else logger.debug("value is String:{}", value); eventPublisher.postUpdate(itemName, StringType.valueOf(value.toString())); } // try { // GenericRequest genericRequest = new GenericRequest(); // genericRequest.setProc(provider.getRPC(itemName)); // String value = genericRequest.getValue(URL, // provider.getMeta(itemName)); // if (value != null && !value.isEmpty()) { // // if (NumberUtils.isNumber(value)) { // logger.debug("value isNumber:{}", value); // eventPublisher.postUpdate(itemName, // DecimalType.valueOf(value)); // } else // logger.debug("value is String:{}", value); // eventPublisher.postUpdate(itemName, // StringType.valueOf(value)); // } else { // logger.warn("{} value is null",itemName); // eventPublisher.postUpdate(itemName, // StringType.valueOf("null")); // } // } catch (Exception e) { // //e.printStackTrace(); // logger.error("Execute WS error", e); // } } } }
From source file:gov.va.isaac.sync.view.SyncView.java
private Set<String> resolveMergeFailure(MergeFailure mf) throws IllegalArgumentException, IOException { Set<String> changedFiles = mf.getFilesChangedDuringMergeAttempt(); CountDownLatch cdl = new CountDownLatch(1); HashMap<String, MergeFailOption> resolutions = new HashMap<String, MergeFailOption>(); Platform.runLater(() -> {/* www . j a va2s . c o m*/ new ResolveConflicts(root_.getScene().getWindow(), mf.getMergeFailures(), new Consumer<HashMap<String, MergeFailOption>>() { @Override public void accept(HashMap<String, MergeFailOption> t) { resolutions.putAll(t); cdl.countDown(); } }); }); try { cdl.await(); } catch (InterruptedException e) { log.info("Interrupted during wait for resolutions"); } try { syncService_.resolveMergeFailures(resolutions); } catch (MergeFailure nestedMF) { changedFiles.addAll(resolveMergeFailure(nestedMF)); } return changedFiles; }
From source file:uk.co.revsys.oddball.Oddball.java
public Collection<String> findQueryCasesForEach(String ruleSetName, String query, Map<String, String> options) throws IOException, RuleSetNotLoadedException, DaoException, TransformerNotLoadedException, AggregationException, UnknownBinException, InvalidCaseException, InvalidTimePeriodException, ProcessorNotLoadedException, ComparisonException, FilterException, IdentificationSchemeNotLoadedException { ArrayList<String> cases = new ArrayList<String>(); String forEach = options.get("forEach"); HashMap<String, String> distinctOptions = new HashMap<String, String>(); distinctOptions.putAll(options); distinctOptions.put("distinct", forEach); distinctOptions.remove("transformer"); distinctOptions.remove("aggregator"); distinctOptions.remove("selector"); distinctOptions.remove("identifier"); distinctOptions.remove("comparator"); distinctOptions.remove("tagger"); distinctOptions.remove("filter"); distinctOptions.remove("forEach"); distinctOptions.remove("processor"); distinctOptions.remove("processorChain"); ArrayList<String> allDistinct = new ArrayList<String>(); allDistinct.addAll(findQueryCases(ruleSetName, query, distinctOptions)); for (String distinctValue : allDistinct) { options.put("forEachValue", distinctValue.replace("\"", "")); cases.addAll(findQueryCases(ruleSetName, query, options)); }/*from w w w . j ava 2 s. com*/ return cases; }
From source file:com.odoo.core.rpc.wrapper.OdooWrapper.java
public HashMap<String, Object> updateContext(HashMap<String, Object> newContext) { newContext.putAll(odooSession.userContext()); return newContext; }
From source file:com.k42b3.neodym.oauth.Oauth.java
@SuppressWarnings("unchecked") public void signRequest(HttpRequestBase request) throws Exception { // add values HashMap<String, String> values = new HashMap<String, String>(); HashMap<String, String> auth; values.put("oauth_consumer_key", this.provider.getConsumerKey()); values.put("oauth_token", this.token); values.put("oauth_signature_method", provider.getMethod()); values.put("oauth_timestamp", this.getTimestamp()); values.put("oauth_nonce", this.getNonce()); auth = (HashMap<String, String>) values.clone(); // add get vars to values values.putAll(parseQuery(request.getURI().getQuery())); // build base string String baseString = this.buildBaseString(request.getMethod(), request.getURI().toString(), values); // get signature SignatureInterface signature = this.getSignature(); if (signature == null) { throw new Exception("Invalid signature method"); }//from ww w.j a va 2s.c o m // build signature auth.put("oauth_signature", signature.build(baseString, provider.getConsumerSecret(), this.tokenSecret)); // add header to request request.addHeader("Authorization", "OAuth realm=\"neodym\", " + this.buildAuthString(auth)); }
From source file:oscar.oscarDemographic.pageUtil.DiabetesExportAction.java
void setImmunizations(PatientRecord patientRecord, String demoNo) { ArrayList<String> inject = new ArrayList<String>(); ArrayList<? extends Map<String, ? extends Object>> preventionList = PreventionDisplayConfig.getInstance() .getPreventions();//from w w w . ja v a2s .c om for (int i = 0; i < preventionList.size(); i++) { HashMap<String, Object> h = new HashMap<String, Object>(); h.putAll(preventionList.get(i)); if (h != null && h.get("layout") != null && h.get("layout").equals("injection")) { inject.add((String) h.get("name")); } } preventionList = PreventionData.getPreventionData(demoNo); for (int i = 0; i < preventionList.size(); i++) { HashMap<String, Object> h = new HashMap<String, Object>(); h.putAll(preventionList.get(i)); if (h != null && inject.contains(h.get("type"))) { Immunizations immunizations = null; Date preventionDate = UtilDateUtilities.StringToDate((String) h.get("prevention_date"), "yyyy-MM-dd"); if (preventionDate != null) { if (startDate.after(preventionDate) || endDate.before(preventionDate)) continue; } String data = (String) h.get("type"); if (StringUtils.filled(data)) { if (data.equalsIgnoreCase("Flu")) { immunizations = patientRecord.addNewImmunizations(); immunizations.setImmunizationName(Immunizations.ImmunizationName.INFLUENZA); } else if (data.equalsIgnoreCase("Pneumovax") || data.equalsIgnoreCase("Pneu-C")) { immunizations = patientRecord.addNewImmunizations(); immunizations.setImmunizationName(Immunizations.ImmunizationName.PNEUMOCOCCAL); } else { continue; } } immunizations.addNewDate().setFullDate(Util.calDate(preventionDate)); if (preventionDate == null) { errors.add("Error! Missing/Invalid Immunization Date (id=" + h.get("id") + ") for Patient " + demoNo + " (" + immunizations.getImmunizationName() + ")"); } data = (String) h.get("refused"); cdsDt.YnIndicator refused = immunizations.addNewRefusedFlag(); if (StringUtils.empty(data)) { errors.add("Error! No Refused Flag for Patient " + demoNo + " (" + immunizations.getImmunizationName() + ")"); refused.setYnIndicatorsimple(null); } else { refused.setBoolean(Util.convert10toboolean(data)); } } } }
From source file:info.raack.appliancelabeler.data.JDBCDatabase.java
public void saveOAuthTokensForUserId(String userId, String email, Map<String, OAuthConsumerToken> tokens) { HashMap<String, OAuthConsumerToken> hashMapForTokens = new HashMap<String, OAuthConsumerToken>(); hashMapForTokens.putAll(tokens); SqlLobValue blob = new SqlLobValue(SerializationUtils.serialize(hashMapForTokens)); if (email != null) { jdbcTemplate.update(saveAccessTokensForUser, new Object[] { userId, email, blob }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.BLOB }); } else {/*from w ww . j a va 2 s . co m*/ jdbcTemplate.update(saveAccessTokensForUserWithoutEmail, new Object[] { userId, blob }, new int[] { Types.VARCHAR, Types.BLOB }); } }
From source file:org.akita.proxy.ProxyInvocationHandler.java
/** * AkApiParams to hashmap, filter out of null-value * * @param annosArr Method's params' annotation array[][] * @param args Method's params' values// w ww .ja va 2 s . c o m * @param filesToSend * @return HashMap all (paramName -> paramValue) */ private HashMap<String, String> getRawApiParams2HashMap(Annotation[][] annosArr, Object[] args, HashMap<String, File> filesToSend, HashMap<String, String> paramsMapOri) { HashMap<String, String> paramsMap = new HashMap<String, String>(); for (int idx = 0; idx < args.length; idx++) { String paramName = null; String encode = "none"; for (Annotation a : annosArr[idx]) { if (AkParam.class.equals(a.annotationType())) { AkParam ap = (AkParam) a; paramName = ap.value(); encode = ap.encode(); } } if (paramName != null) { Object arg = args[idx]; if (arg != null) { // filter out of null-value param if ("$paramMap".equals(paramName)) { Map<String, String> paramMap = (Map<String, String>) arg; paramsMapOri.putAll(paramMap); if (encode != null && !"none".equals(encode)) { HashMap<String, String> encodedMap = new HashMap<String, String>(); for (Entry<String, String> entry : paramMap.entrySet()) { try { encodedMap.put(entry.getKey(), URLEncoder.encode(entry.getValue(), encode)); } catch (Exception e) { Log.w(TAG, "UnsupportedEncodingException:" + encode); encodedMap.put(entry.getKey(), entry.getValue()); } } paramsMap.putAll(encodedMap); } else { paramsMap.putAll(paramMap); } } else if ("$filesToSend".equals(paramName)) { if (arg instanceof Map) { Map<String, File> files = (Map<String, File>) arg; filesToSend.putAll(files); } } else if (encode != null && !"none".equals(encode)) { try { paramsMap.put(paramName, URLEncoder.encode(arg.toString(), encode)); } catch (UnsupportedEncodingException e) { Log.w(TAG, "UnsupportedEncodingException:" + encode); paramsMap.put(paramName, arg.toString()); } paramsMapOri.put(paramName, arg.toString()); } else { paramsMap.put(paramName, arg.toString()); paramsMapOri.put(paramName, arg.toString()); } } } } return paramsMap; }
From source file:org.guzz.builder.GuzzConfigFileBuilder.java
/** * @return (@link Map) id~~CompiledSQL/* w w w. j a v a 2s. com*/ */ public Map listConfiguedCompiledSQLs(TemplatedSQLService templatedSQLService) throws IOException, ClassNotFoundException { /* <sqlMap> .... </sqlMap> <sqlMap> .... </sqlMap> */ List sqlMaps = this.rootDoc.selectNodes("sqlMap"); HashMap sqls = new HashMap(); for (int i = 0; i < sqlMaps.size(); i++) { Element e = (Element) sqlMaps.get(i); sqls.putAll(loadSQLMap(gf, templatedSQLService, gf.getObjectMappingManager(), gf.getCompiledSQLBuilder(), e, true)); } return sqls; }
From source file:org.milyn.smooks.mule.core.MuleDispatcher.java
/** * Creates the message properties map from the static message properties and the possible * properties from the Map found under the messageProperties bean Id. * * @param executionContext//from w w w .ja va 2 s. c o m * @return */ @SuppressWarnings("unchecked") private Map<String, Object> createMessagePropertiesMap(ExecutionContext executionContext) { HashMap<String, Object> props = evaluateStaticMessageProperties(executionContext); if (messagePropertiesBeanId != null) { BeanContext beanContext = executionContext.getBeanContext(); Map<String, Object> bProperties = (Map<String, Object>) beanContext.getBean(messagePropertiesBeanId); if (bProperties == null) { throw new SmooksConfigurationException("No properties map could be found under the beanId '" + messagePropertiesBeanId.getName() + "'"); } props.putAll(bProperties); } return props; }