Search in sources :

Example 1 with SubmenuInfo

use of org.motechproject.osgi.web.SubmenuInfo in project motech by motech.

the class MenuBuilder method getModuleMenuSection.

private ModuleMenuSection getModuleMenuSection(String username, List<String> userRoles, ModuleRegistrationData moduleRegistrationData) {
    String moduleName = moduleRegistrationData.getModuleName();
    ModuleMenuSection menuSection = new ModuleMenuSection(moduleName, moduleRegistrationData.isNeedsAttention());
    menuSection.setModuleDocsUrl(moduleRegistrationData.getDocumentationUrl());
    for (Map.Entry<String, SubmenuInfo> submenuEntry : moduleRegistrationData.getSubMenu().entrySet()) {
        SubmenuInfo submenuInfo = submenuEntry.getValue();
        if (isSubMenuLinkAccessibleByCurrentUser(username, userRoles, submenuInfo)) {
            String name = submenuEntry.getKey();
            String angularName = getAngularModuleName(moduleRegistrationData);
            ModuleMenuLink link = new ModuleMenuLink(name, angularName, submenuInfo.getUrl(), submenuInfo.isNeedsAttention(), null);
            menuSection.addLink(link);
        }
    }
    return menuSection;
}
Also used : ModuleMenuLink(org.motechproject.server.web.dto.ModuleMenuLink) ModuleMenuSection(org.motechproject.server.web.dto.ModuleMenuSection) SubmenuInfo(org.motechproject.osgi.web.SubmenuInfo) Map(java.util.Map)

Example 2 with SubmenuInfo

use of org.motechproject.osgi.web.SubmenuInfo in project motech by motech.

the class MenuBuilderTest method setUpToTestAccessControlledSubMenuLinks.

private void setUpToTestAccessControlledSubMenuLinks(boolean addSubMenuWithoutAccessControl) {
    ModuleRegistrationData fooRegData = new ModuleRegistrationData("foo", "foo");
    Map<String, SubmenuInfo> subMenuMap = new HashMap<>();
    SubmenuInfo subMenuWithAccessForUserFoo = new SubmenuInfo("#/foo");
    subMenuWithAccessForUserFoo.setRoleForAccess("foo");
    SubmenuInfo subMenuWithAccessForUserBar = new SubmenuInfo("#/bar");
    subMenuWithAccessForUserBar.setRoleForAccess("bar");
    SubmenuInfo subMenuWithoutAccessControl = new SubmenuInfo("#/random");
    subMenuMap.put("Foo", subMenuWithAccessForUserFoo);
    subMenuMap.put("Bar", subMenuWithAccessForUserBar);
    if (addSubMenuWithoutAccessControl) {
        subMenuMap.put("Random", subMenuWithoutAccessControl);
    }
    fooRegData.setSubMenu(subMenuMap);
    fooRegData.setBundle(bundle);
    ModuleRegistrations modules = new ModuleRegistrations();
    modules.setModulesWithSubMenu(Arrays.asList(fooRegData));
    when(uiFrameworkService.getRegisteredModules()).thenReturn(modules);
    RoleDto fooRole = new RoleDto("fooRole", Arrays.asList("foo"));
    RoleDto someOtherRole = new RoleDto("someOtherRole", Arrays.asList("someOtherPermission"));
    when(roleService.getRole("fooRole")).thenReturn(fooRole);
    when(roleService.getRole("someOtherRole")).thenReturn(someOtherRole);
}
Also used : RoleDto(org.motechproject.security.model.RoleDto) ModuleRegistrations(org.motechproject.osgi.web.util.ModuleRegistrations) HashMap(java.util.HashMap) ModuleRegistrationData(org.motechproject.osgi.web.ModuleRegistrationData) SubmenuInfo(org.motechproject.osgi.web.SubmenuInfo)

Example 3 with SubmenuInfo

use of org.motechproject.osgi.web.SubmenuInfo in project motech by motech.

the class UIFrameworkServiceImpl method moduleNeedsAttention.

@Override
public void moduleNeedsAttention(String moduleName, String submenu, String message) {
    SubmenuInfo submenuInfo = getSubmenu(moduleName, submenu);
    if (submenuInfo != null) {
        submenuInfo.setNeedsAttention(true);
        submenuInfo.setCriticalMessage(message);
    }
}
Also used : SubmenuInfo(org.motechproject.osgi.web.SubmenuInfo)

Aggregations

SubmenuInfo (org.motechproject.osgi.web.SubmenuInfo)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ModuleRegistrationData (org.motechproject.osgi.web.ModuleRegistrationData)1 ModuleRegistrations (org.motechproject.osgi.web.util.ModuleRegistrations)1 RoleDto (org.motechproject.security.model.RoleDto)1 ModuleMenuLink (org.motechproject.server.web.dto.ModuleMenuLink)1 ModuleMenuSection (org.motechproject.server.web.dto.ModuleMenuSection)1