Search in sources :

Example 1 with TagValidator

use of org.molgenis.data.validation.meta.TagValidator in project molgenis by molgenis.

the class EmxMetaDataParser method buildValidationReport.

private EntitiesValidationReport buildValidationReport(RepositoryCollection source, MyEntitiesValidationReport report, Map<String, EntityType> metaDataMap) {
    metaDataMap.values().forEach(entityTypeValidator::validate);
    metaDataMap.values().stream().map(EntityType::getAllAttributes).forEach(attributes -> attributes.forEach(attr -> {
        attributeValidator.validate(attr, ValidationMode.ADD_SKIP_ENTITY_VALIDATION);
    }));
    // validate package/entity/attribute tags
    metaDataMap.values().stream().map(EntityType::getPackage).filter(Objects::nonNull).forEach(package_ -> package_.getTags().forEach(tagValidator::validate));
    metaDataMap.values().forEach(entityType -> entityType.getTags().forEach(tagValidator::validate));
    metaDataMap.values().stream().map(EntityType::getAllAttributes).forEach(attributes -> attributes.forEach(attr -> {
        attr.getTags().forEach(tagValidator::validate);
    }));
    report = generateEntityValidationReport(source, report, metaDataMap);
    // Add entities without data
    for (String entityTypeId : metaDataMap.keySet()) {
        if (!report.getSheetsImportable().containsKey(entityTypeId))
            report.addEntity(entityTypeId, true);
    }
    return report;
}
Also used : EntitiesValidationReport(org.molgenis.data.importer.EntitiesValidationReport) DefaultPackage(org.molgenis.data.meta.DefaultPackage) Language(org.molgenis.data.i18n.model.Language) StringUtils(org.apache.commons.lang3.StringUtils) L10N_STRING(org.molgenis.data.i18n.model.L10nStringMetaData.L10N_STRING) SystemEntityType(org.molgenis.data.meta.SystemEntityType) PACKAGE_SEPARATOR(org.molgenis.data.meta.model.Package.PACKAGE_SEPARATOR) EntityTypeValidator(org.molgenis.data.validation.meta.EntityTypeValidator) L10nString(org.molgenis.data.i18n.model.L10nString) AttributeState(org.molgenis.data.importer.MyEntitiesValidationReport.AttributeState) LanguageService(org.molgenis.i18n.LanguageService) MetaDataParser(org.molgenis.data.importer.MetaDataParser) ValidationMode(org.molgenis.data.validation.meta.AttributeValidator.ValidationMode) org.molgenis.data(org.molgenis.data) ImmutableMap(com.google.common.collect.ImmutableMap) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) Collections.emptyList(java.util.Collections.emptyList) EntityTypeUtils(org.molgenis.data.support.EntityTypeUtils) ParsedMetaData(org.molgenis.data.importer.ParsedMetaData) TagValidator(org.molgenis.data.validation.meta.TagValidator) String.format(java.lang.String.format) EntityTypeUtils.isStringType(org.molgenis.data.support.EntityTypeUtils.isStringType) FILE_META(org.molgenis.data.file.model.FileMetaMetaData.FILE_META) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) AttributeUtils.isIdAttributeTypeAllowed(org.molgenis.data.support.AttributeUtils.isIdAttributeTypeAllowed) EntityTypeUtils.isReferenceType(org.molgenis.data.support.EntityTypeUtils.isReferenceType) LANGUAGE(org.molgenis.data.i18n.model.LanguageMetadata.LANGUAGE) Maps.newLinkedHashMap(com.google.common.collect.Maps.newLinkedHashMap) TRUE(java.lang.Boolean.TRUE) EntityTypeDependencyResolver(org.molgenis.data.meta.EntityTypeDependencyResolver) I18nUtils.getLanguageCode(org.molgenis.data.i18n.I18nUtils.getLanguageCode) EntityUtils(org.molgenis.data.util.EntityUtils) Iterables(com.google.common.collect.Iterables) java.util(java.util) I18nUtils.isI18n(org.molgenis.data.i18n.I18nUtils.isI18n) MyEntitiesValidationReport(org.molgenis.data.importer.MyEntitiesValidationReport) DataConverter.toList(org.molgenis.data.DataConverter.toList) ENTITY_TYPE_META_DATA(org.molgenis.data.meta.model.EntityTypeMetadata.ENTITY_TYPE_META_DATA) Objects.requireNonNull(java.util.Objects.requireNonNull) ATTRIBUTE_META_DATA(org.molgenis.data.meta.model.AttributeMetadata.ATTRIBUTE_META_DATA) FALSE(java.lang.Boolean.FALSE) AttributeType(org.molgenis.data.meta.AttributeType) L10nStringFactory(org.molgenis.data.i18n.model.L10nStringFactory) LanguageFactory(org.molgenis.data.i18n.model.LanguageFactory) org.molgenis.data.meta.model(org.molgenis.data.meta.model) ImmutableMap.builder(com.google.common.collect.ImmutableMap.builder) Package(org.molgenis.data.meta.model.Package) AttributeValidator(org.molgenis.data.validation.meta.AttributeValidator) TAG(org.molgenis.data.meta.model.TagMetadata.TAG) SystemEntityType(org.molgenis.data.meta.SystemEntityType) L10nString(org.molgenis.data.i18n.model.L10nString)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableMap.builder (com.google.common.collect.ImmutableMap.builder)1 Iterables (com.google.common.collect.Iterables)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 Maps.newLinkedHashMap (com.google.common.collect.Maps.newLinkedHashMap)1 FALSE (java.lang.Boolean.FALSE)1 TRUE (java.lang.Boolean.TRUE)1 String.format (java.lang.String.format)1 java.util (java.util)1 Collections.emptyList (java.util.Collections.emptyList)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 StringUtils (org.apache.commons.lang3.StringUtils)1 org.molgenis.data (org.molgenis.data)1 DataConverter.toList (org.molgenis.data.DataConverter.toList)1 FILE_META (org.molgenis.data.file.model.FileMetaMetaData.FILE_META)1 I18nUtils.getLanguageCode (org.molgenis.data.i18n.I18nUtils.getLanguageCode)1 I18nUtils.isI18n (org.molgenis.data.i18n.I18nUtils.isI18n)1 L10nString (org.molgenis.data.i18n.model.L10nString)1 L10nStringFactory (org.molgenis.data.i18n.model.L10nStringFactory)1