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