public void processGroupSync(List<Group> groups) {
   List<FlwGroup> flwGroups = new ArrayList<>();
   for (Group group : groups) {
     String id = group.getId();
     logger.info(String.format("Creating/Updating group with id: %s", id));
     try {
       FlwGroup flwGroup = processGroup(group);
       flwGroups.add(flwGroup);
     } catch (Exception e) {
       logger.error(String.format("Error occurred while processing group with id: %s", id), e);
     }
   }
   service.saveOrUpdateAllByExternalPrimaryKey(FlwGroup.class, flwGroups);
 }
 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);
 }
 private List<FlwGroup> getAssociatedFlwGroups(
     List<String> groups, Map<String, FlwGroup> existingFlwGroups) {
   ArrayList<FlwGroup> flwGroups = new ArrayList<>();
   if (groups == null) return flwGroups;
   for (String groupId : groups) {
     FlwGroup group;
     if (existingFlwGroups.containsKey(groupId)) {
       group = existingFlwGroups.get(groupId);
     } else {
       group = service.getOrCreateGroup(groupId);
       existingFlwGroups.put(groupId, group);
     }
     flwGroups.add(group);
   }
   return flwGroups;
 }
 private LocationDimension getLocationDimension(Map<String, Object> parsedProvider) {
   return service.getLocation(
       (String) parsedProvider.get("state"),
       (String) parsedProvider.get("district"),
       (String) parsedProvider.get("block"));
 }