use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeInitializer method initialize.
public void initialize(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
ctx.getBeansOfType(SystemPackage.class).values().forEach(SystemPackage::bootstrap);
EntityTypeMetadata entityTypeMetaData = ctx.getBean(EntityTypeMetadata.class);
ctx.getBean(AttributeMetadata.class).bootstrap(entityTypeMetaData);
// TODO: doesn't this mean all attributes get added twice?
Map<String, SystemEntityType> systemEntityTypeMap = ctx.getBeansOfType(SystemEntityType.class);
genericDependencyResolver.resolve(systemEntityTypeMap.values(), SystemEntityType::getDependencies).forEach(systemEntityType -> initialize(systemEntityType, entityTypeMetaData));
}
use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeRegistryImplTest method testGetSystemEntityTypesNotPermitted.
@Test
public void testGetSystemEntityTypesNotPermitted() {
String entityTypeId = "entityType";
SystemEntityType systemEntityType = mock(SystemEntityType.class);
when(systemEntityType.getId()).thenReturn(entityTypeId);
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.COUNT)).thenReturn(false);
systemEntityTypeRegistry.addSystemEntityType(systemEntityType);
assertEquals(systemEntityTypeRegistry.getSystemEntityTypes().count(), 0);
}
use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeRegistryImplTest method testGetSystemAttributeCompound.
@Test
public void testGetSystemAttributeCompound() {
String entityTypeId = "entityType";
SystemEntityType systemEntityType = mock(SystemEntityType.class);
when(systemEntityType.getId()).thenReturn(entityTypeId);
Attribute attr = when(mock(Attribute.class).getIdentifier()).thenReturn("attr").getMock();
when(attr.getDataType()).thenReturn(AttributeType.STRING);
Attribute compoundAttr = when(mock(Attribute.class).getIdentifier()).thenReturn("compoundAttr").getMock();
when(compoundAttr.getDataType()).thenReturn(AttributeType.COMPOUND);
when(compoundAttr.getChildren()).thenReturn(singletonList(attr));
when(systemEntityType.getAllAttributes()).thenReturn(singletonList(compoundAttr));
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.COUNT)).thenReturn(true);
systemEntityTypeRegistry.addSystemEntityType(systemEntityType);
assertEquals(systemEntityTypeRegistry.getSystemAttribute("attr"), attr);
}
use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeRegistryImplTest method testHasSystemAttributePermittedNotExists.
@Test
public void testHasSystemAttributePermittedNotExists() {
String entityTypeId = "entityType";
SystemEntityType systemEntityType = mock(SystemEntityType.class);
when(systemEntityType.getId()).thenReturn(entityTypeId);
when(systemEntityType.getAllAttributes()).thenReturn(emptyList());
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.COUNT)).thenReturn(true);
systemEntityTypeRegistry.addSystemEntityType(systemEntityType);
assertFalse(systemEntityTypeRegistry.hasSystemAttribute("attr"));
}
use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeRegistryImplTest method testGetSystemEntityTypesPermitted.
@Test
public void testGetSystemEntityTypesPermitted() {
String entityTypeId = "entityType";
SystemEntityType systemEntityType = mock(SystemEntityType.class);
when(systemEntityType.getId()).thenReturn(entityTypeId);
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.COUNT)).thenReturn(true);
systemEntityTypeRegistry.addSystemEntityType(systemEntityType);
assertEquals(systemEntityTypeRegistry.getSystemEntityTypes().collect(toList()), singletonList(systemEntityType));
}
Aggregations