private Flw processProvider(Map<String, FlwGroup> flwGroups, Provider provider) { logger.info(String.format("Creating/Updating provider with id: %s", provider.getId())); Map<String, Object> parsedProvider = providerParser.parse(provider); Flw flw = genericMapper.map(Flw.class, parsedProvider); flw.setFlwGroups(new HashSet<>(getAssociatedFlwGroups(provider.getGroups(), flwGroups))); flw.setLocationDimension(getLocationDimension(parsedProvider)); return flw; }
public void processProviderSync(List<Provider> providers) { List<Flw> flws = new ArrayList<>(); Map<String, FlwGroup> flwGroups = new HashMap<>(); for (Provider provider : providers) { try { Flw flw = processProvider(flwGroups, provider); flws.add(flw); } catch (Exception e) { logger.error( String.format("Error occurred while processing provider with id: %s", provider.getId()), e); } } service.saveOrUpdateAllByExternalPrimaryKey(Flw.class, flws); }