From 367684565f49fd6375da7d0a589396ee364e7e38 Mon Sep 17 00:00:00 2001 From: pierrejego Date: Wed, 27 Mar 2019 20:18:27 +0100 Subject: [PATCH] Patch 1.7.1 Modify getFic to keep respond to this service when onglet = 1 Do not concat adress for this service. Add deprecated logs for this service. --- cadastrapp/pom.xml | 2 +- .../cadastrapp/helper/ProprietaireHelper.java | 66 +++++++++++++++++++ .../cadastrapp/service/CadController.java | 3 + .../service/ProprietaireController.java | 40 ++--------- .../service/UniteCadastraleController.java | 10 ++- pom.xml | 2 +- 6 files changed, 85 insertions(+), 38 deletions(-) create mode 100644 cadastrapp/src/main/java/org/georchestra/cadastrapp/helper/ProprietaireHelper.java diff --git a/cadastrapp/pom.xml b/cadastrapp/pom.xml index d2dddde4..24397aa6 100644 --- a/cadastrapp/pom.xml +++ b/cadastrapp/pom.xml @@ -4,7 +4,7 @@ org.georchestra cadastrapp-parent - 1.8-SNAPSHOT + 1.7.1 cadastrapp war diff --git a/cadastrapp/src/main/java/org/georchestra/cadastrapp/helper/ProprietaireHelper.java b/cadastrapp/src/main/java/org/georchestra/cadastrapp/helper/ProprietaireHelper.java new file mode 100644 index 00000000..a376233d --- /dev/null +++ b/cadastrapp/src/main/java/org/georchestra/cadastrapp/helper/ProprietaireHelper.java @@ -0,0 +1,66 @@ +package org.georchestra.cadastrapp.helper; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.HttpHeaders; + +import org.georchestra.cadastrapp.service.CadController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Component; + +@Component +public final class ProprietaireHelper extends CadController { + + static final Logger logger = LoggerFactory.getLogger(ProprietaireHelper.class); + + /** + * + * @param parcelle + * @return + */ + public List> getProprietairesByParcelles(HttpHeaders headers, List parcelleList, boolean isAddressConcat) { + + // Init list to return response even if nothing in it. + List> proprietaires = new ArrayList>(); + + // User need to be at least CNIL1 level + if (getUserCNILLevel(headers)>0){ + + if(parcelleList != null && !parcelleList.isEmpty()){ + + StringBuilder queryBuilder = new StringBuilder(); + queryBuilder.append("select distinct prop.dnulp, proparc.parcelle, prop.comptecommunal, prop.app_nom_usage, prop.app_nom_naissance, prop.dldnss, prop.jdatnss, prop.ccodro_lib , prop.ccodro, prop.dformjur, "); + if(isAddressConcat){ + queryBuilder.append(" COALESCE(prop.dlign3, '')||' '||COALESCE(prop.dlign4,'')||' '||COALESCE(prop.dlign5,'')||' '||COALESCE(prop.dlign6,'') as adresse "); + + }else{ + queryBuilder.append(" prop.dlign3, prop.dlign4, prop.dlign5, prop.dlign6 "); + } + queryBuilder.append(" from "); + queryBuilder.append(databaseSchema); + queryBuilder.append(".proprietaire prop, "); + queryBuilder.append(databaseSchema); + queryBuilder.append(".proprietaire_parcelle proparc "); + queryBuilder.append(createWhereInQuery(parcelleList.size(), "proparc.parcelle")); + queryBuilder.append(" and prop.comptecommunal = proparc.comptecommunal"); + queryBuilder.append(addAuthorizationFiltering(headers, "prop.")); + queryBuilder.append(" ORDER BY prop.dnulp, prop.app_nom_usage "); + + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); + proprietaires = jdbcTemplate.queryForList(queryBuilder.toString(), parcelleList.toArray()); + + } + else{ + //log empty request + logger.info(EMPTY_REQUEST_LOG); + } + }else{ + logger.info(ACCES_ERROR_LOG); + } + return proprietaires; + } +} diff --git a/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/CadController.java b/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/CadController.java index 84d02d49..39be9505 100644 --- a/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/CadController.java +++ b/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/CadController.java @@ -40,6 +40,9 @@ public class CadController { protected boolean isSearchFiltered; + protected final String ACCES_ERROR_LOG = "User does not have rights to see thoses informations"; + protected final String EMPTY_REQUEST_LOG = "Parcelle Id List is empty nothing to search"; + /** * diff --git a/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/ProprietaireController.java b/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/ProprietaireController.java index 42d1c484..001901e2 100644 --- a/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/ProprietaireController.java +++ b/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/ProprietaireController.java @@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils; import org.georchestra.cadastrapp.configuration.CadastrappPlaceHolder; +import org.georchestra.cadastrapp.helper.ProprietaireHelper; import org.georchestra.cadastrapp.service.export.ExportHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,11 +34,12 @@ public class ProprietaireController extends CadController{ static final Logger logger = LoggerFactory.getLogger(ProprietaireController.class); - private final String ACCES_ERROR_LOG = "User does not have rights to see thoses informations"; - private final String EMPTY_REQUEST_LOG = "Parcelle Id List is empty nothing to search"; @Autowired ExportHelper exportHelper; + + @Autowired + ProprietaireHelper proprietaireHelper; @GET @Path("/getProprietaire") @@ -196,39 +198,7 @@ public List> getProprietairesByParcelle( @QueryParam("parcelles") List parcelleList ) throws SQLException { - // Init list to return response even if nothing in it. - List> proprietaires = new ArrayList>();; - - // User need to be at least CNIL1 level - if (getUserCNILLevel(headers)>0){ - - if(parcelleList != null && !parcelleList.isEmpty()){ - - StringBuilder queryBuilder = new StringBuilder(); - queryBuilder.append("select distinct prop.dnulp, proparc.parcelle, prop.comptecommunal, prop.app_nom_usage, prop.app_nom_naissance, prop.dldnss, prop.jdatnss, prop.ccodro_lib , prop.ccodro, prop.dformjur, "); - queryBuilder.append(" COALESCE(prop.dlign3, '')||' '||COALESCE(prop.dlign4,'')||' '||COALESCE(prop.dlign5,'')||' '||COALESCE(prop.dlign6,'') as adresse "); - queryBuilder.append(" from "); - queryBuilder.append(databaseSchema); - queryBuilder.append(".proprietaire prop, "); - queryBuilder.append(databaseSchema); - queryBuilder.append(".proprietaire_parcelle proparc "); - queryBuilder.append(createWhereInQuery(parcelleList.size(), "proparc.parcelle")); - queryBuilder.append(" and prop.comptecommunal = proparc.comptecommunal"); - queryBuilder.append(addAuthorizationFiltering(headers, "prop.")); - queryBuilder.append(" ORDER BY prop.dnulp, prop.app_nom_usage "); - - JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); - proprietaires = jdbcTemplate.queryForList(queryBuilder.toString(), parcelleList.toArray()); - } - else{ - //log empty request - logger.info(EMPTY_REQUEST_LOG); - } - }else{ - logger.info(ACCES_ERROR_LOG); - } - - return proprietaires; + return proprietaireHelper.getProprietairesByParcelles(headers, parcelleList, true); } @GET diff --git a/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/UniteCadastraleController.java b/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/UniteCadastraleController.java index 214f25b5..b9805f45 100644 --- a/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/UniteCadastraleController.java +++ b/cadastrapp/src/main/java/org/georchestra/cadastrapp/service/UniteCadastraleController.java @@ -13,6 +13,7 @@ import javax.ws.rs.core.MediaType; import org.georchestra.cadastrapp.helper.BatimentHelper; +import org.georchestra.cadastrapp.helper.ProprietaireHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +26,9 @@ public class UniteCadastraleController extends CadController { @Autowired BatimentHelper batimentHelper; + + @Autowired + ProprietaireHelper proprietaireHelper; @Path("/getFIC") @GET @@ -57,7 +61,11 @@ public List> getInformationCadastrale(@Context HttpHeaders h information = infoOngletParcelle(parcelle, headers); break; case 1: - logger.info("Service not used anymore, use getProprietaireByParcelle instead"); + // Get information about plot owner + List parcelles = new ArrayList(); + parcelles.add(parcelle); + information = proprietaireHelper.getProprietairesByParcelles(headers, parcelles, false); + logger.warn("Deprecated service, use getProprietairesByParcelle instead"); break; case 2: if (getUserCNILLevel(headers)>1){ diff --git a/pom.xml b/pom.xml index 98ab2a05..b42e3f21 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.georchestra cadastrapp-parent - 1.8-SNAPSHOT + 1.7.1 pom cadastrapp