use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EntityTypeRepositorySecurityDecorator method createAcl.
@Override
public void createAcl(EntityType entityType) {
MutableAcl acl = mutableAclService.createAcl(new EntityTypeIdentity(entityType.getId()));
Package pack = entityType.getPackage();
if (pack != null) {
ObjectIdentity objectIdentity = new PackageIdentity(pack);
acl.setParent(mutableAclService.readAclById(objectIdentity));
mutableAclService.updateAcl(acl);
}
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EntityTypeRepositorySecurityDecorator method updateAcl.
@Override
public void updateAcl(EntityType entityType) {
MutableAcl acl = (MutableAcl) mutableAclService.readAclById(new EntityTypeIdentity(entityType.getId()));
Package pack = entityType.getPackage();
if (pack != null) {
ObjectIdentity objectIdentity = new PackageIdentity(pack);
Acl parentAcl = mutableAclService.readAclById(objectIdentity);
if (!parentAcl.equals(acl.getParentAcl())) {
acl.setParent(parentAcl);
mutableAclService.updateAcl(acl);
}
}
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MappingServiceControllerTest method testCreateIntegratedEntity.
@Test
public void testCreateIntegratedEntity() throws Exception {
when(mappingService.getMappingProject("mappingProjectId")).thenReturn(mappingProject);
Package aPackage = mock(Package.class);
when(aPackage.getId()).thenReturn("base");
when(aPackage.getRootPackage()).thenReturn(null);
when(metaDataService.getPackage("base")).thenReturn(aPackage);
when(mappingJobExecutionFactory.create()).thenReturn(mappingJobExecution);
when(mappingJobExecution.getEntityType()).thenReturn(mappingJobExecutionMetadata);
when(mappingJobExecution.getIdValue()).thenReturn("abcde");
when(mappingJobExecutionMetadata.getId()).thenReturn("MappingJobExecution");
when(userAccountService.getCurrentUser()).thenReturn(me);
when(jobsController.createJobExecutionViewHref(mappingJobExecution, 1000)).thenReturn("/jobs/viewJob/?jobHref=jobHref&refreshTimeoutMillis=1000");
mockMvc.perform(post(URI + "/createIntegratedEntity").param("mappingProjectId", "mappingProjectId").param("targetEntityTypeId", "targetEntityTypeId").param("label", "label").param("package", "base").accept("text/plain")).andExpect(status().isFound()).andExpect(header().string("Location", "/jobs/viewJob/?jobHref=jobHref&refreshTimeoutMillis=1000"));
Mockito.verify(jobExecutor).submit(mappingJobExecution);
Mockito.verify(mappingJobExecution).setMappingProjectId("mappingProjectId");
Mockito.verify(mappingJobExecution).setLabel("label");
Mockito.verify(mappingJobExecution).setAddSourceAttribute(null);
Mockito.verify(mappingJobExecution).setTargetEntityTypeId("targetEntityTypeId");
Mockito.verify(mappingJobExecution).setPackageId("base");
Mockito.verify(mappingJobExecution).setUser(me);
Mockito.verifyNoMoreInteractions(mappingJobExecution);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MappingServiceControllerTest method testMap.
@Test
public void testMap() throws Exception {
when(mappingService.getMappingProject("mappingProjectId")).thenReturn(mappingProject);
Package aPackage = mock(Package.class);
when(aPackage.getId()).thenReturn("base");
when(aPackage.getRootPackage()).thenReturn(null);
when(metaDataService.getPackage("base")).thenReturn(aPackage);
when(mappingJobExecutionFactory.create()).thenReturn(mappingJobExecution);
when(mappingJobExecution.getEntityType()).thenReturn(mappingJobExecutionMetadata);
when(mappingJobExecution.getIdValue()).thenReturn("abcde");
when(mappingJobExecutionMetadata.getId()).thenReturn("MappingJobExecution");
when(userAccountService.getCurrentUser()).thenReturn(me);
mockMvc.perform(post(URI + "/map").param("mappingProjectId", "mappingProjectId").param("targetEntityTypeId", "targetEntityTypeId").param("label", "label").param("package", "base").accept("text/plain")).andExpect(status().isCreated()).andExpect(content().contentType("text/plain")).andExpect(content().string("/api/v2/MappingJobExecution/abcde"));
Mockito.verify(jobExecutor).submit(mappingJobExecution);
Mockito.verify(mappingJobExecution).setMappingProjectId("mappingProjectId");
Mockito.verify(mappingJobExecution).setLabel("label");
Mockito.verify(mappingJobExecution).setAddSourceAttribute(null);
Mockito.verify(mappingJobExecution).setTargetEntityTypeId("targetEntityTypeId");
Mockito.verify(mappingJobExecution).setPackageId("base");
Mockito.verify(mappingJobExecution).setUser(me);
Mockito.verify(mappingJobExecution).getEntityType();
Mockito.verify(mappingJobExecution).getIdValue();
Mockito.verifyNoMoreInteractions(mappingJobExecution);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MappingServiceImplTest method createMetaWithNonNullParameters.
@Test
public void createMetaWithNonNullParameters() {
MappingTarget mappingTarget = Mockito.mock(MappingTarget.class);
when(mappingTarget.getTarget()).thenReturn(hopMetaData);
Package targetPackage = Mockito.mock(Package.class);
when(metaDataService.getPackage("targetPackage")).thenReturn(targetPackage);
EntityType targetMetadata = mappingService.createTargetMetadata(mappingTarget, "test", "targetPackage", "target label", true);
assertEquals(targetMetadata.getId(), "test");
assertEquals(targetMetadata.getLabel(), "target label");
assertEquals(targetMetadata.getPackage(), targetPackage);
Assert.assertNotNull(targetMetadata.getAttribute(SOURCE));
}
Aggregations