List of usage examples for java.util LinkedHashMap get
public V get(Object key)
From source file:com.smhumayun.mi_plus.impl.MIMethodResolverImpl.java
/** * Resolve method based on following strategy: * - Iterate over composed objects (order will be the same as defined in {@link com.smhumayun.mi_plus.MISupport} * - For each composed object, check if there's a matching 'accessible' method based on the algorithm defined by * {@link MethodUtils#getAccessibleMethod(Class, String, Class[])} i.e. it finds an accessible method that matches * the given name and has compatible parameters. Compatible parameters mean that every method parameter is * assignable from the given parameters. In other words, it finds a method with the given name that will take the * parameters given./*from w w w. ja va 2s. c o m*/ * - If a match is found, break the iteration and exit from the loop; * - Return the corresponding composed object and the matched method * * @param miContainerClass MI Container class * @param composedObjects map of composed objects * @param methodCall method call made on Proxy * @param methodCallArgs method call arguments * @return resolved target method and object * @throws com.smhumayun.mi_plus.MIException {@link com.smhumayun.mi_plus.MIException} */ public Pair<Object, Method> resolve(Class miContainerClass, LinkedHashMap<Class, Object> composedObjects, Method methodCall, Object[] methodCallArgs) throws MIException { logger.info("resolve " + methodCall.toGenericString()); Class[] methodCallArgsClasses = utils.getClasses(methodCallArgs); logger.fine("methodCallArgs classes = " + Arrays.toString(methodCallArgsClasses)); Object targetObject = null; Method targetMethod = null; for (Class composedObjectClass : composedObjects.keySet()) { try { targetMethod = MethodUtils.getMatchingAccessibleMethod(composedObjectClass, methodCall.getName(), methodCallArgsClasses); if (targetMethod != null) { logger.info("matching method found! " + targetMethod.toGenericString()); targetObject = composedObjects.get(composedObjectClass); break; } } catch (Exception e) { /* SWALLOW */ } } //if not found if (targetMethod == null) //throw exception throw new UnsupportedOperationException("method '" + methodCall.toGenericString() + "' not found"); //else return the target object and method to caller return new Pair<Object, Method>(targetObject, targetMethod); }
From source file:com.vip.saturn.job.console.service.impl.RegistryCenterServiceImpl.java
private void refreshRegistryCenterFromJsonFile() throws IOException { ArrayList<RegistryCenterConfiguration> list = new ArrayList<>(); String json = FileUtils.readFileToString(new File(SaturnEnvProperties.REG_CENTER_JSON_FILE), StandardCharsets.UTF_8); list = (ArrayList<RegistryCenterConfiguration>) JSON.parseArray(json, RegistryCenterConfiguration.class); LinkedHashMap<String/** zkAddr **/ , ZkCluster> newClusterMap = new LinkedHashMap<>(); for (RegistryCenterConfiguration conf : list) { try {/*from w w w .j a v a2s .c o m*/ conf.initNameAndNamespace(conf.getNameAndNamespace()); if (conf.getZkAlias() == null) { conf.setZkAlias(conf.getZkAddressList()); } if (conf.getBootstrapKey() == null) { conf.setBootstrapKey(conf.getZkAddressList()); } ZkCluster cluster = newClusterMap.get(conf.getZkAddressList()); if (cluster == null) { CuratorFramework curatorFramework = curatorRepository.connect(conf.getZkAddressList(), "", conf.getDigest()); cluster = new ZkCluster(conf.getZkAlias(), conf.getZkAddressList(), curatorFramework); newClusterMap.put(conf.getZkAddressList(), cluster); } else if (cluster.getCuratorFramework() == null) { if (cluster.getCuratorFramework() != null && !cluster.getCuratorFramework().getZookeeperClient().isConnected()) { cluster.getCuratorFramework().close(); } CuratorFramework curatorFramework = curatorRepository.connect(conf.getZkAddressList(), "", conf.getDigest()); cluster.setCuratorFramework(curatorFramework); } if (cluster.getCuratorFramework() == null) { throw new IllegalArgumentException(); } cluster.setOffline(false); conf.setVersion(getVersion(conf.getNamespace(), cluster.getCuratorFramework())); cluster.getRegCenterConfList().add(conf); } catch (Exception e) { log.error("found an offline zkCluster: {}", conf); log.error(e.getMessage(), e); ZkCluster cluster = new ZkCluster(conf.getZkAlias(), conf.getZkAddressList(), null); cluster.setOffline(true); newClusterMap.put(conf.getZkAddressList(), cluster); } } shutdownZkClientInZkClusterMap(); ZKADDR_TO_ZKCLUSTER_MAP = newClusterMap; }
From source file:org.devgateway.ocds.web.rest.controller.CostEffectivenessVisualsController.java
@ApiOperation(value = "Aggregated version of /api/costEffectivenessTenderAmount and " + "/api/costEffectivenessAwardAmount." + "This endpoint aggregates the responses from the specified endpoints, per year. " + "Responds to the same filters.") @RequestMapping(value = "/api/costEffectivenessTenderAwardAmount", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json") public List<DBObject> costEffectivenessTenderAwardAmount( @ModelAttribute @Valid final GroupingFilterPagingRequest filter) { Future<List<DBObject>> costEffectivenessAwardAmountFuture = controllerLookupService.asyncInvoke( new AsyncBeanParamControllerMethodCallable<List<DBObject>, GroupingFilterPagingRequest>() { @Override/* w ww. ja v a 2 s .c om*/ public List<DBObject> invokeControllerMethod(GroupingFilterPagingRequest filter) { return costEffectivenessAwardAmount(filter); } }, filter); Future<List<DBObject>> costEffectivenessTenderAmountFuture = controllerLookupService.asyncInvoke( new AsyncBeanParamControllerMethodCallable<List<DBObject>, GroupingFilterPagingRequest>() { @Override public List<DBObject> invokeControllerMethod(GroupingFilterPagingRequest filter) { return costEffectivenessTenderAmount(filter); } }, filter); //this is completely unnecessary since the #get methods are blocking //controllerLookupService.waitTillDone(costEffectivenessAwardAmountFuture, costEffectivenessTenderAmountFuture); LinkedHashMap<Object, DBObject> response = new LinkedHashMap<>(); try { costEffectivenessAwardAmountFuture.get() .forEach(dbobj -> response.put(getYearMonthlyKey(filter, dbobj), dbobj)); costEffectivenessTenderAmountFuture.get().forEach(dbobj -> { if (response.containsKey(getYearMonthlyKey(filter, dbobj))) { Map<?, ?> map = dbobj.toMap(); map.remove(Keys.YEAR); if (filter.getMonthly()) { map.remove(Keys.MONTH); } response.get(getYearMonthlyKey(filter, dbobj)).putAll(map); } else { response.put(getYearMonthlyKey(filter, dbobj), dbobj); } }); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } Collection<DBObject> respCollection = response.values(); respCollection.forEach(dbobj -> { BigDecimal totalTenderAmount = BigDecimal.valueOf(dbobj.get(Keys.TOTAL_TENDER_AMOUNT) == null ? 0d : ((Number) dbobj.get(Keys.TOTAL_TENDER_AMOUNT)).doubleValue()); BigDecimal totalAwardAmount = BigDecimal.valueOf(dbobj.get(Keys.TOTAL_AWARD_AMOUNT) == null ? 0d : ((Number) dbobj.get(Keys.TOTAL_AWARD_AMOUNT)).doubleValue()); dbobj.put(Keys.DIFF_TENDER_AWARD_AMOUNT, totalTenderAmount.subtract(totalAwardAmount)); dbobj.put(Keys.PERCENTAGE_AWARD_AMOUNT, totalTenderAmount.compareTo(BigDecimal.ZERO) != 0 ? (totalAwardAmount.setScale(15).divide(totalTenderAmount, BigDecimal.ROUND_HALF_UP) .multiply(ONE_HUNDRED)) : BigDecimal.ZERO); dbobj.put(Keys.PERCENTAGE_DIFF_AMOUNT, totalTenderAmount.compareTo(BigDecimal.ZERO) != 0 ? (((BigDecimal) dbobj.get(Keys.DIFF_TENDER_AWARD_AMOUNT)).setScale(15) .divide(totalTenderAmount, BigDecimal.ROUND_HALF_UP).multiply(ONE_HUNDRED)) : BigDecimal.ZERO); }); return new ArrayList<>(respCollection); }
From source file:com.intel.iotkitlib.LibUtils.IotKit.java
public String prepareUrl(String urlToAppend, LinkedHashMap urlSlugNameValues) { String urlPrepared = null;/*w w w . java 2 s . c o m*/ if (urlToAppend != null) { if (Utilities.sharedPreferences == null) { Log.w(TAG, "cannot find shared preferences object,not able to create URL"); return null; } //Handling Slug param replacement in URL if (urlToAppend.contains("data_account_id")) { if (urlSlugNameValues != null && urlSlugNameValues.containsKey("account_id")) { urlToAppend = urlToAppend.replace("data_account_id", urlSlugNameValues.get("account_id").toString()); } else { urlToAppend = urlToAppend.replace("data_account_id", Utilities.sharedPreferences.getString("account_id", "")); } //updating device id url-value if (urlToAppend.contains("other_device_id")) { urlToAppend = urlToAppend.replace("other_device_id", urlSlugNameValues.get("other_device_id").toString()); } if (urlToAppend.contains("device_id")) { urlToAppend = urlToAppend.replace("device_id", Utilities.sharedPreferences.getString("deviceId", "")); } if (urlToAppend.contains("cmp_catalog_id")) { urlToAppend = urlToAppend.replace("cmp_catalog_id", urlSlugNameValues.get("cmp_catalog_id").toString()); } if (urlToAppend.contains("cid")) { String sensorId = null; if ((sensorId = Utilities.getSensorId(urlSlugNameValues.get("cname").toString())) != null) { urlToAppend = urlToAppend.replace("cid", sensorId); } else { Log.d(TAG, "No component found with this name-To Delete"); } /*if (Utilities.sharedPreferences.getString("cname", ""). contentEquals(urlSlugNameValues.get("cname").toString())) { urlToAppend = urlToAppend.replace("cid", Utilities.sharedPreferences.getString("cid", "")); } */ } if (urlToAppend.contains("email")) { urlToAppend = urlToAppend.replace("email", urlSlugNameValues.get("email").toString()); } if (urlToAppend.contains("rule_id")) { urlToAppend = urlToAppend.replace("rule_id", urlSlugNameValues.get("rule_id").toString()); } if (urlToAppend.contains("alert_id")) { urlToAppend = urlToAppend.replace("alert_id", urlSlugNameValues.get("alert_id").toString()); } if (urlToAppend.contains("invitee_user_id")) { urlToAppend = urlToAppend.replace("invitee_user_id", urlSlugNameValues.get("invitee_user_id").toString()); } } else if (urlToAppend.contains("device_id")) { urlToAppend = urlToAppend.replace("device_id", Utilities.sharedPreferences.getString("deviceId", "")); } else if (urlToAppend.contains("user_id")) { urlToAppend = urlToAppend.replace("user_id", urlSlugNameValues.get("user_id").toString()); } else if (urlToAppend.contains("email")) { urlToAppend = urlToAppend.replace("email", urlSlugNameValues.get("email").toString()); } else { Log.d(TAG, "URL with out slugs"); } } urlToAppend = urlToAppend.replaceAll("\\{", ""); urlToAppend = urlToAppend.replaceAll("\\}", ""); //appending the module url to base url urlPrepared = base_Url + urlToAppend; return urlPrepared; }
From source file:org.openmeetings.app.remote.ConferenceService.java
/** * /*from www . ja v a 2s . co m*/ * @param SID * @param argObject * @return */ public Long saveOrUpdateRoom(String SID, Object argObject) { try { Long users_id = sessionManagement.checkSession(SID); long User_level = userManagement.getUserLevelByID(users_id); log.debug("argObject: 1 - " + argObject.getClass().getName()); @SuppressWarnings("unchecked") LinkedHashMap<String, Object> argObjectMap = (LinkedHashMap<String, Object>) argObject; log.debug("argObject: 2 - " + argObjectMap.get("organisations").getClass().getName()); @SuppressWarnings("unchecked") List<Integer> organisations = (List<Integer>) argObjectMap.get("organisations"); Long rooms_id = Long.valueOf(argObjectMap.get("rooms_id").toString()).longValue(); log.debug("rooms_id " + rooms_id); @SuppressWarnings("unchecked") List<Map<String, Object>> roomModerators = (List<Map<String, Object>>) argObjectMap .get("roomModerators"); Integer demoTime = null; if (argObjectMap.get("demoTime").toString() != null && argObjectMap.get("demoTime").toString().length() > 0) { demoTime = Integer.valueOf(argObjectMap.get("demoTime").toString()).intValue(); } if (rooms_id == 0) { return roommanagement.addRoom(User_level, argObjectMap.get("name").toString(), Long.valueOf(argObjectMap.get("roomtypes_id").toString()).longValue(), argObjectMap.get("comment").toString(), Long.valueOf(argObjectMap.get("numberOfPartizipants").toString()).longValue(), Boolean.valueOf(argObjectMap.get("ispublic").toString()), organisations, Boolean.valueOf(argObjectMap.get("appointment").toString()), Boolean.valueOf(argObjectMap.get("isDemoRoom").toString()), demoTime, Boolean.valueOf(argObjectMap.get("isModeratedRoom").toString()), roomModerators, Boolean.valueOf(argObjectMap.get("allowUserQuestions").toString()), Boolean.valueOf(argObjectMap.get("isAudioOnly").toString()), Boolean.valueOf(argObjectMap.get("isClosed").toString()), argObjectMap.get("redirectURL").toString(), argObjectMap.get("sipNumber").toString(), argObjectMap.get("conferencePin").toString(), Long.valueOf(argObjectMap.get("ownerId").toString()).longValue(), Boolean.valueOf(argObjectMap.get("waitForRecording").toString()), Boolean.valueOf(argObjectMap.get("allowRecording").toString()), Boolean.valueOf(argObjectMap.get("hideTopBar").toString()), Boolean.valueOf(argObjectMap.get("hideChat").toString()), Boolean.valueOf(argObjectMap.get("hideActivitiesAndActions").toString()), Boolean.valueOf(argObjectMap.get("hideFilesExplorer").toString()), Boolean.valueOf(argObjectMap.get("hideActionsMenu").toString()), Boolean.valueOf(argObjectMap.get("hideScreenSharing").toString()), Boolean.valueOf(argObjectMap.get("hideWhiteboard").toString()), Boolean.valueOf(argObjectMap.get("showMicrophoneStatus").toString())); } else if (rooms_id > 0) { return roommanagement.updateRoom(User_level, rooms_id, Long.valueOf(argObjectMap.get("roomtypes_id").toString()).longValue(), argObjectMap.get("name").toString(), Boolean.valueOf(argObjectMap.get("ispublic").toString()), argObjectMap.get("comment").toString(), Long.valueOf(argObjectMap.get("numberOfPartizipants").toString()).longValue(), organisations, Boolean.valueOf(argObjectMap.get("appointment").toString()), Boolean.valueOf(argObjectMap.get("isDemoRoom").toString()), demoTime, Boolean.valueOf(argObjectMap.get("isModeratedRoom").toString()), roomModerators, Boolean.valueOf(argObjectMap.get("allowUserQuestions").toString()), Boolean.valueOf(argObjectMap.get("isAudioOnly").toString()), Boolean.valueOf(argObjectMap.get("isClosed").toString()), argObjectMap.get("redirectURL").toString(), argObjectMap.get("sipNumber").toString(), argObjectMap.get("conferencePin").toString(), Long.valueOf(argObjectMap.get("ownerId").toString()).longValue(), Boolean.valueOf(argObjectMap.get("waitForRecording").toString()), Boolean.valueOf(argObjectMap.get("allowRecording").toString()), Boolean.valueOf(argObjectMap.get("hideTopBar").toString()), Boolean.valueOf(argObjectMap.get("hideChat").toString()), Boolean.valueOf(argObjectMap.get("hideActivitiesAndActions").toString()), Boolean.valueOf(argObjectMap.get("hideFilesExplorer").toString()), Boolean.valueOf(argObjectMap.get("hideActionsMenu").toString()), Boolean.valueOf(argObjectMap.get("hideScreenSharing").toString()), Boolean.valueOf(argObjectMap.get("hideWhiteboard").toString()), Boolean.valueOf(argObjectMap.get("showMicrophoneStatus").toString())); } } catch (Exception e) { log.error("saveOrUpdateRoom", e); } return null; }
From source file:com.amalto.workbench.dialogs.AddBrowseItemsWizard.java
private TreeObject createNewTreeObject(XSDElementDeclaration decl, String browseItem) { WSView view = new WSView(); view.setIsTransformerActive(new WSBoolean(false)); view.setTransformerPK("");//$NON-NLS-1$ view.setName(browseItem);/*from www . j ava2 s . co m*/ EList<XSDIdentityConstraintDefinition> idtylist = decl.getIdentityConstraintDefinitions(); List<String> keys = new ArrayList<String>(); for (XSDIdentityConstraintDefinition idty : idtylist) { EList<XSDXPathDefinition> xpathList = idty.getFields(); for (XSDXPathDefinition path : xpathList) { String key = decl.getName(); // remove key = key.replaceFirst("#.*", "");//$NON-NLS-1$//$NON-NLS-2$ key += "/" + path.getValue();//$NON-NLS-1$ keys.add(key); } } view.getSearchableBusinessElements().addAll(keys); view.getViewableBusinessElements().addAll(keys); StringBuffer desc = new StringBuffer(); LinkedHashMap<String, String> labels = new LinkedHashMap<String, String>(); if (decl.getAnnotation() != null) { labels = new XSDAnnotationsStructure(decl.getAnnotation()).getLabels(); } if (labels.size() == 0) { labels.put("EN", decl.getName());//$NON-NLS-1$ } for (String lan : labels.keySet()) { desc.append("[" + lan.toUpperCase() + ":" + labels.get(lan) + "]");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } view.setDescription(desc.toString()); WSPutView wrap = new WSPutView(); wrap.setWsView(view); WSViewPK viewPk = new WSViewPK(); viewPk.setPk(browseItem); WSDeleteView delView = new WSDeleteView(); delView.setWsViewPK(viewPk); WSGetView getView = new WSGetView(); getView.setWsViewPK(viewPk); service.putView(wrap); // add node in the root TreeParent root = page.getXObject().getServerRoot(); TreeObject obj = new TreeObject(browseItem, root, TreeObject.VIEW, viewPk, null // no storage to save // space ); return obj; }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.SimpleXY_ChartPanel.java
private XYDataset createDeltaDataset(OSM_FabricDeltaCollection deltaHistory, Object userElement, String seriesName) {/*from ww w . j av a2 s .c o m*/ // PortCounterName portCounter = null; // MAD_Counter madCounter = null; // OsmEvent osmEvent = null; // // if((Port != null) && (userElement instanceof PortCounterName)) // portCounter = (PortCounterName)userElement; // // if((MAD_Stats != null) && (userElement instanceof MAD_Counter)) // madCounter = (MAD_Counter)userElement; // // if((EventStats != null) && (userElement instanceof OsmEvent)) // osmEvent = (OsmEvent)userElement; // TimeSeries series = new TimeSeries(seriesName); // iterate through the collection, and build up a time series for (int j = 0; j < deltaHistory.getSize(); j++) { OSM_FabricDelta delta = deltaHistory.getOSM_FabricDelta(j); // the dataset is a timeseries collection long lValue = 0; TimeStamp ts = null; RegularTimePeriod ms = null; if (Port != null) { // find the desired port counter, in this instance LinkedHashMap<String, PFM_PortChange> pcL = delta.getPortChanges(); PFM_PortChange pC = pcL.get(OSM_Port.getOSM_PortKey(Port)); lValue = pC.getDelta_port_counter(PortCounter); ts = pC.getCounterTimeStamp(); // correct for missing time periods int deltaSeconds = delta.getDeltaSeconds(); long sweepPeriod = delta.getFabric2().getPerfMgrSweepSecs(); if (sweepPeriod < deltaSeconds) { // graph is reported as counts per period, so if the period is too long, interpolate lValue *= sweepPeriod; lValue /= deltaSeconds; } } else if (MADCounter != null) { // find the desired MAD counter, in this instance OSM_Stats mStats = delta.getStatChanges(); lValue = MADCounter.getCounterValue(mStats); ts = delta.getTimeStamp(); // correct for missing time periods int deltaSeconds = delta.getDeltaSeconds(); long sweepPeriod = delta.getFabric2().getPerfMgrSweepSecs(); if (sweepPeriod < deltaSeconds) { // graph is reported as counts per period, so if the period is too long, interpolate lValue *= sweepPeriod; lValue /= deltaSeconds; } } else if (EventType != null) { // find the desired Event counter, in this instance OSM_EventStats eStats = delta.getEventChanges(); lValue = eStats.getCounter(EventType); ts = delta.getTimeStamp(); // correct for missing time periods int deltaSeconds = delta.getDeltaSeconds(); long sweepPeriod = delta.getFabric2().getPerfMgrSweepSecs(); if (sweepPeriod < deltaSeconds) { // graph is reported as counts per period, so if the period is too long, interpolate lValue *= sweepPeriod; lValue /= deltaSeconds; } } else continue; ms = new FixedMillisecond(ts.getTimeInMillis()); series.add(ms, (double) lValue); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); return dataset; }
From source file:msi.gama.outputs.layers.charts.ChartOutput.java
public void updateOutput(final IScope scope) { if (chartdataset.doResetAll(scope, lastUpdateCycle)) { clearDataSet(scope);//from w ww . ja v a 2 s . c o m for (final String serieid : chartdataset.getDataSeriesIds(scope)) { createNewSerie(scope, serieid); } preResetSeries(scope); for (final String serieid : chartdataset.getDataSeriesIds(scope)) { this.resetSerie(scope, serieid); } resetAxes(scope); } else { final LinkedHashMap<String, Integer> toremove = chartdataset.getSerieRemovalDate(); for (final String serieid : toremove.keySet()) { if (toremove.get(serieid) >= lastUpdateCycle) { removeSerie(scope, serieid); toremove.put(serieid, toremove.get(serieid) - 1); } } final LinkedHashMap<String, Integer> toadd = chartdataset.getSerieCreationDate(); for (final String serieid : toadd.keySet()) { if (toadd.get(serieid) >= lastUpdateCycle) { createNewSerie(scope, serieid); toadd.put(serieid, toadd.get(serieid) - 1); } } preResetSeries(scope); for (final String serieid : chartdataset.getDataSeriesIds(scope)) { this.resetSerie(scope, serieid); } resetAxes(scope); } updateImage(scope); lastUpdateCycle = scope.getClock().getCycle(); // DEBUG.LOG("output last update:" + lastUpdateCycle); }
From source file:org.fao.fenix.wds.web.rest.crowdprices.CrowdPricesDataRESTService.java
private String createGeoJsonDisabled(List<List<String>> table) { String s = "{ \"type\":\"FeatureCollection\",\"features\":["; int i = 0;/*from w w w . j av a 2s. co m*/ LinkedHashMap<String, List<List<String>>> markets = getCrowdPricesPoints(table); for (String marketname : markets.keySet()) { String popupcontent = "<b>" + marketname + "</b><br> No available data for that market in the current selection"; String lat = ""; String lon = ""; for (List<String> row : markets.get(marketname)) { lon = row.get(1); lat = row.get(2); } // System.out.println("popup: " + popupcontent); s += "{\"type\":\"Feature\",\"properties\":{\"iconurl\":\"images/marker-icon-disabled.png\"," + "\"name\":\"Countrys\"," + "\"popupContent\":\"" + popupcontent + " \"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[" + lon + "," + lat + "]}}"; if (i < markets.size() - 1) { s += ","; } i++; } s += "]}"; return s; }
From source file:hydrograph.ui.graph.controller.ComponentEditPart.java
/** * Updates the status of a component./*from ww w.jav a2 s .c o m*/ */ public void updateComponentStatus() { Component component = this.getCastedModel(); LinkedHashMap<String, Object> properties = component.getProperties(); String statusName = Component.Props.VALIDITY_STATUS.getValue(); if (properties.containsKey(statusName)) { ((ComponentFigure) this.getFigure()).setPropertyStatus((String) properties.get(statusName)); this.getFigure().repaint(); } }