List of usage examples for java.util SortedSet addAll
boolean addAll(Collection<? extends E> c);
From source file:io.wcm.config.core.management.impl.ParameterResolverImpl.java
/** * Apply configured values for given configuration id (except those for which the parameter names are locked on a * higher configuration level).//from w ww. j a v a 2 s. com * @param resolver Resource resolver * @param configurationId Configuration id * @param parameterValues Parameter values * @param ancestorLockedParameterNames Set of locked parameter names on the configuration levels above. * @return Set of locked parameter names on this configuration level combined with the from the levels above. */ private SortedSet<String> applyConfiguredValues(ResourceResolver resolver, String configurationId, Map<String, Object> parameterValues, SortedSet<String> ancestorLockedParameterNames) { // get data from persistence ParameterPersistenceData data = parameterPersistence.getData(resolver, configurationId); // ensure the types provided by persistence are valid Map<String, Object> configuredValues = ensureValidValueTypes(data.getValues()); // put parameter values to map (respect locked parameter names that may be defined on ancestor level) if (!ancestorLockedParameterNames.isEmpty()) { for (Map.Entry<String, Object> entry : configuredValues.entrySet()) { if (!ancestorLockedParameterNames.contains(entry.getKey())) { parameterValues.put(entry.getKey(), entry.getValue()); } } } else { parameterValues.putAll(configuredValues); } // aggregate set of locked parameter names from ancestor levels and this level SortedSet<String> lockedParameterNames = ancestorLockedParameterNames; if (!data.getLockedParameterNames().isEmpty()) { lockedParameterNames = new TreeSet<>(); lockedParameterNames.addAll(ancestorLockedParameterNames); lockedParameterNames.addAll(data.getLockedParameterNames()); } return lockedParameterNames; }
From source file:net.sourceforge.fenixedu.domain.alumni.AlumniReportFile.java
public PhysicalAddress getLastPersonalAddress(final Person person) { if (person.getStudent().getAlumni() != null) { return person.getStudent().getAlumni().getLastPersonalAddress(); }/*from ww w.j a va 2 s . com*/ SortedSet<PhysicalAddress> addressSet = new TreeSet<PhysicalAddress>(DomainObjectUtil.COMPARATOR_BY_ID); addressSet.addAll(person.getPhysicalAddresses()); return !addressSet.isEmpty() && addressSet.last() != null ? addressSet.last() : null; }
From source file:cross.datastructures.pipeline.ResultAwareCommandPipeline.java
/** * Used to check, whether any files have changed compared to the last * invocation.// w w w .j a v a 2 s . c o m * * @param inputFiles * @return */ protected String getRecursiveFileHash(Collection<File> inputFiles) { //list files below input and output SortedSet<File> files = new TreeSet<>(); for (File file : inputFiles) { if (file.isDirectory()) { files.addAll(FileUtils.listFiles(file, new String[] { "*" }, true)); } else { files.add(file); } } return digest(files); }
From source file:org.openmrs.module.privilegehelper.web.controller.PrivilegeAssignerController.java
@RequestMapping(value = "/assignRoles", method = RequestMethod.GET) public void assignRoles(@ModelAttribute(PRIVILEGES) final SortedSet<PrivilegeLogEntry> privileges, @ModelAttribute(MISSING_PRIVILEGES) final SortedSet<PrivilegeLogEntry> missingPrivileges, final User user, final ModelMap model) { Map<PrivilegeLogEntry, Boolean[]> rolesByPrivileges = new TreeMap<PrivilegeLogEntry, Boolean[]>(); SortedSet<Role> userRoles = new TreeSet<Role>(new Comparator<Role>() { @Override/* w w w . j a va 2 s. co m*/ public int compare(Role o1, Role o2) { return o1.getName().compareTo(o2.getName()); } }); userRoles.addAll(user.getAllRoles()); for (PrivilegeLogEntry privilege : privileges) { Boolean[] roles = new Boolean[userRoles.size()]; int i = 0; for (Role role : userRoles) { roles[i++] = !role.hasPrivilege(privilege.getPrivilege()); } if (privilege.isRequired()) { //Remove not required privilege if there's a required one. rolesByPrivileges.remove(new PrivilegeLogEntry(user.getUserId(), privilege.getPrivilege(), false, !user.hasPrivilege(privilege.getPrivilege()))); rolesByPrivileges.put(new PrivilegeLogEntry(user.getUserId(), privilege.getPrivilege(), privilege.isRequired(), !user.hasPrivilege(privilege.getPrivilege())), roles); } else { //Add not required privilege only if there's no required one. if (!rolesByPrivileges.containsKey(new PrivilegeLogEntry(user.getUserId(), privilege.getPrivilege(), true, !user.hasPrivilege(privilege.getPrivilege())))) { rolesByPrivileges.put(new PrivilegeLogEntry(user.getUserId(), privilege.getPrivilege(), privilege.isRequired(), !user.hasPrivilege(privilege.getPrivilege())), roles); } } } SortedSet<String> roles = new TreeSet<String>(); for (Role role : userRoles) { roles.add(role.getName()); } model.addAttribute("roles", roles); model.addAttribute("rolesByPrivileges", rolesByPrivileges); model.addAttribute("user", user); }
From source file:org.squashtest.tm.service.internal.infolist.InfoListManagerServiceImpl.java
/** * @see org.squashtest.tm.service.infolist.InfoListManagerService#findAllWithBoundInfo() *//*from w w w . j av a 2s . co m*/ @Override @Transactional(readOnly = true) public List<IsBoundInfoListAdapter> findAllWithBoundInfo() { List<IsBoundInfoListAdapter> unbound = createBoundAdapters(infoListDao.findAllUnbound(), false); List<IsBoundInfoListAdapter> bound = createBoundAdapters(infoListDao.findAllBound(), true); SortedSet<IsBoundInfoListAdapter> res = new TreeSet<>(new Comparator<IsBoundInfoListAdapter>() { @Override public int compare(IsBoundInfoListAdapter kore, IsBoundInfoListAdapter sore) { return kore.getLabel().compareTo(sore.getLabel()); } }); res.addAll(bound); res.addAll(unbound); return filterSystemLists(res); }
From source file:com.gopivotal.cla.web.RepositoriesController.java
private SortedSet<Repository> getAdminRepositories() { SortedSet<Repository> adminRepositories = new TreeSet<>(); for (Organization organization : this.gitHubClient.getUser().getOrganizations()) { for (Repository repository : organization.getRepositories()) { if (repository.getPermissions().isAdmin()) { adminRepositories.add(repository); }/* ww w. j a v a 2 s .c o m*/ } } adminRepositories.addAll(this.gitHubClient.getUser().getRepositories()); return adminRepositories; }
From source file:com.ngdata.sep.tools.monitoring.ReplicationStatusRetriever.java
public ReplicationStatus collectStatusFromZooKeepeer() throws Exception { Map<String, Map<String, Status>> statusByPeerAndServer = Maps.newHashMap(); String regionServerPath = "/hbase/replication/rs"; List<String> regionServers = zk.getChildren(regionServerPath, false); for (String server : regionServers) { String peersPath = regionServerPath + "/" + server; List<String> peers; try {/*from w w w. j a v a 2 s . c o m*/ peers = zk.getChildren(peersPath, false); } catch (KeeperException.NoNodeException e) { // server was removed since we called getChildren, skip it continue; } for (String peer : peers) { // The peer nodes are either real peers or recovered queues, we make no distinction for now String hlogsPath = peersPath + "/" + peer; SortedSet<String> logs; try { // The hlogs are not correctly sorted when we get them from ZK logs = new TreeSet<String>(Collections.reverseOrder()); logs.addAll(zk.getChildren(hlogsPath, false)); } catch (KeeperException.NoNodeException e) { // peer was removed since we called getChildren, skip it continue; } for (String log : logs) { Map<String, Status> statusByServer = statusByPeerAndServer.get(peer); if (statusByServer == null) { statusByServer = new TreeMap<String, Status>(); statusByPeerAndServer.put(peer, statusByServer); } Status status = statusByServer.get(server); if (status == null) { status = new Status(); statusByServer.put(server, status); } try { Stat stat = new Stat(); byte[] data = zk.getData(hlogsPath + "/" + log, false, stat); // Determine position in hlog, if already started on the hlog long position = -1; if (data != null && data.length > 0) { data = removeMetaData(data); position = Long.parseLong(new String(data, "UTF-8")); } HLogInfo hlogInfo = new HLogInfo(log); hlogInfo.size = getLogFileSize(server, log); hlogInfo.position = position; status.hlogs.add(hlogInfo); } catch (KeeperException.NoNodeException e) { // fine, node was removed since we called getChildren } } } } return new ReplicationStatus(statusByPeerAndServer); }
From source file:org.neo4j.gis.spatial.OsmAnalysisTest.java
private SortedSet<User> getTopTen(Map<String, User> userIndex) { SortedSet<User> userList = new TreeSet<User>(); userList.addAll(userIndex.values()); // for (String name : userIndex.keySet()) { // userList.add(userIndex.get(name)); // }/* w ww . j ava 2s . co m*/ SortedSet<User> topTen = new TreeSet<User>(); int count = 0; for (User user : userList) { if (count < 10) { topTen.add(user); user.internalId = count++; } else { break; } } for (User user : topTen) { System.out.println(user.id + "# " + user.name + " = " + user.changesets.size()); } return topTen; }
From source file:net.sourceforge.fenixedu.presentationTier.docs.academicAdministrativeOffice.DegreeFinalizationCertificate.java
final private String getDegreeFinalizationInfo(final DegreeFinalizationCertificateRequest request) { final StringBuilder result = new StringBuilder(); if (request.getDetailed()) { final SortedSet<ICurriculumEntry> entries = new TreeSet<ICurriculumEntry>( ICurriculumEntry.COMPARATOR_BY_EXECUTION_PERIOD_AND_NAME_AND_ID); entries.addAll(request.getEntriesToReport()); final Map<Unit, String> academicUnitIdentifiers = new HashMap<Unit, String>(); reportEntries(result, entries, academicUnitIdentifiers); if (getDocumentRequest().isToShowCredits()) { result.append(getRemainingCreditsInfo(request.getCurriculum())); }//from w w w . j ava 2 s.co m result.append(generateEndLine()); if (!academicUnitIdentifiers.isEmpty()) { result.append(LINE_BREAK) .append(getAcademicUnitInfo(academicUnitIdentifiers, request.getMobilityProgram())); } } return result.toString(); }
From source file:org.rhq.enterprise.server.test.AbstractEJB3PerformanceTest.java
protected void printTimings(String testName) { System.out.println("=== " + testName + " ==="); Set<Map.Entry<String, Long>> data = timings.entrySet(); SortedSet<Map.Entry<String, Long>> sorted = new TreeSet<Map.Entry<String, Long>>( new Comparator<Map.Entry<String, Long>>() { public int compare(Map.Entry<String, Long> item1, Map.Entry<String, Long> item2) { return item1.getKey().compareTo(item2.getKey()); }//from ww w.j a v a 2s.com }); sorted.addAll(data); long summaryTime = 0L; for (Map.Entry<String, Long> item : sorted) { log.info(":| " + item.getKey() + " => " + item.getValue()); System.out.println(":| " + item.getKey() + " => " + item.getValue()); summaryTime += item.getValue(); } System.out.println("Total: " + summaryTime + " ms"); }