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;
}
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);
}
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);
}
}
Aggregations