Example usage for java.util TreeSet addAll

List of usage examples for java.util TreeSet addAll

Introduction

In this page you can find the example usage for java.util TreeSet addAll.

Prototype

public boolean addAll(Collection<? extends E> c) 

Source Link

Document

Adds all of the elements in the specified collection to this set.

Usage

From source file:net.spfbl.core.Peer.java

public synchronized TreeSet<String> getReputationKeySet() {
    TreeSet<String> keySet = new TreeSet<String>();
    if (reputationMap2 != null) {
        keySet.addAll(reputationMap2.keySet());
    }// www  .  j  a  v  a  2s  . c o  m
    return keySet;
}

From source file:org.geoserver.security.iride.IrideRoleService.java

@Override
public SortedSet<GeoServerRole> getRolesForUser(final String username) throws IOException {
    LOGGER.trace("User: {}", username);

    final TreeSet<GeoServerRole> roles = new TreeSet<>();

    final IrideIdentity irideIdentity = IrideIdentity.parseIrideIdentity(username);
    if (irideIdentity != null) {
        final IrideRole[] irideRoles = this.getIrideService().findRuoliForPersonaInApplication(irideIdentity,
                new IrideApplication(this.config.applicationName));
        for (final IrideRole irideRole : irideRoles) {
            roles.add(this.createRoleObject(irideRole.toMnemonicRepresentation()));
        }//w  w  w. j  ava2  s. c  o m
    }

    // Rely on the fallback RoleService (if configured) when no IRIDE roles are available for the given user
    if (roles.isEmpty() && this.config.hasFallbackRoleServiceName()) {
        LOGGER.info("No IRIDE roles available for the given user {}: falling back to RoleService '{}'",
                username, this.config.fallbackRoleServiceName);

        final GeoServerRoleService fallbackRoleService = this.getSecurityManager()
                .loadRoleService(this.config.fallbackRoleServiceName);
        if (fallbackRoleService != null) {
            roles.addAll(fallbackRoleService.getRolesForUser(username));
        } else {
            LOGGER.warn("A fallback RoleService '{}' was specified, but none was found!",
                    this.config.fallbackRoleServiceName);
        }
    }

    LOGGER.trace("Added {} roles for User {}", roles.size(), username);

    return ImmutableSortedSet.copyOf(roles);
}

From source file:com.dtolabs.rundeck.core.cli.acl.AclTool.java

private Set<Decision> sortByAction(final Set<Decision> evaluate) {
    TreeSet<Decision> sorted = new TreeSet<>(comparator);
    sorted.addAll(evaluate);
    return sorted;
}

From source file:net.sourceforge.fenixedu.domain.phd.PhdIndividualProgramProcess.java

public Collection<ThesisSubjectOrder> getThesisSubjectOrdersSorted() {
    TreeSet<ThesisSubjectOrder> subjectOrders = new TreeSet<ThesisSubjectOrder>(
            ThesisSubjectOrder.COMPARATOR_BY_ORDER);
    subjectOrders.addAll(getThesisSubjectOrdersSet());
    return subjectOrders;
}

From source file:net.spfbl.core.Peer.java

private synchronized Set<String> subSet(String begin, String end) {
    TreeSet<String> subSet = new TreeSet<String>();
    if (reputationMap2 != null) {
        NavigableMap<String, Binomial> subMap = reputationMap2.subMap(begin, false, end, false);
        subSet.addAll(subMap.keySet());
    }//from  w w  w  . j  a va 2  s. c  o m
    return subSet;
}

From source file:org.apache.axis2.jaxws.runtime.description.marshal.impl.PackageSetBuilder.java

/**
 * Walks the schemas of the serviceDesc's wsdl (or generated wsdl) to determine the list of
 * packages. This is the preferred algorithm for discovering the package set.
 *
 * @param serviceDesc ServiceDescription
 * @return Set of Packages//from w  w  w  .ja va  2s  .  co  m
 */
public static TreeSet<String> getPackagesFromSchema(ServiceDescription serviceDesc) {

    if (log.isDebugEnabled()) {
        log.debug("start getPackagesFromSchema");
        log.debug("ServiceDescription = " + serviceDesc.toString());
    }

    TreeSet<String> set = new TreeSet<String>();
    //If we are on client side we will get wsdl definition from ServiceDescription. If we are on server side we will have to
    //read wsdlLocation from @WebService Annotation.
    ServiceDescriptionWSDL sdw = (ServiceDescriptionWSDL) serviceDesc;
    Definition wsdlDefinition = sdw.getWSDLDefinition();
    Collection<EndpointDescription> endpointDescs = serviceDesc.getEndpointDescriptions_AsCollection();
    if (endpointDescs != null) {
        for (EndpointDescription ed : endpointDescs) {

            if (wsdlDefinition == null) {
                // TODO I don't think we should be trying to load the wsdlDefinition here.

                //Let see if we can get wsdl definition from endpoint @WebService annotation.
                if (ed instanceof EndpointDescriptionJava) {
                    String wsdlLocation = ((EndpointDescriptionJava) ed).getAnnoWebServiceWSDLLocation();
                    wsdlDefinition = getWSDLDefinition(wsdlLocation);
                }
            }
            //So at this point either we got wsdl definition from ServiceDescription (which means we are running this code
            //on client side) or we got it from the @WebService annotation (which means we are running this code on server side)
            if (wsdlDefinition != null) {
                SchemaReader sr = new SchemaReaderImpl();
                try {
                    Set<String> pkgSet = sr.readPackagesFromSchema(wsdlDefinition);
                    set.addAll(pkgSet);
                } catch (SchemaReaderException e) {
                    throw ExceptionFactory.makeWebServiceException(e);
                }
            }
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("end getPackagesFromSchema");
    }
    return set;
}

From source file:com.smi.travel.controller.AirTicketDetailController.java

private void setResponseAttribute(HttpServletRequest request, AirticketPnr airticketPnr, String referenceNo) {
    String codeAirline = request.getParameter("");
    Master master = utilservice.getMasterdao().getBookingFromRefno(referenceNo);
    request.setAttribute(Master, master);
    // Mbookstatus ==> 2 Finish , 5 Finish by Finance
    if (("1").equals(String.valueOf(master.getFlagAir()))
            || ("2").equals(String.valueOf(master.getMBookingstatus().getId()))
            || ("5").equals(String.valueOf(master.getMBookingstatus().getId()))) {
        request.setAttribute(LockUnlockBooking, 1);
    } else {/* w w w.  j a  v a  2s.co m*/
        request.setAttribute(LockUnlockBooking, 0);
    }

    int[] booksize = utilservice.getCountItemFromBooking(referenceNo);
    request.setAttribute(Bookiing_Size, booksize);

    List<MFlight> mFlightList = utilservice.getListMFlightClass();
    request.setAttribute(MFlightList, mFlightList);

    List<MTicketType> mTicketTypeList = utilservice.getListMTicketType();
    request.setAttribute(MTicketTypeList, mTicketTypeList);

    List<MPricecategory> mPricecategorysList = utilservice.getListMPricecategory();
    request.setAttribute(MPricecategorysList, mPricecategorysList);
    MAirline airline = new MAirline();
    List<MAirline> mAirlines = bookingAirticketService.getmAirlineDao().getListAirLine(airline, 1);
    request.setAttribute(MAirlineList, mAirlines);

    List<MItemstatus> mItemstatuses = utilservice.getListMItemstatus();
    request.setAttribute(MItemstatusList, mItemstatuses);

    MAirport airport = new MAirport();
    List<MAirport> mAirport = new ArrayList<MAirport>(mAirportService.searchAirport(airport, 1));
    request.setAttribute(Airport, mAirport);

    List<MInitialname> mInitialname = utilservice.getListMInitialname();
    request.setAttribute(MInitialname, mInitialname);

    List<BookingPnr> listBookingPnr = bookingAirticketService.getListBookingPnr();

    List<MInitialname> listInitialName = utilservice.getListMInitialname();
    request.setAttribute(InitialName, listInitialName);
    request.setAttribute(List_BookingPnrs, listBookingPnr);

    calculateTotalEachFlightInPnr(airticketPnr);
    TreeSet<AirticketFlight> sortedFlight = new TreeSet<AirticketFlight>(new AirticketFlightComparator());
    if (airticketPnr != null) {
        List<AirticketAirline> airlines = new ArrayList<AirticketAirline>(airticketPnr.getAirticketAirlines());
        List<AirticketFlight> allFlights = new ArrayList<AirticketFlight>();
        List<AirticketPassenger> allPassengers = new ArrayList<AirticketPassenger>();
        for (int i = 0; i < airlines.size(); i++) {
            //                allFlights.addAll(airlines.get(i).getAirticketFlights());
            // AirTicketDetail.jsp in TableAir
            sortedFlight.addAll(airlines.get(i).getAirticketFlights());
            allPassengers.addAll(airlines.get(i).getAirticketPassengers());
        }

        allFlights.addAll(sortedFlight);
        request.setAttribute(CurrentPnr, airticketPnr);
        request.setAttribute(Airline, airlines);
        request.setAttribute(AllFlights, allFlights);
        request.setAttribute(AllPassengers, allPassengers);
    }
}

From source file:com.hichinaschool.flashcards.anki.CardEditor.java

private void actualizeTagDialog(StyledDialog ad) {
    TreeSet<String> tags = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    for (String tag : mCol.getTags().all()) {
        tags.add(tag);/*from  ww  w .j a v  a 2 s.co  m*/
    }
    tags.addAll(selectedTags);
    int len = tags.size();
    allTags = new String[len];
    boolean[] checked = new boolean[len];
    int i = 0;
    for (String t : tags) {
        allTags[i++] = t;
        if (selectedTags.contains(t)) {
            checked[i - 1] = true;
        }
    }
    ad.setMultiChoiceItems(allTags, checked, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface arg0, int which) {
            String tag = allTags[which];
            if (selectedTags.contains(tag)) {
                // Log.i(AnkiDroidApp.TAG, "unchecked tag: " + tag);
                selectedTags.remove(tag);
            } else {
                // Log.i(AnkiDroidApp.TAG, "checked tag: " + tag);
                selectedTags.add(tag);
            }
        }
    });
}

From source file:org.unitime.timetable.test.ExportPreferences.java

public void exportAll(Long solverGroupId, File outFile) throws Exception {
    SolverGroup solverGroup = (new SolverGroupDAO()).get(solverGroupId);
    Session session = solverGroup.getSession();
    Document document = DocumentHelper.createDocument();
    Element root = document.addElement("export");
    root.addAttribute("solverGroup", solverGroup.getUniqueId().toString());
    root.addAttribute("solverGroupName", solverGroup.getName());
    root.addAttribute("session", session.getUniqueId().toString());
    root.addAttribute("academicYearTerm", session.getAcademicYearTerm());
    root.addAttribute("academicInitiative", session.getAcademicInitiative());
    for (Iterator i = TimePattern.findAll(session, null).iterator(); i.hasNext();) {
        TimePattern t = (TimePattern) i.next();
        exportTimePattern(root, t);//from w  w  w.j av a 2s  . c o m
    }
    for (Iterator i = DatePattern.findAll(session, true, null, null).iterator(); i.hasNext();) {
        DatePattern d = (DatePattern) i.next();
        exportDatePattern(root, d);
    }
    classCmp = new Comparator() {
        public int compare(Object o1, Object o2) {
            Class_ c1 = (Class_) o1;
            Class_ c2 = (Class_) o2;
            int cmp = c1.getCourseName().compareTo(c2.getCourseName());
            if (cmp != 0)
                return cmp;
            cmp = c1.getSchedulingSubpart().getItype().getItype()
                    .compareTo(c2.getSchedulingSubpart().getItype().getItype());
            if (cmp != 0)
                return cmp;
            cmp = c1.getSchedulingSubpart().getSchedulingSubpartSuffix()
                    .compareTo(c2.getSchedulingSubpart().getSchedulingSubpartSuffix());
            if (cmp != 0)
                return cmp;
            return c1.getUniqueId().compareTo(c2.getUniqueId());
        }
    };
    TreeSet classes = new TreeSet(classCmp);
    subpartCmp = new Comparator() {
        public int compare(Object o1, Object o2) {
            SchedulingSubpart s1 = (SchedulingSubpart) o1;
            SchedulingSubpart s2 = (SchedulingSubpart) o2;
            int cmp = s1.getCourseName().compareTo(s2.getCourseName());
            if (cmp != 0)
                return cmp;
            cmp = s1.getItype().getItype().compareTo(s2.getItype().getItype());
            if (cmp != 0)
                return cmp;
            return s1.getUniqueId().compareTo(s2.getUniqueId());
        }
    };
    TreeSet subparts = new TreeSet(subpartCmp);
    ioCmp = new Comparator() {
        public int compare(Object o1, Object o2) {
            InstructionalOffering i1 = (InstructionalOffering) o1;
            InstructionalOffering i2 = (InstructionalOffering) o2;
            int cmp = i1.getCourseName().compareTo(i2.getCourseName());
            if (cmp != 0)
                return cmp;
            return i1.getUniqueId().compareTo(i2.getUniqueId());
        }
    };
    TreeSet offerings = new TreeSet(ioCmp);
    classes.addAll(solverGroup.getClasses());
    for (Iterator i = classes.iterator(); i.hasNext();) {
        Class_ c = (Class_) i.next();
        exportClass(root, c);
        SchedulingSubpart s = c.getSchedulingSubpart();
        offerings.add(s.getInstrOfferingConfig().getInstructionalOffering());
        if (solverGroup.getDepartments().contains(s.getManagingDept())) {
            subparts.add(s);
        }
    }
    for (Iterator i = subparts.iterator(); i.hasNext();) {
        SchedulingSubpart s = (SchedulingSubpart) i.next();
        exportSchedulingSubpart(root, s);
    }
    for (Iterator i = offerings.iterator(); i.hasNext();) {
        InstructionalOffering io = (InstructionalOffering) i.next();
        exportInstructionalOffering(root, io);
    }
    for (Iterator i = solverGroup.getDepartments().iterator(); i.hasNext();) {
        Department d = (Department) i.next();
        exportInstructors(root, d);
    }
    for (Iterator i = solverGroup.getDistributionPreferences().iterator(); i.hasNext();) {
        DistributionPref d = (DistributionPref) i.next();
        exportDistributionPref(root, d);
    }
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(outFile);
        (new XMLWriter(fos, OutputFormat.createPrettyPrint())).write(document);
        fos.flush();
        fos.close();
        fos = null;
    } finally {
        try {
            if (fos != null)
                fos.close();
        } catch (IOException e) {
        }
    }
}

From source file:it.geosolutions.geobatch.flow.file.FileBasedFlowManager.java

/**
 * returns an unmodifiable descending ordered by creation time list of all the consumers
 * //from  w ww  . j  a  v  a2  s  . c om
 * @return
 */
public final Set<BaseEventConsumer> getEventConsumers() {
    TreeSet tree = new TreeSet<BaseEventConsumer<EventObject, EventConsumerConfiguration>>(
            new Comparator<BaseEventConsumer<EventObject, EventConsumerConfiguration>>() {
                @Override
                public int compare(BaseEventConsumer<EventObject, EventConsumerConfiguration> o1,
                        BaseEventConsumer<EventObject, EventConsumerConfiguration> o2) {
                    Calendar cal = o1.getCreationTimestamp();
                    Calendar currentcal = o2.getCreationTimestamp();
                    if (cal.before(currentcal))
                        return 1;
                    else if (cal.after(currentcal))
                        return -1;
                    else
                        return 0;
                }
            });
    tree.addAll(eventConsumers.values());
    return tree;
}