List of usage examples for java.util Map remove
V remove(Object key);
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//ww w . j a v a 2 s . co m 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.lillicoder.newsblurry.net.PreferenceCookieStore.java
/** * Deletes the given {@link Cookie} from this store's * in-memory cache and persistent storage. If the cookie * is not currently stored, this method does nothing. * @param cookie {@link Cookie} to delete from cache and storage. */// ww w . j a v a2 s.c o m private void deleteCookie(Cookie cookie) { Assert.assertTrue(cookie != null); Map<String, Cookie> cache = this.getCookieCache(); cache.remove(cookie.getName()); String cookieId = this.getCookiePreferenceEntryId(cookie); SharedPreferences.Editor editor = this.getPreferences().edit(); editor.remove(cookieId); editor.commit(); // We have removed a cookie, we must update the ID set with current valid cookie IDs. this.updateCookieIds(cache.keySet()); }
From source file:it.unibo.alchemist.model.implementations.nodes.CellNodeImpl.java
@Override public void removeJunction(final Junction j, final CellNode neighbor) { if (junctions.containsKey(j)) { final Map<CellNode, Integer> inner = junctions.get(j); if (inner.containsKey(neighbor)) { if (inner.get(neighbor) == 1) { // only one junction j with neighbor inner.remove(neighbor); } else { inner.put(neighbor, inner.get(neighbor) - 1); }/*from w ww.j av a 2s.com*/ if (inner.isEmpty()) { junctions.remove(j); } else { junctions.put(j, inner); } for (final Map.Entry<Biomolecule, Double> e : j.getMoleculesInCurrentNode().entrySet()) { setConcentration(e.getKey(), getConcentration(e.getKey()) + e.getValue()); } } } }
From source file:com.glaf.oa.traveladdress.web.springmvc.TraveladdressController.java
@RequestMapping("/update") public ModelAndView update(HttpServletRequest request, ModelMap modelMap) { Map<String, Object> params = RequestUtils.getParameterMap(request); params.remove("status"); params.remove("wfStatus"); Traveladdress traveladdress = traveladdressService .getTraveladdress(RequestUtils.getLong(request, "addressid")); traveladdress.setTravelid(RequestUtils.getLong(request, "travelid")); traveladdress.setStartadd(request.getParameter("startadd")); traveladdress.setEndadd(request.getParameter("endadd")); traveladdress.setTransportation(request.getParameter("transportation")); traveladdressService.save(traveladdress); return this.list(request, modelMap); }
From source file:com.linkedin.pinot.routing.builder.RandomRoutingTableBuilder.java
@Override public synchronized List<ServerToSegmentSetMap> computeRoutingTableFromExternalView(String tableName, ExternalView externalView, List<InstanceConfig> instanceConfigList) { RoutingTableInstancePruner pruner = new RoutingTableInstancePruner(instanceConfigList); List<Map<String, Set<String>>> routingTables = new ArrayList<Map<String, Set<String>>>(); for (int i = 0; i < _numberOfRoutingTables; ++i) { routingTables.add(new HashMap<String, Set<String>>()); }//from w w w.j ava 2 s. co m String[] segmentSet = externalView.getPartitionSet().toArray(new String[0]); for (String segment : segmentSet) { Map<String, String> instanceToStateMap = externalView.getStateMap(segment); for (String instance : instanceToStateMap.keySet().toArray(new String[0])) { if (!instanceToStateMap.get(instance).equals("ONLINE") || pruner.isInactive(instance)) { instanceToStateMap.remove(instance); } } if (instanceToStateMap.size() > 0) { String[] instances = instanceToStateMap.keySet().toArray(new String[0]); Random randomSeed = new Random(System.currentTimeMillis()); for (int i = 0; i < _numberOfRoutingTables; ++i) { String instance = instances[randomSeed.nextInt(instances.length)]; if (routingTables.get(i).containsKey(instance)) { routingTables.get(i).get(instance).add(segment); } else { Set<String> instanceSegmentSet = new HashSet<String>(); instanceSegmentSet.add(segment); routingTables.get(i).put(instance, instanceSegmentSet); } } } } List<ServerToSegmentSetMap> resultRoutingTableList = new ArrayList<ServerToSegmentSetMap>(); for (int i = 0; i < _numberOfRoutingTables; ++i) { resultRoutingTableList.add(new ServerToSegmentSetMap(routingTables.get(i))); } return resultRoutingTableList; }
From source file:net.minewriter.StatThread.java
public String favoriteLicense() throws JSONException { Map<String, Integer> books = new HashMap<String, Integer>(); for (Book b : localLibrary) { String license = b.getLicense(); if (books.containsKey(license)) { int c = books.get(license); books.remove(license); books.put(license, c++);/*from ww w. j ava 2s . c om*/ continue; } books.put(b.getLicense(), 0); } Entry<String, Integer> maxEntry = null; for (Entry<String, Integer> entry : books.entrySet()) { if (maxEntry == null || entry.getValue() > maxEntry.getValue()) { maxEntry = entry; } } Stat s = new Stat("FavLicense", maxEntry.getKey()); stats.add(s); return maxEntry.getKey(); }
From source file:com.glaf.oa.travelpersonnel.web.springmvc.TravelpersonnelController.java
@RequestMapping("/update") public ModelAndView update(HttpServletRequest request, ModelMap modelMap) { Map<String, Object> params = RequestUtils.getParameterMap(request); params.remove("status"); params.remove("wfStatus"); Travelpersonnel travelpersonnel = travelpersonnelService .getTravelpersonnel(RequestUtils.getLong(request, "personnelid")); travelpersonnel.setTravelid(RequestUtils.getLong(request, "travelid")); travelpersonnel.setDept(request.getParameter("dept")); travelpersonnel.setPersonnel(request.getParameter("personnel")); travelpersonnel.setRemark(request.getParameter("remark")); travelpersonnelService.save(travelpersonnel); return this.list(request, modelMap); }
From source file:com.liferay.portal.util.PortalUtil.java
public static void destroyPortletInstance(Portlet portlet) { String scpId = PortalUtil.class.getName() + "." + com.dotcms.repackage.javax.portlet.Portlet.class.getName(); if (!portlet.isWARFile()) { scpId += "." + portlet.getCompanyId(); }/*from w w w.j ava 2 s .c o m*/ Map map = (Map) SimpleCachePool.get(scpId); if (map == null) { return; } CachePortlet portletInstance = (CachePortlet) map.get(portlet.getPortletId()); if (portletInstance != null) { portletInstance.destroy(); map.remove(portlet.getPortletId()); } if (portlet.isWARFile()) { PortletContextWrapper pcw = (PortletContextWrapper) PortletContextPool.get(portlet.getPortletId()); pcw.removePortletInstance(); } destroyPortletConfig(portlet); destroyPortletContext(portlet); }