@Test void testParse() { initMetaFactories(); MetaDataService metaDataService = createMetaDataService(); when(dataService.getMeta()).thenReturn(metaDataService); RepositoryCollection repositoryCollection = createEmxRepositoryCollection(); ParsedMetaData expectedParsedMetaData = new ParsedMetaData( ImmutableList.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of()); ParsedMetaData parsedMetaData = emxMetadataParser.parse(repositoryCollection, null); assertEquals(expectedParsedMetaData, parsedMetaData); }
@Override public ParsedMetaData parse( final RepositoryCollection source, @Nullable @CheckForNull String packageId) { if (source.getRepository(EMX_ATTRIBUTES) != null) { IntermediateParseResults intermediateResults = getEntityTypeFromSource(source); List<EntityType> entities; if (packageId == null) { entities = intermediateResults.getEntityTypes(); } else { entities = putEntitiesInDefaultPackage(intermediateResults, packageId); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(entities), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } else { List<EntityType> metadataList = new ArrayList<>(); for (String emxName : source.getEntityTypeIds()) { String repoName = EMX_NAME_TO_REPO_NAME_MAP.get(emxName); if (repoName == null) repoName = emxName; metadataList.add(dataService.getRepository(repoName).getEntityType()); } IntermediateParseResults intermediateResults = parseTagsSheet(source.getRepository(EMX_TAGS)); parsePackagesSheet(source.getRepository(EMX_PACKAGES), intermediateResults); if (source.hasRepository(EMX_LANGUAGES)) { parseLanguages(source.getRepository(EMX_LANGUAGES), intermediateResults); } if (source.hasRepository(EMX_I18NSTRINGS)) { parseI18nStrings(source.getRepository(EMX_I18NSTRINGS), intermediateResults); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(metadataList), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } }
EmxMetadataParser implements MetadataParser { @Override public ParsedMetaData parse( final RepositoryCollection source, @Nullable @CheckForNull String packageId) { if (source.getRepository(EMX_ATTRIBUTES) != null) { IntermediateParseResults intermediateResults = getEntityTypeFromSource(source); List<EntityType> entities; if (packageId == null) { entities = intermediateResults.getEntityTypes(); } else { entities = putEntitiesInDefaultPackage(intermediateResults, packageId); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(entities), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } else { List<EntityType> metadataList = new ArrayList<>(); for (String emxName : source.getEntityTypeIds()) { String repoName = EMX_NAME_TO_REPO_NAME_MAP.get(emxName); if (repoName == null) repoName = emxName; metadataList.add(dataService.getRepository(repoName).getEntityType()); } IntermediateParseResults intermediateResults = parseTagsSheet(source.getRepository(EMX_TAGS)); parsePackagesSheet(source.getRepository(EMX_PACKAGES), intermediateResults); if (source.hasRepository(EMX_LANGUAGES)) { parseLanguages(source.getRepository(EMX_LANGUAGES), intermediateResults); } if (source.hasRepository(EMX_I18NSTRINGS)) { parseI18nStrings(source.getRepository(EMX_I18NSTRINGS), intermediateResults); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(metadataList), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } } }
EmxMetadataParser implements MetadataParser { @Override public ParsedMetaData parse( final RepositoryCollection source, @Nullable @CheckForNull String packageId) { if (source.getRepository(EMX_ATTRIBUTES) != null) { IntermediateParseResults intermediateResults = getEntityTypeFromSource(source); List<EntityType> entities; if (packageId == null) { entities = intermediateResults.getEntityTypes(); } else { entities = putEntitiesInDefaultPackage(intermediateResults, packageId); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(entities), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } else { List<EntityType> metadataList = new ArrayList<>(); for (String emxName : source.getEntityTypeIds()) { String repoName = EMX_NAME_TO_REPO_NAME_MAP.get(emxName); if (repoName == null) repoName = emxName; metadataList.add(dataService.getRepository(repoName).getEntityType()); } IntermediateParseResults intermediateResults = parseTagsSheet(source.getRepository(EMX_TAGS)); parsePackagesSheet(source.getRepository(EMX_PACKAGES), intermediateResults); if (source.hasRepository(EMX_LANGUAGES)) { parseLanguages(source.getRepository(EMX_LANGUAGES), intermediateResults); } if (source.hasRepository(EMX_I18NSTRINGS)) { parseI18nStrings(source.getRepository(EMX_I18NSTRINGS), intermediateResults); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(metadataList), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } } EmxMetadataParser(
      DataService dataService,
      PackageFactory packageFactory,
      AttributeFactory attrMetaFactory,
      EntityTypeFactory entityTypeFactory,
      TagFactory tagFactory,
      LanguageFactory languageFactory,
      L10nStringFactory l10nStringFactory,
      EntityTypeValidator entityTypeValidator,
      AttributeValidator attributeValidator,
      TagValidator tagValidator,
      EntityTypeDependencyResolver entityTypeDependencyResolver); }
EmxMetadataParser implements MetadataParser { @Override public ParsedMetaData parse( final RepositoryCollection source, @Nullable @CheckForNull String packageId) { if (source.getRepository(EMX_ATTRIBUTES) != null) { IntermediateParseResults intermediateResults = getEntityTypeFromSource(source); List<EntityType> entities; if (packageId == null) { entities = intermediateResults.getEntityTypes(); } else { entities = putEntitiesInDefaultPackage(intermediateResults, packageId); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(entities), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } else { List<EntityType> metadataList = new ArrayList<>(); for (String emxName : source.getEntityTypeIds()) { String repoName = EMX_NAME_TO_REPO_NAME_MAP.get(emxName); if (repoName == null) repoName = emxName; metadataList.add(dataService.getRepository(repoName).getEntityType()); } IntermediateParseResults intermediateResults = parseTagsSheet(source.getRepository(EMX_TAGS)); parsePackagesSheet(source.getRepository(EMX_PACKAGES), intermediateResults); if (source.hasRepository(EMX_LANGUAGES)) { parseLanguages(source.getRepository(EMX_LANGUAGES), intermediateResults); } if (source.hasRepository(EMX_I18NSTRINGS)) { parseI18nStrings(source.getRepository(EMX_I18NSTRINGS), intermediateResults); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(metadataList), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } } EmxMetadataParser(
      DataService dataService,
      PackageFactory packageFactory,
      AttributeFactory attrMetaFactory,
      EntityTypeFactory entityTypeFactory,
      TagFactory tagFactory,
      LanguageFactory languageFactory,
      L10nStringFactory l10nStringFactory,
      EntityTypeValidator entityTypeValidator,
      AttributeValidator attributeValidator,
      TagValidator tagValidator,
      EntityTypeDependencyResolver entityTypeDependencyResolver); @Override ParsedMetaData parse(
      final RepositoryCollection source, @Nullable @CheckForNull String packageId); @Override EntitiesValidationReport validate(RepositoryCollection source); }
EmxMetadataParser implements MetadataParser { @Override public ParsedMetaData parse( final RepositoryCollection source, @Nullable @CheckForNull String packageId) { if (source.getRepository(EMX_ATTRIBUTES) != null) { IntermediateParseResults intermediateResults = getEntityTypeFromSource(source); List<EntityType> entities; if (packageId == null) { entities = intermediateResults.getEntityTypes(); } else { entities = putEntitiesInDefaultPackage(intermediateResults, packageId); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(entities), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } else { List<EntityType> metadataList = new ArrayList<>(); for (String emxName : source.getEntityTypeIds()) { String repoName = EMX_NAME_TO_REPO_NAME_MAP.get(emxName); if (repoName == null) repoName = emxName; metadataList.add(dataService.getRepository(repoName).getEntityType()); } IntermediateParseResults intermediateResults = parseTagsSheet(source.getRepository(EMX_TAGS)); parsePackagesSheet(source.getRepository(EMX_PACKAGES), intermediateResults); if (source.hasRepository(EMX_LANGUAGES)) { parseLanguages(source.getRepository(EMX_LANGUAGES), intermediateResults); } if (source.hasRepository(EMX_I18NSTRINGS)) { parseI18nStrings(source.getRepository(EMX_I18NSTRINGS), intermediateResults); } return new ParsedMetaData( entityTypeDependencyResolver.resolve(metadataList), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings()); } } EmxMetadataParser(
      DataService dataService,
      PackageFactory packageFactory,
      AttributeFactory attrMetaFactory,
      EntityTypeFactory entityTypeFactory,
      TagFactory tagFactory,
      LanguageFactory languageFactory,
      L10nStringFactory l10nStringFactory,
      EntityTypeValidator entityTypeValidator,
      AttributeValidator attributeValidator,
      TagValidator tagValidator,
      EntityTypeDependencyResolver entityTypeDependencyResolver); @Override ParsedMetaData parse(
      final RepositoryCollection source, @Nullable @CheckForNull String packageId); @Override EntitiesValidationReport validate(RepositoryCollection source); static final String EMX_PACKAGES; static final String EMX_ENTITIES; static final String EMX_ATTRIBUTES; static final String EMX_PACKAGE_NAME; static final String EMX_PACKAGE_DESCRIPTION; static final String EMX_PACKAGE_PARENT; static final String EMX_PACKAGE_TAGS; static final String EMX_PACKAGE_LABEL; static final String EMX_ENTITIES_NAME; static final String EMX_ENTITIES_PACKAGE; static final String EMX_ENTITIES_LABEL; static final String EMX_ENTITIES_DESCRIPTION; static final String EMX_ENTITIES_ABSTRACT; static final String EMX_ENTITIES_EXTENDS; static final String EMX_ENTITIES_BACKEND; static final String EMX_ENTITIES_TAGS; static final String EMX_ATTRIBUTES_NAME; static final String EMX_ATTRIBUTES_ENTITY; static final String EMX_ATTRIBUTES_REF_ENTITY; static final String EMX_ATTRIBUTES_MAPPED_BY; static final String EMX_ATTRIBUTES_DEFAULT_VALUE; static final String EMX_ATTRIBUTES_ID_ATTRIBUTE; static final String EMX_ATTRIBUTES_LOOKUP_ATTRIBUTE; static final String EMX_ATTRIBUTES_LABEL_ATTRIBUTE; static final String EMX_ATTRIBUTES_PART_OF_ATTRIBUTE; static final String EMX_ATTRIBUTES_AGGREGATEABLE; static final String EMX_ATTRIBUTES_DATA_TYPE; static final String EMX_ATTRIBUTES_EXPRESSION; static final String EMX_ATTRIBUTES_NILLABLE; static final String EMX_ATTRIBUTES_VISIBLE; static final String EMX_ATTRIBUTES_LABEL; static final String EMX_ATTRIBUTES_DESCRIPTION; static final String EMX_ATTRIBUTES_ENUM_OPTIONS; static final String EMX_ATTRIBUTES_RANGE_MIN; static final String EMX_ATTRIBUTES_RANGE_MAX; static final String EMX_ATTRIBUTES_READ_ONLY; static final String EMX_ATTRIBUTES_UNIQUE; static final String EMX_ATTRIBUTES_VALIDATION_EXPRESSION; static final String EMX_ATTRIBUTES_TAGS; static final String EMX_ATTRIBUTES_AUTO; static final String AUTO; }