Search in sources :

Example 1 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class MenuManagerServiceImpl method loadDefaultMenu.

private Menu loadDefaultMenu(Molgenis molgenis) {
    Menu molgenisMenu = new Menu();
    parseDefaultMenuRec(molgenisMenu, molgenis.getMenu());
    return molgenisMenu;
}
Also used : Menu(org.molgenis.core.ui.menu.Menu)

Example 2 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class MappingServiceControllerTest method getFirstAttributeMappingInfo_dob.

@Test
public void getFirstAttributeMappingInfo_dob() throws Exception {
    when(mappingService.getMappingProject("asdf")).thenReturn(mappingProject);
    Menu menu = mock(Menu.class);
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(menu.findMenuItemPath(ID)).thenReturn("/menu/main/mappingservice");
    mappingProject.getMappingTarget("HOP").getMappingForSource("LifeLines").getAttributeMapping("age").setAlgorithmState(AttributeMapping.AlgorithmState.CURATED);
    MvcResult result2 = mockMvc.perform(post(URI + "/firstattributemapping").param("mappingProjectId", "asdf").param("target", "HOP").param("source", "LifeLines").param("skipAlgorithmStates[]", "CURATED", "DISCUSS").accept(MediaType.APPLICATION_JSON)).andReturn();
    String actual2 = result2.getResponse().getContentAsString();
    assertEquals(actual2, "{\"mappingProjectId\":\"asdf\",\"target\":\"HOP\",\"source\":\"LifeLines\",\"targetAttribute\":\"dob\"}");
}
Also used : Menu(org.molgenis.core.ui.menu.Menu) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 3 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class MappingServiceControllerTest method itShouldUpdateExistingAttributeMappingWhenSaving.

@Test
public void itShouldUpdateExistingAttributeMappingWhenSaving() throws Exception {
    when(mappingService.getMappingProject("asdf")).thenReturn(mappingProject);
    Menu menu = mock(Menu.class);
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(menu.findMenuItemPath(ID)).thenReturn("/menu/main/mappingservice");
    mockMvc.perform(post(URI + "/saveattributemapping").param("mappingProjectId", "asdf").param("target", "HOP").param("source", "LifeLines").param("targetAttribute", "age").param("algorithm", "$('length').value()").param("algorithmState", "CURATED")).andExpect(redirectedUrl("/menu/main/mappingservice/mappingproject/asdf"));
    MappingProject expected = new MappingProject("hop hop hop", me);
    expected.setIdentifier("asdf");
    MappingTarget mappingTarget = expected.addTarget(hop);
    EntityMapping entityMapping = mappingTarget.addSource(lifeLines);
    AttributeMapping ageMapping = entityMapping.addAttributeMapping("age");
    ageMapping.setAlgorithm("$('length').value()");
    ageMapping.setAlgorithmState(AttributeMapping.AlgorithmState.CURATED);
    Mockito.verify(mappingService).updateMappingProject(expected);
}
Also used : EntityMapping(org.molgenis.semanticmapper.mapping.model.EntityMapping) MappingProject(org.molgenis.semanticmapper.mapping.model.MappingProject) AttributeMapping(org.molgenis.semanticmapper.mapping.model.AttributeMapping) Menu(org.molgenis.core.ui.menu.Menu) MappingTarget(org.molgenis.semanticmapper.mapping.model.MappingTarget) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 4 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class MappingServiceControllerTest method getFirstAttributeMappingInfo_none.

@Test
public void getFirstAttributeMappingInfo_none() throws Exception {
    when(mappingService.getMappingProject("asdf")).thenReturn(mappingProject);
    Menu menu = mock(Menu.class);
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(menu.findMenuItemPath(ID)).thenReturn("/menu/main/mappingservice");
    mappingProject.getMappingTarget("HOP").getMappingForSource("LifeLines").getAttributeMapping("age").setAlgorithmState(AttributeMapping.AlgorithmState.DISCUSS);
    MappingTarget mappingTarget = mappingProject.getMappingTarget("HOP");
    EntityMapping entityMapping = mappingTarget.getMappingForSource("LifeLines");
    AttributeMapping attributeMapping = entityMapping.addAttributeMapping("dob");
    attributeMapping.setAlgorithm("$('dob').age()");
    attributeMapping.setAlgorithmState(AttributeMapping.AlgorithmState.DISCUSS);
    MvcResult result3 = mockMvc.perform(post(URI + "/firstattributemapping").param("mappingProjectId", "asdf").param("target", "HOP").param("source", "LifeLines").param("skipAlgorithmStates[]", "CURATED", "DISCUSS").accept(MediaType.APPLICATION_JSON)).andReturn();
    String actual3 = result3.getResponse().getContentAsString();
    assertEquals(actual3, "");
}
Also used : EntityMapping(org.molgenis.semanticmapper.mapping.model.EntityMapping) AttributeMapping(org.molgenis.semanticmapper.mapping.model.AttributeMapping) Menu(org.molgenis.core.ui.menu.Menu) MvcResult(org.springframework.test.web.servlet.MvcResult) MappingTarget(org.molgenis.semanticmapper.mapping.model.MappingTarget) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 5 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class MenuManagerServiceImpl method getDefaultMenuValue.

public String getDefaultMenuValue() {
    Molgenis molgenis;
    try {
        molgenis = new XmlMolgenisUiLoader().load();
    } catch (IOException e) {
        // default menu does not exist, no op
        return null;
    }
    Menu defaultMenu = loadDefaultMenu(molgenis);
    return new GsonBuilder().create().toJson(defaultMenu);
}
Also used : Molgenis(org.molgenis.core.ui.Molgenis) GsonBuilder(com.google.gson.GsonBuilder) XmlMolgenisUiLoader(org.molgenis.core.ui.XmlMolgenisUiLoader) IOException(java.io.IOException) Menu(org.molgenis.core.ui.menu.Menu)

Aggregations

Menu (org.molgenis.core.ui.menu.Menu)14 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)6 BeforeMethod (org.testng.annotations.BeforeMethod)6 Test (org.testng.annotations.Test)6 User (org.molgenis.data.security.auth.User)5 MappingTarget (org.molgenis.semanticmapper.mapping.model.MappingTarget)4 AttributeMapping (org.molgenis.semanticmapper.mapping.model.AttributeMapping)3 EntityMapping (org.molgenis.semanticmapper.mapping.model.EntityMapping)3 MappingProject (org.molgenis.semanticmapper.mapping.model.MappingProject)3 MvcResult (org.springframework.test.web.servlet.MvcResult)3 FormHttpMessageConverter (org.springframework.http.converter.FormHttpMessageConverter)2 GsonBuilder (com.google.gson.GsonBuilder)1 IOException (java.io.IOException)1 Locale (java.util.Locale)1 Molgenis (org.molgenis.core.ui.Molgenis)1 XmlMolgenisUiLoader (org.molgenis.core.ui.XmlMolgenisUiLoader)1 EntityType (org.molgenis.data.meta.model.EntityType)1 EntityTypeIdentity (org.molgenis.data.security.EntityTypeIdentity)1 OneClickImportJobExecution (org.molgenis.oneclickimporter.job.OneClickImportJobExecution)1 StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)1