Search in sources :

Example 1 with GlobalMenu

use of org.jaffa.components.navigation.domain.GlobalMenu in project jaffa-framework by jaffa-projects.

the class NavigationXmlLoadTest method testXmlLoad.

/**
 * Verifies that we can load the menus from the navigation.xml file into our navigation repository.
 */
@Test
public void testXmlLoad() {
    NavigationManager navigationManager = xmlLoaderConfig.getBean(NavigationManager.class);
    assertNotNull(navigationManager.getNavigationRepository());
    GlobalMenu globalMenu = navigationManager.getNavigationRepository().getAllValues().get(0);
    assertEquals(4, globalMenu.getMenuOption().size());
}
Also used : GlobalMenu(org.jaffa.components.navigation.domain.GlobalMenu) Test(org.junit.Test)

Example 2 with GlobalMenu

use of org.jaffa.components.navigation.domain.GlobalMenu in project jaffa-framework by jaffa-projects.

the class NavigationManager method unregisterResource.

/**
 * unregisterXML - Unregisters the navigation global menu from the IRepository
 * @param resource the object that contains the xml config file.
 * @param precedence associated with the module based on its definition in manifest
 * @param variation associated with the module based on its definition in manifest
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void unregisterResource(Resource resource, String precedence, String variation) throws JAXBException, SAXException, IOException {
    GlobalMenu globalMenu = JAXBHelper.unmarshalConfigFile(GlobalMenu.class, resource, CONFIGURATION_SCHEMA_FILE);
    if (globalMenu != null) {
        ContextKey key = new ContextKey(GLOBAL_MENU_ID, resource.getURI().toString(), variation, precedence);
        unregisterGlobalMenu(key);
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) GlobalMenu(org.jaffa.components.navigation.domain.GlobalMenu)

Example 3 with GlobalMenu

use of org.jaffa.components.navigation.domain.GlobalMenu in project jaffa-framework by jaffa-projects.

the class NavigationManager method registerResource.

/**
 * registerXML - Registers the navigation global menu into the IRepository
 * @param resource the object that contains the xml config file.
 * @param precedence associated with the module based on its definition in manifest
 * @param variation associated with the module based on its definition in manifest
 * @throws JAXBException
 * @throws SAXException
 * @throws IOException
 */
@Override
public void registerResource(Resource resource, String precedence, String variation) throws JAXBException, SAXException, IOException {
    GlobalMenu globalMenu = JAXBHelper.unmarshalConfigFile(GlobalMenu.class, resource, CONFIGURATION_SCHEMA_FILE);
    if (globalMenu != null) {
        ContextKey key = new ContextKey(GLOBAL_MENU_ID, resource.getURI().toString(), variation, precedence);
        registerGlobalMenu(key, globalMenu);
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) GlobalMenu(org.jaffa.components.navigation.domain.GlobalMenu)

Example 4 with GlobalMenu

use of org.jaffa.components.navigation.domain.GlobalMenu in project jaffa-framework by jaffa-projects.

the class NavigationXmlLoadTest method testNavigationRegistration.

/**
 * testNavigationRegistration - Verifies that the navigation.xml has been loaded correctly into the NavigationManager.
 */
@Test
public void testNavigationRegistration() {
    NavigationManager navigationManager = xmlLoaderConfig.getBean(NavigationManager.class);
    ContextKey key = new ContextKey("CONTRACTOR", "roles.xml", "DEF", "100-Highest");
    assertNull(navigationManager.getNavigationRepository().query(key));
    GlobalMenu globalMenu = new GlobalMenu();
    MenuOption menuOption = new MenuOption();
    menuOption.setLabel("Label 1");
    globalMenu.getMenuOption().add(menuOption);
    navigationManager.registerGlobalMenu(key, globalMenu);
    assertNotNull(navigationManager.getNavigationRepository().query(key));
    navigationManager.unregisterGlobalMenu(key);
    assertNull(navigationManager.getNavigationRepository().query(key));
}
Also used : ContextKey(org.jaffa.loader.ContextKey) MenuOption(org.jaffa.components.navigation.domain.MenuOption) GlobalMenu(org.jaffa.components.navigation.domain.GlobalMenu) Test(org.junit.Test)

Aggregations

GlobalMenu (org.jaffa.components.navigation.domain.GlobalMenu)4 ContextKey (org.jaffa.loader.ContextKey)3 Test (org.junit.Test)2 MenuOption (org.jaffa.components.navigation.domain.MenuOption)1