private void updateAlternateContactNumber( FrontLineWorker frontLineWorker, MsisdnImportRequest request) { if (!request.isUpdateAlternateContactNumber()) { return; } frontLineWorker.setAlternateContactNumber(request.alternateContactNumberAsLong()); }
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; }
@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); }