Example usage for java.util SortedSet addAll

List of usage examples for java.util SortedSet addAll

Introduction

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

Prototype

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

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:net.sourceforge.fenixedu.presentationTier.Action.scientificCouncil.thesis.ManageSecondCycleThesisSearchBean.java

public SortedSet<Person> findPersonBySearchString() {
    final SortedSet<Person> result = new TreeSet<Person>(Person.COMPARATOR_BY_NAME_AND_ID);
    if (searchString != null && !searchString.isEmpty()) {
        result.addAll(searchName(searchString));
        result.addAll(searchUsername(searchString));
        result.addAll(searchStudentNumber(searchString));
    }/*  ww w.  ja  v a  2  s. c  om*/
    return result;
}

From source file:org.uncommons.reportng.HTMLReporter.java

/**
 * Sorts groups alphabetically and also sorts methods within groups alphabetically
 * (class name first, then method name).  Also eliminates duplicate entries.
 *//*from  w w  w. ja v  a 2  s .  c  o  m*/
private SortedMap<String, SortedSet<ITestNGMethod>> sortGroups(Map<String, Collection<ITestNGMethod>> groups) {
    SortedMap<String, SortedSet<ITestNGMethod>> sortedGroups = new TreeMap<String, SortedSet<ITestNGMethod>>();
    for (Map.Entry<String, Collection<ITestNGMethod>> entry : groups.entrySet()) {
        SortedSet<ITestNGMethod> methods = new TreeSet<ITestNGMethod>(METHOD_COMPARATOR);
        methods.addAll(entry.getValue());
        sortedGroups.put(entry.getKey(), methods);
    }
    return sortedGroups;
}

From source file:info.magnolia.importexport.Bootstrapper.java

/**
 * Get the files to bootstrap. The method garantees that only one file is imported if it occures twice in the
 * bootstrap dir. The set is returned sorted, so that the execution fo the import will import the upper most nodes
 * first. This is done using the filelength.
 *
 * @return the sorted set/* w w w.  j a  va2  s . c om*/
 */
private static SortedSet<File> getBootstrapFiles(String[] bootdirs, final String repositoryName,
        final BootstrapFilter filter) {
    SortedSet<File> xmlfileset = new TreeSet<File>(new BootstrapFilesComparator());

    for (int j = 0; j < bootdirs.length; j++) {
        String bootdir = bootdirs[j];
        File xmldir = new File(bootdir);
        if (!xmldir.exists() || !xmldir.isDirectory()) {
            continue;
        }

        @SuppressWarnings("unchecked")
        Collection<File> files = FileUtils.listFiles(xmldir, new IOFileFilter() {
            @Override
            public boolean accept(File file) {
                return accept(file.getParentFile(), file.getName());
            }

            @Override
            public boolean accept(File dir, String name) {
                return name.startsWith(repositoryName + ".") && filter.accept(name)
                        && (name.endsWith(DataTransporter.XML) || name.endsWith(DataTransporter.ZIP)
                                || name.endsWith(DataTransporter.GZ)
                                || name.endsWith(DataTransporter.PROPERTIES));
            }
        }, FileFilterUtils.trueFileFilter());

        xmlfileset.addAll(files);
    }

    return xmlfileset;
}

From source file:org.sonatype.nexus.testsuite.task.nexus2692.AbstractEvictTaskIt.java

protected SortedSet<String> buildListOfExpectedFilesForAllRepos(int days) {
    SortedSet<String> expectedFiles = new TreeSet<String>();
    expectedFiles.addAll(getNeverDeleteFiles());
    for (Entry<String, Integer> entry : pathMap.entrySet()) {
        if (entry.getValue() > (-days)) {
            expectedFiles.add(entry.getKey());
        }/*from w w w .ja  va 2 s  . c  o  m*/
    }

    List<String> expectedShadows = new ArrayList<String>();

    // loop once more to look for the shadows (NOTE: the shadow id must be in the format of targetId-*
    for (String expectedFile : expectedFiles) {
        String prefix = expectedFile.substring(0, expectedFile.indexOf("/")) + "-";
        String fileName = new File(expectedFile).getName();

        for (String originalFile : pathMap.keySet()) {
            if (originalFile.startsWith(prefix) && originalFile.endsWith(fileName)) {
                expectedShadows.add(originalFile);
                break;
            }
        }
    }

    expectedFiles.addAll(expectedShadows);

    return expectedFiles;
}

From source file:com.tamingtext.classifier.mlt.MoreLikeThisCategorizer.java

public CategoryHits[] categorize(Reader reader) throws IOException {
    Query query = moreLikeThis.like(reader);

    HashMap<String, CategoryHits> categoryHash = new HashMap<String, CategoryHits>(25);

    for (ScoreDoc sd : indexSearcher.search(query, maxResults).scoreDocs) {
        String cat = getDocClass(sd.doc);
        if (cat == null)
            continue;
        CategoryHits ch = categoryHash.get(cat);
        if (ch == null) {
            ch = new CategoryHits();
            ch.setLabel(cat);/*from   w w w.  ja v a 2 s .c  o  m*/
            categoryHash.put(cat, ch);
        }

        ch.incrementScore(sd.score);
    }

    SortedSet<CategoryHits> sortedCats = new TreeSet<CategoryHits>(CategoryHits.byScoreComparator());
    sortedCats.addAll(categoryHash.values());
    return sortedCats.toArray(new CategoryHits[0]);
}

From source file:de.tudarmstadt.ukp.dkpro.tc.fstore.simple.SparseFeatureStore.java

@Override
public SortedSet<String> getUniqueOutcomes() {
    SortedSet<String> result = new TreeSet<>();

    for (List<String> outcomes : outcomeList) {
        result.addAll(outcomes);
    }//from   w  w  w .  ja  v a 2s.  c  o  m

    return result;
}

From source file:org.fenixedu.academic.presentationTier.Action.gep.TeachingStaffDispatchAction.java

public ActionForward selectExecutionDegree(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response) throws FenixServiceException {

    DynaActionForm dynaActionForm = (DynaActionForm) actionForm;
    String degreeCurricularPlanID = (String) dynaActionForm.get("degreeCurricularPlanID");
    String executionYearID = (String) dynaActionForm.get("executionYearID");

    Set<DegreeModuleScope> degreeModuleScopes = readActiveCurricularCourseScopesByDegreeCurricularPlanIDAndExecutionYearID(
            degreeCurricularPlanID, executionYearID);

    SortedSet<DegreeModuleScope> sortedScopes = new TreeSet<DegreeModuleScope>(
            DegreeModuleScope.COMPARATOR_BY_NAME);
    sortedScopes.addAll(degreeModuleScopes);

    InfoExecutionYear infoExecutionYear = ReadExecutionYearByID.run(executionYearID);

    request.setAttribute("sortedScopes", sortedScopes);
    request.setAttribute("executionYear", infoExecutionYear.getYear());

    return mapping.findForward("chooseExecutionCourse");
}

From source file:fr.aliasource.webmail.proxy.impl.CompletionRegistry.java

public List<Completion> complete(IAccount account, String type, String query, int limit) {
    SortedSet<Completion> comps = new TreeSet<Completion>(completionComparator);
    for (ICompletionSourceFactory csf : factories) {
        if (csf.supports(type)) {
            List<Completion> cResult = csf.getInstance(type).complete(account, query, limit);
            comps.addAll(cResult);
        }// w w w .  j a  va2s.c o m
    }

    Iterator<Completion> it = comps.iterator();
    int i = 0;
    List<Completion> ret = new ArrayList<Completion>(limit);
    while (it.hasNext() && i < limit) {
        ret.add(it.next());
        i++;
    }
    if (logger.isInfoEnabled()) {
        logger.info("complete(" + type + ", " + query + ", " + limit + ") => " + ret.size() + " results.");
    }
    return ret;
}

From source file:org.sakaiproject.component.app.messageforums.dao.hibernate.BaseForumImpl.java

public List getTopics() {
    boolean isUnsorted = false;
    int c = 1;/*from w  w w  . j  a  va 2  s. c  o  m*/
    for (Iterator i = this.topicsSet.iterator(); i.hasNext(); c++) {
        Topic topic = (Topic) i.next();
        if (topic.getSortIndex().intValue() != c) {
            isUnsorted = true;
            break;
        }
    }
    if (isUnsorted) {
        SortedSet sortedTopics = new TreeSet(new TopicBySortIndexAscAndCreatedDateDesc());
        sortedTopics.addAll(this.topicsSet);
        int x = 1;
        for (Iterator i = sortedTopics.iterator(); i.hasNext(); x++) {
            Topic topic = (Topic) i.next();
            topic.setSortIndex(Integer.valueOf(x));
        }
        this.topicsSet = sortedTopics;
    }
    return Util.setToList(this.topicsSet);
}

From source file:uk.ac.ebi.fg.jobs.PubMedDataMinerJob.java

public void doExecute(JobExecutionContext jobExecutionContext)
        throws JobExecutionException, InterruptedException {
    JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap();

    Set<String> pubMedNewIds = (Set<String>) dataMap.get("pubMedNewIds");
    ConcurrentHashMap<String, SortedSet<PubMedId>> pubMedIdRelationMap = (ConcurrentHashMap<String, SortedSet<PubMedId>>) dataMap
            .get("pubMedIdRelationMap");
    Configuration properties = (Configuration) dataMap.get("properties");
    AtomicInteger pubMedCounter = (AtomicInteger) dataMap.get("pubMedCounter");
    PubMedRetriever pubMedRetriever = (PubMedRetriever) dataMap.get("pubMedRetriever");
    String entry = (String) dataMap.get("entry");

    String pubMedURL = properties.getString("pub_med_url");
    int maxPubMedDist = properties.getInt("max_pubmed_distance");
    SortedSet<PubMedId> similarPublications = new TreeSet<PubMedId>();

    // add publication with distance 0
    similarPublications.add(new PubMedId(entry, 0));

    // get similar publications (distance 1)
    if (maxPubMedDist >= 1)
        similarPublications.addAll(getPubMedIdSet(pubMedRetriever.getSimilars(pubMedURL, entry), 1));

    // get publications with distance 2
    if (null != similarPublications && maxPubMedDist == 2) {
        SortedSet<PubMedId> iterationSet = new TreeSet<PubMedId>(similarPublications);

        for (PubMedId publication : iterationSet)
            similarPublications.addAll(/*from   w  w w  .  ja va 2  s.  c  o  m*/
                    getPubMedIdSet(pubMedRetriever.getSimilars(pubMedURL, publication.getPublicationId()), 2));
    }

    if (!similarPublications.isEmpty())
        pubMedIdRelationMap.putIfAbsent(entry, similarPublications);

    // delay job to run for 1 second
    Thread.currentThread().wait(1000);

    logger.debug("Finished " + pubMedCounter.incrementAndGet() + " of " + pubMedNewIds.size()
            + " PubMedDataMinerJobs");
}