List of usage examples for java.util HashSet addAll
boolean addAll(Collection<? extends E> c);
From source file:com.lynnlyc.web.taintanalysis.JSTaintAnalysis.java
public Set<List<Integer>> getTaintPathsFrom(Integer sourceId) { HashSet<List<Integer>> paths = new HashSet<>(); HashSet<Integer> markedSites = this.getMarkedSites(sourceId); if (markedSites.isEmpty()) { List<Integer> path = new ArrayList<>(); path.add(sourceId);// ww w. ja v a2 s .c om paths.add(path); } else { for (int site : markedSites) { Set<List<Integer>> succPaths = getTaintPathsFrom(site); for (List<Integer> path : succPaths) { path.add(0, sourceId); } paths.addAll(succPaths); } } return paths; }
From source file:org.libreplan.web.limitingresources.LimitingResourceQueueModel.java
@Override @Transactional(readOnly = true)//from w w w . jav a2 s . c o m public List<LimitingResourceQueueElement> replaceLimitingResourceQueueElement( LimitingResourceQueueElement oldElement, LimitingResourceQueueElement newElement) { List<LimitingResourceQueueElement> result = new ArrayList<>(); boolean needToReassign = oldElement.hasDayAssignments(); limitingResourceQueueElementDAO.save(oldElement); limitingResourceQueueElementDAO.save(newElement); toBeSaved.remove(oldElement); queuesState.replaceLimitingResourceQueueElement(oldElement, newElement); if (needToReassign) { result.addAll(assignLimitingResourceQueueElement(newElement)); } HashSet<LimitingResourceQueueDependency> dependencies = new HashSet<>(); dependencies.addAll(newElement.getDependenciesAsOrigin()); dependencies.addAll(newElement.getDependenciesAsDestiny()); toBeSavedDependencies.put(newElement, dependencies); markAsModified(newElement); return result; }
From source file:net.tbnr.gearz.game.GearzGame.java
/** * Gets the players which are playing the game * * @return List<GearzPlayer> ~ List of players */// w w w . j ava2 s. c om public final HashSet<PlayerType> getPlayers() { HashSet<PlayerType> players = new HashSet<>(); players.addAll(this.players); return players; }
From source file:kevin.gvmsgarch.Worker.java
private void archiveAll(String authToken, String rnrse) throws IOException, ParserConfigurationException, SAXException, XPathExpressionException, JSONException { try {/* w w w . j a v a 2 s. c o m*/ Collection<String> msgIds = Collections.EMPTY_LIST; int page = 1; int processed = 0; HashSet<String> alreadyProcessed = new HashSet<String>(); do { int numParsed = 0; do { String json = App.extractInboxJson(authToken, this.location, page); msgIds = getMessageIds(json); if (msgIds != null) { numParsed += msgIds.size(); msgIds.removeAll(alreadyProcessed); processed += msgIds.size(); if (msgIds.removeAll(getFilterIds(json, this.filter))) { this.firePropertyChange("progress", null, processed); } if (msgIds.isEmpty()) { page++; } } } while (msgIds != null && msgIds.isEmpty() && !pm.isCanceled()); if (!pm.isCanceled() && msgIds != null && msgIds.size() > 0) { archiveThese(authToken, rnrse, msgIds, mode); alreadyProcessed.addAll(msgIds); this.firePropertyChange("progress", null, processed); } } while (msgIds != null && msgIds.size() > 0 && !pm.isCanceled()); this.firePropertyChange("finish", null, null); } catch (Exception ex) { this.firePropertyChange("error", null, ex); } }
From source file:net.tbnr.gearz.game.GearzGame.java
/** * Gets all the players including spectators * * @return List<PlayerType> List of players (in GearzPlayer wrapper) inc. Spectators *///from ww w .ja va2 s .c o m public final HashSet<PlayerType> allPlayers() { HashSet<PlayerType> allPlayers = new HashSet<>(); allPlayers.addAll(this.getPlayers()); allPlayers.addAll(this.getSpectators()); return allPlayers; }
From source file:org.jivesoftware.openfire.group.GroupManager.java
/** * Returns an unmodifiable Collection of all shared groups in the system for a given userName. * * @param groupToCheck The group to check * @return an unmodifiable Collection of all shared groups for the given userName. *//*from w ww.j a v a2 s . c o m*/ public Collection<Group> getVisibleGroups(Group groupToCheck) { // Get all the public shared groups. HashSet<String> groupNames = getPublicGroupsFromCache(); if (groupNames == null) { synchronized (PUBLIC_GROUPS) { groupNames = getPublicGroupsFromCache(); if (groupNames == null) { groupNames = new HashSet<>(provider.getPublicSharedGroupNames()); savePublicGroupsInCache(groupNames); } } } // Now get all visible groups to the given group. groupNames.addAll(provider.getVisibleGroupNames(groupToCheck.getName())); return new GroupCollection(groupNames); }
From source file:org.exoplatform.services.cms.templates.impl.TemplateServiceImpl.java
public Set<String> getAllEditedConfiguredNodeTypes() throws Exception { DocumentContext.getCurrent().getAttributes().put(DocumentContext.IS_SKIP_RAISE_ACT, true); HashSet<String> editedConfigNodetypes = new HashSet<String>(); Node serviceLogContentNode = Utils.getServiceLogContentNode(this.getClass().getSimpleName(), EDITED_CONFIGURED_NODE_TYPES); if (serviceLogContentNode != null) { String logData = serviceLogContentNode.getProperty(NodetypeConstant.JCR_DATA).getString(); editedConfigNodetypes.addAll(Arrays.asList(logData.split(";"))); }/*from w ww . j av a 2s . c o m*/ return editedConfigNodetypes; }
From source file:aml.match.CompoundAlignment.java
/** * @return the list of all target classes that have mappings *///from w w w . java2 s . com public Set<Integer> getTargets1() { HashSet<Integer> tMaps = new HashSet<Integer>(); tMaps.addAll(targetMaps1.keySet()); return tMaps; }
From source file:aml.match.CompoundAlignment.java
/** * @return the list of all target classes that have mappings *//*from www. j a va 2s. c o m*/ public Set<Integer> getTargets2() { HashSet<Integer> tMaps = new HashSet<Integer>(); tMaps.addAll(targetMaps2.keySet()); return tMaps; }
From source file:org.bedework.notifier.outbound.email.EmailAdaptor.java
private List<TemplateResult> applyTemplates(final Action action) throws NoteException { final Note note = action.getNote(); final NotificationType nt = note.getNotification(); final EmailSubscription sub = EmailSubscription.rewrap(action.getSub()); List<TemplateResult> results = new ArrayList<TemplateResult>(); try {/*from ww w.j a v a 2s . c o m*/ String prefix = nt.getParsed().getDocumentElement().getPrefix(); if (prefix == null) { prefix = "default"; } final String abstractPath = Util.buildPath(false, Note.DeliveryMethod.email.toString(), "/", prefix, "/", nt.getNotification().getElementName().getLocalPart()); File templateDir = new File(Util.buildPath(false, globalConfig.getTemplatesPath(), "/", abstractPath)); if (templateDir.isDirectory()) { Map<String, Object> root = new HashMap<String, Object>(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource(new StringReader(nt.toXml(true)))); Element el = doc.getDocumentElement(); NodeModel.simplify(el); NodeModel.useJaxenXPathSupport(); root.put("notification", el); HashSet<String> recipients = new HashSet<String>(); for (String email : sub.getEmails()) { recipients.add(MAILTO + email); } root.put("recipients", recipients); if (globalConfig.getCardDAVHost() != null && globalConfig.getCardDAVPort() != 0 && globalConfig.getCardDAVContextPath() != null) { HashMap<String, Object> vcards = new HashMap<String, Object>(); BasicHttpClient client; try { ArrayList<Header> hdrs = new ArrayList<Header>(); BasicHeader h = new BasicHeader(HEADER_ACCEPT, globalConfig.getVCardContentType()); hdrs.add(h); client = new BasicHttpClient(globalConfig.getCardDAVHost(), globalConfig.getCardDAVPort(), null, 15 * 1000); XPathExpression exp = xPath.compile("//*[local-name() = 'href']"); NodeList nl = (NodeList) exp.evaluate(doc, XPathConstants.NODESET); HashSet<String> vcardLookups = new HashSet<String>(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); String text = n.getTextContent(); text = pMailto.matcher(text).replaceFirst(MAILTO); if (text.startsWith(MAILTO) || text.startsWith(globalConfig.getCardDAVPrincipalsPath())) { vcardLookups.add(text); } } // Get vCards for recipients too. They may not be referenced in the notification. vcardLookups.addAll(recipients); for (String lookup : vcardLookups) { String path = Util.buildPath(false, globalConfig.getCardDAVContextPath() + "/" + lookup.replace(':', '/')); final InputStream is = client.get(path + VCARD_SUFFIX, "application/text", hdrs); if (is != null) { ObjectMapper om = new ObjectMapper(); @SuppressWarnings("unchecked") ArrayList<Object> hm = om.readValue(is, ArrayList.class); vcards.put(lookup, hm); } } root.put("vcards", vcards); } catch (final Throwable t) { error(t); } } if (nt.getNotification() instanceof ResourceChangeType) { ResourceChangeType chg = (ResourceChangeType) nt.getNotification(); BedeworkConnectorConfig cfg = ((BedeworkConnector) action.getConn()).getConnectorConfig(); BasicHttpClient cl = getClient(cfg); List<Header> hdrs = getHeaders(cfg, new BedeworkSubscription(action.getSub())); String href = null; if (chg.getCreated() != null) { href = chg.getCreated().getHref(); } else if (chg.getDeleted() != null) { href = chg.getDeleted().getHref(); } else if (chg.getUpdated() != null && chg.getUpdated().size() > 0) { href = chg.getUpdated().get(0).getHref(); } if (href != null) { if (chg.getDeleted() == null) { // We only have an event for the templates on a create or update, not on delete. ObjectMapper om = new ObjectMapper(); final InputStream is = cl.get(cfg.getSystemUrl() + href, null, hdrs); JsonNode a = om.readValue(is, JsonNode.class); // Check for a recurrence ID on this notification. XPathExpression exp = xPath.compile("//*[local-name() = 'recurrenceid']/text()"); String rid = exp.evaluate(doc); if (rid != null && !rid.isEmpty()) { Calendar rcal = Calendar.getInstance(); recurIdFormat.setTimeZone(TimeZone.getTimeZone("UTC")); rcal.setTime(recurIdFormat.parse(rid)); // Find the matching recurrence ID in the JSON, and make that the only vevent object. Calendar c = Calendar.getInstance(); ArrayNode vevents = (ArrayNode) a.get(2); for (JsonNode vevent : vevents) { if (vevent.size() > 1 && vevent.get(1).size() > 1) { JsonNode n = vevent.get(1).get(0); if (n.get(0).asText().equals("recurrence-id")) { if (n.get(1).size() > 0 && n.get(1).get("tzid") != null) { jsonIdFormatTZ.setTimeZone( TimeZone.getTimeZone(n.get(1).get("tzid").asText())); c.setTime(jsonIdFormatTZ.parse(n.get(3).asText())); } else { jsonIdFormatUTC.setTimeZone(TimeZone.getTimeZone("UTC")); c.setTime(jsonIdFormatUTC.parse(n.get(3).asText())); } if (rcal.compareTo(c) == 0) { vevents.removeAll(); vevents.add(vevent); break; } } } } } root.put("vevent", (ArrayList<Object>) om.convertValue(a, ArrayList.class)); } // TODO: Provide some calendar information to the templates. This is currently the publisher's // calendar, but needs to be fixed to be the subscriber's calendar. String chref = href.substring(0, href.lastIndexOf("/")); hdrs.add(new BasicHeader(HEADER_DEPTH, "0")); int rc = cl.sendRequest("PROPFIND", cfg.getSystemUrl() + chref, hdrs, "text/xml", CALENDAR_PROPFIND.length(), CALENDAR_PROPFIND.getBytes()); if (rc == HttpServletResponse.SC_OK || rc == SC_MULTISTATUS) { Document d = builder.parse(new InputSource(cl.getResponseBodyAsStream())); HashMap<String, String> hm = new HashMap<String, String>(); XPathExpression exp = xPath.compile("//*[local-name() = 'href']/text()"); hm.put("href", exp.evaluate(d)); exp = xPath.compile("//*[local-name() = 'displayname']/text()"); hm.put("name", (String) exp.evaluate(d)); exp = xPath.compile("//*[local-name() = 'calendar-description']/text()"); hm.put("description", (String) exp.evaluate(d)); root.put("calendar", hm); } } } if (note.getExtraValues() != null) { root.putAll(note.getExtraValues()); } DefaultObjectWrapper wrapper = new DefaultObjectWrapperBuilder( Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build(); root.put("timezone", (TemplateHashModel) wrapper.getStaticModels().get("java.util.TimeZone")); // Sort files so the user can control the order of content types/body parts of the email by template file name. File[] templates = templateDir.listFiles(templateFilter); Arrays.sort(templates); for (File f : templates) { Template template = fmConfig.getTemplate(Util.buildPath(false, abstractPath, "/", f.getName())); Writer out = new StringWriter(); Environment env = template.createProcessingEnvironment(root, out); env.process(); TemplateResult r = new TemplateResult(f.getName(), out.toString(), env); if (!r.getBooleanVariable("skip")) { results.add(new TemplateResult(f.getName(), out.toString(), env)); } } } } catch (final Throwable t) { throw new NoteException(t); } return results; }