List of usage examples for java.util Set removeAll
boolean removeAll(Collection<?> c);
From source file:fr.gouv.vitam.cases.VitamType.java
/** * Update the links//from w ww . j a va 2 s. c o m * * @param vtReloaded * @return the update part */ protected final Set<String> updateUpLinks(final VitamType vtReloaded) { if (vtReloaded != null) { final Set<String> srcList = vtReloaded.up; final Set<String> targetList = up; if (srcList != null && targetList != null) { targetList.removeAll(srcList); } else if (targetList != null) { // srcList empty } else { // targetList empty up = srcList; } if (targetList != null && !targetList.isEmpty()) { // need to add $addToSet return targetList; } } else { // nothing since save will be done just after, except checking array exists if (up == null) { up = new HashSet<String>(); } } return null; }
From source file:fr.gouv.vitam.cases.VitamType.java
/** * Update the links/*from w ww .j a v a 2 s.c o m*/ * * @param vtReloaded * @return the update part */ protected final Set<String> updateDuasLinks(final VitamType vtReloaded) { if (vtReloaded != null) { final Set<String> srcList = vtReloaded.dua; final Set<String> targetList = dua; if (srcList != null && targetList != null) { targetList.removeAll(srcList); } else if (targetList != null) { // srcList empty } else { // targetList empty dua = srcList; } if (targetList != null && !targetList.isEmpty()) { // need to add $addToSet return targetList; } } else { // nothing since save will be done just after, except checking array exists if (dua == null) { dua = new HashSet<String>(); } } return null; }
From source file:fr.gouv.vitam.cases.VitamType.java
/** * Update the links/*from w ww . j a v a2 s. c om*/ * * @param vtReloaded * @return the update part */ protected final Set<String> updateDdsLinks(final VitamType vtReloaded) { if (vtReloaded != null) { final Set<String> srcList = vtReloaded.dds; final Set<String> targetList = dds; if (srcList != null && targetList != null) { targetList.removeAll(srcList); } else if (targetList != null) { // srcList empty } else { // targetList empty dds = srcList; } if (targetList != null && !targetList.isEmpty()) { // need to add $addToSet return targetList; } } else { // nothing since save will be done just after, except checking array exists if (dds == null) { dds = new HashSet<String>(); } } return null; }
From source file:edu.stanford.muse.index.IndexUtils.java
/** version that stores actual dates instead of just counts for each facet */ public static Map<String, Collection<DetailedFacetItem>> computeDetailedFacets(Collection<Document> docs, Archive archive) {//from w w w .j a v a 2 s.c o m AddressBook addressBook = archive.addressBook; GroupAssigner groupAssigner = archive.groupAssigner; Map<String, Collection<DetailedFacetItem>> facetMap = new LinkedHashMap<String, Collection<DetailedFacetItem>>(); // Note: order is important here -- the facets will be displayed in the order they are inserted in facetMap // current order: sentiments, groups, people, direction, folders /* disabling sentiment facets if (indexer != null) { List<DetailedFacetItem> sentimentItems = new ArrayList<DetailedFacetItem>(); Set<Document> docSet = new LinkedHashSet<Document>(docs); // rather brute-force, compute docs for all sentiments and then intersect... // a better way might be to process the selected messages and see which sentiments they reflect Map<String, String> captionToQueryMap; if (lexicon != null && !ModeConfig.isPublicMode()) captionToQueryMap = lexicon.getCaptionToQueryMap(docs); else captionToQueryMap = new LinkedHashMap<>(); for (String sentiment : captionToQueryMap.keySet()) { String query = captionToQueryMap.get(sentiment); Indexer.QueryOptions options = new Indexer.QueryOptions(); //options.setQueryType(Indexer.QueryType.ORIGINAL); options.setSortBy(Indexer.SortBy.RELEVANCE); // to avoid unnecessary sorting Collection<Document> docsForTerm = indexer.docsForQuery(query, options); docsForTerm.retainAll(docSet); sentimentItems.add(new DetailedFacetItem(sentiment, captionToQueryMap.get(sentiment), new ArrayList<Document>(docsForTerm), "sentiment", sentiment)); } facetMap.put("sentiments", sentimentItems); } */ Set<Document> docSet = new LinkedHashSet<Document>(docs); Map<String, Set<Document>> tagToDocs = new LinkedHashMap<String, Set<Document>>(); for (Document d : docs) { if (!Util.nullOrEmpty(d.comment)) { String tag = d.comment.toLowerCase(); Set<Document> set = tagToDocs.get(tag); if (set == null) { set = new LinkedHashSet<Document>(); tagToDocs.put(tag, set); } set.add(d); } } if (addressBook != null) { // groups if (!ModeConfig.isPublicMode() && groupAssigner != null) { Map<SimilarGroup<String>, DetailedFacetItem> groupMap = partitionDocsByGroup(docs, groupAssigner); facetMap.put("groups", groupMap.values()); } // people Map<Contact, DetailedFacetItem> peopleMap = partitionDocsByPerson(docs, addressBook); facetMap.put("correspondent", peopleMap.values()); // direction Map<String, DetailedFacetItem> directionMap = partitionDocsByDirection(docs, addressBook); if (directionMap.size() > 1) facetMap.put("direction", directionMap.values()); // flags -- provide them only if they have at least 2 types in these docs. if all docs have the same value for a particular flag, no point showing it. Map<String, DetailedFacetItem> doNotTransferMap = partitionDocsByDoNotTransfer(docs); if (doNotTransferMap.size() > 1) facetMap.put("transfer", doNotTransferMap.values()); Map<String, DetailedFacetItem> transferWithRestrictionsMap = partitionDocsByTransferWithRestrictions( docs); if (transferWithRestrictionsMap.size() > 1) facetMap.put("restrictions", transferWithRestrictionsMap.values()); Map<String, DetailedFacetItem> reviewedMap = partitionDocsByReviewed(docs); if (reviewedMap.size() > 1) facetMap.put("reviewed", reviewedMap.values()); List<DetailedFacetItem> tagItems = new ArrayList<DetailedFacetItem>(); Set<Document> unannotatedDocs = new LinkedHashSet<Document>(docSet); for (String tag : tagToDocs.keySet()) { Set<Document> docsForTag = tagToDocs.get(tag); docsForTag.retainAll(docSet); unannotatedDocs.removeAll(docsForTag); tagItems.add(new DetailedFacetItem(tag, tag, new HashSet<Document>(docsForTag), "annotation", tag)); } if (unannotatedDocs.size() > 0) tagItems.add(new DetailedFacetItem("none", "none", new HashSet<Document>(unannotatedDocs), "annotation", "" /* empty value for annotation */)); if (tagItems.size() > 1) facetMap.put("annotations", tagItems); // attachments if (!ModeConfig.isPublicMode()) { Map<String, DetailedFacetItem> attachmentTypesMap = partitionDocsByAttachmentType(docs); facetMap.put("attachment type", attachmentTypesMap.values()); } } if (!ModeConfig.isPublicMode()) { Map<String, DetailedFacetItem> folderNameMap = partitionDocsByFolder(docs); if (folderNameMap.size() > 1) facetMap.put("folders", folderNameMap.values()); } // sort so that in each topic, the heaviest facets are first for (String s : facetMap.keySet()) { Collection<DetailedFacetItem> detailedFacets = facetMap.get(s); List<DetailedFacetItem> list = new ArrayList<DetailedFacetItem>(detailedFacets); Collections.sort(list); facetMap.put(s, list); } return facetMap; }
From source file:fr.gouv.vitam.cases.VitamType.java
/** * Update the links//from w w w .ja va2 s .co m * * @param vtReloaded * @return the update part */ protected final Set<String> updateDomsLinks(final VitamType vtReloaded) { if (vtReloaded != null) { final Set<String> srcList = vtReloaded.doms; final Set<String> targetList = doms; if (srcList != null && targetList != null) { targetList.removeAll(srcList); } else if (targetList != null) { // srcList empty } else { // targetList empty doms = srcList; } if (targetList != null && !targetList.isEmpty()) { // need to add $addToSet return targetList; } } else { // nothing since save will be done just after, except checking array exists if (doms == null) { doms = new HashSet<String>(); } } return null; }
From source file:fr.gouv.vitam.cases.VitamType.java
/** * Update the links/*w w w . ja v a2s.c o m*/ * * @param vtReloaded * @return the update part */ protected final Set<String> updateDaipsLinks(final VitamType vtReloaded) { if (vtReloaded != null) { final Set<String> srcList = vtReloaded.daips; final Set<String> targetList = daips; if (srcList != null && targetList != null) { targetList.removeAll(srcList); } else if (targetList != null) { // srcList empty } else { // targetList empty daips = srcList; } if (targetList != null && !targetList.isEmpty()) { // need to add $addToSet return targetList; } } else { // nothing since save will be done just after, except checking array exists if (daips == null) { daips = new HashSet<String>(); } } return null; }
From source file:com.github.javaplugs.jsf.ViewScope.java
/** * Removing bean from scope and unregister it destruction callback without executing them. * * @see Scope for more details/*from w w w . jav a 2 s.c o m*/ */ @Override public Object remove(String name) { Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap(); if (viewMap.containsKey(name)) { Object removed; synchronized (viewMap) { if (viewMap.containsKey(name)) { removed = FacesContext.getCurrentInstance().getViewRoot().getViewMap().remove(name); } else { return null; } } HttpSession httpSession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext() .getSession(true); Set<ViewScopeViewMapListener> sessionListeners; sessionListeners = sessionToListeners.get(httpSession); if (sessionListeners != null) { Set<ViewScopeViewMapListener> toRemove = new HashSet<>(); for (ViewScopeViewMapListener listener : sessionListeners) { if (listener.getName().equals(name)) { toRemove.add(listener); FacesContext.getCurrentInstance().getViewRoot() .unsubscribeFromViewEvent(PreDestroyViewMapEvent.class, listener); } } synchronized (sessionListeners) { sessionListeners.removeAll(toRemove); } } return removed; } return null; }
From source file:edu.harvard.med.screensaver.ui.arch.util.converter.EmptyWellsConverter.java
public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException { if (value == null) { return ""; }//w ww . j a v a2s . c om Set<WellName> wellNames = new TreeSet<WellName>(); wellNames.addAll((Set<WellName>) value); StringBuilder s = new StringBuilder(); Set<WellName> toRemove = new HashSet<WellName>(); for (Integer fullColumn : getFullColumns(wellNames)) { if (s.length() > 0) { s.append(DELIMITER); } s.append("Col:").append(WellName.getColumnLabel(fullColumn)); toRemove.addAll(makeFullColumn(fullColumn)); } for (Integer fullRow : getFullRows(wellNames)) { if (s.length() > 0) { s.append(DELIMITER); } s.append("Row:").append(WellName.getRowLabel(fullRow)); toRemove.addAll(makeFullRow(fullRow)); } wellNames.removeAll(toRemove); if (s.length() > 0 && wellNames.size() > 0) { s.append(DELIMITER); } s.append(StringUtils.join(wellNames.iterator(), DELIMITER)); return s.toString(); }
From source file:alliance.docs.DocumentationTest.java
@Test public void testBrokenAnchorsPresent() throws IOException, URISyntaxException { List<Path> docs = Files.list(getPath()).filter(f -> f.toString().endsWith(HTML_DIRECTORY)) .collect(Collectors.toList()); Set<String> links = new HashSet<>(); Set<String> anchors = new HashSet<>(); for (Path path : docs) { Document doc = Jsoup.parse(path.toFile(), "UTF-8", EMPTY_STRING); String thisDoc = StringUtils.substringAfterLast(path.toString(), File.separator); Elements elements = doc.body().getAllElements(); for (Element element : elements) { if (!element.toString().contains(":") && StringUtils.substringBetween(element.toString(), HREF_ANCHOR, CLOSE) != null) { links.add(thisDoc + "#" + StringUtils.substringBetween(element.toString(), HREF_ANCHOR, CLOSE)); }//from w w w . j a v a2s . c o m anchors.add(thisDoc + "#" + StringUtils.substringBetween(element.toString(), ID, CLOSE)); } } links.removeAll(anchors); assertThat("Anchors missing section reference: " + links.toString(), links.isEmpty()); }
From source file:com.mockey.ui.JsonSchemaValidateServlet.java
@Override public void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final Set<String> params = Sets.newHashSet(); final Enumeration<String> enumeration = req.getParameterNames(); // FIXME: no duplicates, it seems, but I cannot find the spec which // guarantees that while (enumeration.hasMoreElements()) params.add(enumeration.nextElement()); // We have required parameters if (!params.containsAll(ValidateRequest.REQUIRED_PARAMS)) { logger.warn("Missing parameters! Someone using me as a web service?"); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing parameters"); return;/*from www . j ava2 s . c o m*/ } // We don't want extraneous parameters params.removeAll(ValidateRequest.VALID_PARAMS); if (!params.isEmpty()) { logger.warn("Invalid parameters! Someone using me as a web service?"); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid parameters"); return; } final String rawSchema = req.getParameter(ValidateRequest.SCHEMA); final String data = req.getParameter(ValidateRequest.DATA); // Set correct content type resp.setContentType(MediaType.JSON_UTF_8.toString()); final boolean useV3 = Boolean.parseBoolean(req.getParameter(ValidateRequest.USE_V3)); final boolean useId = Boolean.parseBoolean(req.getParameter(ValidateRequest.USE_ID)); final JsonNode ret = JsonSchemaUtil.buildResult(rawSchema, data, useV3, useId); final OutputStream out = resp.getOutputStream(); try { out.write(ret.toString().getBytes(Charset.forName("UTF-8"))); out.flush(); } finally { Closeables.closeQuietly(out); } }