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:com.symbian.utils.config.ConfigUtils.java

/**
 * completeConfigFromStore/*from ww w.  j  a  v a  2 s . c om*/
 * add any extra elements from the store. For example, if the plugins have been activated before, there settings 
 * would have been loaded by their activators.
 *
 */
protected void completeConfigFromStore() {
    try {
        TreeSet<String> storeKeys = new TreeSet<String>();
        storeKeys.addAll(Arrays.asList(iPrefrences.keys()));
        TreeSet<String> localKeys = new TreeSet<String>();
        localKeys.addAll(Arrays.asList(iPreferenceLiterals));

        for (String key : storeKeys) {
            if (!localKeys.contains(key)) {
                addConfig(key, iPrefrences.get(key, ""), new CheckGetConfig(), new CheckSetConfig(),
                        String.class);
            }
        }
    } catch (BackingStoreException e) {
        LOGGER.log(Level.SEVERE, "Could not initialise the config " + e.getMessage());
    }
}

From source file:pt.ist.fenix.ui.struts.action.messaging.SearchPerson.java

public CollectionPager<Person> run(SearchParameters searchParameters, Predicate predicate) {

    if (searchParameters.emptyParameters()) {
        return new CollectionPager<Person>(new ArrayList<Person>(), 25);
    }//from w w w  .jav a  2s  .  c om

    final Collection<Person> persons;

    if (searchParameters.getUsername() != null && searchParameters.getUsername().length() > 0) {

        final Person person = Person.readPersonByUsername(searchParameters.getUsername());
        persons = new ArrayList<Person>();
        if (person != null) {
            persons.add(person);
        }

    } else if (searchParameters.getDocumentIdNumber() != null
            && searchParameters.getDocumentIdNumber().length() > 0) {
        persons = Person.findPersonByDocumentID(searchParameters.getDocumentIdNumber());

    } else if (searchParameters.getStudentNumber() != null) {

        final Student student = Student.readStudentByNumber(searchParameters.getStudentNumber());
        persons = new ArrayList<Person>();
        if (student != null) {
            persons.add(student.getPerson());
        }

    } else if (searchParameters.getEmail() != null && searchParameters.getEmail().length() > 0) {

        final Person person = Person.readPersonByEmailAddress(searchParameters.getEmail());
        persons = new ArrayList<Person>();
        if (person != null) {
            persons.add(person);
        }

    } else if (searchParameters.getMechanoGraphicalNumber() != null) {
        final Employee employee = Employee.readByNumber(searchParameters.getMechanoGraphicalNumber());
        final Student student = Student.readStudentByNumber(searchParameters.getMechanoGraphicalNumber());
        persons = new TreeSet<Person>();
        if (employee != null) {
            persons.add(employee.getPerson());
        }
        if (student != null) {
            persons.add(student.getPerson());
        }

    } else if (searchParameters.getName() != null) {

        persons = new ArrayList<Person>();

        persons.addAll(Person.findPerson(searchParameters.getName()));
        final String roleBd = searchParameters.getRole();
        if (roleBd != null) {
            for (final Iterator<Person> peopleIterator = persons.iterator(); peopleIterator.hasNext();) {
                final Person person = peopleIterator.next();
                if (!hasRole(person.getUser(), roleBd)) {
                    peopleIterator.remove();
                }
            }
        }
        final Department department = searchParameters.getDepartment();
        if (department != null) {
            for (final Iterator<Person> peopleIterator = persons.iterator(); peopleIterator.hasNext();) {
                final Person person = peopleIterator.next();
                final Teacher teacher = person.getTeacher();
                if (teacher == null || teacher.getDepartment() != department) {
                    peopleIterator.remove();
                }
            }
        }

    } else if (!StringUtils.isEmpty(searchParameters.getPaymentCode())) {
        persons = new ArrayList<Person>();

        PaymentCode paymentCode = PaymentCode.readByCode(searchParameters.getPaymentCode());

        if (paymentCode != null && paymentCode.getPerson() != null) {
            persons.add(paymentCode.getPerson());
        }
    } else {
        persons = new ArrayList<Person>(0);
    }

    TreeSet<Person> result = new TreeSet<Person>(Person.COMPARATOR_BY_NAME_AND_ID);
    result.addAll(CollectionUtils.select(persons, predicate));
    return new CollectionPager<Person>(result, 25);
}

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

@Override
protected ModelAndView process(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
    int result = 0;
    String action = request.getParameter("action");
    String refNo = request.getParameter("referenceNo");
    String airBookingId = request.getParameter("airBookingId");
    String airDescRows = request.getParameter("counter");
    SystemUser owner = null;/* ww w .  j a va2 s  .c om*/
    SystemUser issue = null;
    System.out.println(AirTicketController.class.getName() + " action=[" + action + "] refNo[" + refNo
            + "],[airId=" + airBookingId + "] [airDescrows=" + airDescRows + "]");

    if ("new".equalsIgnoreCase(action)) {
        System.out.println("AirTicketController new not supported yet");
        //            request.setAttribute(ACTION, "new");
    } else if ("edit".equalsIgnoreCase(action)) {
        System.out.println("AirTciketController edit ");
        AirticketBooking airBook = bookingAirticketService.getBookDetailAir(refNo);

        int[] booksize = utilservice.getCountItemFromBooking(refNo);
        request.setAttribute(Bookiing_Size, booksize);
        if (airBook != null) {
            System.out.println("AirBook is not null");
            TreeSet<AirticketPnr> sortedPnr = new TreeSet<AirticketPnr>(new AirticketPnrComparator());

            sortedPnr.addAll(airBook.getAirticketPnrs());
            List<AirticketPnr> pnrList = new ArrayList<AirticketPnr>();
            pnrList.addAll(sortedPnr);
            request.setAttribute(airTicketPnrList, pnrList);

            if (pnrList != null) {
                request.setAttribute(AirticketBooking, airBook);

                List<AirticketDesc> airticketDescsList = new ArrayList<AirticketDesc>(
                        airBook.getAirticketDescs());
                request.setAttribute(AirticketDescsList, airticketDescsList);
            }

            owner = airBook.getStaffByOwnerBy();
            request.setAttribute(OwnerBy, owner);

            SystemUser issueBy = airBook.getStaffByIssueBy();
            request.setAttribute(IssueBy, issueBy);
        } else {
            //airBook is null;
            SystemUser user = (SystemUser) session.getAttribute("USER");
            request.setAttribute(OwnerBy, user);
            request.setAttribute(IssueBy, user);
            request.setAttribute(AddButton, "disabled");
        }

        request.setAttribute(ACTION, "update");
    } else if ("update".equalsIgnoreCase(action)) {
        String ownerName = request.getParameter("staff_username");
        String issueName = request.getParameter("issue_username");
        String deadline = request.getParameter("get_deadline");
        String reconfirm = request.getParameter("reconfirm");
        String remark = request.getParameter("remark");
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date deadlineDate = null;
        try {
            deadlineDate = formatter.parse(deadline);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println(
                "[ownerName=" + ownerName + "], [issueName=" + issueName + "], [deadline=" + deadline + "]");
        AirticketBooking airBook = bookingAirticketService.getBookDetailAir(refNo);

        if (airBook == null) {
            airBook = new AirticketBooking();

            owner = getUpdateSystemUserByName(ownerName, airBook.getStaffByOwnerBy());
            System.out.println("owner " + owner);
            airBook.setStaffByOwnerBy(owner);
            //                System.out.println("OwnerName " + ownerName + " Owner name" + owner.getName() + ", [OwnerId=" + owner.getId() + "]");

            issue = getUpdateSystemUserByName(issueName, airBook.getStaffByIssueBy());
            airBook.setStaffByIssueBy(issue);
            airBook.setReConfirm(reconfirm);
            airBook.setRemark(remark);
            airBook.setDeadline(deadlineDate);
            Master master = utilservice.getMasterdao().getBookingFromRefno(refNo);
            master.setFlagAir(new Integer("1"));
            airBook.setMaster(master);

            setAirticketDescRows(request, airDescRows, airBook);

            //                master.getAirticketBookings().add(airBook);
            result = bookingAirticketService.insertBookingAirTicket(airBook);

        } else {
            airBook = bookingAirticketService.getBookDetailAir(refNo);
            System.out.println("airBook id=" + airBook.getId());

            issue = getUpdateSystemUserByName(issueName, airBook.getStaffByIssueBy());
            owner = getUpdateSystemUserByName(ownerName, airBook.getStaffByOwnerBy());
            airBook.setStaffByIssueBy(issue);
            airBook.setStaffByOwnerBy(owner);
            airBook.setReConfirm(reconfirm);
            airBook.setDeadline(deadlineDate);
            airBook.setRemark(remark);
            setAirticketDescRows(request, airDescRows, airBook);
            System.out.println("updateBookingAirticket-----");
            result = bookingAirticketService.updateBookingAirTicket(airBook);
        }
        request.setAttribute(Result, result);
        return new ModelAndView(
                "redirect:AirTicket.smi?referenceNo=" + refNo + "&action=edit&result=" + result);
    } else if ("disablePnr".equalsIgnoreCase(action)) {
        String pnrId = request.getParameter("disablePnrId");
        result = bookingAirticketService.cancelBookAirticketPNR(pnrId);
        System.out.println("Mark PNR ID[" + pnrId + "] as disable");
        return new ModelAndView(
                "redirect:AirTicket.smi?referenceNo=" + refNo + "&action=edit&result=" + result);
    } else if ("enablePnr".equalsIgnoreCase(action)) {
        String pnrId = request.getParameter("enablePnrId");
        result = bookingAirticketService.enableBookAirticketPNR(pnrId);
        System.out.println("Mark PNR ID[" + pnrId + "] as enable");
        return new ModelAndView(
                "redirect:AirTicket.smi?referenceNo=" + refNo + "&action=edit&result=" + result);
    } else if ("deleteDesc".equalsIgnoreCase(action)) {
        String bId = request.getParameter("bId");
        String dId = request.getParameter("dId");
        AirticketBooking airticketBooking = bookingAirticketService.getBookDetailAir(bId);
        result = bookingAirticketService.DeleteDesc(airticketBooking, dId);
    } else {
        AirticketBooking airBook = bookingAirticketService.getBookDetailAir(refNo);
        if (airBook == null) {
            System.out.println("AirBook is null");
            request.setAttribute(AddButton, "disabled");
        } else {

            if ("".equalsIgnoreCase(refNo) || (refNo == null)) {
                System.out.println("*****This should not be executed!!!!");
                request.setAttribute(ACTION, "edit");
            } else {

                AirticketBooking AirBook = bookingAirticketService.getBookDetailAir(refNo);
                List<AirticketPnr> pnrList = new ArrayList<AirticketPnr>(AirBook.getAirticketPnrs());
                request.setAttribute(airTicketPnrList, pnrList);

                AirticketBooking airticketBooking = pnrList.get(0).getAirticketBooking();
                request.setAttribute(AirticketBooking, airticketBooking);

                List<AirticketDesc> airticketDescsList = new ArrayList<AirticketDesc>(
                        AirBook.getAirticketDescs());
                request.setAttribute(AirticketDescsList, airticketDescsList);

                SystemUser ownerBy = airticketBooking.getStaffByOwnerBy();
                System.out.println("ownerBy : " + ownerBy.getName());
                request.setAttribute(OwnerBy, ownerBy);

                SystemUser issueBy = airticketBooking.getStaffByIssueBy();
                request.setAttribute(IssueBy, issueBy);

            }
        }
    }

    setGeneralResponseAttribute(request, refNo);

    return AirTicket;
}

From source file:com.symbian.utils.config.ConfigUtils.java

/**
 * Print the Configuration setting//from ww w  .j a  v  a2 s.co  m
 * 
 * @param aLogger
 *            If <code>true</code> then prints to logger, else if
 *            <code>false</code> then prints to STDOUT.
 * @throws IOException
 */
public void printConfig(final boolean aLogger) throws IOException {
    try {

        StringBuffer lOutput = new StringBuffer();

        lOutput.append("\n");

        TreeSet<String> sortedKeys = new TreeSet<String>();
        sortedKeys.addAll(iSavedConfig.keySet());

        //sortedKeys.addAll(Arrays.asList(iPrefrences.keys()));

        for (Iterator lConfigIter = sortedKeys.iterator(); lConfigIter.hasNext();) {
            String lKey = (String) lConfigIter.next();
            //for lite version enhancement. Depreciate "sysbin", instead use "statLite"
            if (lKey.equalsIgnoreCase("platsec")) //PlatSec will not be used and should not be displayed to user
                continue;
            String lKeyDisplayName = lKey.equalsIgnoreCase("sysbin") ? "statlite" : lKey;
            String lMessage = "Preference " + lKeyDisplayName + ":"
                    + (lKeyDisplayName.length() < 12 ? "\t\t" : "\t") + iSavedConfig.get(lKey);
            if (aLogger) {
                lOutput.append(lMessage + "\n");
            } else {
                System.out.println(lMessage);
            }
        }

        if (aLogger) {
            LOGGER.info(lOutput.toString());
        }

    } catch (SecurityException lSecurityException) {
        throw new IOException("Security exception: " + lSecurityException.getMessage());
    }
}

From source file:com.murati.oszk.audiobook.model.MusicProvider.java

private Collection<MediaBrowserCompat.MediaItem> createGroupList(
        ConcurrentMap<String, List<String>> categoryMap, String mediaIdCategory, Uri imageUri,
        Resources resources) {//from ww  w  .  j  a v  a  2  s  .c  om
    if (mCurrentState != State.INITIALIZED)
        return Collections.emptyList();

    TreeSet<String> sortedCategoryList = new TreeSet<String>(collator);
    sortedCategoryList.addAll(categoryMap.keySet());

    List<MediaBrowserCompat.MediaItem> categoryList = new ArrayList<MediaBrowserCompat.MediaItem>();
    for (String categoryName : sortedCategoryList) {
        try {
            MediaBrowserCompat.MediaItem browsableCategory = createGroupItem(
                    createMediaID(null, mediaIdCategory, categoryName), categoryName,
                    String.format(resources.getString(R.string.browse_title_count),
                            String.valueOf(categoryMap.get(categoryName).size())),
                    imageUri);
            categoryList.add(browsableCategory);
        } catch (Exception e) {
            //TODO: log
        }
    }
    return categoryList;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.CommonPhdIndividualProgramProcessDA.java

public ActionForward viewUnreadAlertMessages(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {/*from  w w  w  .  j a  va  2 s.  co m*/

    TreeSet<PhdAlertMessage> orderedMessages = new TreeSet<PhdAlertMessage>(
            Collections.reverseOrder(PhdAlertMessage.COMPARATOR_BY_WHEN_CREATED_AND_ID));
    orderedMessages.addAll(getLoggedPerson(request).getUnreadedPhdAlertMessages());

    request.setAttribute("unread", "true");
    request.setAttribute("alertMessages", orderedMessages);
    return mapping.findForward("viewAlertMessages");
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.CommonPhdIndividualProgramProcessDA.java

public ActionForward viewUnreadProcessAlertMessages(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) {

    TreeSet<PhdAlertMessage> orderedMessages = new TreeSet<PhdAlertMessage>(
            Collections.reverseOrder(PhdAlertMessage.COMPARATOR_BY_WHEN_CREATED_AND_ID));
    orderedMessages.addAll(getProcess(request).getUnreadAlertMessagesForLoggedPerson());

    request.setAttribute("unread", "true");
    request.setAttribute("alertMessages", orderedMessages);
    return mapping.findForward("viewProcessAlertMessages");
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.CommonPhdIndividualProgramProcessDA.java

public ActionForward viewAlertMessages(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {/*from  ww w  .  j a va 2s .c  o  m*/

    TreeSet<PhdAlertMessage> orderedMessages = new TreeSet<PhdAlertMessage>(
            Collections.reverseOrder(PhdAlertMessage.COMPARATOR_BY_WHEN_CREATED_AND_ID));
    orderedMessages.addAll(getLoggedPerson(request).getPhdAlertMessagesSet());
    ArrayList<PhdAlertMessage> lastMessages = new ArrayList<PhdAlertMessage>();
    lastMessages.addAll(orderedMessages);

    request.setAttribute("unread", "false");
    request.setAttribute("alertMessages",
            lastMessages.subList(0, Math.min(lastMessages.size(), NUMBER_OF_LAST_MESSAGES)));
    request.setAttribute("tooManyMessages", (lastMessages.size() > NUMBER_OF_LAST_MESSAGES) ? "true" : "false");
    return mapping.findForward("viewAlertMessages");
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.CommonPhdIndividualProgramProcessDA.java

public ActionForward viewProcessAlertMessages(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) {

    TreeSet<PhdAlertMessage> orderedMessages = new TreeSet<PhdAlertMessage>(
            Collections.reverseOrder(PhdAlertMessage.COMPARATOR_BY_WHEN_CREATED_AND_ID));
    orderedMessages.addAll(getProcess(request).getAlertMessagesForLoggedPerson());
    ArrayList<PhdAlertMessage> lastMessages = new ArrayList<PhdAlertMessage>();
    lastMessages.addAll(orderedMessages);

    request.setAttribute("unread", "false");
    request.setAttribute("alertMessages",
            lastMessages.subList(0, Math.min(lastMessages.size(), NUMBER_OF_LAST_MESSAGES)));
    request.setAttribute("tooManyMessages", (lastMessages.size() > NUMBER_OF_LAST_MESSAGES) ? "true" : "false");
    return mapping.findForward("viewProcessAlertMessages");
}

From source file:eu.numberfour.n4js.npmexporter.ui.NpmExportWizard.java

@Override
public void init(IWorkbench targetWorkbench, IStructuredSelection currentSelection) {

    // this.selection = currentSelection;

    List<?> selectedResources = IDE.computeSelectedResources(currentSelection);

    // Find all projects
    Set<IProject> projects = selectedResources.stream().filter(m -> m instanceof IResource)
            .map(m -> ((IResource) m).getProject()).filter(p -> p.isOpen()) // only open projects
            .collect(Collectors.toSet());
    // make the behavior predictable by ordering:
    TreeSet<IProject> sortedProjects = Sets
            .<IProject>newTreeSet((a, b) -> a.getName().compareToIgnoreCase(b.getName()));
    sortedProjects.addAll(projects);

    // 0) turn into IN4JSProject and give and process further.
    // a) find out which projects fulfill the npm-"exportable"-contract
    // b) give back a list to the user what to export,
    // c) disable things not fullfilling the contract.
    // d) take choosing from the list and pass to exporter in non-ui package.

    // 0)//from w  ww.  j  a v a 2 s.c  o  m
    List<IN4JSEclipseProject> rawN4jsProjects = Lists.newArrayList();
    iP2in4jsP = HashBiMap.create();
    for (IProject iProject : sortedProjects) {
        IN4JSEclipseProject mappedIn4jsProject = map2In4js(iProject);
        if (mappedIn4jsProject != null) {
            rawN4jsProjects.add(mappedIn4jsProject);

            iP2in4jsP.put(iProject, mappedIn4jsProject);
        }
    }

    // remove all filtered out Non-N4JS-projects.
    sortedProjects.retainAll(iP2in4jsP.keySet());

    // if (!selectedResources.isEmpty()) {
    // this.selection = new StructuredSelection(sortedProjects.toArray());
    // }

    setWindowTitle("N4JS to npm Export");
    setNeedsProgressMonitor(true);

    // exportPage = new ExportSelectionPage("Export Page", rawN4jsProjects, labelProvider);
    exportPage = new ExportSelectionPage("Export Page", newArrayList(sortedProjects));
    if (runTools())
        toolRunnerPage = new NpmToolRunnerPage("npm Execution Page");
    comparePage = new PackageJsonComparePage("Compare package.json Page");

    pageListener = new IPageChangedListener() {

        @Override
        public void pageChanged(PageChangedEvent event) {
            if (event.getSelectedPage() == comparePage) {
                udpatePackagJasonComparison();
            }
        }
    };
}