Search in sources :

Example 41 with SortedSet

use of java.util.SortedSet in project uPortal by Jasig.

the class ChannelListController method getRegistry43.

/*
     * Private methods that support the 4.3 version of the API
     */
/**
 * Gathers and organizes the response based on the specified rootCategory and the permissions of
 * the specified user.
 */
private Map<String, SortedSet<?>> getRegistry43(WebRequest request, IPerson user, PortletCategory rootCategory, boolean includeUncategorized) {
    /*
         * This collection of all the portlets in the portal is for the sake of
         * tracking which ones are uncategorized.  They will be added to the
         * output if includeUncategorized=true.
         */
    Set<IPortletDefinition> portletsNotYetCategorized = includeUncategorized ? new HashSet<IPortletDefinition>(portletDefinitionRegistry.getAllPortletDefinitions()) : new HashSet<// Not necessary to fetch them if we're not
    IPortletDefinition>();
    // tracking them
    // construct a new channel registry
    Map<String, SortedSet<?>> rslt = new TreeMap<String, SortedSet<?>>();
    SortedSet<PortletCategoryBean> categories = new TreeSet<PortletCategoryBean>();
    // add the root category and all its children to the registry
    final Locale locale = getUserLocale(user);
    categories.add(preparePortletCategoryBean(request, rootCategory, portletsNotYetCategorized, user, locale));
    if (includeUncategorized) {
        /*
             * uPortal historically has provided for a convention that portlets not in any category
             * may potentially be viewed by users but may not be subscribed to.
             *
             * As of uPortal 4.2, the logic below now takes any portlets the user has BROWSE access to
             * that have not already been identified as belonging to a category and adds them to a category
             * called Uncategorized.
             */
        EntityIdentifier ei = user.getEntityIdentifier();
        IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
        Set<PortletDefinitionBean> marketplacePortlets = new HashSet<>();
        for (IPortletDefinition portlet : portletsNotYetCategorized) {
            if (authorizationService.canPrincipalBrowse(ap, portlet)) {
                PortletDefinitionBean pdb = preparePortletDefinitionBean(request, portlet, locale);
                marketplacePortlets.add(pdb);
            }
        }
        // construct a new channel category bean for this category
        final String uncName = messageSource.getMessage(UNCATEGORIZED, new Object[] {}, locale);
        final String uncDescription = messageSource.getMessage(UNCATEGORIZED_DESC, new Object[] {}, locale);
        PortletCategory pc = new PortletCategory(// Use of this String for Id matches earlier version of API
        uncName);
        pc.setName(uncName);
        pc.setDescription(uncDescription);
        PortletCategoryBean unc = PortletCategoryBean.fromPortletCategory(pc, null, marketplacePortlets);
        // Add even if no portlets in category
        categories.add(unc);
    }
    rslt.put("categories", categories);
    return rslt;
}
Also used : Locale(java.util.Locale) EntityIdentifier(org.apereo.portal.EntityIdentifier) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) PortletCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean) TreeSet(java.util.TreeSet) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

Example 42 with SortedSet

use of java.util.SortedSet in project felix by apache.

the class ConfigurationAdminConfigurationPrinter method printConfiguration.

private void printConfiguration(PrintWriter pw, Configuration config) {
    ConfigurationRender.infoLine(pw, "", "PID", config.getPid());
    if (config.getFactoryPid() != null) {
        ConfigurationRender.infoLine(pw, "  ", "Factory PID", config.getFactoryPid());
    }
    String loc = (config.getBundleLocation() != null) ? config.getBundleLocation() : "Unbound";
    ConfigurationRender.infoLine(pw, "  ", "BundleLocation", loc);
    Dictionary props = config.getProperties();
    if (props != null) {
        SortedSet keys = new TreeSet();
        for (Enumeration ke = props.keys(); ke.hasMoreElements(); ) {
            keys.add(ke.nextElement());
        }
        for (Iterator ki = keys.iterator(); ki.hasNext(); ) {
            String key = (String) ki.next();
            ConfigurationRender.infoLine(pw, "  ", key, props.get(key));
        }
    }
    pw.println();
}
Also used : Dictionary(java.util.Dictionary) Enumeration(java.util.Enumeration) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) SortedSet(java.util.SortedSet)

Example 43 with SortedSet

use of java.util.SortedSet in project processdash by dtuma.

the class AbstractLabelColumn method getValuesInUse.

protected Set<String> getValuesInUse() {
    SortedSet values = new TreeSet();
    collectValuesInUse(values, wbsModel.getRoot());
    return values;
}
Also used : TreeSet(java.util.TreeSet) SortedSet(java.util.SortedSet)

Example 44 with SortedSet

use of java.util.SortedSet in project gatk by broadinstitute.

the class RecalibrationReport method logTablesWithMissingReadGroups.

/**
     * helper function to output log messages if there are tables that are missing read groups that were seen in the other tables
     * @param allReadGroups a set of all of the read groups across inputs
     * @param inputReadGroups a map from file to the read groups that file contains
     */
private static void logTablesWithMissingReadGroups(SortedSet<String> allReadGroups, Map<File, Set<String>> inputReadGroups) {
    // Log the read groups that are missing from specific inputs
    for (final Map.Entry<File, Set<String>> entry : inputReadGroups.entrySet()) {
        final File input = entry.getKey();
        final Set<String> readGroups = entry.getValue();
        if (allReadGroups.size() != readGroups.size()) {
            // Since this is not completely unexpected, more than debug, but less than a proper warning.
            logger.info("Missing read group(s)" + ": " + input.getAbsolutePath());
            for (final Object readGroup : CollectionUtils.subtract(allReadGroups, readGroups)) {
                logger.info("  " + readGroup);
            }
        }
    }
}
Also used : SortedSet(java.util.SortedSet) TreeSet(java.util.TreeSet) Set(java.util.Set) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File)

Example 45 with SortedSet

use of java.util.SortedSet in project bnd by bndtools.

the class Project method getBundlesWildcard.

/**
	 * Get all bundles matching a wildcard expression.
	 *
	 * @param bsnPattern A bsn wildcard, e.g. "osgi*" or just "*".
	 * @param range A range to narrow the versions of bundles found, or null to
	 *            return any version.
	 * @param strategyx The version selection strategy, which may be 'HIGHEST'
	 *            or 'LOWEST' only -- 'EXACT' is not permitted.
	 * @param attrs Additional search attributes.
	 * @throws Exception
	 */
public List<Container> getBundlesWildcard(String bsnPattern, String range, Strategy strategyx, Map<String, String> attrs) throws Exception {
    if (VERSION_ATTR_SNAPSHOT.equals(range) || VERSION_ATTR_PROJECT.equals(range))
        return Collections.singletonList(new Container(this, bsnPattern, range, TYPE.ERROR, null, "Cannot use snapshot or project version with wildcard matches", null, null));
    if (strategyx == Strategy.EXACT)
        return Collections.singletonList(new Container(this, bsnPattern, range, TYPE.ERROR, null, "Cannot use exact version strategy with wildcard matches", null, null));
    VersionRange versionRange;
    if (range == null || VERSION_ATTR_LATEST.equals(range))
        versionRange = new VersionRange("0");
    else
        versionRange = new VersionRange(range);
    RepoFilter repoFilter = parseRepoFilter(attrs);
    if (bsnPattern != null) {
        bsnPattern = bsnPattern.trim();
        if (bsnPattern.length() == 0 || bsnPattern.equals("*"))
            bsnPattern = null;
    }
    SortedMap<String, Pair<Version, RepositoryPlugin>> providerMap = new TreeMap<String, Pair<Version, RepositoryPlugin>>();
    List<RepositoryPlugin> plugins = workspace.getRepositories();
    for (RepositoryPlugin plugin : plugins) {
        if (repoFilter != null && !repoFilter.match(plugin))
            continue;
        List<String> bsns = plugin.list(bsnPattern);
        if (bsns != null)
            for (String bsn : bsns) {
                SortedSet<Version> versions = plugin.versions(bsn);
                if (versions != null && !versions.isEmpty()) {
                    Pair<Version, RepositoryPlugin> currentProvider = providerMap.get(bsn);
                    Version candidate;
                    switch(strategyx) {
                        case HIGHEST:
                            candidate = versions.last();
                            if (currentProvider == null || candidate.compareTo(currentProvider.getFirst()) > 0) {
                                providerMap.put(bsn, new Pair<Version, RepositoryPlugin>(candidate, plugin));
                            }
                            break;
                        case LOWEST:
                            candidate = versions.first();
                            if (currentProvider == null || candidate.compareTo(currentProvider.getFirst()) < 0) {
                                providerMap.put(bsn, new Pair<Version, RepositoryPlugin>(candidate, plugin));
                            }
                            break;
                        default:
                            // we shouldn't have reached this point!
                            throw new IllegalStateException("Cannot use exact version strategy with wildcard matches");
                    }
                }
            }
    }
    List<Container> containers = new ArrayList<Container>(providerMap.size());
    for (Entry<String, Pair<Version, RepositoryPlugin>> entry : providerMap.entrySet()) {
        String bsn = entry.getKey();
        Version version = entry.getValue().getFirst();
        RepositoryPlugin repo = entry.getValue().getSecond();
        DownloadBlocker downloadBlocker = new DownloadBlocker(this);
        File bundle = repo.get(bsn, version, attrs, downloadBlocker);
        if (bundle != null && !bundle.getName().endsWith(".lib")) {
            containers.add(new Container(this, bsn, range, Container.TYPE.REPO, bundle, null, attrs, downloadBlocker));
        }
    }
    return containers;
}
Also used : ArrayList(java.util.ArrayList) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) VersionRange(aQute.bnd.version.VersionRange) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) Version(aQute.bnd.version.Version) File(java.io.File) Pair(aQute.libg.tuple.Pair)

Aggregations

SortedSet (java.util.SortedSet)377 TreeSet (java.util.TreeSet)174 Iterator (java.util.Iterator)116 HashMap (java.util.HashMap)94 Map (java.util.Map)94 Set (java.util.Set)90 ArrayList (java.util.ArrayList)78 List (java.util.List)78 TreeMap (java.util.TreeMap)61 HashSet (java.util.HashSet)60 IOException (java.io.IOException)58 NavigableSet (java.util.NavigableSet)56 Test (org.junit.Test)50 Collectors (java.util.stream.Collectors)35 Collections (java.util.Collections)34 SortedMap (java.util.SortedMap)31 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)30 Comparator (java.util.Comparator)30 File (java.io.File)28 Collection (java.util.Collection)28