List of usage examples for java.util Set remove
boolean remove(Object o);
From source file:org.openmrs.module.report.web.controller.reportRole.ReportRoleController.java
@RequestMapping(value = "/module/report/addRemoveReportToRole.form", method = RequestMethod.POST) public String addRemoveReportToRole(@RequestParam("roleId") String roleId, @RequestParam("reportId") Integer reportId, @RequestParam(value = "action") Integer action, Model model) {/* w w w . ja v a 2s . co m*/ BirtReportService birtReportService = Context.getService(BirtReportService.class); BirtReport report = birtReportService.getBirtReportById(reportId); if (report != null) { Role role = Context.getUserService().getRole(roleId); Set<Role> roles = report.getReportRoles(); if (action == 1) { if (!roles.contains(role)) { roles.add(role); report.setReportRoles(roles); birtReportService.saveReport(report); } } else { if (roles.contains(role)) { roles.remove(role); report.setReportRoles(roles); birtReportService.saveReport(report); } } } return "/module/report/blank/blank"; }
From source file:com.denismo.aws.iam.IAMAccountPasswordValidator.java
private boolean containsHeaders(HttpResponse response, String... headers) { Header[] headerList = response.getHeaders("Set-Cookie"); Set<String> lookup = new HashSet<String>(Arrays.asList(headers)); for (Header header : headerList) { String value = header.getValue(); if (!value.contains("=")) continue; String[] parts = value.split("="); if (parts.length < 2) continue; lookup.remove(parts[0]); }/*from w w w . j a va2 s. c om*/ return lookup.isEmpty(); }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.persongrantcount.PersonGrantCountVisCodeGenerator.java
/** * This method is used to setup parameters for the sparkline value object. These parameters * will be used in the template to construct the actual html/javascript code. * @param visMode/*ww w . j a va2 s .c om*/ * @param visContainer * @param authorDocuments * @return */ private SparklineData setupSparklineParameters(String visMode, String providedVisContainerID) { SparklineData sparklineData = new SparklineData(); sparklineData.setYearToActivityCount(yearToGrantCount); int numOfYearsToBeRendered = 0; /* * It was decided that to prevent downward curve that happens if there are no publications * in the current year seems a bit harsh, so we consider only publications from the last 10 * complete years. * */ int currentYear = Calendar.getInstance().get(Calendar.YEAR) - 1; int shortSparkMinYear = currentYear - VisConstants.MINIMUM_YEARS_CONSIDERED_FOR_SPARKLINE + 1; /* * This is required because when deciding the range of years over which * the vis was rendered we dont want to be influenced by the * "DEFAULT_GRANT_YEAR". */ Set<String> grantYears = new HashSet<String>(yearToGrantCount.keySet()); grantYears.remove(VOConstants.DEFAULT_GRANT_YEAR); /* * We are setting the default value of minGrantYear to be 10 years * before the current year (which is suitably represented by the * shortSparkMinYear), this in case we run into invalid set of grant * years. */ int minGrantYear = shortSparkMinYear; String visContainerID = null; if (yearToGrantCount.size() > 0) { try { minGrantYear = Integer.parseInt(Collections.min(grantYears)); } catch (NoSuchElementException e1) { log.debug("vis: " + e1.getMessage() + " error occurred for " + yearToGrantCount.toString()); } catch (NumberFormatException e2) { log.debug("vis: " + e2.getMessage() + " error occurred for " + yearToGrantCount.toString()); } } int minGrantYearConsidered = 0; /* * There might be a case that the author investigated his first grant * within the last 10 years but we want to make sure that the sparkline * is representative of at least the last 10 years, so we will set the * minGrantYearConsidered to "currentYear - 10" which is also given by * "shortSparkMinYear". */ if (minGrantYear > shortSparkMinYear) { minGrantYearConsidered = shortSparkMinYear; } else { minGrantYearConsidered = minGrantYear; } numOfYearsToBeRendered = currentYear - minGrantYearConsidered + 1; sparklineData.setNumOfYearsToBeRendered(numOfYearsToBeRendered); int grantCounter = 0; /* * For the purpose of this visualization I have come up with a term * "Sparks" which essentially means data points. Sparks that will be * rendered in full mode will always be the one's which have any year * associated with it. Hence. */ int renderedFullSparks = 0; List<YearToEntityCountDataElement> yearToGrantCountDataTable = new ArrayList<YearToEntityCountDataElement>(); for (int grantYear = minGrantYearConsidered; grantYear <= currentYear; grantYear++) { String stringInvestigatedYear = String.valueOf(grantYear); Integer currentGrants = yearToGrantCount.get(stringInvestigatedYear); if (currentGrants == null) { currentGrants = 0; } yearToGrantCountDataTable .add(new YearToEntityCountDataElement(grantCounter, stringInvestigatedYear, currentGrants)); /* * Sparks that will be rendered will always be the one's which has * any year associated with it. Hence. */ renderedFullSparks += currentGrants; grantCounter++; } sparklineData.setYearToEntityCountDataTable(yearToGrantCountDataTable); sparklineData.setRenderedSparks(renderedFullSparks); /* * Total grants will also consider grants that have no year * associated with it. Hence. */ Integer unknownYearGrants = 0; if (yearToGrantCount.get(VOConstants.DEFAULT_GRANT_YEAR) != null) { unknownYearGrants = yearToGrantCount.get(VOConstants.DEFAULT_GRANT_YEAR); } sparklineData.setUnknownYearGrants(unknownYearGrants); if (providedVisContainerID != null) { visContainerID = providedVisContainerID; } else { visContainerID = DEFAULT_VIS_CONTAINER_DIV_ID; } sparklineData.setVisContainerDivID(visContainerID); /* * By default these represents the range of the rendered sparks. Only in * case of "short" sparkline mode we will set the Earliest * RenderedGrant year to "currentYear - 10". */ sparklineData.setEarliestYearConsidered(minGrantYearConsidered); sparklineData.setEarliestRenderedGrantYear(minGrantYear); sparklineData.setLatestRenderedGrantYear(currentYear); /* * The Full Sparkline will be rendered by default. Only if the url has * specific mention of SHORT_SPARKLINE_MODE_URL_HANDLE then we render * the short sparkline and not otherwise. */ if (VisualizationFrameworkConstants.SHORT_SPARKLINE_VIS_MODE.equalsIgnoreCase(visMode)) { sparklineData.setEarliestRenderedGrantYear(shortSparkMinYear); sparklineData.setShortVisMode(true); } else { sparklineData.setShortVisMode(false); } if (yearToGrantCount.size() > 0) { sparklineData.setFullTimelineNetworkLink(UtilityFunctions.getCollaboratorshipNetworkLink(individualURI, VisualizationFrameworkConstants.PERSON_LEVEL_VIS, VisualizationFrameworkConstants.COPI_VIS_MODE)); sparklineData.setDownloadDataLink(UtilityFunctions.getCSVDownloadURL(individualURI, VisualizationFrameworkConstants.PERSON_GRANT_COUNT_VIS, "")); } return sparklineData; }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.personpubcount.PersonPublicationCountVisCodeGenerator.java
/** * This method is used to setup parameters for the sparkline value object. These parameters * will be used in the template to construct the actual html/javascript code. * @param visMode//from www . ja v a 2 s . c om * @param visContainer * @return */ private SparklineData setupSparklineParameters(String visMode, String providedVisContainerID) { SparklineData sparklineData = new SparklineData(); sparklineData.setYearToActivityCount(yearToPublicationCount); int numOfYearsToBeRendered = 0; /* * It was decided that to prevent downward curve that happens if there are no publications * in the current year seems a bit harsh, so we consider only publications from the last 10 * complete years. * */ int currentYear = Calendar.getInstance().get(Calendar.YEAR) - 1; int shortSparkMinYear = currentYear - VisConstants.MINIMUM_YEARS_CONSIDERED_FOR_SPARKLINE + 1; /* * This is required because when deciding the range of years over which the vis * was rendered we dont want to be influenced by the "DEFAULT_PUBLICATION_YEAR". * */ Set<String> publishedYears = new HashSet<String>(yearToPublicationCount.keySet()); publishedYears.remove(VOConstants.DEFAULT_PUBLICATION_YEAR); /* * We are setting the default value of minPublishedYear to be 10 years before * the current year (which is suitably represented by the shortSparkMinYear), * this in case we run into invalid set of published years. * */ int minPublishedYear = shortSparkMinYear; String visContainerID = null; if (yearToPublicationCount.size() > 0) { try { minPublishedYear = Integer.parseInt(Collections.min(publishedYears)); } catch (NoSuchElementException e1) { log.debug("vis: " + e1.getMessage() + " error occurred for " + yearToPublicationCount.toString()); } catch (NumberFormatException e2) { log.debug("vis: " + e2.getMessage() + " error occurred for " + yearToPublicationCount.toString()); } } int minPubYearConsidered = 0; /* * There might be a case that the author has made his first publication within the * last 10 years but we want to make sure that the sparkline is representative of * at least the last 10 years, so we will set the minPubYearConsidered to * "currentYear - 10" which is also given by "shortSparkMinYear". * */ if (minPublishedYear > shortSparkMinYear) { minPubYearConsidered = shortSparkMinYear; } else { minPubYearConsidered = minPublishedYear; } numOfYearsToBeRendered = currentYear - minPubYearConsidered + 1; sparklineData.setNumOfYearsToBeRendered(numOfYearsToBeRendered); int publicationCounter = 0; /* * For the purpose of this visualization I have come up with a term "Sparks" which * essentially means data points. * Sparks that will be rendered in full mode will always be the one's which have any year * associated with it. Hence. * */ int renderedFullSparks = 0; List<YearToEntityCountDataElement> yearToPublicationCountDataTable = new ArrayList<YearToEntityCountDataElement>(); for (int publicationYear = minPubYearConsidered; publicationYear <= currentYear; publicationYear++) { String stringPublishedYear = String.valueOf(publicationYear); Integer currentPublications = yearToPublicationCount.get(stringPublishedYear); if (currentPublications == null) { currentPublications = 0; } yearToPublicationCountDataTable.add( new YearToEntityCountDataElement(publicationCounter, stringPublishedYear, currentPublications)); /* * Sparks that will be rendered will always be the one's which has * any year associated with it. Hence. * */ renderedFullSparks += currentPublications; publicationCounter++; } sparklineData.setYearToEntityCountDataTable(yearToPublicationCountDataTable); sparklineData.setRenderedSparks(renderedFullSparks); /* * Total publications will also consider publications that have no year associated with * it. Hence. * */ Integer unknownYearPublications = 0; if (yearToPublicationCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR) != null) { unknownYearPublications = yearToPublicationCount.get(VOConstants.DEFAULT_PUBLICATION_YEAR); } sparklineData.setUnknownYearPublications(unknownYearPublications); if (providedVisContainerID != null) { visContainerID = providedVisContainerID; } else { visContainerID = DEFAULT_VIS_CONTAINER_DIV_ID; } sparklineData.setVisContainerDivID(visContainerID); /* * By default these represents the range of the rendered sparks. Only in case of * "short" sparkline mode we will set the Earliest RenderedPublication year to * "currentYear - 10". * */ sparklineData.setEarliestYearConsidered(minPubYearConsidered); sparklineData.setEarliestRenderedPublicationYear(minPublishedYear); sparklineData.setLatestRenderedPublicationYear(currentYear); if (yearToPublicationCount.size() > 0) { sparklineData.setFullTimelineNetworkLink(UtilityFunctions.getCollaboratorshipNetworkLink(individualURI, VisualizationFrameworkConstants.PERSON_LEVEL_VIS, VisualizationFrameworkConstants.COAUTHOR_VIS_MODE)); sparklineData.setDownloadDataLink(UtilityFunctions.getCSVDownloadURL(individualURI, VisualizationFrameworkConstants.PERSON_PUBLICATION_COUNT_VIS, "")); } /* * The Full Sparkline will be rendered by default. Only if the url has specific mention of * SHORT_SPARKLINE_MODE_URL_HANDLE then we render the short sparkline and not otherwise. * */ if (VisualizationFrameworkConstants.SHORT_SPARKLINE_VIS_MODE.equalsIgnoreCase(visMode)) { sparklineData.setEarliestRenderedPublicationYear(shortSparkMinYear); sparklineData.setShortVisMode(true); } else { sparklineData.setShortVisMode(false); } return sparklineData; }
From source file:com.premiumminds.webapp.wicket.repeaters.AjaxListSetView.java
private void updateItems(Set<ListSetItem<T>> newItems, Set<ListSetItem<T>> removedItems) { Set<T> componentsNotHandled = new HashSet<T>(elementToComponent.keySet()); for (T el : getList()) { if (componentsNotHandled.contains(el)) { componentsNotHandled.remove(el); } else {/*from w w w. ja v a 2 s . c o m*/ ListSetItem<T> item = newItem(Model.of(el)); elementToComponent.put(el, item); newItems.add(item); add(item); } } for (T el : componentsNotHandled) { removedItems.add(elementToComponent.get(el)); remove(elementToComponent.get(el)); elementToComponent.remove(el); } }
From source file:org.openbaton.nfvo.core.core.DependencyQueuer.java
/** * Check all dependencies that are waiting in in the map queues for the source vnfr to get * instantiated. If the vnfr that got ready was the last source in a waiting dependency send a * modify message to the target vnfr./*w ww . j ava 2 s . c o m*/ * * @param vnfrSourceName * @param nsrFather * @throws NotFoundException */ @Override public synchronized void releaseVNFR(String vnfrSourceName, NetworkServiceRecord nsrFather) throws NotFoundException { List<String> dependencyIdToBeRemoved = new ArrayList<>(); log.debug("Doing release for VNFR id: " + vnfrSourceName); for (Entry<String, Set<String>> entry : queues.entrySet()) { String dependencyId = entry.getKey(); Set<String> sourceList = entry.getValue(); log.debug("Dependency " + dependencyId + " contains " + sourceList.size() + " dependencies: " + sourceList); if (sourceList.contains(vnfrSourceName + nsrFather.getId())) { sourceList.remove(vnfrSourceName + nsrFather.getId()); if (sourceList.isEmpty()) { VNFRecordDependency vnfRecordDependency = vnfrDependencyRepository.findFirstById(dependencyId); log.debug("Found VNFRecordDependency: " + vnfRecordDependency); //get the vnfr target by its name VirtualNetworkFunctionRecord target = null; for (VirtualNetworkFunctionRecord vnfr : nsrFather.getVnfr()) if (vnfr.getName().equals(vnfRecordDependency.getTarget())) target = vnfrRepository.findFirstById(vnfr.getId()); log.info("Found target of relation: " + target.getName()); // for (LifecycleEvent lifecycleEvent : target.getLifecycle_event()) { // if (lifecycleEvent.getEvent().ordinal() == Event.CONFIGURE.ordinal()) { // LinkedHashSet<String> strings = new LinkedHashSet<>(); // strings.addAll(lifecycleEvent.getLifecycle_events()); // lifecycleEvent.setLifecycle_events(Arrays.asList(strings.toArray(new String[1]))); // } // } log.debug("Sending MODIFY to " + target.getName()); OrVnfmGenericMessage orVnfmGenericMessage = new OrVnfmGenericMessage(target, Action.MODIFY); orVnfmGenericMessage.setVnfrd(vnfRecordDependency); vnfmManager.sendMessageToVNFR(target, orVnfmGenericMessage); dependencyIdToBeRemoved.add(dependencyId); } } } for (String depIdToRem : dependencyIdToBeRemoved) { for (String depId : queues.keySet()) { if (depIdToRem.equals(depId)) { queues.remove(depId); break; } } } }
From source file:org.labkey.graphql.GraphQLController.java
public static GraphQLType ensureType(ForeignKey fk, Set<GraphQLType> types) { // Only create GraphQLType for lookups in the public schema if (fk.getLookupSchemaName() == null || fk.getLookupTableName() == null) return null; String typeName = fk.getLookupSchemaName().replace(".", "_") + "__" + fk.getLookupTableName(); GraphQLType fkType = findType(typeName, types); if (fkType == null) { TableInfo lookupTable = fk.getLookupTableInfo(); if (lookupTable == null) return null; // Add a temporary type reference avoid type recursion going to infinity GraphQLType temp = new GraphQLTypeReference(typeName); types.add(temp);// w ww . j a va2 s . co m fkType = createObject(fk.getLookupTableInfo(), typeName, types); types.add(fkType); types.remove(temp); } return fkType; }
From source file:com.devicehive.websockets.handlers.NotificationHandlers.java
private Set<String> prepareActualList(Set<String> deviceIdSet, final String deviceId) { if (deviceId == null && deviceIdSet == null) { return null; }//from w ww . j a va 2s . co m if (deviceIdSet != null && deviceId == null) { deviceIdSet.remove(null); return deviceIdSet; } if (deviceIdSet == null) { return new HashSet<String>() { { add(deviceId); } private static final long serialVersionUID = 955343867580964077L; }; } throw new HiveException(Messages.INVALID_REQUEST_PARAMETERS, SC_BAD_REQUEST); }
From source file:com.dal.unity.Config.java
public Set<TestType> getTestTypes() { Set<TestType> result = EnumSet.allOf(TestType.class); if (!maxTests) { result.remove(TestType.Max); }//from ww w. ja v a2s.c om if (!minTests) { result.remove(TestType.Min); } if (!nullTests) { result.remove(TestType.Nulls); } return result; }
From source file:lirmm.inria.fr.math.OpenLongToDoubleHashMapTest.java
@Test public void testRemove2() { OpenLongToDoubleHashMap map = createFromJavaMap(); int mapSize = javaMap.size(); int count = 0; Set<Long> keysInMap = new HashSet<>(javaMap.keySet()); for (Map.Entry<Long, Double> mapEntry : javaMap.entrySet()) { keysInMap.remove(mapEntry.getKey()); map.remove(mapEntry.getKey());/*from ww w. j a va 2s . c om*/ Assert.assertEquals(--mapSize, map.size()); Assert.assertTrue(Double.isNaN(map.get(mapEntry.getKey()))); if (count++ > 5) { break; } } /* Ensure that put and get still work correctly after removals */ assertPutAndGet(map, mapSize, keysInMap); }