List of usage examples for java.util SortedSet addAll
boolean addAll(Collection<? extends E> c);
From source file:de.interactive_instruments.ShapeChange.Model.EA.EADocument.java
/** * Return all ClassInfo objects contained in the given package and in sub- * packages, which do not belong to an app schema different to the one of * the given package.// ww w. j ava 2 s . c o m */ // 2014-04-03: clarify javadoc private SortedSet<ClassInfo> addClasses(PackageInfoEA pi, String tns, SortedSet<ClassInfo> res) { // Are we a different app schema? If so, skip String ctns = pi.targetNamespace(); if (ctns != null && (tns == null || !tns.equals(ctns))) return res; // Same app schema, first add classes to output ... res.addAll(pi.childCI); // .. then descend to next packages for (PackageInfoEA cpi : pi.childPI) { res = addClasses(cpi, tns, res); } return res; }
From source file:org.apereo.portal.rest.permissions.PermissionsRESTController.java
/** * Return a list of targets defined for a particular IPermissionActivity * matching the specified search query. * // ww w .j av a 2s .c o m * @param activityId * @param query * @param req * @param response * @return * @throws Exception */ @PreAuthorize("hasPermission('string', 'ALL', new org.apereo.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/{activity}/targets.json", method = RequestMethod.GET) public ModelAndView getTargets(@PathVariable("activity") Long activityId, @RequestParam("q") String query, HttpServletRequest req, HttpServletResponse response) throws Exception { IPermissionActivity activity = permissionOwnerDao.getPermissionActivity(activityId); IPermissionTargetProvider provider = targetProviderRegistry .getTargetProvider(activity.getTargetProviderKey()); SortedSet<IPermissionTarget> matchingTargets = new TreeSet<IPermissionTarget>(); // add matching results for this identifier provider to the set Collection<IPermissionTarget> targets = provider.searchTargets(query); for (IPermissionTarget target : targets) { if ((StringUtils.isNotBlank(target.getName()) && target.getName().toLowerCase().contains(query)) || target.getKey().toLowerCase().contains(query)) { matchingTargets.addAll(targets); } } ModelAndView mv = new ModelAndView(); mv.addObject("targets", targets); mv.setViewName("json"); return mv; }
From source file:org.jasig.portal.rest.permissions.PermissionsRESTController.java
/** * Return a list of targets defined for a particular IPermissionActivity * matching the specified search query. * /* ww w .jav a 2 s . c o m*/ * @param activityId * @param query * @param req * @param response * @return * @throws Exception */ @PreAuthorize("hasPermission('string', 'ALL', new org.jasig.portal.spring.security.evaluator.AuthorizableActivity('UP_PERMISSIONS', 'VIEW_PERMISSIONS'))") @RequestMapping(value = "/permissions/{activity}/targets.json", method = RequestMethod.GET) public ModelAndView getTargets(@PathVariable("activity") Long activityId, @RequestParam("q") String query, HttpServletRequest req, HttpServletResponse response) throws Exception { IPermissionActivity activity = permissionOwnerDao.getPermissionActivity(activityId); IPermissionTargetProvider provider = targetProviderRegistry .getTargetProvider(activity.getTargetProviderKey()); SortedSet<IPermissionTarget> matchingTargets = new TreeSet<IPermissionTarget>(); // add matching results for this identifier provider to the set Collection<IPermissionTarget> targets = provider.searchTargets(query); for (IPermissionTarget target : targets) { if ((StringUtils.isNotBlank(target.getName()) && target.getName().toLowerCase().contains(query)) || target.getKey().toLowerCase().contains(query)) { matchingTargets.addAll(targets); } } ModelAndView mv = new ModelAndView(); mv.addObject("targets", targets); mv.setViewName("json"); return mv; }
From source file:org.slc.sli.dashboard.manager.impl.StudentProgressManagerImpl.java
/** * Returns a sorted unique set of gradebook entries(tests) * /* w w w .j av a2 s.c o m*/ * @param gradebookEntryData * The gradebook entry data for a section * @return */ @Override public SortedSet<GenericEntity> retrieveSortedGradebookEntryList( Map<String, Map<String, GenericEntity>> gradebookEntryData) { SortedSet<GenericEntity> list = new TreeSet<GenericEntity>(new DateFulFilledComparator()); // Sorting by entity to be able to handle the introduction of GradebookEntry/type in the // future // Can be sorted by the keyset if GradebookEntry/type will not be used // go through and add the tests into one list for (Map<String, GenericEntity> map : gradebookEntryData.values()) { list.addAll(map.values()); } return list; }
From source file:spade.storage.CompressedTextFile.java
public static Pair<Pair<Integer, SortedSet<Integer>>, Pair<Integer, SortedSet<Integer>>> uncompressAncestorsSuccessorsWithLayer( Integer id, boolean uncompressAncestors, boolean uncompressSuccessors) { //System.out.println("step a"); SortedSet<Integer> ancestors = new TreeSet<Integer>(); SortedSet<Integer> successors = new TreeSet<Integer>(); Integer ancestorLayer = 1;//from ww w .j a v a 2 s . c o m Integer successorLayer = 1; String aux = get(scaffoldWriter, id); //System.out.println("step b"); if (aux != null && aux.contains("/")) { // split the line in two parts : ancestor list and successor list. String ancestorList = aux.substring(0, aux.indexOf('/')); String successorList = aux.substring(aux.indexOf('/') + 2); ancestorLayer = Integer.parseInt(ancestorList.substring(0, ancestorList.indexOf(' '))); successorLayer = Integer.parseInt(successorList.substring(0, successorList.indexOf(' '))); ancestorList = ancestorList.substring(ancestorList.indexOf(' ') + 1); successorList = successorList.substring(successorList.indexOf(' ') + 1); //System.out.println("step c"); if (uncompressAncestors) { //uncompressAncestors if (ancestorList.contains("_")) { // means there is no reference //System.out.println("step d"); String ancestorList2 = ancestorList.substring(ancestorList.indexOf("_") + 1); ancestors.addAll(uncompressRemainingNodes(id, ancestorList2)); } else { // there is a reference that we have to uncompress // uncompress the remaining Nodes //System.out.println("step e"); String remaining = ancestorList.substring(ancestorList.indexOf(" ") + 1); remaining = remaining.substring(remaining.indexOf(" ") + 1); ancestors.addAll(uncompressRemainingNodes(id, remaining)); //uncompress the reference and its reference after that try { ancestors.addAll(uncompressReference(id, ancestorList, true)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } //System.out.println("step f"); if (uncompressSuccessors) { // uncompressSuccessors if (successorList.contains("_")) { // means there is no reference //System.out.println("step g " ); String successorList2 = successorList.substring(successorList.indexOf("_") + 1); successors.addAll(uncompressRemainingNodes(id, successorList2)); } else { // there is a reference that we have to uncompress // uncompress the remaining Nodes //System.out.println("step h"); /* String remaining = successorList.substring(successorList.indexOf(" ")+1); remaining = remaining.substring(remaining.indexOf(" ")+1); System.out.println("remaining" +remaining); //System.out.println("step i "); successors.addAll(uncompressRemainingNodes(id, remaining));*/ //uncompress the reference and its reference after that try { //System.out.println("step j "); successors.addAll(uncompressReference(id, successorList, false)); //System.out.println("step k"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } } //System.out.println("step k"); Pair<Integer, SortedSet<Integer>> ancestorsAndLayer = new Pair<Integer, SortedSet<Integer>>(ancestorLayer, ancestors); Pair<Integer, SortedSet<Integer>> successorsAndLayer = new Pair<Integer, SortedSet<Integer>>(successorLayer, successors); Pair<Pair<Integer, SortedSet<Integer>>, Pair<Integer, SortedSet<Integer>>> ancestorsAndSuccessors = new Pair<Pair<Integer, SortedSet<Integer>>, Pair<Integer, SortedSet<Integer>>>( ancestorsAndLayer, successorsAndLayer); return ancestorsAndSuccessors; }
From source file:de.appsolve.padelcampus.utils.BookingUtil.java
public void addWeekView(HttpServletRequest request, LocalDate selectedDate, List<Facility> selectedFacilities, ModelAndView mav, Boolean onlyFutureTimeSlots, Boolean preventOverlapping) throws JsonProcessingException { //calculate date configuration for datepicker LocalDate today = new LocalDate(DEFAULT_TIMEZONE); LocalDate firstDay = today.dayOfMonth().withMinimumValue(); LocalDate lastDay = getLastBookableDay(request).plusDays(1); List<CalendarConfig> calendarConfigs = calendarConfigDAO.findBetween(firstDay, lastDay); Collections.sort(calendarConfigs); Map<String, DatePickerDayConfig> dayConfigs = getDayConfigMap(firstDay, lastDay, calendarConfigs); List<Booking> confirmedBookings = bookingDAO.findBlockedBookingsBetween(firstDay, lastDay); //calculate available time slots List<TimeSlot> timeSlots = new ArrayList<>(); List<LocalDate> weekDays = new ArrayList<>(); for (int i = 1; i <= CalendarWeekDay.values().length; i++) { LocalDate date = selectedDate.withDayOfWeek(i); weekDays.add(date);/* w w w .java 2 s.c om*/ if ((!onlyFutureTimeSlots || !date.isBefore(today)) && lastDay.isAfter(date)) { try { //generate list of bookable time slots timeSlots.addAll(getTimeSlotsForDate(date, calendarConfigs, confirmedBookings, onlyFutureTimeSlots, preventOverlapping)); } catch (CalendarConfigException e) { //safe to ignore } } } SortedSet<Offer> offers = new TreeSet<>(); List<TimeRange> rangeList = new ArrayList<>(); //Map<TimeRange, List<TimeSlot>> rangeList = new TreeMap<>(); for (TimeSlot slot : timeSlots) { Set<Offer> slotOffers = slot.getConfig().getOffers(); offers.addAll(slotOffers); TimeRange range = new TimeRange(); range.setStartTime(slot.getStartTime()); range.setEndTime(slot.getEndTime()); if (rangeList.contains(range)) { range = rangeList.get(rangeList.indexOf(range)); } else { rangeList.add(range); } List<TimeSlot> slotis = range.getTimeSlots(); slotis.add(slot); range.setTimeSlots(slotis); } Collections.sort(rangeList); List<Offer> selectedOffers = new ArrayList<>(); if (selectedFacilities.isEmpty()) { selectedOffers = offerDAO.findAll(); } else { for (Facility facility : selectedFacilities) { selectedOffers.addAll(facility.getOffers()); } } Collections.sort(selectedOffers); mav.addObject("dayConfigs", objectMapper.writeValueAsString(dayConfigs)); mav.addObject("maxDate", lastDay.toString()); mav.addObject("Day", selectedDate); mav.addObject("NextMonday", selectedDate.plusDays(8 - selectedDate.getDayOfWeek())); mav.addObject("PrevSunday", selectedDate.minusDays(selectedDate.getDayOfWeek())); mav.addObject("WeekDays", weekDays); mav.addObject("RangeMap", rangeList); mav.addObject("Offers", offers); mav.addObject("SelectedOffers", selectedOffers); mav.addObject("SelectedFacilities", selectedFacilities); mav.addObject("Facilities", facilityDAO.findAll()); }
From source file:pt.ist.expenditureTrackingSystem.domain.organization.Unit.java
public SortedSet<Authorization> getSortedAuthorizationsSet() { final SortedSet<Authorization> authorizations = new TreeSet<Authorization>( Authorization.COMPARATOR_BY_NAME_AND_DATE); authorizations.addAll(getAuthorizationsSet()); return authorizations; }
From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.acquisitions.SearchPaymentProcessesAction.java
private void fillXlsInfo(Set<PaymentProcess> processes, StyledExcelSpreadsheet spreadsheet, OutputStream outputStream) throws IOException { spreadsheet.newRow();//from ww w . j a va2 s .co m spreadsheet.addCell(processes.size() + " " + getAcquisitionResourceMessage("label.processes")); spreadsheet.newRow(); setHeaders(spreadsheet); TreeSet<PaymentProcess> sortedProcesses = new TreeSet<PaymentProcess>( PaymentProcess.COMPARATOR_BY_YEAR_AND_ACQUISITION_PROCESS_NUMBER); sortedProcesses.addAll(processes); for (PaymentProcess process : sortedProcesses) { spreadsheet.newRow(); spreadsheet.addCell(process.getAcquisitionProcessId()); spreadsheet.addCell(process.getTypeShortDescription()); AcquisitionItemClassification classification = process.getGoodsOrServiceClassification(); spreadsheet.addCell(classification == null ? " " : classification.getLocalizedName()); spreadsheet.addCell(process.getSuppliersDescription()); spreadsheet.addCell(process.getRequest().getRequestItemsSet().size()); spreadsheet.addCell(process.getProcessStateDescription()); DateTime time = new DateTime(); if (process.getPaymentProcessYear().getYear() != time.getYear()) { time = new DateTime(process.getPaymentProcessYear().getYear().intValue(), 12, 31, 23, 59, 59, 0); } spreadsheet.addCell(describeState(process, time)); DateTime date = process.getDateFromLastActivity(); spreadsheet.addCell((date == null) ? "" : date.getDayOfMonth() + "-" + date.getMonthOfYear() + "-" + date.getYear() + " " + date.getHourOfDay() + ":" + date.getMinuteOfHour()); spreadsheet.addCell(process.getRequest().getRequester().getFirstAndLastName()); spreadsheet.addCell(process.getRequest().getRequestingUnit().getName()); final StringBuilder builderAccountingUnit = new StringBuilder(); final StringBuilder builderUnits = new StringBuilder(); for (final Financer financer : process.getFinancersWithFundsAllocated()) { final AccountingUnit accountingUnit = financer.getAccountingUnit(); if (accountingUnit != null) { if (builderAccountingUnit.length() > 0) { builderAccountingUnit.append(", "); } builderAccountingUnit.append(accountingUnit.getName()); } final Unit unit = financer.getUnit(); if (unit != null) { if (builderUnits.length() > 0) { builderUnits.append(", "); } builderUnits.append(unit.getUnit().getAcronym()); } } spreadsheet.addCell(builderAccountingUnit.length() == 0 ? " " : builderAccountingUnit.toString()); spreadsheet.addCell(builderUnits.length() == 0 ? " " : builderUnits.toString()); final Money totalValue = process.getTotalValue(); spreadsheet.addCell((totalValue == null ? Money.ZERO : totalValue).toFormatString()); final StringBuilder fundAllocationNumbers = new StringBuilder(); final StringBuilder commitmentNumbers = new StringBuilder(); final StringBuilder efectiveFundAllocationNumbers = new StringBuilder(); final StringBuilder requestOrderNumber = new StringBuilder(); LocalDate invoiceDate = null; Money invoiceValue = Money.ZERO; if (process instanceof SimplifiedProcedureProcess) { SimplifiedProcedureProcess simplifiedProcedureProcess = (SimplifiedProcedureProcess) process; final AcquisitionRequest acquisitionRequest = simplifiedProcedureProcess.getAcquisitionRequest(); for (PayingUnitTotalBean payingUnitTotal : acquisitionRequest.getTotalAmountsForEachPayingUnit()) { if ((simplifiedProcedureProcess.getFundAllocationPresent()) && (payingUnitTotal.getFinancer().isFundAllocationPresent())) { if (fundAllocationNumbers.length() > 0) { fundAllocationNumbers.append(", "); } fundAllocationNumbers.append(payingUnitTotal.getFinancer().getFundAllocationIds().trim()); } if (commitmentNumbers.length() > 0) { fundAllocationNumbers.append(", "); } String commitmentNumber = payingUnitTotal.getFinancer().getCommitmentNumber(); if (commitmentNumber != null) { commitmentNumber = commitmentNumber.trim(); if (commitmentNumber.length() > 0) { commitmentNumbers.append(commitmentNumber); } } if ((simplifiedProcedureProcess.getEffectiveFundAllocationPresent()) && (payingUnitTotal.getFinancer().isEffectiveFundAllocationPresent())) { if (efectiveFundAllocationNumbers.length() > 0) { efectiveFundAllocationNumbers.append(", "); } efectiveFundAllocationNumbers .append(payingUnitTotal.getFinancer().getEffectiveFundAllocationIds().trim()); } } boolean hasFullInvoice = false; for (final Invoice invoice : acquisitionRequest.getInvoices()) { // final AcquisitionInvoice acquisitionInvoice = (AcquisitionInvoice) invoice; final LocalDate localDate = invoice.getInvoiceDate(); if (invoiceDate == null || invoiceDate.isBefore(localDate)) { invoiceDate = localDate; } hasFullInvoice = true; // if (!hasFullInvoice) { // final String confirmationReport = acquisitionInvoice.getConfirmationReport(); // if (confirmationReport == null) { // hasFullInvoice = true; // } else { // for (int i = 0; i < confirmationReport.length(); ) { // final int ulli = confirmationReport.indexOf("<ul><li>", i); // final int q = confirmationReport.indexOf(" - Quantidade:", ulli); // final int ulliClose = confirmationReport.indexOf("</li></ul>", q); // final String itemDescription = confirmationReport.substring(i + "<ul><li>".length(), q); // final int quantity = Integer.parseInt(confirmationReport.substring(q + " - Quantidade:".length(), ulliClose)); // // invoiceValue = invoiceValue.add(calculate(acquisitionRequest, itemDescription, quantity)); // } // } // } } if (hasFullInvoice) { invoiceValue = totalValue; } final PurchaseOrderDocument purchaseOrderDocument = simplifiedProcedureProcess .getPurchaseOrderDocument(); if (purchaseOrderDocument != null) { requestOrderNumber.append(purchaseOrderDocument.getRequestId()); } } spreadsheet.addCell(fundAllocationNumbers.length() == 0 ? " " : fundAllocationNumbers.toString()); spreadsheet.addCell(commitmentNumbers.length() == 0 ? " " : commitmentNumbers.toString()); spreadsheet.addCell(requestOrderNumber.length() == 0 ? " " : requestOrderNumber.toString()); spreadsheet.addCell( efectiveFundAllocationNumbers.length() == 0 ? " " : efectiveFundAllocationNumbers.toString()); spreadsheet.addCell(invoiceDate == null ? " " : invoiceDate.toString("yyyy-MM-dd")); spreadsheet.addCell(invoiceValue.toFormatString()); DateTime creationDate = process.getCreationDate(); spreadsheet.addCell(creationDate == null ? " " : creationDate.toString("yyyy-MM-dd")); SortedSet<WorkflowLog> executionLogsSet = new TreeSet<WorkflowLog>( WorkflowLog.COMPARATOR_BY_WHEN_REVERSED); executionLogsSet.addAll(process.getExecutionLogsSet()); DateTime approvalDate = getApprovalDate(process, executionLogsSet); spreadsheet.addCell(approvalDate == null ? " " : approvalDate.toString("yyyy-MM-dd")); DateTime authorizationDate = getAuthorizationDate(process, executionLogsSet); spreadsheet.addCell(authorizationDate == null ? " " : authorizationDate.toString("yyyy-MM-dd")); } }
From source file:org.codehaus.mojo.license.LicenseMap.java
public void mergeLicenses(String... licenses) { if (licenses.length == 0) { return;// w w w . ja v a2s. co m } String mainLicense = licenses[0].trim(); SortedSet<MavenProject> mainSet = get(mainLicense); if (mainSet == null) { getLog().warn("No license [" + mainLicense + "] found, will create it."); mainSet = new TreeSet<MavenProject>(ArtifactHelper.getProjectComparator()); put(mainLicense, mainSet); } int size = licenses.length; for (int i = 1; i < size; i++) { String license = licenses[i].trim(); SortedSet<MavenProject> set = get(license); if (set == null) { getLog().warn("No license [" + license + "] found, skip this merge."); continue; } getLog().info("Merge license [" + license + "] (" + set.size() + " depedencies)."); mainSet.addAll(set); set.clear(); remove(license); } }
From source file:com.opengamma.financial.analytics.curve.CurveNodeIdMapper.java
/** * Gets the unique tenors for all curve node types sorted by period. * @return All unique tenors/*from w w w. j av a2s.c o m*/ */ public SortedSet<Tenor> getAllTenors() { final SortedSet<Tenor> allTenors = new TreeSet<>(); if (_cashNodeIds != null) { allTenors.addAll(_cashNodeIds.keySet()); } if (_continuouslyCompoundedRateNodeIds != null) { allTenors.addAll(_continuouslyCompoundedRateNodeIds.keySet()); } if (_creditSpreadNodeIds != null) { allTenors.addAll(_creditSpreadNodeIds.keySet()); } if (_deliverableSwapFutureNodeIds != null) { allTenors.addAll(_deliverableSwapFutureNodeIds.keySet()); } if (_discountFactorNodeIds != null) { allTenors.addAll(_discountFactorNodeIds.keySet()); } if (_fraNodeIds != null) { allTenors.addAll(_fraNodeIds.keySet()); } if (_fxForwardNodeIds != null) { allTenors.addAll(_fxForwardNodeIds.keySet()); } if (_rateFutureNodeIds != null) { allTenors.addAll(_rateFutureNodeIds.keySet()); } if (_swapNodeIds != null) { allTenors.addAll(_swapNodeIds.keySet()); } if (_zeroCouponInflationNodeIds != null) { allTenors.addAll(_zeroCouponInflationNodeIds.keySet()); } return allTenors; }