List of usage examples for java.util SortedSet addAll
boolean addAll(Collection<? extends E> c);
From source file:de.appsolve.padelcampus.controller.events.EventsBookingController.java
@RequestMapping(value = "{eventId}/confirm", method = POST) public ModelAndView confirmBooking(HttpServletRequest request) throws Exception { Booking booking = sessionUtil.getBooking(request); ModelAndView confirmView = getBookingConfirmView(booking); try {/*from ww w .j a v a2 s . co m*/ if (booking == null) { throw new Exception(msg.get("SessionTimeout")); } String publicBooking = request.getParameter("public-booking"); Boolean isPublicBooking = !StringUtils.isEmpty(publicBooking) && publicBooking.equalsIgnoreCase("on"); booking.setPublicBooking(isPublicBooking); String cancellationPolicyCheckbox = request.getParameter("accept-cancellation-policy"); if (StringUtils.isEmpty(cancellationPolicyCheckbox) || !cancellationPolicyCheckbox.equals("on")) { throw new Exception(msg.get("BookingCancellationPolicyNotAccepted")); } if (booking.getConfirmed()) { throw new Exception(msg.get("BookingAlreadyConfirmed")); } isEventBookingPossible(booking); booking.setBlockingTime(new LocalDateTime()); booking.setUUID(BookingUtil.generateUUID()); if (booking.getCommunity() != null) { SortedSet<Player> communityPlayers = new TreeSet<>(); if (booking.getPlayerParticipates()) { communityPlayers.add(booking.getPlayer()); } communityPlayers.addAll(booking.getPlayers()); booking.getCommunity().setPlayers(communityPlayers); booking.setCommunity(communityDAO.saveOrUpdate(booking.getCommunity())); } bookingDAO.saveOrUpdate(booking); switch (booking.getPaymentMethod()) { case Cash: case ExternalVoucher: if (booking.getConfirmed()) { throw new Exception(msg.get("BookingAlreadyConfirmed")); } return new ModelAndView("redirect:/events/bookings/" + booking.getUUID() + "/success"); case PayPal: return bookingsPayPalController.redirectToPaypal(booking, request); case PayDirekt: return bookingsPayDirektController.redirectToPayDirekt(booking, request); case DirectDebit: return bookingsPayMillController.redirectToDirectDebit(booking); case CreditCard: return bookingsPayMillController.redirectToCreditCard(booking); case Voucher: return bookingsVoucherController.redirectToVoucher(booking); default: confirmView.addObject("error", booking.getPaymentMethod() + " not implemented"); return confirmView; } } catch (Exception e) { LOG.warn("Error while processing booking request: " + e.getMessage(), e); confirmView.addObject("error", e.getMessage()); return confirmView; } }
From source file:com.thoughtworks.go.server.service.UserService.java
public Set<String> rolesThatCanOperateOnStage(CruiseConfig cruiseConfig, PipelineConfig pipelineConfig) { PipelineConfigs group = cruiseConfig.findGroupOfPipeline(pipelineConfig); SortedSet<String> roles = new TreeSet<>(); if (group.hasAuthorizationDefined()) { if (group.hasOperationPermissionDefined()) { roles.addAll(group.getOperateRoleNames()); }/*from w ww . j a v a 2 s . com*/ } else { roles.addAll(allRoleNames(cruiseConfig)); } return roles; }
From source file:net.sourceforge.fenixedu.domain.Shift.java
public SortedSet<Lesson> getLessonsOrderedByWeekDayAndStartTime() { final SortedSet<Lesson> lessons = new TreeSet<Lesson>(Lesson.LESSON_COMPARATOR_BY_WEEKDAY_AND_STARTTIME); lessons.addAll(getAssociatedLessonsSet()); return lessons; }
From source file:io.lavagna.service.LavagnaImporter.java
/** * Import only the users that are not present in the system. *//*w w w . ja v a 2s . c om*/ private void importMissingUsers(Path tempFile) { List<User> users = readObject("users.json", tempFile, new TypeToken<List<User>>() { }); SortedSet<User> usersToImport = new TreeSet<>(new Comparator<User>() { @Override public int compare(User o1, User o2) { return new CompareToBuilder().append(o1.getProvider(), o2.getProvider()) .append(o1.getUsername(), o2.getUsername()).toComparison(); } }); usersToImport.addAll(users); usersToImport.removeAll(userRepository.findAll()); userRepository.createUsers(usersToImport); }
From source file:org.mindswap.swoop.renderer.BaseEntityRenderer.java
protected SortedSet orderedEntities(Set entities) { SortedSet ss = new TreeSet(new Comparator() { public int compare(Object o1, Object o2) { try { return ((OWLEntity) o1).getURI().toString().compareTo(((OWLEntity) o2).getURI().toString()); } catch (Exception ex) { return o1.toString().compareTo(o2.toString()); }//from w w w . j ava2s.c o m } }); ss.addAll(entities); return ss; }
From source file:module.mailtracking.domain.CorrespondenceEntry.java
public SortedSet<CorrespondenceEntryLog> getSortedLogs() { final SortedSet<CorrespondenceEntryLog> logs = new TreeSet<CorrespondenceEntryLog>(); logs.addAll(getLogsSet()); return logs;/*ww w. ja v a 2s .co m*/ }
From source file:com.puppycrawl.tools.checkstyle.Checker.java
/** * Processes a set of files with all FileSetChecks. * Once this is done, it is highly recommended to call for * the destroy method to close and remove the listeners. * @param files the list of files to be audited. * @return the total number of errors found * @throws CheckstyleException if error condition within Checkstyle occurs * @see #destroy()/*from ww w . ja va2 s . com*/ */ public int process(List<File> files) throws CheckstyleException { // Prepare to start fireAuditStarted(); for (final FileSetCheck fsc : fileSetChecks) { fsc.beginProcessing(charset); } // Process each file for (final File file : files) { if (!CommonUtils.matchesFileExtension(file, fileExtensions)) { continue; } final String fileName = file.getAbsolutePath(); fireFileStarted(fileName); final SortedSet<LocalizedMessage> fileMessages = Sets.newTreeSet(); try { final FileText theText = new FileText(file.getAbsoluteFile(), charset); for (final FileSetCheck fsc : fileSetChecks) { fileMessages.addAll(fsc.process(file, theText)); } } catch (final IOException ioe) { LOG.debug("IOException occurred.", ioe); fileMessages.add(new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, "general.exception", new String[] { ioe.getMessage() }, null, getClass(), null)); } fireErrors(fileName, fileMessages); fireFileFinished(fileName); } // Finish up for (final FileSetCheck fsc : fileSetChecks) { // It may also log!!! fsc.finishProcessing(); } for (final FileSetCheck fsc : fileSetChecks) { // It may also log!!! fsc.destroy(); } final int errorCount = counter.getCount(); fireAuditFinished(); return errorCount; }
From source file:com.mapr.synth.TermGeneratorTest.java
@Test public void speciesCounts() { final boolean transpose = false; // generate an example of species sampled on multiple days LongTail<Integer> terms = new LongTail<Integer>(0.5, 0.3) { int max = 0; @Override/* ww w. j ava2 s. c o m*/ protected Integer createThing() { return ++max; } }; // I picked seeds to get a good illustration ... want a reasonable number of species and surprises terms.setSeed(2); Random gen = new Random(1); SortedSet<Integer> vocabulary = Sets.newTreeSet(); List<Multiset<Integer>> r = Lists.newArrayList(); for (int i = 0; i < 2000; i++) { double length = Math.rint(gen.nextGaussian() * 10 + 50); Multiset<Integer> counts = HashMultiset.create(); for (int j = 0; j < length; j++) { counts.add(terms.sample()); } r.add(counts); } if (transpose) { for (Multiset<Integer> day : r) { vocabulary.addAll(day.elementSet()); } System.out.printf("%d\n", vocabulary.size()); for (Integer s : vocabulary) { String sep = ""; for (Multiset<Integer> day : r) { System.out.printf("%s%s", sep, day.count(s)); sep = "\t"; } System.out.printf("\n"); } } else { System.out.printf("%d\n", vocabulary.size()); for (Multiset<Integer> day : r) { vocabulary.addAll(day.elementSet()); String sep = ""; System.out.printf("%s%s", sep, vocabulary.size()); sep = "\t"; for (Integer s : vocabulary) { System.out.printf("%s%s", sep, day.count(s)); sep = "\t"; } System.out.printf("\n"); } Multiset<Integer> total = HashMultiset.create(); for (Multiset<Integer> day : r) { for (Integer species : day.elementSet()) { total.add(species, day.count(species)); } } String sep = ""; System.out.printf("%s%s", sep, total.elementSet().size()); sep = "\t"; for (Integer s : vocabulary) { System.out.printf("%s%s", sep, total.count(s)); sep = "\t"; } System.out.printf("\n"); } }
From source file:org.solenopsis.checkstyle.Checker.java
/** * Processes a file with all FileSetChecks. * @param file a file to process./*from w ww . j ava 2s. co m*/ * @return a sorted set of messages to be logged. * @throws CheckstyleException if error condition within Checkstyle occurs. */ private SortedSet<LocalizedMessage> processFile(File file) throws CheckstyleException { final SortedSet<LocalizedMessage> fileMessages = Sets.newTreeSet(); try { final FileText theText = new FileText(file.getAbsoluteFile(), charset); for (final FileSetCheck fsc : fileSetChecks) { fileMessages.addAll(fsc.process(file, theText)); } } catch (final IOException ioe) { LOG.debug("IOException occurred.", ioe); fileMessages.add(new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, "general.exception", new String[] { ioe.getMessage() }, null, getClass(), null)); } return fileMessages; }
From source file:net.sourceforge.fenixedu.domain.Shift.java
public SortedSet<ShiftEnrolment> getShiftEnrolmentsOrderedByDate() { final SortedSet<ShiftEnrolment> shiftEnrolments = new TreeSet<ShiftEnrolment>( ShiftEnrolment.COMPARATOR_BY_DATE); shiftEnrolments.addAll(getShiftEnrolmentsSet()); return shiftEnrolments; }