use of org.molgenis.data.importer.PersistResult in project molgenis by molgenis.
the class ImportWriter method doImport.
@Transactional
public EntityImportReport doImport(EmxImportJob job) {
runAsSystem(() -> {
importTags(job.parsedMetaData);
importPackages(job.parsedMetaData);
});
GroupedEntityTypes groupedEntityTypes = groupEntityTypes(job.parsedMetaData.getEntities());
validateEntityTypePermissions(groupedEntityTypes.getUpdatedEntityTypes());
PersistResult persistResult = runAsSystem(() -> dataPersister.persist(new EmxDataProvider(job, entityManager), UPSERT, toDataMode(job.dbAction)));
permissionSystemService.giveUserWriteMetaPermissions(groupedEntityTypes.getNewEntityTypes());
persistResult.getNrPersistedEntitiesMap().forEach((key, value) -> job.report.addEntityCount(key, Math.toIntExact(value)));
groupedEntityTypes.getNewEntityTypes().stream().map(EntityType::getId).forEach(job.report::addNewEntity);
return job.report;
}
Aggregations