Search in sources :

Example 1 with ParsedMetaData

use of org.molgenis.data.importer.ParsedMetaData in project molgenis by molgenis.

the class EmxMetaDataParser method parse.

@Override
public // FIXME The source is parsed twice!!! Once by determineImportableEntities and once by doImport
ParsedMetaData parse(final RepositoryCollection source, String packageId) {
    if (source.getRepository(EMX_ATTRIBUTES) != null) {
        IntermediateParseResults intermediateResults = getEntityTypeFromSource(source);
        List<EntityType> entities;
        if (packageId == null) {
            entities = intermediateResults.getEntities();
        } else {
            entities = putEntitiesInDefaultPackage(intermediateResults, packageId);
        }
        return new ParsedMetaData(entityTypeDependencyResolver.resolve(entities), intermediateResults.getPackages(), intermediateResults.getTags(), intermediateResults.getLanguages(), intermediateResults.getL10nStrings());
    } else {
        if (dataService != null) {
            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());
        } else {
            throw new UnsupportedOperationException();
        }
    }
}
Also used : SystemEntityType(org.molgenis.data.meta.SystemEntityType) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ParsedMetaData(org.molgenis.data.importer.ParsedMetaData) L10nString(org.molgenis.data.i18n.model.L10nString)

Example 2 with ParsedMetaData

use of org.molgenis.data.importer.ParsedMetaData in project molgenis by molgenis.

the class EmxDataProviderTest method testGetEntityTypes.

@Test
public void testGetEntityTypes() throws Exception {
    ImmutableCollection<EntityType> entityTypes = ImmutableList.of();
    ParsedMetaData parsedMetaData = mock(ParsedMetaData.class);
    when(parsedMetaData.getEntities()).thenReturn(entityTypes).getMock();
    when(emxImportJob.getParsedMetaData()).thenReturn(parsedMetaData);
    assertEquals(emxDataProvider.getEntityTypes().collect(toList()), emptyList());
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) ParsedMetaData(org.molgenis.data.importer.ParsedMetaData) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Aggregations

ParsedMetaData (org.molgenis.data.importer.ParsedMetaData)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 L10nString (org.molgenis.data.i18n.model.L10nString)1 SystemEntityType (org.molgenis.data.meta.SystemEntityType)1 EntityType (org.molgenis.data.meta.model.EntityType)1 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)1 Test (org.testng.annotations.Test)1