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();
}
}
}
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());
}
Aggregations