Search in sources :

Example 6 with PortletCategoryBean

use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.

the class PortletCategoryBeanTest method testCompareToDifferent.

@Test
public void testCompareToDifferent() {
    String name1 = "name1";
    String name2 = "name2";
    PortletCategoryBean pcb1 = buildTestPortletCategoryBean("id1", name1, "desc");
    PortletCategoryBean pcb2 = buildTestPortletCategoryBean("id1", name2, "desc");
    assertEquals(name1.compareTo(name2), pcb1.compareTo(pcb2));
}
Also used : PortletCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean) Test(org.junit.Test)

Example 7 with PortletCategoryBean

use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.

the class PortletCategoryBeanTest method testCompareToSimilar.

@Test
public void testCompareToSimilar() {
    String name1 = "name1";
    String name2 = "name1";
    PortletCategoryBean pcb1 = buildTestPortletCategoryBean("id1", name1, "desc");
    PortletCategoryBean pcb2 = buildTestPortletCategoryBean("id1", name2, "desc");
    assertEquals(name1.compareTo(name2), pcb1.compareTo(pcb2));
}
Also used : PortletCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean) Test(org.junit.Test)

Example 8 with PortletCategoryBean

use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.

the class ChannelListController method preparePortletCategoryBean.

private PortletCategoryBean preparePortletCategoryBean(WebRequest req, PortletCategory category, Set<IPortletDefinition> portletsNotYetCategorized, IPerson user, Locale locale, Set<IPortletDefinition> favorites) {
    /* Prepare child categories. */
    Set<PortletCategoryBean> subcategories = new HashSet<>();
    for (PortletCategory childCategory : this.portletCategoryRegistry.getChildCategories(category)) {
        PortletCategoryBean childBean = preparePortletCategoryBean(req, childCategory, portletsNotYetCategorized, user, locale, favorites);
        subcategories.add(childBean);
    }
    // add the direct child channels for this category
    Set<IPortletDefinition> portlets = portletCategoryRegistry.getChildPortlets(category);
    EntityIdentifier ei = user.getEntityIdentifier();
    IAuthorizationPrincipal ap = AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
    Set<PortletDefinitionBean> marketplacePortlets = new HashSet<>();
    for (IPortletDefinition portlet : portlets) {
        if (authorizationService.canPrincipalBrowse(ap, portlet)) {
            PortletDefinitionBean pdb = preparePortletDefinitionBean(req, portlet, locale, favorites.contains(portlet));
            marketplacePortlets.add(pdb);
        }
        /*
             * Remove the portlet from the uncategorized collection;
             * note -- this approach will not prevent portlets from
             * appearing in multiple categories (as appropriate).
             */
        portletsNotYetCategorized.remove(portlet);
    }
    // construct a new portlet category bean for this category
    PortletCategoryBean categoryBean = PortletCategoryBean.fromPortletCategory(category, subcategories, marketplacePortlets);
    categoryBean.setName(messageSource.getMessage(category.getName(), new Object[] {}, locale));
    return categoryBean;
}
Also used : PortletCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) EntityIdentifier(org.apereo.portal.EntityIdentifier) PortletDefinitionBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean) HashSet(java.util.HashSet) PortletCategory(org.apereo.portal.portlet.om.PortletCategory) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 9 with PortletCategoryBean

use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.

the class ChannelListController method filterRegistryFavoritesOnly.

private Map<String, SortedSet<PortletCategoryBean>> filterRegistryFavoritesOnly(Map<String, SortedSet<PortletCategoryBean>> registry) {
    final Set<PortletCategoryBean> inpt = registry.get(CATEGORIES_MAP_KEY);
    final SortedSet<PortletCategoryBean> otpt = new TreeSet<>();
    inpt.forEach(categoryIn -> {
        final PortletCategoryBean categoryOut = filterCategoryFavoritesOnly(categoryIn);
        if (categoryOut != null) {
            otpt.add(categoryOut);
        }
    });
    final Map<String, SortedSet<PortletCategoryBean>> rslt = new TreeMap<>();
    rslt.put(CATEGORIES_MAP_KEY, otpt);
    return rslt;
}
Also used : PortletCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean) TreeSet(java.util.TreeSet) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet)

Example 10 with PortletCategoryBean

use of org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean in project uPortal by Jasig.

the class PortletCategoryBeanTest method testFromPortletCategoryInflatedSubCatsAndPortlets.

@Test
public void testFromPortletCategoryInflatedSubCatsAndPortlets() {
    String id = "id_test";
    String name = "name_test";
    String desc = "desc_test";
    String cat1id = "cat1_id_test";
    String cat1name = "cat1_name_test";
    String cat1desc = "cat1_desc_test";
    PortletCategoryBean pcb = buildTestPortletCategoryBean(id, name, desc, cat1id, cat1name, cat1desc);
    assertEquals(id, pcb.getId());
    assertEquals(name, pcb.getName());
    assertEquals(desc, pcb.getDescription());
    // Check the portlets set
    assertEquals(Collections.emptySet(), pcb.getPortlets());
    // Check the subCat set
    assertEquals(1, pcb.getSubcategories().size());
    assertEquals(cat1id, pcb.getSubcategories().first().getId());
    assertEquals(cat1name, pcb.getSubcategories().first().getName());
    assertEquals(cat1desc, pcb.getSubcategories().first().getDescription());
}
Also used : PortletCategoryBean(org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean) Test(org.junit.Test)

Aggregations

PortletCategoryBean (org.apereo.portal.layout.dlm.remoting.registry.v43.PortletCategoryBean)16 Test (org.junit.Test)10 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)5 HashSet (java.util.HashSet)4 TreeSet (java.util.TreeSet)4 PortletDefinitionBean (org.apereo.portal.layout.dlm.remoting.registry.v43.PortletDefinitionBean)4 SortedSet (java.util.SortedSet)3 TreeMap (java.util.TreeMap)3 EntityIdentifier (org.apereo.portal.EntityIdentifier)3 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)3 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)3 Locale (java.util.Locale)2