List of usage examples for java.util SortedSet addAll
boolean addAll(Collection<? extends E> c);
From source file:edu.harvard.med.screensaver.model.screenresults.ScreenResult.java
private SortedSet<AssayPlate> findOrCreateAssayPlatesDataLoaded(int plateNumber, int replicatesDataLoaded) { SortedSet<AssayPlate> mostRecentAssayPlatesForPlateNumber = Sets.newTreeSet(); SortedSet<AssayPlate> allAssayPlatesForPlateNumber = getScreen().findAssayPlates(plateNumber); if (!allAssayPlatesForPlateNumber.isEmpty()) { final LibraryScreening lastLibraryScreening = ImmutableSortedSet .copyOf(Iterables.transform(allAssayPlatesForPlateNumber, AssayPlate.ToLibraryScreening)) .last();//from w w w . j a v a 2s . co m assert lastLibraryScreening != null; mostRecentAssayPlatesForPlateNumber .addAll(Sets.filter(allAssayPlatesForPlateNumber, new Predicate<AssayPlate>() { public boolean apply(AssayPlate ap) { return lastLibraryScreening.equals(ap.getLibraryScreening()); } })); } SortedSet<AssayPlate> assayPlatesDataLoaded = Sets.newTreeSet(); // if there are fewer assay plates screened replicates than we have data // for, then a library screening must not have been recorded for the assay // plates that were used to generate this data, so we'll create them now if (mostRecentAssayPlatesForPlateNumber.size() < replicatesDataLoaded) { //log.warn("creating missing assay plate(s) for plate number " + plateNumber); for (int r = 0; r < replicatesDataLoaded; r++) { assayPlatesDataLoaded.add(getScreen().createAssayPlate(plateNumber, r)); } } else { for (AssayPlate assayPlate : mostRecentAssayPlatesForPlateNumber) { if (assayPlate.getReplicateOrdinal() < replicatesDataLoaded) { assayPlatesDataLoaded.add(assayPlate); } } } return assayPlatesDataLoaded; }
From source file:fr.cnes.sitools.proxy.AbstractDirectoryServerResource.java
/** * Returns the list of variants for the given method. * //from w w w .j a v a 2 s . c o m * @param method * The related method. * @return The list of variants for the given method. * * @see DirectoryServerResource.getVariants(Method method) */ public List<Variant> getVariants(Method method) { List<Variant> result = null; if ((Method.GET.equals(method) || Method.HEAD.equals(method))) { if (variantsGet != null) { result = variantsGet; } else { getLogger().fine("Getting variants for : " + getTargetUri()); if ((this.getDirectoryContent() != null) && (getReference() != null) && (getReference().getBaseRef() != null)) { // Allows to sort the list of representations SortedSet<Representation> resultSet = new TreeSet<Representation>( getRepresentationsComparator()); // Compute the base reference (from a call's client point of // view) String baseRef = getReference().getBaseRef().toString(false, false); if (!baseRef.endsWith("/")) { baseRef += "/"; } int lastIndex = this.relativePart.lastIndexOf("/"); if (lastIndex != -1) { baseRef += this.relativePart.substring(0, lastIndex); } int rootLength = getDirectoryUri().length(); if (this.getBaseName() != null) { String filePath; for (Reference ref : getVariantsReferences()) { // Add the new variant to the result list Response contextResponse = getRepresentation(ref.toString()); if (contextResponse.getStatus().isSuccess() && (contextResponse.getEntity() != null)) { filePath = ref.toString(false, false).substring(rootLength); Representation rep = contextResponse.getEntity(); if (filePath.startsWith("/")) { rep.setLocationRef(baseRef + filePath); } else { rep.setLocationRef(baseRef + "/" + filePath); } resultSet.add(rep); } } } if (!resultSet.isEmpty()) { result = new ArrayList<Variant>(resultSet); } if (resultSet.isEmpty()) { if (isDirectoryTarget() && getDirectory().isListingAllowed()) { ReferenceFileList userList = new ReferenceFileList(this.getDirectoryContent().size()); // Set the list identifier userList.setIdentifier(baseRef); userList.setRegexp(directory.getRegexp()); SortedSet<Reference> sortedSet = new TreeSet<Reference>(getDirectory().getComparator()); sortedSet.addAll(this.getDirectoryContent()); for (Reference ref : sortedSet) { String filePart = ref.toString(false, false).substring(rootLength); StringBuilder filePath = new StringBuilder(); if ((!baseRef.endsWith("/")) && (!filePart.startsWith("/"))) { filePath.append('/'); } filePath.append(filePart); // SITOOLS2 - ReferenceFileList = reference and File String path = ref.getPath(); String repertoire = Reference.decode(path); File file = new File(repertoire); userList.addFileReference(baseRef + filePath, file); // SITOOLS2 instead of simple reference : userList.add(baseRef + filePath); } List<Variant> list = getDirectory().getIndexVariants(userList); for (Variant variant : list) { if (result == null) { result = new ArrayList<Variant>(); } result.add(getDirectory().getIndexRepresentation(variant, userList)); } } } } else if (isFileTarget() && (this.fileContent != null)) { // Sets the location of the target representation. if (getOriginalRef() != null) { this.fileContent.setLocationRef(getRequest().getOriginalRef()); } else { this.fileContent.setLocationRef(getReference()); } result = new ArrayList<Variant>(); result.add(this.fileContent); } this.variantsGet = result; } } return result; }
From source file:org.jasig.ssp.service.impl.PersonServiceImpl.java
@Override public SortedSet<Person> getAllCurrentCoaches(Comparator<Person> sortBy) { final Collection<Person> officialCoaches = getAllCoaches(null).getRows(); SortedSet<Person> currentCoachesSet = Sets .newTreeSet(sortBy == null ? Person.PERSON_NAME_AND_ID_COMPARATOR : sortBy); currentCoachesSet.addAll(officialCoaches); final Collection<Person> assignedCoaches = getAllAssignedCoaches(null).getRows(); currentCoachesSet.addAll(assignedCoaches); return currentCoachesSet; }
From source file:com.espertech.esper.core.deploy.EPDeploymentAdminImpl.java
public synchronized DeploymentOrder getDeploymentOrder(Collection<Module> modules, DeploymentOrderOptions options) throws DeploymentOrderException { if (options == null) { options = new DeploymentOrderOptions(); }//from w w w . j a v a2s .c o m String[] deployments = deploymentStateService.getDeployments(); List<Module> proposedModules = new ArrayList<Module>(); proposedModules.addAll(modules); Set<String> availableModuleNames = new HashSet<String>(); for (Module proposedModule : proposedModules) { if (proposedModule.getName() != null) { availableModuleNames.add(proposedModule.getName()); } } // Collect all uses-dependencies of existing modules Map<String, Set<String>> usesPerModuleName = new HashMap<String, Set<String>>(); for (String deployment : deployments) { DeploymentInformation info = deploymentStateService.getDeployment(deployment); if (info == null) { continue; } if ((info.getModule().getName() == null) || (info.getModule().getUses() == null)) { continue; } Set<String> usesSet = usesPerModuleName.get(info.getModule().getName()); if (usesSet == null) { usesSet = new HashSet<String>(); usesPerModuleName.put(info.getModule().getName(), usesSet); } usesSet.addAll(info.getModule().getUses()); } // Collect uses-dependencies of proposed modules for (Module proposedModule : proposedModules) { // check uses-dependency is available if (options.isCheckUses()) { if (proposedModule.getUses() != null) { for (String uses : proposedModule.getUses()) { if (availableModuleNames.contains(uses)) { continue; } if (isDeployed(uses)) { continue; } String message = "Module-dependency not found"; if (proposedModule.getName() != null) { message += " as declared by module '" + proposedModule.getName() + "'"; } message += " for uses-declaration '" + uses + "'"; throw new DeploymentOrderException(message); } } } if ((proposedModule.getName() == null) || (proposedModule.getUses() == null)) { continue; } Set<String> usesSet = usesPerModuleName.get(proposedModule.getName()); if (usesSet == null) { usesSet = new HashSet<String>(); usesPerModuleName.put(proposedModule.getName(), usesSet); } usesSet.addAll(proposedModule.getUses()); } Map<String, SortedSet<Integer>> proposedModuleNames = new HashMap<String, SortedSet<Integer>>(); int count = 0; for (Module proposedModule : proposedModules) { SortedSet<Integer> moduleNumbers = proposedModuleNames.get(proposedModule.getName()); if (moduleNumbers == null) { moduleNumbers = new TreeSet<Integer>(); proposedModuleNames.put(proposedModule.getName(), moduleNumbers); } moduleNumbers.add(count); count++; } DependencyGraph graph = new DependencyGraph(proposedModules.size(), false); int fromModule = 0; for (Module proposedModule : proposedModules) { if ((proposedModule.getUses() == null) || (proposedModule.getUses().isEmpty())) { fromModule++; continue; } SortedSet<Integer> dependentModuleNumbers = new TreeSet<Integer>(); for (String use : proposedModule.getUses()) { SortedSet<Integer> moduleNumbers = proposedModuleNames.get(use); if (moduleNumbers == null) { continue; } dependentModuleNumbers.addAll(moduleNumbers); } dependentModuleNumbers.remove(fromModule); graph.addDependency(fromModule, dependentModuleNumbers); fromModule++; } if (options.isCheckCircularDependency()) { Stack<Integer> circular = graph.getFirstCircularDependency(); if (circular != null) { String message = ""; String delimiter = ""; for (int i : circular) { message += delimiter; message += "module '" + proposedModules.get(i).getName() + "'"; delimiter = " uses (depends on) "; } throw new DeploymentOrderException( "Circular dependency detected in module uses-relationships: " + message); } } List<Module> reverseDeployList = new ArrayList<Module>(); Set<Integer> ignoreList = new HashSet<Integer>(); while (ignoreList.size() < proposedModules.size()) { // seconardy sort according to the order of listing Set<Integer> rootNodes = new TreeSet<Integer>(new Comparator<Integer>() { public int compare(Integer o1, Integer o2) { return -1 * o1.compareTo(o2); } }); rootNodes.addAll(graph.getRootNodes(ignoreList)); if (rootNodes.isEmpty()) { // circular dependency could cause this for (int i = 0; i < proposedModules.size(); i++) { if (!ignoreList.contains(i)) { rootNodes.add(i); break; } } } for (Integer root : rootNodes) { ignoreList.add(root); reverseDeployList.add(proposedModules.get(root)); } } Collections.reverse(reverseDeployList); return new DeploymentOrder(reverseDeployList); }
From source file:nl.minbzk.dwr.zoeken.enricher.processor.UIMAInjector.java
private void orderTypes(final String detectedLanguage, final ProcessorContent processorOutput, final Map<String, Map<String, Integer>> annotationsWithCounts) { // Ordered by their occurrence for (Entry<String, Map<String, Integer>> fieldWithEntities : annotationsWithCounts.entrySet()) { List<String> entities = new ArrayList<String>(fieldWithEntities.getValue().size()); SortedSet<Entry<String, Integer>> sortedEntities = new TreeSet<Entry<String, Integer>>( new Comparator<Entry<String, Integer>>() { @Override// w w w.ja va2s. co m public int compare(final Entry<String, Integer> e1, final Entry<String, Integer> e2) { int result = e2.getValue().compareTo(e1.getValue()); return result != 0 ? result : 1; } }); sortedEntities.addAll(fieldWithEntities.getValue().entrySet()); for (Entry<String, Integer> sortedEntity : sortedEntities) { if (logger.isDebugEnabled()) logger.debug("Adding sorted entity '" + sortedEntity.getKey() + "' to entity list for field '" + fieldWithEntities.getKey() + "-" + detectedLanguage + "'"); entities.add(sortedEntity.getKey()); } logger.info("[ORDERED] " + fieldWithEntities.getKey() + "-" + detectedLanguage + " : " + entities); processorOutput.getMetadata().put(fieldWithEntities.getKey() + "-" + detectedLanguage, entities); } }
From source file:org.fenixedu.ulisboa.specifications.domain.evaluation.markSheet.CompetenceCourseMarkSheet.java
public SortedSet<EnrolmentEvaluation> getSortedEnrolmentEvaluations() { final Comparator<EnrolmentEvaluation> byStudentName = (x, y) -> CompetenceCourseMarkSheet.COMPARATOR_FOR_STUDENT_NAME.compare( x.getRegistration().getStudent().getName(), y.getRegistration().getStudent().getName()); final SortedSet<EnrolmentEvaluation> result = Sets .newTreeSet(byStudentName.thenComparing(DomainObjectUtil.COMPARATOR_BY_ID)); result.addAll(getEnrolmentEvaluationSet()); return result; }
From source file:org.eclipse.skalli.core.rest.admin.StatisticsConverter.java
private Map<String, SortedSet<Member>> collectUniqueMembers(ProjectService projectService, List<UUID> uuids) { Map<String, SortedSet<Member>> uniqueMembers = new HashMap<String, SortedSet<Member>>(); for (UUID uuid : uuids) { Map<String, SortedSet<Member>> membersByRole = projectService.getMembersByRole(uuid); for (Entry<String, SortedSet<Member>> entry : membersByRole.entrySet()) { SortedSet<Member> members = uniqueMembers.get(entry.getKey()); if (members == null) { members = new TreeSet<Member>(); uniqueMembers.put(entry.getKey(), members); }/*from ww w. jav a 2s .com*/ members.addAll(entry.getValue()); } } return uniqueMembers; }
From source file:org.jasig.ssp.service.impl.PersonServiceImpl.java
@Override public SortedSet<CoachPersonLiteTO> getAllCurrentCoachesLite(Comparator<CoachPersonLiteTO> sortBy) { final Collection<CoachPersonLiteTO> officialCoaches = getAllCoachesLite(null).getRows(); SortedSet<CoachPersonLiteTO> currentCoachesSet = Sets.newTreeSet( sortBy == null ? CoachPersonLiteTO.COACH_PERSON_LITE_TO_NAME_AND_ID_COMPARATOR : sortBy); currentCoachesSet.addAll(officialCoaches); final Collection<CoachPersonLiteTO> assignedCoaches = getAllAssignedCoachesLite(null).getRows(); currentCoachesSet.addAll(assignedCoaches); return currentCoachesSet; }
From source file:org.jasig.ssp.service.impl.PersonServiceImpl.java
@Override public SortedSet<CoachPersonLiteTO> getAllCurrentCoachesLite(Comparator<CoachPersonLiteTO> sortBy, String homeDepartment) {/*from w ww.jav a2s . com*/ final Collection<CoachPersonLiteTO> officialCoaches = getAllCoachesLite(null, homeDepartment).getRows(); SortedSet<CoachPersonLiteTO> currentCoachesSet = Sets.newTreeSet( sortBy == null ? CoachPersonLiteTO.COACH_PERSON_LITE_TO_NAME_AND_ID_COMPARATOR : sortBy); currentCoachesSet.addAll(officialCoaches); final Collection<CoachPersonLiteTO> assignedCoaches = getAllAssignedCoachesLite(null, homeDepartment) .getRows(); currentCoachesSet.addAll(assignedCoaches); return currentCoachesSet; }
From source file:org.fenixedu.ulisboa.specifications.domain.evaluation.markSheet.CompetenceCourseMarkSheet.java
public SortedSet<CompetenceCourseMarkSheetChangeRequest> getSortedChangeRequests() { final SortedSet<CompetenceCourseMarkSheetChangeRequest> result = Sets .newTreeSet(CompetenceCourseMarkSheetChangeRequest.COMPARATOR_BY_REQUEST_DATE.reversed()); result.addAll(getChangeRequestsSet()); return result; }