fusion maj parcelle,batiment,ulo et leur enquete
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 2m33s
All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 2m33s
This commit is contained in:
@@ -54,6 +54,7 @@ public class EnqueteBatimentController {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e.getLocalizedMessage());
|
||||
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -94,6 +94,7 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
@Override
|
||||
@Transactional
|
||||
public EnquetePayLoadWeb createEnquete(EnquetePayLoadWeb enquetePayLoadWeb) throws BadRequestException {
|
||||
|
||||
Optional<User> optionalUser = userRepository.findById(enquetePayLoadWeb.getEnqueteurId());
|
||||
if (!optionalUser.isPresent()) {
|
||||
throw new BadRequestException("Echec de l'enregistrement : Enquêteur inexistant");
|
||||
@@ -115,10 +116,6 @@ public class EnqueteServiceImpl implements EnqueteService {
|
||||
throw new BadRequestException("Echec de l'enregistrement : zone inexistante");
|
||||
}
|
||||
|
||||
// if (enquetePayLoadWeb.getParcelleId() == null) {
|
||||
// throw new ApplicationException("Echec de l'enregistrement : La parcelle non renseignée.");
|
||||
// }
|
||||
|
||||
ParcellePayLoadWeb parcellePayLoadWeb= getParcellePayloadFromEnquetePl(enquetePayLoadWeb);
|
||||
|
||||
if(enquetePayLoadWeb.getParcelleId()==null){
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package io.gmss.fiscad.implementations.rfu.metier;
|
||||
|
||||
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
|
||||
import io.gmss.fiscad.entities.rfu.metier.Batiment;
|
||||
import io.gmss.fiscad.entities.rfu.parametre.CategorieBatiment;
|
||||
import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.BatimentPaylaodWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CategorieBatimentRepository;
|
||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -19,6 +23,8 @@ import java.util.Optional;
|
||||
public class BatimentServiceImpl implements BatimentService {
|
||||
|
||||
private final BatimentRepository batimentRepository;
|
||||
private final ParcelleRepository parcelleRepository;
|
||||
private final CategorieBatimentRepository categorieBatimentRepository;
|
||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||
|
||||
|
||||
@@ -27,8 +33,22 @@ public class BatimentServiceImpl implements BatimentService {
|
||||
if (batimentPaylaodWeb.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment ayant un id non null.");
|
||||
}
|
||||
if (batimentPaylaodWeb.getParcelleId() == null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment: La parcelle doit être précisée.");
|
||||
}else {
|
||||
if(!parcelleRepository.existsById(batimentPaylaodWeb.getParcelleId()))
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment: La parcelle doit être précisée.");
|
||||
}
|
||||
|
||||
if (batimentPaylaodWeb.getCategorieBatimentId() == null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment: La catégorie doit être précisée.");
|
||||
}else {
|
||||
if(!categorieBatimentRepository.existsById(batimentPaylaodWeb.getCategorieBatimentId()))
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment: La catégorie doit être précisée.");
|
||||
}
|
||||
Batiment batiment= entityFromPayLoadService.getBatimentFromPayLoadWeb(batimentPaylaodWeb);
|
||||
batiment= batimentRepository.save(batiment);
|
||||
System.out.println(batiment.getId());
|
||||
return batimentRepository.findBatimentAvecOccupantCourantToDto(batiment.getId()).orElse(null);
|
||||
}
|
||||
|
||||
@@ -40,6 +60,19 @@ public class BatimentServiceImpl implements BatimentService {
|
||||
if (!batimentRepository.existsById(batimentPaylaodWeb.getId())) {
|
||||
throw new NotFoundException("Impossible de trouver le batiment spécifié dans notre base de données.");
|
||||
}
|
||||
if (batimentPaylaodWeb.getParcelleId() == null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment: La parcelle doit être précisée.");
|
||||
}else {
|
||||
if(!parcelleRepository.existsById(batimentPaylaodWeb.getParcelleId()))
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment: La parcelle doit être précisée.");
|
||||
}
|
||||
|
||||
if (batimentPaylaodWeb.getCategorieBatimentId() == null) {
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment: La catégorie doit être précisée.");
|
||||
}else {
|
||||
if(!categorieBatimentRepository.existsById(batimentPaylaodWeb.getCategorieBatimentId()))
|
||||
throw new BadRequestException("Impossible de créer un nouveau batiment: La catégorie doit être précisée.");
|
||||
}
|
||||
Batiment batiment= entityFromPayLoadService.getBatimentFromPayLoadWeb(batimentPaylaodWeb);
|
||||
batiment= batimentRepository.save(batiment);
|
||||
return batimentRepository.findBatimentAvecOccupantCourantToDto(batiment.getId()).orElse(null);
|
||||
|
||||
@@ -48,9 +48,12 @@ public class EnqueteBatimentServiceImpl implements EnqueteBatimentService {
|
||||
@Transactional
|
||||
public EnqueteBatimentPayloadWeb createEnqueteBatiment(EnqueteBatimentPayloadWeb enqueteBatimentPayloadWeb) throws BadRequestException {
|
||||
EnqueteBatiment enqueteBatiment=new EnqueteBatiment();
|
||||
|
||||
if(enqueteBatimentPayloadWeb.getBatimentId()!=null) {
|
||||
if (!batimentRepository.existsById(enqueteBatimentPayloadWeb.getBatimentId())) {
|
||||
throw new NotFoundException("Impossible d'enregistrer sans le batiment.");
|
||||
}
|
||||
}
|
||||
BatimentPaylaodWeb batimentPaylaodWeb= getBatimentPayloadFromEnqueteBat(enqueteBatimentPayloadWeb);
|
||||
|
||||
if(enqueteBatimentPayloadWeb.getBatimentId()==null){
|
||||
|
||||
@@ -47,9 +47,12 @@ public class EnqueteUniteLogementServiceImpl implements EnqueteUniteLogementServ
|
||||
EnqueteUniteLogement enqueteUniteLogement=new EnqueteUniteLogement();
|
||||
Optional<UniteLogement> optionalUniteLogement= Optional.empty();
|
||||
|
||||
if (enqueteUniteLogementPayloadWeb.getUniteLogementId() == null) {
|
||||
throw new BadRequestException("Impossible d'enregistrer une nouvelle enquete d'unité de logement sans l'unité de logement.");
|
||||
if(enqueteUniteLogementPayloadWeb.getUniteLogementId()!=null) {
|
||||
if (!uniteLogementRepository.existsById(enqueteUniteLogementPayloadWeb.getUniteLogementId())) {
|
||||
throw new NotFoundException("Unité de logement inexistant.");
|
||||
}
|
||||
}
|
||||
|
||||
UniteLogementPaylaodWeb uniteLogementPaylaodWeb=getUniteLogementPayloadFromEnqueteUl(enqueteUniteLogementPayloadWeb);
|
||||
|
||||
if(enqueteUniteLogementPayloadWeb.getId()==null){
|
||||
|
||||
@@ -5,7 +5,10 @@ import io.gmss.fiscad.exceptions.BadRequestException;
|
||||
import io.gmss.fiscad.exceptions.NotFoundException;
|
||||
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
|
||||
import io.gmss.fiscad.paylaods.request.crudweb.UniteLogementPaylaodWeb;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.metier.BatimentRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.metier.UniteLogementRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuNonBatiRepository;
|
||||
import io.gmss.fiscad.persistence.repositories.rfu.parametre.CategorieBatimentRepository;
|
||||
import io.gmss.fiscad.service.EntityFromPayLoadService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -20,6 +23,8 @@ public class UniteLogementServiceImpl implements UniteLogementService {
|
||||
|
||||
private final UniteLogementRepository uniteLogementRepository;
|
||||
private final EntityFromPayLoadService entityFromPayLoadService;
|
||||
private final BatimentRepository batimentRepository;
|
||||
private final CategorieBatimentRepository categorieBatimentRepository;
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +33,21 @@ public class UniteLogementServiceImpl implements UniteLogementService {
|
||||
if (uniteLogementPaylaodWeb.getId() != null) {
|
||||
throw new BadRequestException("Impossible de créer une nouvelle unité de logement ayant un id non null.");
|
||||
}
|
||||
|
||||
if (uniteLogementPaylaodWeb.getBatimentId() == null) {
|
||||
throw new BadRequestException("Impossible de créer l'unité de logement: Le batiment doit être précisé.");
|
||||
}else {
|
||||
if(!batimentRepository.existsById(uniteLogementPaylaodWeb.getBatimentId()))
|
||||
throw new BadRequestException("Impossible de créer l'unite de logement: L'unité de logement doit être précisée.");
|
||||
}
|
||||
|
||||
if (uniteLogementPaylaodWeb.getCategorieBatimentId() == null) {
|
||||
throw new BadRequestException("Impossible de créer l'unite de logement: La catégorie doit être précisée.");
|
||||
}else {
|
||||
if(!categorieBatimentRepository.existsById(uniteLogementPaylaodWeb.getCategorieBatimentId()))
|
||||
throw new BadRequestException("Impossible de créer l'unite de logement: La catégorie doit être précisée.");
|
||||
}
|
||||
|
||||
UniteLogement uniteLogement = entityFromPayLoadService.getUniteLogementFromPayLoadWeb(uniteLogementPaylaodWeb);
|
||||
uniteLogement = uniteLogementRepository.save(uniteLogement);
|
||||
return uniteLogementRepository.findUniteLogementAvecOccupantCourantToDto(uniteLogement.getId()).orElse(null);
|
||||
|
||||
Reference in New Issue
Block a user