Search in sources :

Example 11 with Package

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);
    }
}
Also used : EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) PackageIdentity(org.molgenis.data.security.PackageIdentity) MutableAcl(org.springframework.security.acls.model.MutableAcl) Package(org.molgenis.data.meta.model.Package)

Example 12 with Package

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);
        }
    }
}
Also used : EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) PackageIdentity(org.molgenis.data.security.PackageIdentity) MutableAcl(org.springframework.security.acls.model.MutableAcl) Package(org.molgenis.data.meta.model.Package) Acl(org.springframework.security.acls.model.Acl) MutableAcl(org.springframework.security.acls.model.MutableAcl)

Example 13 with Package

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);
}
Also used : Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 14 with Package

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);
}
Also used : Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 15 with Package

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));
}
Also used : DefaultPackage(org.molgenis.data.meta.DefaultPackage) Package(org.molgenis.data.meta.model.Package) MappingTarget(org.molgenis.semanticmapper.mapping.model.MappingTarget) Test(org.testng.annotations.Test)

Aggregations

Package (org.molgenis.data.meta.model.Package)98 Test (org.testng.annotations.Test)70 EntityType (org.molgenis.data.meta.model.EntityType)22 Stream (java.util.stream.Stream)20 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)13 Attribute (org.molgenis.data.meta.model.Attribute)11 DefaultPackage (org.molgenis.data.meta.DefaultPackage)10 MolgenisValidationException (org.molgenis.data.validation.MolgenisValidationException)10 Objects.requireNonNull (java.util.Objects.requireNonNull)6 L10nString (org.molgenis.data.i18n.model.L10nString)6 PackageIdentity (org.molgenis.data.security.PackageIdentity)6 Collectors.toList (java.util.stream.Collectors.toList)5 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)5 DataService (org.molgenis.data.DataService)5 QueryImpl (org.molgenis.data.support.QueryImpl)5 RepositoryCollection (org.molgenis.data.RepositoryCollection)4 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)3 java.util (java.util)3 Collections.singletonList (java.util.Collections.singletonList)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3