Search in sources :

Example 1 with PersistResult

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;
}
Also used : PersistResult(org.molgenis.data.importer.PersistResult) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PersistResult (org.molgenis.data.importer.PersistResult)1 Transactional (org.springframework.transaction.annotation.Transactional)1