List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.eclipse.skalli.core.project.ProjectComponent.java
@Override public SortedSet<Member> getMembers(UUID uuid) { TreeSet<Member> ret = new TreeSet<Member>(); Project project = getByUUID(uuid);//from w w w. j a v a 2s. co m if (project != null) { for (RoleProvider roleProvider : roleProviders) { ret.addAll(roleProvider.getMembers(project)); } } return ret; }
From source file:org.eclipse.skalli.core.project.ProjectComponent.java
@Override public SortedSet<Member> getMembers(UUID uuid, String... roles) { TreeSet<Member> ret = new TreeSet<Member>(); Project project = getByUUID(uuid);// w ww . j av a 2 s. c o m if (project != null) { for (RoleProvider roleProvider : roleProviders) { ret.addAll(roleProvider.getMembers(project, roles)); } } return ret; }
From source file:io.apicurio.hub.api.rest.impl.DesignsResourceTest.java
@Test public void testListDesigns() throws ServerError, AlreadyExistsException, NotFoundException, ApiValidationException { ImportApiDesign info = new ImportApiDesign(); info.setUrl("https://github.com/Apicurio/api-samples/blob/master/pet-store/pet-store.json"); resource.importDesign(info);/*from w ww.j av a 2 s . c om*/ info = new ImportApiDesign(); info.setUrl("https://github.com/Apicurio/api-samples/blob/master/apiman-rls/apiman-rls.json"); resource.importDesign(info); Collection<ApiDesign> apis = resource.listDesigns(); Assert.assertNotNull(apis); Assert.assertEquals(2, apis.size()); TreeSet<ApiDesign> sortedApis = new TreeSet<>(new Comparator<ApiDesign>() { @Override public int compare(ApiDesign o1, ApiDesign o2) { return o1.getName().compareTo(o2.getName()); } }); sortedApis.addAll(apis); Iterator<ApiDesign> iter = sortedApis.iterator(); ApiDesign design1 = iter.next(); ApiDesign design2 = iter.next(); Assert.assertNotNull(design1); Assert.assertNotNull(design2); Assert.assertEquals("apiman-rls.json", design1.getName()); Assert.assertEquals("pet-store.json", design2.getName()); String ghLog = github.auditLog(); Assert.assertNotNull(ghLog); Assert.assertEquals("---\n" + "validateResourceExists::https://github.com/Apicurio/api-samples/blob/master/pet-store/pet-store.json\n" + "getResourceContent::https://github.com/Apicurio/api-samples/blob/master/pet-store/pet-store.json\n" + "validateResourceExists::https://github.com/Apicurio/api-samples/blob/master/apiman-rls/apiman-rls.json\n" + "getResourceContent::https://github.com/Apicurio/api-samples/blob/master/apiman-rls/apiman-rls.json\n" + "---", ghLog); }
From source file:info.magnolia.cms.core.DefaultContentTest.java
@Test public void testNameFilteringWorksForBothBinaryAndNonBinaryProperties() throws Exception { String contentProperties = StringUtils.join(Arrays.asList("/somepage/mypage@type=mgnl:content", "/somepage/mypage/paragraphs@type=mgnl:contentNode", "/somepage/mypage/paragraphs/0@type=mgnl:contentNode", "/somepage/mypage/paragraphs/0@type=mgnl:contentNode", // 2 regular props "/somepage/mypage/paragraphs/0/attention=booyah", "/somepage/mypage/paragraphs/0/imaginary=date:2009-10-14T08:59:01.227-04:00", // 3 binaries "/somepage/mypage/paragraphs/0/attachment1@type=mgnl:resource", "/somepage/mypage/paragraphs/0/attachment1.fileName=hello", "/somepage/mypage/paragraphs/0/attachment1.extension=gif", // being a binary node, magnolia knows to store data as jcr:data w/o need to be explicitly told so "/somepage/mypage/paragraphs/0/attachment1=binary:X", "/somepage/mypage/paragraphs/0/attachment1.jcr\\:mimeType=image/gif", "/somepage/mypage/paragraphs/0/attachment1.jcr\\:lastModified=date:2009-10-14T08:59:01.227-04:00", "/somepage/mypage/paragraphs/0/attachment2@type=mgnl:resource", "/somepage/mypage/paragraphs/0/attachment2.fileName=test", "/somepage/mypage/paragraphs/0/attachment2.extension=jpeg", "/somepage/mypage/paragraphs/0/attachment2=binary:X", "/somepage/mypage/paragraphs/0/attachment2.jcr\\:mimeType=image/jpeg", "/somepage/mypage/paragraphs/0/attachment2.jcr\\:lastModified=date:2009-10-14T08:59:01.227-04:00", "/somepage/mypage/paragraphs/0/image3@type=mgnl:resource", "/somepage/mypage/paragraphs/0/image3.fileName=third", "/somepage/mypage/paragraphs/0/image3.extension=png", "/somepage/mypage/paragraphs/0/image3=binary:X", "/somepage/mypage/paragraphs/0/image3.jcr\\:mimeType=image/png", "/somepage/mypage/paragraphs/0/image3.jcr\\:lastModified=date:2009-10-14T08:59:01.227-04:00", // and more which should not match "/somepage/mypage/paragraphs/0/foo=bar", "/somepage/mypage/paragraphs/0/mybool=boolean:true", "/somepage/mypage/paragraphs/0/rand@type=mgnl:resource", "/somepage/mypage/paragraphs/0/rand.fileName=randdddd", "/somepage/mypage/paragraphs/0/rand.extension=png", "/somepage/mypage/paragraphs/0/rand=binary:X", "/somepage/mypage/paragraphs/0/rand.jcr\\:mimeType=image/png", "/somepage/mypage/paragraphs/0/rand.jcr\\:lastModified=date:2009-10-14T08:59:01.227-04:00"), "\n"); final HierarchyManager hm = MgnlContext.getHierarchyManager(RepositoryConstants.WEBSITE); new PropertiesImportExport().createContent(hm.getRoot(), IOUtils.toInputStream(contentProperties)); hm.save();//from ww w .j av a 2s .c om final Content content = hm.getContent("/somepage/mypage/paragraphs/0"); final Collection<NodeData> props = content.getNodeDataCollection("att*|ima*"); assertEquals(5, props.size()); // sort by name final TreeSet<NodeData> sorted = new TreeSet<NodeData>(new Comparator<NodeData>() { @Override public int compare(NodeData o1, NodeData o2) { return o1.getName().compareTo(o2.getName()); } }); sorted.addAll(props); // sanity check - just recheck we still have 5 elements assertEquals(5, sorted.size()); final Iterator<NodeData> it = sorted.iterator(); final NodeData a = it.next(); final NodeData b = it.next(); final NodeData c = it.next(); final NodeData d = it.next(); final NodeData e = it.next(); assertEquals("attachment1", a.getName()); assertEquals(PropertyType.BINARY, a.getType()); assertEquals("attachment2", b.getName()); assertEquals(PropertyType.BINARY, b.getType()); assertEquals("image3", d.getName()); assertEquals(PropertyType.BINARY, d.getType()); assertEquals("image3", d.getName()); assertEquals(PropertyType.BINARY, d.getType()); assertEquals("attention", c.getName()); assertEquals(PropertyType.STRING, c.getType()); assertEquals("booyah", c.getString()); assertEquals("imaginary", e.getName()); assertEquals(PropertyType.DATE, e.getType()); assertEquals(true, e.getDate().before(Calendar.getInstance())); }
From source file:net.spfbl.core.Analise.java
public static synchronized TreeSet<Analise> getAnaliseSet() { TreeSet<Analise> queue = new TreeSet<Analise>(); queue.addAll(QUEUE); return queue; }
From source file:net.sourceforge.fenixedu.domain.serviceRequests.documentRequests.DiplomaRequest.java
/** * The DocumentRequestCreator should never have created Past Diploma * Requests as DiplomaRequests. This method can be used for data migrations, * but should be removed once all past diploma requests are migrated. */// ww w . j a va2 s. com @Deprecated private boolean isPastDiplomaRequestHack() { TreeSet<AcademicServiceRequestSituation> sortedSituations = new TreeSet<AcademicServiceRequestSituation>( AcademicServiceRequestSituation.COMPARATOR_BY_MOST_RECENT_SITUATION_DATE_AND_ID); sortedSituations.addAll(getAcademicServiceRequestSituationsSet()); AcademicServiceRequestSituation deliveredSituation, concludedSituation, receivedSituation, sentSituation, processedSituation, newSituation; try { Iterator<AcademicServiceRequestSituation> situationsIterator = sortedSituations.iterator(); deliveredSituation = situationsIterator.next(); concludedSituation = situationsIterator.next(); receivedSituation = situationsIterator.next(); sentSituation = situationsIterator.next(); processedSituation = situationsIterator.next(); newSituation = situationsIterator.next(); } catch (NoSuchElementException ex) { return false; } if (!deliveredSituation.getAcademicServiceRequestSituationType() .equals(AcademicServiceRequestSituationType.DELIVERED)) { return false; } if (!deliveredSituation.getJustification().equals("-")) { return false; } if (!(deliveredSituation.getSituationDate().hourOfDay().get() == 0)) { return false; } if (!(deliveredSituation.getSituationDate().minuteOfHour().get() == 5)) { return false; } // ##################################################### if (!concludedSituation.getCreator().equals(deliveredSituation.getCreator())) { return false; } if (!concludedSituation.getAcademicServiceRequestSituationType() .equals(AcademicServiceRequestSituationType.CONCLUDED)) { return false; } if (!concludedSituation.getJustification().equals("-")) { return false; } if (!(concludedSituation.getSituationDate().hourOfDay().get() == 0)) { return false; } if (!(concludedSituation.getSituationDate().minuteOfHour().get() == 4)) { return false; } // ##################################################### if (!receivedSituation.getCreator().equals(deliveredSituation.getCreator())) { return false; } if (!receivedSituation.getAcademicServiceRequestSituationType() .equals(AcademicServiceRequestSituationType.RECEIVED_FROM_EXTERNAL_ENTITY)) { return false; } if (!receivedSituation.getJustification().equals("-")) { return false; } if (!(receivedSituation.getSituationDate().hourOfDay().get() == 0)) { return false; } if (!(receivedSituation.getSituationDate().minuteOfHour().get() == 3)) { return false; } // ##################################################### if (!sentSituation.getCreator().equals(deliveredSituation.getCreator())) { return false; } if (!sentSituation.getAcademicServiceRequestSituationType() .equals(AcademicServiceRequestSituationType.SENT_TO_EXTERNAL_ENTITY)) { return false; } if (!sentSituation.getJustification().equals("-")) { return false; } if (!(sentSituation.getSituationDate().hourOfDay().get() == 0)) { return false; } if (!(sentSituation.getSituationDate().minuteOfHour().get() == 2)) { return false; } if (!sentSituation.getSituationDate().toLocalDate() .equals(receivedSituation.getSituationDate().toLocalDate())) { return false; } // ##################################################### if (!processedSituation.getCreator().equals(deliveredSituation.getCreator())) { return false; } if (!processedSituation.getAcademicServiceRequestSituationType() .equals(AcademicServiceRequestSituationType.PROCESSING)) { return false; } if (!processedSituation.getJustification().equals("-")) { return false; } if (!(processedSituation.getSituationDate().hourOfDay().get() == 0)) { return false; } if (!(processedSituation.getSituationDate().minuteOfHour().get() == 1)) { return false; } if (!processedSituation.getSituationDate().toLocalDate() .equals(receivedSituation.getSituationDate().toLocalDate())) { return false; } // ##################################################### if (!newSituation.getCreator().equals(deliveredSituation.getCreator())) { return false; } if (!newSituation.getAcademicServiceRequestSituationType() .equals(AcademicServiceRequestSituationType.NEW)) { return false; } if (!StringUtils.isEmpty(newSituation.getJustification())) { return false; } if (!(newSituation.getSituationDate().hourOfDay().get() == 0)) { return false; } if (!(newSituation.getSituationDate().minuteOfHour().get() == 0)) { return false; } if (!newSituation.getSituationDate().toLocalDate() .equals(receivedSituation.getSituationDate().toLocalDate())) { return false; } return true; }
From source file:org.jraf.android.cinetoday.mobile.api.codec.showtime.ShowtimeCodec.java
public void fill(Movie movie, JSONObject jsonMovieShowtime, String theaterName, int position, Date date) throws ParseException { // Example input: // Sances du dimanche 1 novembre 2015 : 10:00 (film 10:15), 14:00 (film 14:15), 16:00 (film 16:15), 20:00 (film 20:15), 21:45 (film 22:00) try {/*from ww w. j a v a2 s. c o m*/ String display = jsonMovieShowtime.getString("display"); // Split per day String[] showtimesDays = display.split("\r\n"); // Find today's date in the list String todayFormatted = DAY_DATE_FORMAT.format(date); String todayShowtimesStr = null; for (String showtimesDay : showtimesDays) { if (showtimesDay.contains(todayFormatted)) { // Found todayShowtimesStr = showtimesDay; break; } } if (todayShowtimesStr == null) { Log.w("Could not find today in showtime days"); return; } // Is 3D? JSONObject screenFormat = jsonMovieShowtime.getJSONObject("screenFormat"); String screenFormatStr = screenFormat.getString("$"); boolean is3d = "3D".equalsIgnoreCase(screenFormatStr); // Remove first part todayShowtimesStr = todayShowtimesStr.substring(todayShowtimesStr.indexOf(':') + 2); // Split times String[] todayShowtimesStrElem = todayShowtimesStr.split(", "); // Clean up for (int i = 0; i < todayShowtimesStrElem.length; i++) { String todayShowtime = todayShowtimesStrElem[i]; int spaceIdx = todayShowtime.indexOf(' '); if (spaceIdx != -1) { todayShowtime = todayShowtime.substring(0, spaceIdx); } todayShowtimesStrElem[i] = todayShowtime; } // Make a set and merge it with the previous one if any TreeSet<Showtime> todayShowtimesSet = new TreeSet<>(); for (String time : todayShowtimesStrElem) { Showtime showtime = new Showtime(); showtime.is3d = is3d; showtime.time = time; todayShowtimesSet.add(showtime); } if (movie.todayShowtimes == null) { movie.todayShowtimes = new Bundle(2); } String key = position + "/" + theaterName; ArrayList<Showtime> showTimesForThisTheater = movie.todayShowtimes.getParcelableArrayList(key); if (showTimesForThisTheater != null) { // The movie already has showtimes for *this* theater: merge them into the new ones todayShowtimesSet.addAll(showTimesForThisTheater); } ArrayList<Showtime> todayShowtimesList = new ArrayList<>(todayShowtimesSet); movie.todayShowtimes.putParcelableArrayList(key, todayShowtimesList); } catch (JSONException e) { throw new ParseException(e); } }
From source file:org.ebayopensource.turmeric.eclipse.template.wsdl.processors.ImportProcessor.java
/** * {@inheritDoc}//from w ww. j a v a2s . c om */ @Override public boolean execute(Object parameter, IProgressMonitor monitor) throws CommandFailedException { if (parameter != null && parameter instanceof CommonWSDLProcessorParam) { try { CommonWSDLProcessorParam processorModel = (CommonWSDLProcessorParam) parameter; definition = processorModel.getDefinition(); // This is the set of types we want to import TreeSet<LibraryType> impTypeSet = new TreeSet<LibraryType>(new LibraryTypeComparator()); // this set is used to add imports for elements in // the request and response in advance. TreeSet<LibraryType> additionalImpTypeSet = new TreeSet<LibraryType>(new LibraryTypeComparator()); for (QName qName : getTypeNames(GlobalRepositorySystem.instanceOf().getActiveRepositorySystem() .getConfigurationRegistry().getTypesInWsdl())) { LibraryType libType = SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry().getType(qName); if (libType != null) { impTypeSet.add(libType); impTypeSet.addAll(SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry() .getDependentParentTypeFiles(libType)); } } PortType portType = ServiceTemplateUtil.getDefaultPort(definition); for (org.ebayopensource.turmeric.eclipse.core.model.services.ServiceFromTemplateWsdlParamModel.Operation operationModel : processorModel .getInputParamModel().getOperations()) { if (!ServiceTemplateUtil.operationExists(portType, operationModel.getName())) { if (operationModel.getInputParameter() != null) { for (IParameterElement inputParam : operationModel.getInputParameter().getElements()) { if (inputParam.getDatatype() != null && inputParam.getDatatype() instanceof LibraryType) { LibraryType libType = (LibraryType) inputParam.getDatatype(); impTypeSet.add(libType); additionalImpTypeSet.add(libType); impTypeSet.addAll(SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry() .getDependentParentTypeFiles(libType)); } } } if (operationModel.getOutputParameter() != null) { for (IParameterElement outputParam : operationModel.getOutputParameter() .getElements()) { if (outputParam.getDatatype() != null && outputParam.getDatatype() instanceof LibraryType) { LibraryType libType = (LibraryType) outputParam.getDatatype(); impTypeSet.add(libType); additionalImpTypeSet.add(libType); impTypeSet.addAll(SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry() .getDependentParentTypeFiles(libType)); } } } } } WTPTypeLibUtil.wrapImport(impTypeSet, additionalImpTypeSet, definition, processorModel.getInputParamModel().getTypeFolding()); return true; } catch (Exception e) { throw new CommandFailedException(SOAMessages.IMPORT_ERR, e); } } else { throw new CommandFailedException(SOAMessages.INPUT_ERR); } }
From source file:org.rhwlab.BHC.BHCTree.java
public TreeMap<Integer, TreeSet<NucleusLogNode>> allTreeCuts(int maxNodes) { TreeMap<Integer, TreeSet<NucleusLogNode>> ret = new TreeMap<>(); TreeSet<NucleusLogNode> cut = firstTreeCut(); ret.put(cut.size(), cut);/*from w w w. j a va 2s.c om*/ while (cut.size() < maxNodes) { NucleusLogNode[] next = nextTreeCut(cut); if (next == null) { return ret; } TreeSet<NucleusLogNode> nextSet = new TreeSet<>(); nextSet.addAll(cut); nextSet.remove(next[2]); nextSet.add(next[0]); nextSet.add(next[1]); ret.put(nextSet.size(), nextSet); cut = nextSet; } return ret; }
From source file:com.joliciel.jochre.graphics.VectorizerImpl.java
/** * Find n longest lines within shape which connect two points in the outline * @param outline/*from w w w .ja v a2s . c o m*/ * @param maxLines * @return */ List<LineSegment> getLongestLines(Shape shape, BitSet outline, int maxLines, int threshold) { TreeSet<LineSegment> lineSegmentSet = new TreeSet<LineSegment>(); int outlineCardinality = outline.cardinality(); int samplingInterval = outlineCardinality / 100; if (samplingInterval == 0) samplingInterval = 1; int samplingIndex = 0; for (int y = 0; y < shape.getHeight(); y++) { for (int x = 0; x < shape.getWidth(); x++) { if (outline.get(y * shape.getWidth() + x)) { // this pixel is part of the outline if (samplingIndex == 0) { lineSegmentSet.addAll(this.getLinesToEdge(shape, x, y, threshold)); } samplingIndex++; if (samplingIndex == samplingInterval) samplingIndex = 0; } } } int i = 0; List<LineSegment> lineSegments = new ArrayList<LineSegment>(); for (LineSegment lineSegment : lineSegmentSet) { lineSegments.add(lineSegment); i++; if (i >= maxLines) break; } if (LOG.isDebugEnabled()) { i = 0; for (LineSegment lineSegment : lineSegments) { double slope = (double) (lineSegment.getEndY() - lineSegment.getStartY()) / (double) (lineSegment.getEndX() - lineSegment.getStartX()); LOG.debug("Line " + i++ + "(" + lineSegment.getStartX() + "," + lineSegment.getStartY() + ") " + "(" + lineSegment.getEndX() + "," + lineSegment.getEndY() + "). Length = " + lineSegment.getLength() + ", Slope = " + slope); } } return lineSegments; }