Search in sources :

Example 1 with PACKAGE_SEPARATOR

use of org.molgenis.data.meta.model.Package.PACKAGE_SEPARATOR in project molgenis by molgenis.

the class EmxImportServiceIT method createUpdateData.

private static Object[] createUpdateData(String fileName, String updateFileName, List<String> packageTokens, Map<String, Integer> entityCountMap, Set<String> entityTypeNames, Runnable entityValidationMethod) {
    File addFile = getFile("/xls/" + fileName);
    File updateFile = getFile("/xls/" + updateFileName);
    String packageName = String.join(PACKAGE_SEPARATOR, packageTokens);
    Map<String, Object> entityTypeCountMap = entityCountMap.entrySet().stream().collect(Collectors.toMap(entry -> packageName + PACKAGE_SEPARATOR + entry.getKey(), Map.Entry::getValue));
    Set<String> entityTypeFullyQualifiedNames = entityTypeNames.stream().map(entityName -> packageName + PACKAGE_SEPARATOR + entityName).collect(toSet());
    return new Object[] { addFile, updateFile, entityTypeCountMap, entityTypeFullyQualifiedNames, entityValidationMethod };
}
Also used : Iterables(com.google.common.collect.Iterables) java.util(java.util) DataProvider(org.testng.annotations.DataProvider) Autowired(org.springframework.beans.factory.annotation.Autowired) 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) Tag(org.molgenis.data.meta.model.Tag) Assert(org.testng.Assert) PACKAGE_SEPARATOR(org.molgenis.data.meta.model.Package.PACKAGE_SEPARATOR) Arrays.asList(java.util.Arrays.asList) PACKAGE_DEFAULT(org.molgenis.data.meta.DefaultPackage.PACKAGE_DEFAULT) MutableAcl(org.springframework.security.acls.model.MutableAcl) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) Collectors.toSet(java.util.stream.Collectors.toSet) ImportService(org.molgenis.data.importer.ImportService) Sid(org.springframework.security.acls.model.Sid) Collections.emptyMap(java.util.Collections.emptyMap) ADD(org.molgenis.data.DatabaseAction.ADD) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) ADD_UPDATE_EXISTING(org.molgenis.data.DatabaseAction.ADD_UPDATE_EXISTING) EntityTypePermissionUtils.getCumulativePermission(org.molgenis.data.security.EntityTypePermissionUtils.getCumulativePermission) EntityImportReport(org.molgenis.data.importer.EntityImportReport) READ(org.molgenis.data.security.EntityTypePermission.READ) Instant(java.time.Instant) EntityType(org.molgenis.data.meta.model.EntityType) 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) LocalDate(java.time.LocalDate) Package(org.molgenis.data.meta.model.Package) MutableAclService(org.springframework.security.acls.model.MutableAclService) Entity(org.molgenis.data.Entity) File(java.io.File) Collections.emptyMap(java.util.Collections.emptyMap) ImmutableMap(com.google.common.collect.ImmutableMap) Maps.newHashMap(com.google.common.collect.Maps.newHashMap)

Example 2 with PACKAGE_SEPARATOR

use of org.molgenis.data.meta.model.Package.PACKAGE_SEPARATOR in project molgenis by molgenis.

the class EmxImportServiceIT method createAddData.

private static Object[] createAddData(String fileName, List<String> packageTokens, Map<String, Integer> entityCountMap, Set<String> entityTypeNames, Runnable entityValidationMethod) {
    File file = getFile("/xls/" + fileName);
    String packageName = String.join(PACKAGE_SEPARATOR, packageTokens);
    Map<String, Object> entityTypeCountMap = entityCountMap.entrySet().stream().collect(Collectors.toMap(entry -> packageName + PACKAGE_SEPARATOR + entry.getKey(), Map.Entry::getValue));
    Set<String> entityTypeFullyQualifiedNames = entityTypeNames.stream().map(entityName -> packageName + PACKAGE_SEPARATOR + entityName).collect(toSet());
    return new Object[] { file, entityTypeCountMap, entityTypeFullyQualifiedNames, entityValidationMethod };
}
Also used : Iterables(com.google.common.collect.Iterables) java.util(java.util) DataProvider(org.testng.annotations.DataProvider) Autowired(org.springframework.beans.factory.annotation.Autowired) 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) Tag(org.molgenis.data.meta.model.Tag) Assert(org.testng.Assert) PACKAGE_SEPARATOR(org.molgenis.data.meta.model.Package.PACKAGE_SEPARATOR) Arrays.asList(java.util.Arrays.asList) PACKAGE_DEFAULT(org.molgenis.data.meta.DefaultPackage.PACKAGE_DEFAULT) MutableAcl(org.springframework.security.acls.model.MutableAcl) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) Collectors.toSet(java.util.stream.Collectors.toSet) ImportService(org.molgenis.data.importer.ImportService) Sid(org.springframework.security.acls.model.Sid) Collections.emptyMap(java.util.Collections.emptyMap) ADD(org.molgenis.data.DatabaseAction.ADD) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) ADD_UPDATE_EXISTING(org.molgenis.data.DatabaseAction.ADD_UPDATE_EXISTING) EntityTypePermissionUtils.getCumulativePermission(org.molgenis.data.security.EntityTypePermissionUtils.getCumulativePermission) EntityImportReport(org.molgenis.data.importer.EntityImportReport) READ(org.molgenis.data.security.EntityTypePermission.READ) Instant(java.time.Instant) EntityType(org.molgenis.data.meta.model.EntityType) 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) LocalDate(java.time.LocalDate) Package(org.molgenis.data.meta.model.Package) MutableAclService(org.springframework.security.acls.model.MutableAclService) Entity(org.molgenis.data.Entity) File(java.io.File) Collections.emptyMap(java.util.Collections.emptyMap) ImmutableMap(com.google.common.collect.ImmutableMap) Maps.newHashMap(com.google.common.collect.Maps.newHashMap)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Iterables (com.google.common.collect.Iterables)2 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)2 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)2 File (java.io.File)2 Instant (java.time.Instant)2 LocalDate (java.time.LocalDate)2 java.util (java.util)2 Arrays.asList (java.util.Arrays.asList)2 Collections.emptyMap (java.util.Collections.emptyMap)2 Collectors (java.util.stream.Collectors)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 ADD (org.molgenis.data.DatabaseAction.ADD)2 ADD_UPDATE_EXISTING (org.molgenis.data.DatabaseAction.ADD_UPDATE_EXISTING)2 Entity (org.molgenis.data.Entity)2 FileRepositoryCollection (org.molgenis.data.file.support.FileRepositoryCollection)2 EntityImportReport (org.molgenis.data.importer.EntityImportReport)2 ImportService (org.molgenis.data.importer.ImportService)2 PACKAGE_DEFAULT (org.molgenis.data.meta.DefaultPackage.PACKAGE_DEFAULT)2