use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class SystemEntityTypePersister method injectExistingPackageIdentifiers.
private void injectExistingPackageIdentifiers(List<Package> systemPackages) {
Map<String, Package> existingPackageMap = dataService.findAll(PACKAGE, Package.class).collect(toMap(Package::getId, pack -> pack));
systemPackages.forEach(pack -> {
Package existingPackage = existingPackageMap.get(pack.getId());
if (existingPackage != null) {
pack.setId(existingPackage.getId());
}
});
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PermissionManagerControllerTest method setUp.
@BeforeMethod
public void setUp() {
config.resetMocks();
mockMvc = MockMvcBuilders.standaloneSetup(permissionManagerController).setMessageConverters(gsonHttpMessageConverter).build();
user1 = when(mock(User.class).getId()).thenReturn("1").getMock();
when(user1.isSuperuser()).thenReturn(true);
when(user1.getUsername()).thenReturn("Ipsum");
userSid = new PrincipalSid("Ipsum");
user2 = when(mock(User.class).getId()).thenReturn("2").getMock();
group1 = when(mock(Group.class).getId()).thenReturn("1").getMock();
groupSid = new GrantedAuthoritySid("ROLE_1");
group2 = when(mock(Group.class).getId()).thenReturn("2").getMock();
plugin1 = when(mock(Plugin.class).getId()).thenReturn("1").getMock();
plugin2 = when(mock(Plugin.class).getId()).thenReturn("2").getMock();
pluginIdentity1 = new PluginIdentity(plugin1);
pluginIdentity2 = new PluginIdentity(plugin2);
entityType1 = when(mock(EntityType.class).getId()).thenReturn("1").getMock();
entityType2 = when(mock(EntityType.class).getId()).thenReturn("2").getMock();
entityType3 = when(mock(EntityType.class).getId()).thenReturn("3").getMock();
when(entityType1.getLabel()).thenReturn("label1");
when(entityType2.getLabel()).thenReturn("label2");
when(entityType3.getLabel()).thenReturn("label3");
entityIdentity1 = new EntityTypeIdentity(entityType1);
entityIdentity2 = new EntityTypeIdentity(entityType2);
entityIdentity3 = new EntityTypeIdentity(entityType3);
package1 = when(mock(Package.class).getId()).thenReturn("1").getMock();
package2 = when(mock(Package.class).getId()).thenReturn("2").getMock();
package3 = when(mock(Package.class).getId()).thenReturn("3").getMock();
packageIdentity1 = new PackageIdentity(package1);
packageIdentity2 = new PackageIdentity(package2);
packageIdentity3 = new PackageIdentity(package3);
when(dataService.findAll(USER, User.class)).thenReturn(Stream.of(user1, user2));
when(dataService.findAll(GROUP, Group.class)).thenReturn(Stream.of(group1, group2));
when(dataService.findOneById(GROUP, "1", Group.class)).thenReturn(group1);
when(dataService.findOneById(USER, "1", User.class)).thenReturn(user1);
when(dataService.findAll(PLUGIN, Plugin.class)).thenReturn(Stream.of(plugin1, plugin2));
when(dataService.findAll(ENTITY_TYPE_META_DATA, EntityType.class)).thenReturn(Stream.of(entityType1, entityType2, entityType3));
when(dataService.findAll(PACKAGE, Package.class)).thenReturn(Stream.of(package1, package2, package3));
pluginPermissionRead = PluginPermission.READ;
cumulativeEntityPermissionWritemeta = new CumulativePermission();
cumulativeEntityPermissionWritemeta.set(EntityTypePermission.WRITEMETA).set(EntityTypePermission.WRITE).set(EntityTypePermission.READ).set(EntityTypePermission.COUNT);
cumulativeEntityPermissionWrite = new CumulativePermission();
cumulativeEntityPermissionWrite.set(EntityTypePermission.WRITE).set(EntityTypePermission.READ).set(EntityTypePermission.COUNT);
cumulativeEntityPermissionRead = new CumulativePermission();
cumulativeEntityPermissionRead.set(EntityTypePermission.READ).set(EntityTypePermission.COUNT);
cumulativeEntityPermissionCount = new CumulativePermission();
cumulativeEntityPermissionCount.set(EntityTypePermission.COUNT);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaUtils method getFullyQualyfiedName.
public static String getFullyQualyfiedName(Package package_) {
String packageId = package_.getId();
Package parentPackage = package_.getParent();
return parentPackage == null ? packageId : getFullyQualyfiedName(parentPackage) + PACKAGE_SEPARATOR + packageId;
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackagePersister method upsertPackages.
private void upsertPackages(Collection<Package> packages) {
List<Package> packagesToAdd = new ArrayList<>(packages.size());
List<Package> packagesToUpdate = new ArrayList<>(packages.size());
Map<String, Package> packageMap = getCandidateExistingPackageMap(packages);
packages.forEach(pack -> {
Package existingPackage = packageMap.get(pack.getId());
if (existingPackage != null) {
// inject existing package identifier into package
pack.setId(existingPackage.getId());
if (!pack.equals(existingPackage)) {
packagesToUpdate.add(pack);
}
} else {
packagesToAdd.add(pack);
}
});
if (!packagesToAdd.isEmpty()) {
dataService.add(PACKAGE, packagesToAdd.stream());
}
if (!packagesToUpdate.isEmpty()) {
dataService.update(PACKAGE, packagesToUpdate.stream());
}
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EmxImportServiceIT method verifyItEmxTags.
private void verifyItEmxTags() {
verifyFirstAndLastRows("sys_md_Tag", tagFirstRow, tagLastRow);
EntityType entityType = dataService.getEntityType("it_emx_tags_TagEntity");
Iterable<Tag> entityTags = entityType.getTags();
assertEquals(getIdsAsSet(entityTags), newHashSet("entitytag0", "entitytag1"));
Iterable<Tag> idTags = entityType.getAttribute("id").getTags();
Iterable<Tag> labelTags = entityType.getAttribute("label").getTags();
assertEquals(getIdsAsSet(idTags), newHashSet("attributetag0", "attributetag1"));
assertEquals(getIdsAsSet(labelTags), newHashSet("attributetag0", "attributetag1"));
Package emxPackage = entityType.getPackage();
Iterable<Tag> packageTags = emxPackage.getTags();
assertEquals(getIdsAsSet(packageTags), newHashSet("packagetag0", "packagetag1"));
}
Aggregations