Search in sources :

Example 1 with AttributeMetadata

use of org.molgenis.data.meta.model.AttributeMetadata 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)

Aggregations

L10nStringMetaData (org.molgenis.data.i18n.model.L10nStringMetaData)1 AttributeMetadata (org.molgenis.data.meta.model.AttributeMetadata)1 EntityTypeMetadata (org.molgenis.data.meta.model.EntityTypeMetadata)1 ApplicationContext (org.springframework.context.ApplicationContext)1