Skip to content

Commit

Permalink
Patch 1.7.1
Browse files Browse the repository at this point in the history
Modify getFic to keep respond to this service when onglet = 1
Do not concat adress for this service.

Add deprecated logs for this service.
  • Loading branch information
pierrejego committed Mar 27, 2019
1 parent 6ac1c1b commit 3676845
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 38 deletions.
2 changes: 1 addition & 1 deletion cadastrapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.georchestra</groupId>
<artifactId>cadastrapp-parent</artifactId>
<version>1.8-SNAPSHOT</version>
<version>1.7.1</version>
</parent>
<artifactId>cadastrapp</artifactId>
<packaging>war</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Map<String, Object>> getProprietairesByParcelles(HttpHeaders headers, List<String> parcelleList, boolean isAddressConcat) {

// Init list to return response even if nothing in it.
List<Map<String,Object>> proprietaires = new ArrayList<Map<String,Object>>();

// 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";


/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand Down Expand Up @@ -196,39 +198,7 @@ public List<Map<String,Object>> getProprietairesByParcelle(
@QueryParam("parcelles") List<String> parcelleList
) throws SQLException {

// Init list to return response even if nothing in it.
List<Map<String,Object>> proprietaires = new ArrayList<Map<String,Object>>();;

// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,6 +26,9 @@ public class UniteCadastraleController extends CadController {

@Autowired
BatimentHelper batimentHelper;

@Autowired
ProprietaireHelper proprietaireHelper;

@Path("/getFIC")
@GET
Expand Down Expand Up @@ -57,7 +61,11 @@ public List<Map<String, Object>> 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<String> parcelles = new ArrayList<String>();
parcelles.add(parcelle);
information = proprietaireHelper.getProprietairesByParcelles(headers, parcelles, false);
logger.warn("Deprecated service, use getProprietairesByParcelle instead");
break;
case 2:
if (getUserCNILLevel(headers)>1){
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.georchestra</groupId>
<artifactId>cadastrapp-parent</artifactId>
<version>1.8-SNAPSHOT</version>
<version>1.7.1</version>
<packaging>pom</packaging>
<modules>
<module>cadastrapp</module>
Expand Down

0 comments on commit 3676845

Please sign in to comment.