Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1.     public UupPotentialPrevention create(@NonNull Case admCase) {
  2.         checkArgument(admCase.getCitizen() != null, "Can't create UupPotentialPrevention, citizen is null, caseId = %s", admCase.getCaseId());
  3.         log.info("Creating UupPotentialPrevention, caseId = {}", admCase.getCaseId());
  4.         UupPrevention prevention = uupPreventionService.findByCitizenId(admCase.getCitizen().getCitizenId());
  5.         House house = houseService.findHouseByAddressId(admCase.getCommitAddress().getAddressId());
  6.         AdmDistrict district = house != null ? house.getDistrict() : null;
  7.  
  8.         if (prevention != null) {
  9.             if (uupPreventionService.hasActiveMonitoringWithCategory(prevention, UUP_PREVENTIVE_CATEGORY_OFFENSE_IN_FAMILY_RELATIONS)) {
  10.                 return null;
  11.             }
  12.             if (district == null || uupPreventionService.hasActiveMonitoring(admCase.getCitizen().getCitizenId())) {
  13.                 district = prevention.getDistrict();
  14.             }
  15.         }
  16.         UupPotentialPrevention entity = new UupPotentialPrevention();
  17.         entity.setAdmDistrict(district);
  18.         entity.setDepartment(district != null && district.getDepartment() != null ? district.getDepartment() : admCase.getDepartment());
  19.         entity.setAdmCase(admCase);
  20.         entity.setPreventiveCategory(listService.findElement(ListEntityItem.PREVENTIVE_CATEGORY, UUP_PREVENTIVE_CATEGORY_OFFENSE_IN_FAMILY_RELATIONS));
  21.  
  22.         if (admCase.getResolutions() != null) {
  23.             admCase.getResolutions().stream()
  24.                     .filter(r -> isAdmPunishmentResolutionType(r.getResolutionType().getReferenceId()))
  25.                     .findFirst()
  26.                     .map(Resolution::getMainPunishment)
  27.                     .map(Punishment::getPunishmentTypeElm)
  28.                     .ifPresent(entity::setMainPunishmentType);
  29.         }
  30.  
  31.         repository.save(entity);
  32.         log.info("created UupPotentialPrevention with id = {}", entity.getPotentialPreventionId());
  33.         return entity;
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement