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.domain.Alumni.java

public PhysicalAddress getLastPersonalAddress() {
    SortedSet<PhysicalAddress> addressSet = new TreeSet<PhysicalAddress>(DomainObjectUtil.COMPARATOR_BY_ID);
    addressSet.addAll(getStudent().getPerson().getPhysicalAddresses());
    return !addressSet.isEmpty() && addressSet.last() != null ? addressSet.last() : null;
}

From source file:net.sourceforge.fenixedu.domain.Professorship.java

public SortedSet<SupportLesson> getSupportLessonsOrderedByStartTimeAndWeekDay() {
    final SortedSet<SupportLesson> supportLessons = new TreeSet<SupportLesson>(
            SupportLesson.SUPPORT_LESSON_COMPARATOR_BY_HOURS_AND_WEEK_DAY);
    supportLessons.addAll(getSupportLessonsSet());
    return supportLessons;
}

From source file:uk.co.flax.biosolr.ontology.core.ols.OLSOntologyHelper.java

/**
 * Find the IRIs of all terms referenced by a related URL.
 *
 * @param baseUrl the base URL to look up, from a Link or similar
 * query-type URL./*from  w  w w.  j a  va  2  s  .  com*/
 * @return a set of IRIs referencing the terms found for the
 * given URL.
 * @throws OntologyHelperException if problems occur accessing the
 * web service.
 */
protected Set<String> queryWebServiceForTerms(String baseUrl) throws OntologyHelperException {
    updateLastCallTime();
    Set<String> retList;

    // Build URL for first page
    List<String> urls = buildPageUrls(baseUrl, 0, 1);
    // Sort returned calls by page number
    SortedSet<RelatedTermsResult> results = new TreeSet<>(
            (RelatedTermsResult r1, RelatedTermsResult r2) -> r1.getPage().compareTo(r2.getPage()));
    results.addAll(olsClient.callOLS(urls, RelatedTermsResult.class));

    if (results.size() == 0) {
        retList = Collections.emptySet();
    } else {
        Page page = results.first().getPage();
        if (page.getTotalPages() > 1) {
            // Get remaining pages
            urls = buildPageUrls(baseUrl, page.getNumber() + 1, page.getTotalPages());
            results.addAll(olsClient.callOLS(urls, RelatedTermsResult.class));
        }

        retList = new HashSet<>(page.getTotalSize());
        for (RelatedTermsResult result : results) {
            result.getTerms().forEach(t -> {
                terms.put(t.getIri(), t);
                retList.add(t.getIri());
            });
        }
    }

    return retList;
}

From source file:org.eclipse.skalli.model.ext.maven.internal.MavenResolverRunnable.java

private void handleIssue(Severity severity, UUID uuid, String message, Exception e, SortedSet<Issue> issues) {
    if (e != null) {
        LOG.error(message, e);/*from  w w w .  ja va2 s.  c o  m*/
        message = MessageFormat.format("{0} [{1}]", message, e.getMessage()); //$NON-NLS-1$
        if (e instanceof ValidationException) {
            issues.addAll(((ValidationException) e).getIssues());
        }
    } else {
        logIssue(message, severity);
    }
    issues.add(new Issue(severity, MavenResolverRunnable.class, uuid, MavenReactorProjectExt.class, null,
            message));
}

From source file:gov.nih.nci.caintegrator.studyQueryService.germline.ObjectQueryHandler.java

private Collection<Study> executeStudyQuery(String studyCritHQL, StringBuffer studyNameJoin,
        StringBuffer sponsorJoin, StringBuffer versionJoin, StringBuffer idJoin, Session session,
        HashMap params) {/*from w w  w.j  av  a 2 s  . com*/
    String hql = MessageFormat.format(studyCritHQL,
            new Object[] { idJoin, studyNameJoin, sponsorJoin, versionJoin, });
    String tempHQL = HQLHelper.removeTrailingToken(new StringBuffer(hql), "AND");
    String finalHQL = HQLHelper.removeTrailingToken(new StringBuffer(tempHQL), "WHERE");
    Query studyQuery = session.createQuery(finalHQL);
    HQLHelper.setParamsOnQuery(params, studyQuery);
    List results = studyQuery.list();
    SortedSet<Study> s = new TreeSet<Study>(new ObjectComparator.StudyIdComparator());
    s.addAll(results);
    return s;
}

From source file:net.sourceforge.fenixedu.domain.alumni.AlumniReportFile.java

private void addCurriculumDataRow(Spreadsheet sheet, String alumniName, Integer studentNumber,
        Student student) {//from   w w w  .j  a v  a2  s  .  c  om
    Alumni alumni = student.getAlumni();

    // "NOME", "NUMERO_ALUNO", "CURSO", "INICIO", "CONCLUSAO", "DESCRICAO",
    // "EMPREGADO ACTUALMENTE"
    for (Registration registration : student.getRegistrationsSet()) {
        if (registration.isBolonha()) {
            if (registration.hasConcluded()) {
                final SortedSet<CycleCurriculumGroup> concludeCycles = new TreeSet<CycleCurriculumGroup>(
                        CycleCurriculumGroup.COMPARATOR_BY_CYCLE_TYPE_AND_ID);
                concludeCycles
                        .addAll(registration.getLastStudentCurricularPlan().getInternalCycleCurriculumGrops());
                Row row = sheet.addRow();
                row.setCell(alumniName);
                row.setCell(studentNumber);
                row.setCell(registration.getDegreeName());
                row.setCell(registration.getStartDate().toString(DATE_FORMAT));
                final CycleCurriculumGroup lastConcludedCycle = concludeCycles.last();
                try {
                    row.setCell(lastConcludedCycle.isConclusionProcessed()
                            ? lastConcludedCycle.getConclusionDate().toString(DATE_FORMAT)
                            : lastConcludedCycle.calculateConclusionDate().toString(DATE_FORMAT));
                } catch (Exception ex) {
                    row.setCell(NOT_AVAILABLE);
                }
                row.setCell("Bolonha");
                row.setCell(alumni != null && alumni.getIsEmployed() != null
                        ? getApp("label." + alumni.getIsEmployed())
                        : NOT_AVAILABLE);
            }
        } else {
            if (registration.isRegistrationConclusionProcessed()) {
                Row row = sheet.addRow();
                row.setCell(alumniName);
                row.setCell(studentNumber);
                row.setCell(registration.getDegreeName());
                row.setCell(registration.getStartDate().toString(DATE_FORMAT));
                row.setCell(registration.getConclusionDate() != null
                        ? registration.getConclusionDate().toString(DATE_FORMAT)
                        : NOT_AVAILABLE);
                row.setCell("Pre-Bolonha");
                row.setCell(alumni != null && alumni.getIsEmployed() != null
                        ? getApp("label." + alumni.getIsEmployed())
                        : NOT_AVAILABLE);
            }
        }
    }
}

From source file:net.sourceforge.fenixedu.domain.Professorship.java

public SortedSet<DegreeTeachingService> getDegreeTeachingServicesOrderedByShift() {
    final SortedSet<DegreeTeachingService> degreeTeachingServices = new TreeSet<DegreeTeachingService>(
            DegreeTeachingService.DEGREE_TEACHING_SERVICE_COMPARATOR_BY_SHIFT);
    degreeTeachingServices.addAll(getDegreeTeachingServicesSet());
    return degreeTeachingServices;
}

From source file:gov.nih.nci.caarray.application.fileaccess.FileAccessServiceBean.java

private void removeFile(CaArrayFile caArrayFile) {
    // A hibernate bug is preventing us from simply calling caArrayFile.getProject().getFiles().remove(caArrayFile)
    // https://hibernate.onjira.com/browse/HHH-3799
    // The workaround is to clear the collection and re-add everything we don't want to delete.
    // This is in reference to issue ARRAY-2349.
    SortedSet<CaArrayFile> files = caArrayFile.getProject().getFiles();
    SortedSet<CaArrayFile> filesToKeep = new TreeSet<CaArrayFile>();
    Long fileId = caArrayFile.getId();
    for (CaArrayFile file : files) {
        if (!file.getId().equals(fileId)) {
            filesToKeep.add(file);/*from   www .  java  2 s .  c o m*/
        }
    }
    files.clear();
    files.addAll(filesToKeep);
    this.fileDao.remove(caArrayFile);
}

From source file:ch.fork.AdHocRailway.manager.impl.TurnoutManagerImpl.java

@Override
public int getNextFreeTurnoutNumber() {
    LOGGER.debug("getNextFreeTurnoutNumber()");

    if (lastProgrammedNumber == 0) {
        final SortedSet<Turnout> turnoutsNumbers = new TreeSet<Turnout>(new Comparator<Turnout>() {

            @Override/*  w w w  .jav  a  2  s.co m*/
            public int compare(final Turnout o1, final Turnout o2) {
                return Integer.valueOf(o1.getNumber()).compareTo(o2.getNumber());
            }
        });
        turnoutsNumbers.addAll(getAllTurnouts());
        if (turnoutsNumbers.isEmpty()) {
            lastProgrammedNumber = 0;
        } else {
            lastProgrammedNumber = turnoutsNumbers.last().getNumber();
        }
    }

    return lastProgrammedNumber + 1;
}

From source file:org.opencastproject.index.service.resources.list.provider.ContributorsListProvider.java

@Override
public Map<String, Object> getList(String listName, ResourceListQuery query, Organization organization) {
    Map<String, Object> usersList = new HashMap<String, Object>();
    int offset = 0;
    int limit = 0;
    SortedSet<String> contributorsList = new TreeSet<String>(new Comparator<String>() {
        @Override//from  w ww . java2 s  . com
        public int compare(String name1, String name2) {
            return name1.compareTo(name2);
        }
    });

    Iterator<User> users = userDirectoryService.findUsers("%", offset, limit);
    while (users.hasNext()) {
        User u = users.next();
        if (StringUtils.isNotBlank(u.getName()))
            contributorsList.add(u.getName());
    }

    contributorsList.addAll(splitStringList(searchIndex.getTermsForField(EventIndexSchema.CONTRIBUTOR,
            Option.some(new String[] { Event.DOCUMENT_TYPE }))));
    contributorsList.addAll(splitStringList(searchIndex.getTermsForField(EventIndexSchema.PRESENTER,
            Option.some(new String[] { Event.DOCUMENT_TYPE }))));
    contributorsList.addAll(splitStringList(searchIndex.getTermsForField(SeriesIndexSchema.CONTRIBUTORS,
            Option.some(new String[] { Series.DOCUMENT_TYPE }))));
    contributorsList.addAll(splitStringList(searchIndex.getTermsForField(SeriesIndexSchema.ORGANIZERS,
            Option.some(new String[] { Series.DOCUMENT_TYPE }))));
    contributorsList.addAll(splitStringList(searchIndex.getTermsForField(SeriesIndexSchema.PUBLISHERS,
            Option.some(new String[] { Series.DOCUMENT_TYPE }))));

    if (query != null) {
        if (query.getLimit().isSome())
            limit = query.getLimit().get();

        if (query.getOffset().isSome())
            offset = query.getOffset().get();
    }

    int i = 0;

    for (String contributor : contributorsList) {
        if (i >= offset && (limit == 0 || i < limit)) {
            usersList.put(contributor, contributor);
        }
        i++;
    }

    return usersList;
}