private void upsertScheduledJobTypes() { dataService .getRepository(SCHEDULED_JOB_TYPE, ScheduledJobType.class) .upsertBatch(scheduledJobTypes); }
public void populate(ApplicationContext ctx) { Map<String, Plugin> newOrChangedPluginMap = getPlugins(ctx); List<Plugin> deletedPlugins = new ArrayList<>(); Map<String, Plugin> existingPluginMap = dataService .findAll(PLUGIN, Plugin.class) .collect(toMap(Plugin::getId, Function.identity())); existingPluginMap.forEach( (pluginId, plugin) -> { if (newOrChangedPluginMap.get(pluginId) == null && !pluginId.startsWith(APP_PREFIX)) { deletedPlugins.add(plugin); } }); if (!newOrChangedPluginMap.isEmpty()) { dataService .getRepository(PLUGIN, Plugin.class) .upsertBatch(newArrayList(newOrChangedPluginMap.values())); } if (!deletedPlugins.isEmpty()) { dataService.delete(PLUGIN, deletedPlugins.stream()); } }
private void processBatch(EntityMapping sourceMapping, Repository<Entity> targetRepo, Progress progress, AtomicLong counter, boolean canAdd, List<Entity> entities) { List<Entity> mappedEntities = mapEntities(sourceMapping, targetRepo.getEntityType(), entities); if (canAdd) { targetRepo.add(mappedEntities.stream()); } else { targetRepo.upsertBatch(mappedEntities); } progress.increment(1); counter.addAndGet(entities.size()); }
private void processBatch( EntityMapping sourceMapping, Repository<Entity> targetRepo, Progress progress, AtomicLong counter, boolean canAdd, List<Entity> entities, int depth) { List<Entity> mappedEntities = mapEntities(sourceMapping, targetRepo.getEntityType(), entities, depth); if (canAdd) { targetRepo.add(mappedEntities.stream()); } else { targetRepo.upsertBatch(mappedEntities); } progress.increment(1); counter.addAndGet(entities.size()); }