Search in sources :

Example 1 with EntityTypeMetadata

use of org.molgenis.data.meta.model.EntityTypeMetadata in project molgenis by molgenis.

the class SystemEntityTypeI18nInitializer method initialize.

/**
 * Initialize internationalization attributes
 *
 * @param event application event
 */
public void initialize(ContextRefreshedEvent event) {
    ApplicationContext ctx = event.getApplicationContext();
    Stream<String> languageCodes = LanguageService.getLanguageCodes();
    EntityTypeMetadata entityTypeMeta = ctx.getBean(EntityTypeMetadata.class);
    AttributeMetadata attrMetaMeta = ctx.getBean(AttributeMetadata.class);
    L10nStringMetaData l10nStringMeta = ctx.getBean(L10nStringMetaData.class);
    languageCodes.forEach(languageCode -> {
        entityTypeMeta.addAttribute(getI18nAttributeName(EntityTypeMetadata.LABEL, languageCode)).setNillable(true).setLabel("Label (" + languageCode + ')');
        entityTypeMeta.addAttribute(getI18nAttributeName(EntityTypeMetadata.DESCRIPTION, languageCode)).setNillable(true).setLabel("Description (" + languageCode + ')').setDataType(TEXT);
        attrMetaMeta.addAttribute(getI18nAttributeName(AttributeMetadata.LABEL, languageCode)).setNillable(true).setLabel("Label (" + languageCode + ')');
        attrMetaMeta.addAttribute(getI18nAttributeName(AttributeMetadata.DESCRIPTION, languageCode)).setNillable(true).setLabel("Description (" + languageCode + ')').setDataType(TEXT);
        l10nStringMeta.addAttribute(languageCode).setNillable(true).setDataType(TEXT);
    });
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) EntityTypeMetadata(org.molgenis.data.meta.model.EntityTypeMetadata) AttributeMetadata(org.molgenis.data.meta.model.AttributeMetadata) L10nStringMetaData(org.molgenis.data.i18n.model.L10nStringMetaData)

Example 2 with EntityTypeMetadata

use of org.molgenis.data.meta.model.EntityTypeMetadata 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));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) EntityTypeMetadata(org.molgenis.data.meta.model.EntityTypeMetadata) SystemPackage(org.molgenis.data.meta.SystemPackage) RootSystemPackage(org.molgenis.data.system.model.RootSystemPackage) AttributeMetadata(org.molgenis.data.meta.model.AttributeMetadata) SystemEntityType(org.molgenis.data.meta.SystemEntityType)

Example 3 with EntityTypeMetadata

use of org.molgenis.data.meta.model.EntityTypeMetadata in project molgenis by molgenis.

the class AbstractMolgenisSpringTest method abstractMolgenisSpringTestBeforeClass.

// long method name, because if a method annotated with @BeforeClass and the same method name exists in a subclass then this method is ignored.
@BeforeClass
public void abstractMolgenisSpringTestBeforeClass() {
    // bootstrap meta data
    EntityTypeMetadata entityTypeMeta = applicationContext.getBean(EntityTypeMetadata.class);
    entityTypeMeta.setBackendEnumOptions(newArrayList("test"));
    applicationContext.getBean(AttributeMetadata.class).bootstrap(entityTypeMeta);
    Map<String, SystemEntityType> systemEntityTypeMap = applicationContext.getBeansOfType(SystemEntityType.class);
    new GenericDependencyResolver().resolve(systemEntityTypeMap.values(), SystemEntityType::getDependencies).forEach(systemEntityType -> systemEntityType.bootstrap(entityTypeMeta));
}
Also used : EntityTypeMetadata(org.molgenis.data.meta.model.EntityTypeMetadata) AttributeMetadata(org.molgenis.data.meta.model.AttributeMetadata) SystemEntityType(org.molgenis.data.meta.SystemEntityType) GenericDependencyResolver(org.molgenis.data.util.GenericDependencyResolver) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

AttributeMetadata (org.molgenis.data.meta.model.AttributeMetadata)3 EntityTypeMetadata (org.molgenis.data.meta.model.EntityTypeMetadata)3 SystemEntityType (org.molgenis.data.meta.SystemEntityType)2 ApplicationContext (org.springframework.context.ApplicationContext)2 L10nStringMetaData (org.molgenis.data.i18n.model.L10nStringMetaData)1 SystemPackage (org.molgenis.data.meta.SystemPackage)1 RootSystemPackage (org.molgenis.data.system.model.RootSystemPackage)1 GenericDependencyResolver (org.molgenis.data.util.GenericDependencyResolver)1 BeforeClass (org.testng.annotations.BeforeClass)1