private void validateNoOtherFLWExistsWithSameMsisdnAndStatus(
     FrontLineWorkerVerificationRequest request, Errors errors) {
   List<FrontLineWorker> flwWithSameMsisdnAndWithSomeStatus =
       allFrontLineWorkers.getByMsisdnWithStatus(request.getMsisdn());
   if (flwWithSameMsisdnAndWithSomeStatus.size() == 1
       && !flwWithSameMsisdnAndWithSomeStatus.get(0).getFlwId().equals(request.getFlwId())
       && !request.isDummyFlwId())
     errors.add("Conflicting flw record exists. Please try again later.");
 }
  @Transactional
  public void updateFLWContactDetailsWithoutValidations(
      List<MsisdnImportRequest> msisdnImportRequests) {
    List<FrontLineWorker> frontLineWorkersToUpdate = new ArrayList<>();
    List<FrontLineWorker> frontLineWorkersToSync = new ArrayList<>();
    for (MsisdnImportRequest msisdnImportRequest : msisdnImportRequests) {
      FrontLineWorker frontLineWorker =
          allFrontLineWorkers.getByMsisdn(msisdnImportRequest.msisdnAsLong()).get(0);
      updateAlternateContactNumber(frontLineWorker, msisdnImportRequest);
      FrontLineWorker frontLineWorkerToSync =
          changeMsisdnAndGetFLWToSync(frontLineWorker, msisdnImportRequest);

      frontLineWorkersToUpdate.add(frontLineWorker);
      frontLineWorkersToSync.add(frontLineWorkerToSync);
    }
    allFrontLineWorkers.createOrUpdateAll(frontLineWorkersToUpdate);
    syncService.syncAllFrontLineWorkers(frontLineWorkersToSync);
  }
  private FrontLineWorker changeMsisdnAndGetFLWToSync(
      FrontLineWorker frontLineWorker, MsisdnImportRequest request) {
    if (!request.isChangeMsisdn()) {
      return frontLineWorker;
    }
    allFrontLineWorkers.deleteByMsisdn(request.newMsisdnAsLong());

    frontLineWorker.setNewMsisdn(
        new NewMsisdn(request.getNewMsisdn(), frontLineWorker.getFlwId().toString()));
    FrontLineWorker frontLineWorkerToSync = frontLineWorker.clone();
    frontLineWorker.updateToNewMsisdn();
    return frontLineWorkerToSync;
  }
 private void validateChangeMSISDNRequest(ChangeMsisdnRequest request, Errors errors) {
   if (request == null
       || isBlank(request.getFlwId())
       || FrontLineWorker.DEFAULT_UUID_STRING.equals(request.getFlwId())) return;
   FrontLineWorker frontLineWorker =
       allFrontLineWorkers.getByFlwId(UUID.fromString(request.getFlwId()));
   if (frontLineWorker == null) {
     errors.add("FrontLine worker with id in newMsisdn section not found");
     return;
   }
   if (!frontLineWorker.getMsisdn().equals(PhoneNumber.formatPhoneNumber(request.getMsisdn()))) {
     errors.add("Frontline worker with new msisdn and id does not exist");
   }
 }