Search in sources :

Example 1 with ADD

use of org.molgenis.data.DatabaseAction.ADD in project molgenis by molgenis.

the class OntologyImportServiceIT method verifyOwlAsSystem.

private void verifyOwlAsSystem() {
    // Verify two imported rows (organization and team, as these are interesting examples)
    List<Entity> entities = dataService.findAll("sys_ont_OntologyTerm").collect(Collectors.toList());
    Optional<Entity> organizationOpt = entities.stream().filter(e -> e.getString("ontologyTermName").equals("organization")).findFirst();
    assertTrue(organizationOpt.isPresent());
    Entity organization = organizationOpt.get();
    Optional<Entity> teamOpt = entities.stream().filter(e -> e.getString("ontologyTermName").equals("team")).findFirst();
    assertTrue(teamOpt.isPresent());
    Entity team = teamOpt.get();
    // Verify organization
    assertEquals(organization.getString("ontologyTermIRI"), "http://www.molgenis.org#Organization");
    assertEquals(organization.getString("ontologyTermName"), "organization");
    // verify organization ontologyTermSynonym
    Iterable<Entity> ontologyTermSynonym = organization.getEntities("ontologyTermSynonym");
    List<Entity> termSynonymRefList = new ArrayList<>();
    ontologyTermSynonym.forEach(termSynonymRefList::add);
    assertEquals(termSynonymRefList.size(), 1);
    Entity organizationOntologyTermSynonym = dataService.findOneById("sys_ont_OntologyTermSynonym", termSynonymRefList.get(0).getIdValue());
    assertEquals(organizationOntologyTermSynonym.getString("ontologyTermSynonym"), "organization");
    // verify organization ontology
    Ontology ontology = (Ontology) organization.get("ontology");
    assertEquals(ontology.getOntologyName(), "ontology-small");
    // Verify the team row
    assertEquals(team.getString("ontologyTermIRI"), "http://www.molgenis.org#Team");
    assertEquals(team.getString("ontologyTermName"), "team");
    // verify team dynamic annotations
    Iterable<Entity> dynamicAnnotationItr = team.getEntities("ontologyTermDynamicAnnotation");
    List<Entity> dynamicAnnotations = new ArrayList<>();
    dynamicAnnotationItr.forEach(dynamicAnnotations::add);
    assertEquals(dynamicAnnotations.size(), 2);
    Entity annotationOne = dataService.findOneById("sys_ont_OntologyTermDynamicAnnotation", dynamicAnnotations.get(0).getIdValue());
    assertEquals(annotationOne.getString("label"), "friday:2412423");
    Entity annotationTwo = dataService.findOneById("sys_ont_OntologyTermDynamicAnnotation", dynamicAnnotations.get(1).getIdValue());
    assertEquals(annotationTwo.getString("label"), "molgenis:1231424");
    // verify team ontology
    ontology = (Ontology) team.get("ontology");
    assertEquals(ontology.getOntologyName(), "ontology-small");
}
Also used : java.util(java.util) Autowired(org.springframework.beans.factory.annotation.Autowired) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) RunAsSystemAspect.runAsSystem(org.molgenis.security.core.runas.RunAsSystemAspect.runAsSystem) EntityTypePermission(org.molgenis.data.security.EntityTypePermission) User(org.molgenis.data.security.auth.User) Ontology(org.molgenis.ontology.core.meta.Ontology) PACKAGE_DEFAULT(org.molgenis.data.meta.DefaultPackage.PACKAGE_DEFAULT) MutableAcl(org.springframework.security.acls.model.MutableAcl) EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) ImportService(org.molgenis.data.importer.ImportService) Sid(org.springframework.security.acls.model.Sid) ADD(org.molgenis.data.DatabaseAction.ADD) Collections.emptySet(java.util.Collections.emptySet) ImmutableMap(com.google.common.collect.ImmutableMap) EntityTypePermissionUtils.getCumulativePermission(org.molgenis.data.security.EntityTypePermissionUtils.getCumulativePermission) EntityImportReport(org.molgenis.data.importer.EntityImportReport) READ(org.molgenis.data.security.EntityTypePermission.READ) Collectors(java.util.stream.Collectors) File(java.io.File) FileRepositoryCollection(org.molgenis.data.file.support.FileRepositoryCollection) SecurityUtils(org.molgenis.security.core.utils.SecurityUtils) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid) WithMockUser(org.springframework.security.test.context.support.WithMockUser) WRITE(org.molgenis.data.security.EntityTypePermission.WRITE) Assert.assertTrue(org.testng.Assert.assertTrue) MutableAclService(org.springframework.security.acls.model.MutableAclService) Entity(org.molgenis.data.Entity) Entity(org.molgenis.data.Entity) Ontology(org.molgenis.ontology.core.meta.Ontology)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 java.util (java.util)1 Collections.emptySet (java.util.Collections.emptySet)1 Collectors (java.util.stream.Collectors)1 ADD (org.molgenis.data.DatabaseAction.ADD)1 Entity (org.molgenis.data.Entity)1 FileRepositoryCollection (org.molgenis.data.file.support.FileRepositoryCollection)1 EntityImportReport (org.molgenis.data.importer.EntityImportReport)1 ImportService (org.molgenis.data.importer.ImportService)1 PACKAGE_DEFAULT (org.molgenis.data.meta.DefaultPackage.PACKAGE_DEFAULT)1 EntityTypeIdentity (org.molgenis.data.security.EntityTypeIdentity)1 EntityTypePermission (org.molgenis.data.security.EntityTypePermission)1 READ (org.molgenis.data.security.EntityTypePermission.READ)1 WRITE (org.molgenis.data.security.EntityTypePermission.WRITE)1 EntityTypePermissionUtils.getCumulativePermission (org.molgenis.data.security.EntityTypePermissionUtils.getCumulativePermission)1 User (org.molgenis.data.security.auth.User)1 Ontology (org.molgenis.ontology.core.meta.Ontology)1 RunAsSystemAspect.runAsSystem (org.molgenis.security.core.runas.RunAsSystemAspect.runAsSystem)1 SecurityUtils (org.molgenis.security.core.utils.SecurityUtils)1