Merge branch 'ch-evo-17-03-2025' into 'main'

Fix :: Erreur 401 sur toutes les ressources à la levée d'une exception quelconque.

See merge request christianakpona/fiscad!6
This commit is contained in:
2025-03-19 07:35:17 +00:00
262 changed files with 8390 additions and 3883 deletions

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import java.net.*; import java.net.*;
import java.io.*; import java.io.*;
import java.nio.channels.*; import java.nio.channels.*;
@@ -25,7 +26,7 @@ public class MavenWrapperDownloader {
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/ */
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/** /**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
@@ -54,7 +55,7 @@ public class MavenWrapperDownloader {
// wrapperUrl parameter. // wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL; String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) { if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null; FileInputStream mavenWrapperPropertyFileInputStream = null;
try { try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
@@ -65,7 +66,7 @@ public class MavenWrapperDownloader {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally { } finally {
try { try {
if(mavenWrapperPropertyFileInputStream != null) { if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close(); mavenWrapperPropertyFileInputStream.close();
} }
} catch (IOException e) { } catch (IOException e) {
@@ -76,8 +77,8 @@ public class MavenWrapperDownloader {
System.out.println("- Downloading from: " + url); System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) { if (!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) { if (!outputFile.getParentFile().mkdirs()) {
System.out.println( System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
} }

View File

@@ -1,6 +1,7 @@
# Getting Started # Getting Started
### Reference Documentation ### Reference Documentation
For further reference, please consider the following sections: For further reference, please consider the following sections:
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) * [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)

View File

@@ -1,245 +1,270 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf --> <!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="60393fd8-8f4e-44f7-8418-0139271081b1"> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<property name="com.jaspersoft.studio.unit." value="pixel"/> xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/> name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802"
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/> leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/> uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/> <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/> <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<parameter name="structure" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<parameter name="logoDroit" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<parameter name="logoGauche" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<queryString> <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<![CDATA[]]> <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
</queryString> <parameter name="structure" class="java.lang.String"/>
<field name="code" class="java.lang.String"/> <parameter name="logoDroit" class="java.lang.String"/>
<field name="nom" class="java.lang.String"/> <parameter name="logoGauche" class="java.lang.String"/>
<field name="arrondissement" class="java.lang.String"/> <queryString>
<field name="commune" class="java.lang.String"/> <![CDATA[]]>
<field name="departement" class="java.lang.String"/> </queryString>
<background> <field name="code" class="java.lang.String"/>
<band splitType="Stretch"/> <field name="nom" class="java.lang.String"/>
</background> <field name="arrondissement" class="java.lang.String"/>
<title> <field name="commune" class="java.lang.String"/>
<band height="134" splitType="Stretch"> <field name="departement" class="java.lang.String"/>
<staticText> <background>
<reportElement x="179" y="75" width="421" height="30" uuid="10a08362-9a39-4235-a0d1-33a733f0861e"/> <band splitType="Stretch"/>
<textElement textAlignment="Center" verticalAlignment="Middle"> </background>
<font size="16" isBold="true"/> <title>
</textElement> <band height="134" splitType="Stretch">
<text><![CDATA[LISTE DES BLOCS]]></text> <staticText>
</staticText> <reportElement x="179" y="75" width="421" height="30" uuid="10a08362-9a39-4235-a0d1-33a733f0861e"/>
<staticText> <textElement textAlignment="Center" verticalAlignment="Middle">
<reportElement x="0" y="112" width="90" height="20" uuid="4368e598-76c3-4ad7-867e-c3c9efe5ebd8"/> <font size="16" isBold="true"/>
<textElement textAlignment="Left" verticalAlignment="Middle"> </textElement>
<font size="14" isBold="true"/> <text><![CDATA[LISTE DES BLOCS]]></text>
</textElement> </staticText>
<text><![CDATA[Structure :]]></text> <staticText>
</staticText> <reportElement x="0" y="112" width="90" height="20" uuid="4368e598-76c3-4ad7-867e-c3c9efe5ebd8"/>
<textField > <textElement textAlignment="Left" verticalAlignment="Middle">
<reportElement x="90" y="112" width="590" height="20" uuid="890f9a0d-98c7-4acd-becc-ea41d147c44d"/> <font size="14" isBold="true"/>
<textElement> </textElement>
<font size="12"/> <text><![CDATA[Structure :]]></text>
</textElement> </staticText>
<textFieldExpression><![CDATA[$P{structure}]]></textFieldExpression> <textField>
</textField> <reportElement x="90" y="112" width="590" height="20" uuid="890f9a0d-98c7-4acd-becc-ea41d147c44d"/>
<image> <textElement>
<reportElement x="0" y="0" width="200" height="70" uuid="e194874d-8732-48bc-b829-5eee66cd557d"/> <font size="12"/>
<imageExpression><![CDATA[$P{logoGauche}]]></imageExpression> </textElement>
</image> <textFieldExpression><![CDATA[$P{structure}]]></textFieldExpression>
<image> </textField>
<reportElement x="455" y="0" width="100" height="70" uuid="f2e94782-7bfb-4a44-b7d7-8a1815583080"/> <image>
<imageExpression><![CDATA[$P{logoDroit}]]></imageExpression> <reportElement x="0" y="0" width="200" height="70" uuid="e194874d-8732-48bc-b829-5eee66cd557d"/>
</image> <imageExpression><![CDATA[$P{logoGauche}]]></imageExpression>
</band> </image>
</title> <image>
<pageHeader> <reportElement x="455" y="0" width="100" height="70" uuid="f2e94782-7bfb-4a44-b7d7-8a1815583080"/>
<band height="19" splitType="Stretch"/> <imageExpression><![CDATA[$P{logoDroit}]]></imageExpression>
</pageHeader> </image>
<columnHeader> </band>
<band height="20" splitType="Stretch"> </title>
<staticText> <pageHeader>
<reportElement mode="Opaque" x="0" y="0" width="110" height="20" backcolor="#E6E3E3" uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3"> <band height="19" splitType="Stretch"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/> </pageHeader>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <columnHeader>
</reportElement> <band height="20" splitType="Stretch">
<box> <staticText>
<topPen lineWidth="0.25"/> <reportElement mode="Opaque" x="0" y="0" width="110" height="20" backcolor="#E6E3E3"
<leftPen lineWidth="0.25"/> uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
<bottomPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</box> value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
<textElement verticalAlignment="Middle"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<font size="12" isBold="true"/> </reportElement>
<paragraph leftIndent="10"/> <box>
</textElement> <topPen lineWidth="0.25"/>
<text><![CDATA[Code]]></text> <leftPen lineWidth="0.25"/>
</staticText> <bottomPen lineWidth="0.25"/>
<staticText> </box>
<reportElement mode="Opaque" x="110" y="0" width="220" height="20" backcolor="#E6E3E3" uuid="c4d92ed2-0221-46f2-927d-b475c27e868f"> <textElement verticalAlignment="Middle">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> <font size="12" isBold="true"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <paragraph leftIndent="10"/>
</reportElement> </textElement>
<box> <text><![CDATA[Code]]></text>
<topPen lineWidth="0.25"/> </staticText>
<leftPen lineWidth="0.25"/> <staticText>
<bottomPen lineWidth="0.25"/> <reportElement mode="Opaque" x="110" y="0" width="220" height="20" backcolor="#E6E3E3"
</box> uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
<textElement verticalAlignment="Middle"> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<font size="12" isBold="true"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<paragraph leftIndent="10"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</textElement> </reportElement>
<text><![CDATA[Nom]]></text> <box>
</staticText> <topPen lineWidth="0.25"/>
<staticText> <leftPen lineWidth="0.25"/>
<reportElement mode="Opaque" x="330" y="0" width="185" height="20" backcolor="#E6E3E3" uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80"> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> </box>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <textElement verticalAlignment="Middle">
</reportElement> <font size="12" isBold="true"/>
<box> <paragraph leftIndent="10"/>
<topPen lineWidth="0.25"/> </textElement>
<leftPen lineWidth="0.25"/> <text><![CDATA[Nom]]></text>
<bottomPen lineWidth="0.25"/> </staticText>
<rightPen lineWidth="0.25"/> <staticText>
</box> <reportElement mode="Opaque" x="330" y="0" width="185" height="20" backcolor="#E6E3E3"
<textElement verticalAlignment="Middle"> uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
<font size="12" isBold="true"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<paragraph leftIndent="10"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</textElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<text><![CDATA[Arrondissement]]></text> </reportElement>
</staticText> <box>
<staticText> <topPen lineWidth="0.25"/>
<reportElement mode="Opaque" x="515" y="0" width="145" height="20" backcolor="#E6E3E3" uuid="86774042-75a8-480b-8cee-b051aaf448f3"> <leftPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <rightPen lineWidth="0.25"/>
</reportElement> </box>
<box> <textElement verticalAlignment="Middle">
<topPen lineWidth="0.25"/> <font size="12" isBold="true"/>
<leftPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
<bottomPen lineWidth="0.25"/> </textElement>
<rightPen lineWidth="0.25"/> <text><![CDATA[Arrondissement]]></text>
</box> </staticText>
<textElement verticalAlignment="Middle"> <staticText>
<font size="12" isBold="true"/> <reportElement mode="Opaque" x="515" y="0" width="145" height="20" backcolor="#E6E3E3"
<paragraph leftIndent="10"/> uuid="86774042-75a8-480b-8cee-b051aaf448f3">
</textElement> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<text><![CDATA[Commune]]></text> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</staticText> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<staticText> </reportElement>
<reportElement mode="Opaque" x="660" y="0" width="140" height="20" backcolor="#E6E3E3" uuid="c083896b-34f1-4034-8422-171bac20fa8b"> <box>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <topPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <leftPen lineWidth="0.25"/>
</reportElement> <bottomPen lineWidth="0.25"/>
<box> <rightPen lineWidth="0.25"/>
<topPen lineWidth="0.25"/> </box>
<leftPen lineWidth="0.25"/> <textElement verticalAlignment="Middle">
<bottomPen lineWidth="0.25"/> <font size="12" isBold="true"/>
<rightPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
</box> </textElement>
<textElement verticalAlignment="Middle"> <text><![CDATA[Commune]]></text>
<font size="12" isBold="true"/> </staticText>
<paragraph leftIndent="10"/> <staticText>
</textElement> <reportElement mode="Opaque" x="660" y="0" width="140" height="20" backcolor="#E6E3E3"
<text><![CDATA[Département]]></text> uuid="c083896b-34f1-4034-8422-171bac20fa8b">
</staticText> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</band> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</columnHeader> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<detail> </reportElement>
<band height="20" splitType="Stretch"> <box>
<textField > <topPen lineWidth="0.25"/>
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="110" height="20" uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90"> <leftPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <rightPen lineWidth="0.25"/>
</reportElement> </box>
<box> <textElement verticalAlignment="Middle">
<leftPen lineWidth="0.25"/> <font size="12" isBold="true"/>
<bottomPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
<rightPen lineWidth="0.25"/> </textElement>
</box> <text><![CDATA[Département]]></text>
<textElement verticalAlignment="Middle"> </staticText>
<font size="12"/> </band>
<paragraph leftIndent="10"/> </columnHeader>
</textElement> <detail>
<textFieldExpression><![CDATA[$F{code}]]></textFieldExpression> <band height="20" splitType="Stretch">
</textField> <textField>
<textField > <reportElement stretchType="ElementGroupHeight" x="0" y="0" width="110" height="20"
<reportElement stretchType="ContainerHeight" x="110" y="0" width="220" height="20" uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30"> uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</reportElement> </reportElement>
<box> <box>
<leftPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/>
</box> </box>
<textElement verticalAlignment="Middle"> <textElement verticalAlignment="Middle">
<font size="12"/> <font size="12"/>
<paragraph leftIndent="10"/> <paragraph leftIndent="10"/>
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{nom}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{code}]]></textFieldExpression>
</textField> </textField>
<textField > <textField>
<reportElement stretchType="ElementGroupHeight" x="330" y="0" width="185" height="20" uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53"> <reportElement stretchType="ContainerHeight" x="110" y="0" width="220" height="20"
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</reportElement> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<box> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<leftPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.width" value="px"/>
<bottomPen lineWidth="0.25"/> </reportElement>
<rightPen lineWidth="0.25"/> <box>
</box> <leftPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> <bottomPen lineWidth="0.25"/>
<font size="12"/> <rightPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> </box>
</textElement> <textElement verticalAlignment="Middle">
<textFieldExpression><![CDATA[$F{arrondissement}]]></textFieldExpression> <font size="12"/>
</textField> <paragraph leftIndent="10"/>
<textField > </textElement>
<reportElement stretchType="ElementGroupHeight" x="515" y="0" width="145" height="20" uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc"> <textFieldExpression><![CDATA[$F{nom}]]></textFieldExpression>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> </textField>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <textField>
</reportElement> <reportElement stretchType="ElementGroupHeight" x="330" y="0" width="185" height="20"
<box> uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
<leftPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<bottomPen lineWidth="0.25"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<rightPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</box> </reportElement>
<textElement verticalAlignment="Middle"> <box>
<font size="12"/> <leftPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> <bottomPen lineWidth="0.25"/>
</textElement> <rightPen lineWidth="0.25"/>
<textFieldExpression><![CDATA[$F{commune}]]></textFieldExpression> </box>
</textField> <textElement verticalAlignment="Middle">
<textField > <font size="12"/>
<reportElement stretchType="ElementGroupHeight" x="660" y="0" width="140" height="20" uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c"> <paragraph leftIndent="10"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> </textElement>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <textFieldExpression><![CDATA[$F{arrondissement}]]></textFieldExpression>
</reportElement> </textField>
<box> <textField>
<leftPen lineWidth="0.25"/> <reportElement stretchType="ElementGroupHeight" x="515" y="0" width="145" height="20"
<bottomPen lineWidth="0.25"/> uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
<rightPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</box> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<textElement verticalAlignment="Middle"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<font size="12"/> </reportElement>
<paragraph leftIndent="10"/> <box>
</textElement> <leftPen lineWidth="0.25"/>
<textFieldExpression><![CDATA[$F{departement}]]></textFieldExpression> <bottomPen lineWidth="0.25"/>
</textField> <rightPen lineWidth="0.25"/>
</band> </box>
</detail> <textElement verticalAlignment="Middle">
<columnFooter> <font size="12"/>
<band height="45" splitType="Stretch"/> <paragraph leftIndent="10"/>
</columnFooter> </textElement>
<pageFooter> <textFieldExpression><![CDATA[$F{commune}]]></textFieldExpression>
<band height="54" splitType="Stretch"/> </textField>
</pageFooter> <textField>
<summary> <reportElement stretchType="ElementGroupHeight" x="660" y="0" width="140" height="20"
<band height="42" splitType="Stretch"/> uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
</summary> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</reportElement>
<box>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle">
<font size="12"/>
<paragraph leftIndent="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{departement}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport> </jasperReport>

View File

@@ -1,419 +1,461 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf --> <!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="60393fd8-8f4e-44f7-8418-0139271081b1"> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<property name="com.jaspersoft.studio.unit." value="pixel"/> xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/> name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802"
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/> leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/> uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/> <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/> <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<parameter name="structure" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<parameter name="logoDroit" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<parameter name="logoGauche" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<parameter name="bloc" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<parameter name="arrondissement" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<parameter name="commune" class="java.lang.String"/> <parameter name="structure" class="java.lang.String"/>
<queryString> <parameter name="logoDroit" class="java.lang.String"/>
<![CDATA[]]> <parameter name="logoGauche" class="java.lang.String"/>
</queryString> <parameter name="bloc" class="java.lang.String"/>
<field name="nupProvisoire" class="java.lang.String"/> <parameter name="arrondissement" class="java.lang.String"/>
<field name="quartier" class="java.lang.String"/> <parameter name="commune" class="java.lang.String"/>
<field name="q" class="java.lang.String"/> <queryString>
<field name="i" class="java.lang.String"/> <![CDATA[]]>
<field name="p" class="java.lang.String"/> </queryString>
<field name="nature" class="java.lang.String"/> <field name="nupProvisoire" class="java.lang.String"/>
<field name="nomProprietaire" class="java.lang.String"/> <field name="quartier" class="java.lang.String"/>
<field name="telephone" class="java.lang.String"/> <field name="q" class="java.lang.String"/>
<field name="litige" class="java.lang.Boolean"/> <field name="i" class="java.lang.String"/>
<background> <field name="p" class="java.lang.String"/>
<band splitType="Stretch"/> <field name="nature" class="java.lang.String"/>
</background> <field name="nomProprietaire" class="java.lang.String"/>
<title> <field name="telephone" class="java.lang.String"/>
<band height="170" splitType="Stretch"> <field name="litige" class="java.lang.Boolean"/>
<staticText> <background>
<reportElement x="302" y="70" width="190" height="30" uuid="10a08362-9a39-4235-a0d1-33a733f0861e"/> <band splitType="Stretch"/>
<textElement textAlignment="Center" verticalAlignment="Middle"> </background>
<font size="16" isBold="true"/> <title>
</textElement> <band height="170" splitType="Stretch">
<text><![CDATA[LISTE DES ENQUETES]]></text> <staticText>
</staticText> <reportElement x="302" y="70" width="190" height="30" uuid="10a08362-9a39-4235-a0d1-33a733f0861e"/>
<staticText> <textElement textAlignment="Center" verticalAlignment="Middle">
<reportElement x="0" y="112" width="120" height="20" uuid="4368e598-76c3-4ad7-867e-c3c9efe5ebd8"/> <font size="16" isBold="true"/>
<textElement textAlignment="Left" verticalAlignment="Middle"> </textElement>
<font size="14" isBold="true"/> <text><![CDATA[LISTE DES ENQUETES]]></text>
</textElement> </staticText>
<text><![CDATA[Structure :]]></text> <staticText>
</staticText> <reportElement x="0" y="112" width="120" height="20" uuid="4368e598-76c3-4ad7-867e-c3c9efe5ebd8"/>
<textField > <textElement textAlignment="Left" verticalAlignment="Middle">
<reportElement x="120" y="112" width="260" height="20" uuid="890f9a0d-98c7-4acd-becc-ea41d147c44d"/> <font size="14" isBold="true"/>
<textElement> </textElement>
<font size="12"/> <text><![CDATA[Structure :]]></text>
</textElement> </staticText>
<textFieldExpression><![CDATA[$P{structure}]]></textFieldExpression> <textField>
</textField> <reportElement x="120" y="112" width="260" height="20" uuid="890f9a0d-98c7-4acd-becc-ea41d147c44d"/>
<image> <textElement>
<reportElement x="0" y="0" width="200" height="70" uuid="e194874d-8732-48bc-b829-5eee66cd557d"/> <font size="12"/>
<imageExpression><![CDATA[$P{logoGauche}]]></imageExpression> </textElement>
</image> <textFieldExpression><![CDATA[$P{structure}]]></textFieldExpression>
<textField > </textField>
<reportElement x="470" y="112" width="330" height="20" uuid="e89fe5e8-8c95-465a-963a-38c89fe7b45c"/> <image>
<textElement> <reportElement x="0" y="0" width="200" height="70" uuid="e194874d-8732-48bc-b829-5eee66cd557d"/>
<font size="14"/> <imageExpression><![CDATA[$P{logoGauche}]]></imageExpression>
</textElement> </image>
<textFieldExpression><![CDATA[$P{bloc}]]></textFieldExpression> <textField>
</textField> <reportElement x="470" y="112" width="330" height="20" uuid="e89fe5e8-8c95-465a-963a-38c89fe7b45c"/>
<staticText> <textElement>
<reportElement x="380" y="112" width="90" height="20" uuid="78fbd365-5e80-486f-8b79-fba9f57ff757"/> <font size="14"/>
<textElement textAlignment="Left" verticalAlignment="Middle"> </textElement>
<font size="14" isBold="true"/> <textFieldExpression><![CDATA[$P{bloc}]]></textFieldExpression>
</textElement> </textField>
<text><![CDATA[Bloc :]]></text> <staticText>
</staticText> <reportElement x="380" y="112" width="90" height="20" uuid="78fbd365-5e80-486f-8b79-fba9f57ff757"/>
<staticText> <textElement textAlignment="Left" verticalAlignment="Middle">
<reportElement x="380" y="150" width="90" height="20" uuid="104de4fb-c535-4e31-a61b-a5c5066de836"/> <font size="14" isBold="true"/>
<textElement textAlignment="Left" verticalAlignment="Middle"> </textElement>
<font size="14" isBold="true"/> <text><![CDATA[Bloc :]]></text>
</textElement> </staticText>
<text><![CDATA[Commune :]]></text> <staticText>
</staticText> <reportElement x="380" y="150" width="90" height="20" uuid="104de4fb-c535-4e31-a61b-a5c5066de836"/>
<textField > <textElement textAlignment="Left" verticalAlignment="Middle">
<reportElement x="470" y="150" width="330" height="20" uuid="7944bfcb-94e3-4fc3-b717-a65820dd64de"/> <font size="14" isBold="true"/>
<textElement> </textElement>
<font size="14"/> <text><![CDATA[Commune :]]></text>
</textElement> </staticText>
<textFieldExpression><![CDATA[$P{commune}]]></textFieldExpression> <textField>
</textField> <reportElement x="470" y="150" width="330" height="20" uuid="7944bfcb-94e3-4fc3-b717-a65820dd64de"/>
</band> <textElement>
</title> <font size="14"/>
<pageHeader> </textElement>
<band height="19" splitType="Stretch"> <textFieldExpression><![CDATA[$P{commune}]]></textFieldExpression>
<staticText> </textField>
<reportElement x="0" y="-18" width="140" height="20" uuid="cb339471-8d6f-446d-9059-97e0f108bbde"/> </band>
<textElement textAlignment="Left" verticalAlignment="Middle"> </title>
<font size="14" isBold="true"/> <pageHeader>
</textElement> <band height="19" splitType="Stretch">
<text><![CDATA[Arrondissement :]]></text> <staticText>
</staticText> <reportElement x="0" y="-18" width="140" height="20" uuid="cb339471-8d6f-446d-9059-97e0f108bbde"/>
<textField > <textElement textAlignment="Left" verticalAlignment="Middle">
<reportElement x="140" y="-18" width="240" height="20" uuid="f187b92d-cabc-4fbf-afae-7ac6d04d0dd6"/> <font size="14" isBold="true"/>
<textElement> </textElement>
<font size="14"/> <text><![CDATA[Arrondissement :]]></text>
</textElement> </staticText>
<textFieldExpression><![CDATA[$P{arrondissement}]]></textFieldExpression> <textField>
</textField> <reportElement x="140" y="-18" width="240" height="20" uuid="f187b92d-cabc-4fbf-afae-7ac6d04d0dd6"/>
</band> <textElement>
</pageHeader> <font size="14"/>
<columnHeader> </textElement>
<band height="20" splitType="Stretch"> <textFieldExpression><![CDATA[$P{arrondissement}]]></textFieldExpression>
<staticText> </textField>
<reportElement mode="Opaque" x="0" y="0" width="110" height="20" backcolor="#E6E3E3" uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3"> </band>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/> </pageHeader>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <columnHeader>
</reportElement> <band height="20" splitType="Stretch">
<box> <staticText>
<topPen lineWidth="0.25"/> <reportElement mode="Opaque" x="0" y="0" width="110" height="20" backcolor="#E6E3E3"
<leftPen lineWidth="0.25"/> uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
<bottomPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</box> value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
<textElement verticalAlignment="Middle"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<font size="12" isBold="true"/> </reportElement>
<paragraph leftIndent="10"/> <box>
</textElement> <topPen lineWidth="0.25"/>
<text><![CDATA[NUP Provisoire]]></text> <leftPen lineWidth="0.25"/>
</staticText> <bottomPen lineWidth="0.25"/>
<staticText> </box>
<reportElement mode="Opaque" x="110" y="0" width="120" height="20" backcolor="#E6E3E3" uuid="c4d92ed2-0221-46f2-927d-b475c27e868f"> <textElement verticalAlignment="Middle">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> <font size="12" isBold="true"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <paragraph leftIndent="10"/>
</reportElement> </textElement>
<box> <text><![CDATA[NUP Provisoire]]></text>
<topPen lineWidth="0.25"/> </staticText>
<leftPen lineWidth="0.25"/> <staticText>
<bottomPen lineWidth="0.25"/> <reportElement mode="Opaque" x="110" y="0" width="120" height="20" backcolor="#E6E3E3"
</box> uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
<textElement verticalAlignment="Middle"> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<font size="12" isBold="true"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<paragraph leftIndent="10"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</textElement> </reportElement>
<text><![CDATA[Quartier]]></text> <box>
</staticText> <topPen lineWidth="0.25"/>
<staticText> <leftPen lineWidth="0.25"/>
<reportElement mode="Opaque" x="230" y="0" width="50" height="20" backcolor="#E6E3E3" uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80"> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> </box>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <textElement verticalAlignment="Middle">
</reportElement> <font size="12" isBold="true"/>
<box> <paragraph leftIndent="10"/>
<topPen lineWidth="0.25"/> </textElement>
<leftPen lineWidth="0.25"/> <text><![CDATA[Quartier]]></text>
<bottomPen lineWidth="0.25"/> </staticText>
<rightPen lineWidth="0.25"/> <staticText>
</box> <reportElement mode="Opaque" x="230" y="0" width="50" height="20" backcolor="#E6E3E3"
<textElement verticalAlignment="Middle"> uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
<font size="12" isBold="true"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<paragraph leftIndent="10"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</textElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<text><![CDATA[Q]]></text> </reportElement>
</staticText> <box>
<staticText> <topPen lineWidth="0.25"/>
<reportElement mode="Opaque" x="280" y="0" width="40" height="20" backcolor="#E6E3E3" uuid="86774042-75a8-480b-8cee-b051aaf448f3"> <leftPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <rightPen lineWidth="0.25"/>
</reportElement> </box>
<box> <textElement verticalAlignment="Middle">
<topPen lineWidth="0.25"/> <font size="12" isBold="true"/>
<leftPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
<bottomPen lineWidth="0.25"/> </textElement>
<rightPen lineWidth="0.25"/> <text><![CDATA[Q]]></text>
</box> </staticText>
<textElement verticalAlignment="Middle"> <staticText>
<font size="12" isBold="true"/> <reportElement mode="Opaque" x="280" y="0" width="40" height="20" backcolor="#E6E3E3"
<paragraph leftIndent="10"/> uuid="86774042-75a8-480b-8cee-b051aaf448f3">
</textElement> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<text><![CDATA[I]]></text> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</staticText> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<staticText> </reportElement>
<reportElement mode="Opaque" x="320" y="0" width="50" height="20" backcolor="#E6E3E3" uuid="c083896b-34f1-4034-8422-171bac20fa8b"> <box>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <topPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <leftPen lineWidth="0.25"/>
</reportElement> <bottomPen lineWidth="0.25"/>
<box> <rightPen lineWidth="0.25"/>
<topPen lineWidth="0.25"/> </box>
<leftPen lineWidth="0.25"/> <textElement verticalAlignment="Middle">
<bottomPen lineWidth="0.25"/> <font size="12" isBold="true"/>
<rightPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
</box> </textElement>
<textElement verticalAlignment="Middle"> <text><![CDATA[I]]></text>
<font size="12" isBold="true"/> </staticText>
<paragraph leftIndent="10"/> <staticText>
</textElement> <reportElement mode="Opaque" x="320" y="0" width="50" height="20" backcolor="#E6E3E3"
<text><![CDATA[P]]></text> uuid="c083896b-34f1-4034-8422-171bac20fa8b">
</staticText> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<staticText> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<reportElement mode="Opaque" x="370" y="0" width="60" height="20" backcolor="#E6E3E3" uuid="43fae784-98c5-4c75-bb0a-11f364bce22f"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> </reportElement>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <box>
</reportElement> <topPen lineWidth="0.25"/>
<box> <leftPen lineWidth="0.25"/>
<topPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/> </box>
</box> <textElement verticalAlignment="Middle">
<textElement verticalAlignment="Middle"> <font size="12" isBold="true"/>
<font size="12" isBold="true"/> <paragraph leftIndent="10"/>
<paragraph leftIndent="10"/> </textElement>
</textElement> <text><![CDATA[P]]></text>
<text><![CDATA[Litige]]></text> </staticText>
</staticText> <staticText>
<staticText> <reportElement mode="Opaque" x="370" y="0" width="60" height="20" backcolor="#E6E3E3"
<reportElement mode="Opaque" x="430" y="0" width="114" height="20" backcolor="#E6E3E3" uuid="6fb97069-4150-4b4d-a7e4-110f7275e530"> uuid="43fae784-98c5-4c75-bb0a-11f364bce22f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
</reportElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<box> </reportElement>
<topPen lineWidth="0.25"/> <box>
<leftPen lineWidth="0.25"/> <topPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/>
</box> <bottomPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> </box>
<font size="12" isBold="true"/> <textElement verticalAlignment="Middle">
<paragraph leftIndent="10"/> <font size="12" isBold="true"/>
</textElement> <paragraph leftIndent="10"/>
<text><![CDATA[Nature Domaine]]></text> </textElement>
</staticText> <text><![CDATA[Litige]]></text>
<staticText> </staticText>
<reportElement mode="Opaque" x="544" y="0" width="156" height="20" backcolor="#E6E3E3" uuid="b609f024-82e7-491d-8558-ad6010c18cb6"> <staticText>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> <reportElement mode="Opaque" x="430" y="0" width="114" height="20" backcolor="#E6E3E3"
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> uuid="6fb97069-4150-4b4d-a7e4-110f7275e530">
</reportElement> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<box> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<topPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<leftPen lineWidth="0.25"/> </reportElement>
<bottomPen lineWidth="0.25"/> <box>
</box> <topPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> <leftPen lineWidth="0.25"/>
<font size="12" isBold="true"/> <bottomPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> </box>
</textElement> <textElement verticalAlignment="Middle">
<text><![CDATA[Nom Propriétaire]]></text> <font size="12" isBold="true"/>
</staticText> <paragraph leftIndent="10"/>
<staticText> </textElement>
<reportElement mode="Opaque" x="700" y="0" width="100" height="20" backcolor="#E6E3E3" uuid="4f3d245d-16c5-4992-81b9-f7de8d10ed45"> <text><![CDATA[Nature Domaine]]></text>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> </staticText>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <staticText>
</reportElement> <reportElement mode="Opaque" x="544" y="0" width="156" height="20" backcolor="#E6E3E3"
<box> uuid="b609f024-82e7-491d-8558-ad6010c18cb6">
<topPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<leftPen lineWidth="0.25"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<bottomPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</box> </reportElement>
<textElement verticalAlignment="Middle"> <box>
<font size="12" isBold="true"/> <topPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> <leftPen lineWidth="0.25"/>
</textElement> <bottomPen lineWidth="0.25"/>
<text><![CDATA[Téléphone]]></text> </box>
</staticText> <textElement verticalAlignment="Middle">
</band> <font size="12" isBold="true"/>
</columnHeader> <paragraph leftIndent="10"/>
<detail> </textElement>
<band height="20" splitType="Stretch"> <text><![CDATA[Nom Propriétaire]]></text>
<textField > </staticText>
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="110" height="20" uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90"> <staticText>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/> <reportElement mode="Opaque" x="700" y="0" width="100" height="20" backcolor="#E6E3E3"
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> uuid="4f3d245d-16c5-4992-81b9-f7de8d10ed45">
</reportElement> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<box> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<leftPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<bottomPen lineWidth="0.25"/> </reportElement>
<rightPen lineWidth="0.25"/> <box>
</box> <topPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> <leftPen lineWidth="0.25"/>
<font size="12"/> <bottomPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> </box>
</textElement> <textElement verticalAlignment="Middle">
<textFieldExpression><![CDATA[$F{nupProvisoire}==null ? "" : $F{nupProvisoire}]]></textFieldExpression> <font size="12" isBold="true"/>
</textField> <paragraph leftIndent="10"/>
<textField > </textElement>
<reportElement stretchType="ContainerHeight" x="110" y="0" width="120" height="20" uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30"> <text><![CDATA[Téléphone]]></text>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> </staticText>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> </band>
<property name="com.jaspersoft.studio.unit.width" value="px"/> </columnHeader>
</reportElement> <detail>
<box> <band height="20" splitType="Stretch">
<leftPen lineWidth="0.25"/> <textField>
<bottomPen lineWidth="0.25"/> <reportElement stretchType="ElementGroupHeight" x="0" y="0" width="110" height="20"
<rightPen lineWidth="0.25"/> uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
</box> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<textElement verticalAlignment="Middle"> value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
<font size="12"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<paragraph leftIndent="10"/> </reportElement>
</textElement> <box>
<textFieldExpression><![CDATA[$F{quartier}==null ? "": $F{quartier}]]></textFieldExpression> <leftPen lineWidth="0.25"/>
</textField> <bottomPen lineWidth="0.25"/>
<textField > <rightPen lineWidth="0.25"/>
<reportElement stretchType="ElementGroupHeight" x="230" y="0" width="50" height="20" uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53"> </box>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <textElement verticalAlignment="Middle">
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <font size="12"/>
</reportElement> <paragraph leftIndent="10"/>
<box> </textElement>
<leftPen lineWidth="0.25"/> <textFieldExpression><![CDATA[$F{nupProvisoire}==null ? "" : $F{nupProvisoire}]]></textFieldExpression>
<bottomPen lineWidth="0.25"/> </textField>
<rightPen lineWidth="0.25"/> <textField>
</box> <reportElement stretchType="ContainerHeight" x="110" y="0" width="120" height="20"
<textElement verticalAlignment="Middle"> uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
<font size="12"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<paragraph leftIndent="10"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
</textElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<textFieldExpression><![CDATA[$F{q}==null ? "" : $F{q}]]></textFieldExpression> <property name="com.jaspersoft.studio.unit.width" value="px"/>
</textField> </reportElement>
<textField > <box>
<reportElement stretchType="ElementGroupHeight" x="280" y="0" width="40" height="20" uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc"> <leftPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <rightPen lineWidth="0.25"/>
</reportElement> </box>
<box> <textElement verticalAlignment="Middle">
<leftPen lineWidth="0.25"/> <font size="12"/>
<bottomPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
<rightPen lineWidth="0.25"/> </textElement>
</box> <textFieldExpression><![CDATA[$F{quartier}==null ? "": $F{quartier}]]></textFieldExpression>
<textElement verticalAlignment="Middle"> </textField>
<font size="12"/> <textField>
<paragraph leftIndent="10"/> <reportElement stretchType="ElementGroupHeight" x="230" y="0" width="50" height="20"
</textElement> uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
<textFieldExpression><![CDATA[$F{i} == null ? "" : $F{i}]]></textFieldExpression> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</textField> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<textField > <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<reportElement stretchType="ElementGroupHeight" x="320" y="0" width="50" height="20" uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c"> </reportElement>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <box>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <leftPen lineWidth="0.25"/>
</reportElement> <bottomPen lineWidth="0.25"/>
<box> <rightPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/> </box>
<bottomPen lineWidth="0.25"/> <textElement verticalAlignment="Middle">
<rightPen lineWidth="0.25"/> <font size="12"/>
</box> <paragraph leftIndent="10"/>
<textElement verticalAlignment="Middle"> </textElement>
<font size="12"/> <textFieldExpression><![CDATA[$F{q}==null ? "" : $F{q}]]></textFieldExpression>
<paragraph leftIndent="10"/> </textField>
</textElement> <textField>
<textFieldExpression><![CDATA[$F{p} == null ? "" : $F{p}]]></textFieldExpression> <reportElement stretchType="ElementGroupHeight" x="280" y="0" width="40" height="20"
</textField> uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
<textField > <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<reportElement stretchType="ElementGroupHeight" x="370" y="0" width="60" height="20" uuid="5d6015a1-12af-4979-9b77-576cb6c99c05"> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> </reportElement>
</reportElement> <box>
<box> <leftPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/> </box>
</box> <textElement verticalAlignment="Middle">
<textElement verticalAlignment="Middle"> <font size="12"/>
<font size="12"/> <paragraph leftIndent="10"/>
<paragraph leftIndent="10"/> </textElement>
</textElement> <textFieldExpression><![CDATA[$F{i} == null ? "" : $F{i}]]></textFieldExpression>
<textFieldExpression><![CDATA[$F{litige}]]></textFieldExpression> </textField>
</textField> <textField>
<textField > <reportElement stretchType="ElementGroupHeight" x="320" y="0" width="50" height="20"
<reportElement stretchType="ElementGroupHeight" x="430" y="0" width="114" height="20" uuid="5880e9de-e658-4cda-b737-0d1e791fff8c"> uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</reportElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<box> </reportElement>
<leftPen lineWidth="0.25"/> <box>
<bottomPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/>
</box> <rightPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> </box>
<font size="12"/> <textElement verticalAlignment="Middle">
<paragraph leftIndent="10"/> <font size="12"/>
</textElement> <paragraph leftIndent="10"/>
<textFieldExpression><![CDATA[$F{nature}]]></textFieldExpression> </textElement>
</textField> <textFieldExpression><![CDATA[$F{p} == null ? "" : $F{p}]]></textFieldExpression>
<textField > </textField>
<reportElement stretchType="ElementGroupHeight" x="544" y="0" width="156" height="20" uuid="34bb5d2b-4841-49b0-a7fa-83217ce30dda"> <textField>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <reportElement stretchType="ElementGroupHeight" x="370" y="0" width="60" height="20"
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> uuid="5d6015a1-12af-4979-9b77-576cb6c99c05">
</reportElement> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<box> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<leftPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<bottomPen lineWidth="0.25"/> </reportElement>
<rightPen lineWidth="0.25"/> <box>
</box> <leftPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> <bottomPen lineWidth="0.25"/>
<font size="12"/> <rightPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> </box>
</textElement> <textElement verticalAlignment="Middle">
<textFieldExpression><![CDATA[$F{nomProprietaire} == null ? "" : $F{nomProprietaire}]]></textFieldExpression> <font size="12"/>
</textField> <paragraph leftIndent="10"/>
<textField > </textElement>
<reportElement stretchType="ElementGroupHeight" x="700" y="0" width="100" height="20" uuid="beeb4530-5e7b-4759-a5ff-b8f2a4115d6d"> <textFieldExpression><![CDATA[$F{litige}]]></textFieldExpression>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> </textField>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <textField>
</reportElement> <reportElement stretchType="ElementGroupHeight" x="430" y="0" width="114" height="20"
<box> uuid="5880e9de-e658-4cda-b737-0d1e791fff8c">
<leftPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<bottomPen lineWidth="0.25"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<rightPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</box> </reportElement>
<textElement verticalAlignment="Middle"> <box>
<font size="12"/> <leftPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> <bottomPen lineWidth="0.25"/>
</textElement> <rightPen lineWidth="0.25"/>
<textFieldExpression><![CDATA[$F{telephone} == null ? "" : $F{telephone}]]></textFieldExpression> </box>
</textField> <textElement verticalAlignment="Middle">
</band> <font size="12"/>
</detail> <paragraph leftIndent="10"/>
<columnFooter> </textElement>
<band height="45" splitType="Stretch"/> <textFieldExpression><![CDATA[$F{nature}]]></textFieldExpression>
</columnFooter> </textField>
<pageFooter> <textField>
<band height="54" splitType="Stretch"/> <reportElement stretchType="ElementGroupHeight" x="544" y="0" width="156" height="20"
</pageFooter> uuid="34bb5d2b-4841-49b0-a7fa-83217ce30dda">
<summary> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<band height="42" splitType="Stretch"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</summary> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</reportElement>
<box>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle">
<font size="12"/>
<paragraph leftIndent="10"/>
</textElement>
<textFieldExpression>
<![CDATA[$F{nomProprietaire} == null ? "" : $F{nomProprietaire}]]></textFieldExpression>
</textField>
<textField>
<reportElement stretchType="ElementGroupHeight" x="700" y="0" width="100" height="20"
uuid="beeb4530-5e7b-4759-a5ff-b8f2a4115d6d">
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</reportElement>
<box>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle">
<font size="12"/>
<paragraph leftIndent="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{telephone} == null ? "" : $F{telephone}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport> </jasperReport>

View File

@@ -1,396 +1,443 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf --> <!-- Created with Jaspersoft Studio version 6.21.3.final using JasperReports Library version 6.21.3-4a3078d20785ebe464f18037d738d12fc98c13cf -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="60393fd8-8f4e-44f7-8418-0139271081b1"> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<property name="com.jaspersoft.studio.unit." value="pixel"/> xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/> name="listBlocParStructure" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802"
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/> leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/> uuid="60393fd8-8f4e-44f7-8418-0139271081b1">
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/> <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/> <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/> <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<parameter name="structure" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<parameter name="logoDroit" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<parameter name="logoGauche" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<parameter name="bloc" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<parameter name="arrondissement" class="java.lang.String"/> <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<parameter name="commune" class="java.lang.String"/> <parameter name="structure" class="java.lang.String"/>
<queryString> <parameter name="logoDroit" class="java.lang.String"/>
<![CDATA[]]> <parameter name="logoGauche" class="java.lang.String"/>
</queryString> <parameter name="bloc" class="java.lang.String"/>
<field name="nupprovisoire" class="java.lang.String"/> <parameter name="arrondissement" class="java.lang.String"/>
<field name="communenom" class="java.lang.String"/> <parameter name="commune" class="java.lang.String"/>
<field name="arrondissementnom" class="java.lang.String"/> <queryString>
<field name="blocnom" class="java.lang.String"/> <![CDATA[]]>
<field name="naturedomaine" class="java.lang.String"/> </queryString>
<field name="prenomraisonsociale" class="java.lang.String"/> <field name="nupprovisoire" class="java.lang.String"/>
<field name="litige" class="java.lang.Boolean"/> <field name="communenom" class="java.lang.String"/>
<field name="structurenom" class="java.lang.String"/> <field name="arrondissementnom" class="java.lang.String"/>
<field name="statusenquete" class="java.lang.String"/> <field name="blocnom" class="java.lang.String"/>
<field name="nomsigle" class="java.lang.String"/> <field name="naturedomaine" class="java.lang.String"/>
<field name="typepersonne" class="java.lang.String"/> <field name="prenomraisonsociale" class="java.lang.String"/>
<background> <field name="litige" class="java.lang.Boolean"/>
<band splitType="Stretch"/> <field name="structurenom" class="java.lang.String"/>
</background> <field name="statusenquete" class="java.lang.String"/>
<title> <field name="nomsigle" class="java.lang.String"/>
<band height="106" splitType="Stretch"> <field name="typepersonne" class="java.lang.String"/>
<staticText> <background>
<reportElement x="240" y="70" width="400" height="30" uuid="10a08362-9a39-4235-a0d1-33a733f0861e"/> <band splitType="Stretch"/>
<textElement textAlignment="Center" verticalAlignment="Middle"> </background>
<font size="16" isBold="true"/> <title>
</textElement> <band height="106" splitType="Stretch">
<text><![CDATA[LISTE DES ENQUETES]]></text> <staticText>
</staticText> <reportElement x="240" y="70" width="400" height="30" uuid="10a08362-9a39-4235-a0d1-33a733f0861e"/>
<image> <textElement textAlignment="Center" verticalAlignment="Middle">
<reportElement x="0" y="0" width="200" height="70" uuid="e194874d-8732-48bc-b829-5eee66cd557d"/> <font size="16" isBold="true"/>
<imageExpression><![CDATA[$P{logoGauche}]]></imageExpression> </textElement>
</image> <text><![CDATA[LISTE DES ENQUETES]]></text>
</band> </staticText>
</title> <image>
<pageHeader> <reportElement x="0" y="0" width="200" height="70" uuid="e194874d-8732-48bc-b829-5eee66cd557d"/>
<band height="19" splitType="Stretch"/> <imageExpression><![CDATA[$P{logoGauche}]]></imageExpression>
</pageHeader> </image>
<columnHeader> </band>
<band height="20" splitType="Stretch"> </title>
<staticText> <pageHeader>
<reportElement mode="Opaque" x="0" y="0" width="70" height="20" backcolor="#E6E3E3" uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3"> <band height="19" splitType="Stretch"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/> </pageHeader>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <columnHeader>
</reportElement> <band height="20" splitType="Stretch">
<box> <staticText>
<topPen lineWidth="0.25"/> <reportElement mode="Opaque" x="0" y="0" width="70" height="20" backcolor="#E6E3E3"
<leftPen lineWidth="0.25"/> uuid="331a2555-93cf-45c8-b0b5-7b2852a4d2f3">
<bottomPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</box> value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
<textElement verticalAlignment="Middle"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<font size="8" isBold="true"/> </reportElement>
<paragraph leftIndent="10"/> <box>
</textElement> <topPen lineWidth="0.25"/>
<text><![CDATA[NUP Provisoire]]></text> <leftPen lineWidth="0.25"/>
</staticText> <bottomPen lineWidth="0.25"/>
<staticText> </box>
<reportElement mode="Opaque" x="200" y="0" width="70" height="20" backcolor="#E6E3E3" uuid="c4d92ed2-0221-46f2-927d-b475c27e868f"> <textElement verticalAlignment="Middle">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> <font size="8" isBold="true"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <paragraph leftIndent="10"/>
</reportElement> </textElement>
<box> <text><![CDATA[NUP Provisoire]]></text>
<topPen lineWidth="0.25"/> </staticText>
<leftPen lineWidth="0.25"/> <staticText>
<bottomPen lineWidth="0.25"/> <reportElement mode="Opaque" x="200" y="0" width="70" height="20" backcolor="#E6E3E3"
</box> uuid="c4d92ed2-0221-46f2-927d-b475c27e868f">
<textElement verticalAlignment="Middle"> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<font size="8" isBold="true"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<paragraph leftIndent="10"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</textElement> </reportElement>
<text><![CDATA[Commune]]></text> <box>
</staticText> <topPen lineWidth="0.25"/>
<staticText> <leftPen lineWidth="0.25"/>
<reportElement mode="Opaque" x="270" y="0" width="80" height="20" backcolor="#E6E3E3" uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80"> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> </box>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <textElement verticalAlignment="Middle">
</reportElement> <font size="8" isBold="true"/>
<box> <paragraph leftIndent="10"/>
<topPen lineWidth="0.25"/> </textElement>
<leftPen lineWidth="0.25"/> <text><![CDATA[Commune]]></text>
<bottomPen lineWidth="0.25"/> </staticText>
<rightPen lineWidth="0.25"/> <staticText>
</box> <reportElement mode="Opaque" x="270" y="0" width="80" height="20" backcolor="#E6E3E3"
<textElement verticalAlignment="Middle"> uuid="2afc91ad-3b7c-4095-a7fc-971d233e3a80">
<font size="8" isBold="true"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<paragraph leftIndent="10"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</textElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<text><![CDATA[Arrondissement]]></text> </reportElement>
</staticText> <box>
<staticText> <topPen lineWidth="0.25"/>
<reportElement mode="Opaque" x="350" y="0" width="80" height="20" backcolor="#E6E3E3" uuid="86774042-75a8-480b-8cee-b051aaf448f3"> <leftPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <rightPen lineWidth="0.25"/>
</reportElement> </box>
<box> <textElement verticalAlignment="Middle">
<topPen lineWidth="0.25"/> <font size="8" isBold="true"/>
<leftPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
<bottomPen lineWidth="0.25"/> </textElement>
<rightPen lineWidth="0.25"/> <text><![CDATA[Arrondissement]]></text>
</box> </staticText>
<textElement verticalAlignment="Middle"> <staticText>
<font size="8" isBold="true"/> <reportElement mode="Opaque" x="350" y="0" width="80" height="20" backcolor="#E6E3E3"
<paragraph leftIndent="10"/> uuid="86774042-75a8-480b-8cee-b051aaf448f3">
</textElement> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<text><![CDATA[Bloc]]></text> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</staticText> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<staticText> </reportElement>
<reportElement mode="Opaque" x="430" y="0" width="70" height="20" backcolor="#E6E3E3" uuid="c083896b-34f1-4034-8422-171bac20fa8b"> <box>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <topPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <leftPen lineWidth="0.25"/>
</reportElement> <bottomPen lineWidth="0.25"/>
<box> <rightPen lineWidth="0.25"/>
<topPen lineWidth="0.25"/> </box>
<leftPen lineWidth="0.25"/> <textElement verticalAlignment="Middle">
<bottomPen lineWidth="0.25"/> <font size="8" isBold="true"/>
<rightPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
</box> </textElement>
<textElement verticalAlignment="Middle"> <text><![CDATA[Bloc]]></text>
<font size="8" isBold="true"/> </staticText>
<paragraph leftIndent="10"/> <staticText>
</textElement> <reportElement mode="Opaque" x="430" y="0" width="70" height="20" backcolor="#E6E3E3"
<text><![CDATA[Structure]]></text> uuid="c083896b-34f1-4034-8422-171bac20fa8b">
</staticText> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<staticText> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<reportElement mode="Opaque" x="140" y="0" width="60" height="20" backcolor="#E6E3E3" uuid="43fae784-98c5-4c75-bb0a-11f364bce22f"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> </reportElement>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <box>
</reportElement> <topPen lineWidth="0.25"/>
<box> <leftPen lineWidth="0.25"/>
<topPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/> </box>
</box> <textElement verticalAlignment="Middle">
<textElement verticalAlignment="Middle"> <font size="8" isBold="true"/>
<font size="8" isBold="true"/> <paragraph leftIndent="10"/>
<paragraph leftIndent="10"/> </textElement>
</textElement> <text><![CDATA[Structure]]></text>
<text><![CDATA[Litige]]></text> </staticText>
</staticText> <staticText>
<staticText> <reportElement mode="Opaque" x="140" y="0" width="60" height="20" backcolor="#E6E3E3"
<reportElement mode="Opaque" x="70" y="0" width="70" height="20" backcolor="#E6E3E3" uuid="6fb97069-4150-4b4d-a7e4-110f7275e530"> uuid="43fae784-98c5-4c75-bb0a-11f364bce22f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
</reportElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<box> </reportElement>
<topPen lineWidth="0.25"/> <box>
<leftPen lineWidth="0.25"/> <topPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/>
</box> <bottomPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> </box>
<font size="8" isBold="true"/> <textElement verticalAlignment="Middle">
<paragraph leftIndent="10"/> <font size="8" isBold="true"/>
</textElement> <paragraph leftIndent="10"/>
<text><![CDATA[Nature Domaine]]></text> </textElement>
</staticText> <text><![CDATA[Litige]]></text>
<staticText> </staticText>
<reportElement mode="Opaque" x="590" y="0" width="110" height="20" backcolor="#E6E3E3" uuid="b609f024-82e7-491d-8558-ad6010c18cb6"> <staticText>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> <reportElement mode="Opaque" x="70" y="0" width="70" height="20" backcolor="#E6E3E3"
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> uuid="6fb97069-4150-4b4d-a7e4-110f7275e530">
</reportElement> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<box> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<topPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<leftPen lineWidth="0.25"/> </reportElement>
<bottomPen lineWidth="0.25"/> <box>
</box> <topPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> <leftPen lineWidth="0.25"/>
<font size="8" isBold="true"/> <bottomPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> </box>
</textElement> <textElement verticalAlignment="Middle">
<text><![CDATA[Nom Propriétaire]]></text> <font size="8" isBold="true"/>
</staticText> <paragraph leftIndent="10"/>
<staticText> </textElement>
<reportElement mode="Opaque" x="700" y="0" width="100" height="20" backcolor="#E6E3E3" uuid="4f3d245d-16c5-4992-81b9-f7de8d10ed45"> <text><![CDATA[Nature Domaine]]></text>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> </staticText>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <staticText>
</reportElement> <reportElement mode="Opaque" x="590" y="0" width="110" height="20" backcolor="#E6E3E3"
<box> uuid="b609f024-82e7-491d-8558-ad6010c18cb6">
<topPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<leftPen lineWidth="0.25"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<bottomPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</box> </reportElement>
<textElement verticalAlignment="Middle"> <box>
<font size="8" isBold="true"/> <topPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> <leftPen lineWidth="0.25"/>
</textElement> <bottomPen lineWidth="0.25"/>
<text><![CDATA[Statut]]></text> </box>
</staticText> <textElement verticalAlignment="Middle">
<staticText> <font size="8" isBold="true"/>
<reportElement mode="Opaque" x="500" y="0" width="90" height="20" backcolor="#E6E3E3" uuid="3a10eece-e81b-408b-b680-d7f31c9931a1"> <paragraph leftIndent="10"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> </textElement>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <text><![CDATA[Nom Propriétaire]]></text>
</reportElement> </staticText>
<box> <staticText>
<topPen lineWidth="0.25"/> <reportElement mode="Opaque" x="700" y="0" width="100" height="20" backcolor="#E6E3E3"
<leftPen lineWidth="0.25"/> uuid="4f3d245d-16c5-4992-81b9-f7de8d10ed45">
<bottomPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</box> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<textElement verticalAlignment="Middle"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<font size="8" isBold="true"/> </reportElement>
<paragraph leftIndent="10"/> <box>
</textElement> <topPen lineWidth="0.25"/>
<text><![CDATA[Type de personne]]></text> <leftPen lineWidth="0.25"/>
</staticText> <bottomPen lineWidth="0.25"/>
</band> </box>
</columnHeader> <textElement verticalAlignment="Middle">
<detail> <font size="8" isBold="true"/>
<band height="20" splitType="Stretch"> <paragraph leftIndent="10"/>
<textField > </textElement>
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="70" height="20" uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90"> <text><![CDATA[Statut]]></text>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/> </staticText>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <staticText>
</reportElement> <reportElement mode="Opaque" x="500" y="0" width="90" height="20" backcolor="#E6E3E3"
<box> uuid="3a10eece-e81b-408b-b680-d7f31c9931a1">
<leftPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<bottomPen lineWidth="0.25"/> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
<rightPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</box> </reportElement>
<textElement verticalAlignment="Middle"> <box>
<font size="8"/> <topPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> <leftPen lineWidth="0.25"/>
</textElement> <bottomPen lineWidth="0.25"/>
<textFieldExpression><![CDATA[$F{nupprovisoire}==null ? "" : $F{nupprovisoire}]]></textFieldExpression> </box>
</textField> <textElement verticalAlignment="Middle">
<textField > <font size="8" isBold="true"/>
<reportElement stretchType="ContainerHeight" x="200" y="0" width="70" height="20" uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30"> <paragraph leftIndent="10"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6a576dff-c575-4984-bac4-07e6f9e677d7"/> </textElement>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <text><![CDATA[Type de personne]]></text>
<property name="com.jaspersoft.studio.unit.width" value="px"/> </staticText>
</reportElement> </band>
<box> </columnHeader>
<leftPen lineWidth="0.25"/> <detail>
<bottomPen lineWidth="0.25"/> <band height="20" splitType="Stretch">
<rightPen lineWidth="0.25"/> <textField>
</box> <reportElement stretchType="ElementGroupHeight" x="0" y="0" width="70" height="20"
<textElement verticalAlignment="Middle"> uuid="1d95f143-1f8d-4f69-a9fe-e35b552a3e90">
<font size="8"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<paragraph leftIndent="10"/> value="6ac9f7a7-6945-49f9-bb3f-304b676fe0cc"/>
</textElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<textFieldExpression><![CDATA[$F{communenom}==null ? "": $F{communenom}]]></textFieldExpression> </reportElement>
</textField> <box>
<textField > <leftPen lineWidth="0.25"/>
<reportElement stretchType="ElementGroupHeight" x="270" y="0" width="80" height="20" uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53"> <bottomPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <rightPen lineWidth="0.25"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> </box>
</reportElement> <textElement verticalAlignment="Middle">
<box> <font size="8"/>
<leftPen lineWidth="0.25"/> <paragraph leftIndent="10"/>
<bottomPen lineWidth="0.25"/> </textElement>
<rightPen lineWidth="0.25"/> <textFieldExpression><![CDATA[$F{nupprovisoire}==null ? "" : $F{nupprovisoire}]]></textFieldExpression>
</box> </textField>
<textElement verticalAlignment="Middle"> <textField>
<font size="8"/> <reportElement stretchType="ContainerHeight" x="200" y="0" width="70" height="20"
<paragraph leftIndent="10"/> uuid="06de3fd6-c3fd-4316-abcb-1a753e951b30">
</textElement> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<textFieldExpression><![CDATA[$F{arrondissementnom}==null ? "" : $F{arrondissementnom}]]></textFieldExpression> value="6a576dff-c575-4984-bac4-07e6f9e677d7"/>
</textField> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<textField > <property name="com.jaspersoft.studio.unit.width" value="px"/>
<reportElement stretchType="ElementGroupHeight" x="350" y="0" width="80" height="20" uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc"> </reportElement>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <box>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <leftPen lineWidth="0.25"/>
</reportElement> <bottomPen lineWidth="0.25"/>
<box> <rightPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/> </box>
<bottomPen lineWidth="0.25"/> <textElement verticalAlignment="Middle">
<rightPen lineWidth="0.25"/> <font size="8"/>
</box> <paragraph leftIndent="10"/>
<textElement verticalAlignment="Middle"> </textElement>
<font size="8"/> <textFieldExpression><![CDATA[$F{communenom}==null ? "": $F{communenom}]]></textFieldExpression>
<paragraph leftIndent="10"/> </textField>
</textElement> <textField>
<textFieldExpression><![CDATA[$F{blocnom} == null ? "" : $F{blocnom}]]></textFieldExpression> <reportElement stretchType="ElementGroupHeight" x="270" y="0" width="80" height="20"
</textField> uuid="2d7a2c15-346a-4977-896c-1ba29cfd5d53">
<textField > <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<reportElement stretchType="ElementGroupHeight" x="430" y="0" width="70" height="20" uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c"> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> </reportElement>
</reportElement> <box>
<box> <leftPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/> <bottomPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/> <rightPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/> </box>
</box> <textElement verticalAlignment="Middle">
<textElement verticalAlignment="Middle"> <font size="8"/>
<font size="8"/> <paragraph leftIndent="10"/>
<paragraph leftIndent="10"/> </textElement>
</textElement> <textFieldExpression>
<textFieldExpression><![CDATA[$F{structurenom}== null ? "" : $F{structurenom}]]></textFieldExpression> <![CDATA[$F{arrondissementnom}==null ? "" : $F{arrondissementnom}]]></textFieldExpression>
</textField> </textField>
<textField > <textField>
<reportElement stretchType="ElementGroupHeight" x="140" y="0" width="60" height="20" uuid="5d6015a1-12af-4979-9b77-576cb6c99c05"> <reportElement stretchType="ElementGroupHeight" x="350" y="0" width="80" height="20"
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> uuid="4e3f26b4-15fe-4bb0-9fae-c912f47021fc">
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
</reportElement> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<box> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<leftPen lineWidth="0.25"/> </reportElement>
<bottomPen lineWidth="0.25"/> <box>
<rightPen lineWidth="0.25"/> <leftPen lineWidth="0.25"/>
</box> <bottomPen lineWidth="0.25"/>
<textElement verticalAlignment="Middle"> <rightPen lineWidth="0.25"/>
<font size="8"/> </box>
<paragraph leftIndent="10"/> <textElement verticalAlignment="Middle">
</textElement> <font size="8"/>
<textFieldExpression><![CDATA[$F{litige}]]></textFieldExpression> <paragraph leftIndent="10"/>
</textField> </textElement>
<textField > <textFieldExpression><![CDATA[$F{blocnom} == null ? "" : $F{blocnom}]]></textFieldExpression>
<reportElement stretchType="ElementGroupHeight" x="70" y="0" width="70" height="20" uuid="5880e9de-e658-4cda-b737-0d1e791fff8c"> </textField>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <textField>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <reportElement stretchType="ElementGroupHeight" x="430" y="0" width="70" height="20"
</reportElement> uuid="0dcd7c23-f011-457e-a503-ce58f0bc710c">
<box> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<leftPen lineWidth="0.25"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<bottomPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<rightPen lineWidth="0.25"/> </reportElement>
</box> <box>
<textElement verticalAlignment="Middle"> <leftPen lineWidth="0.25"/>
<font size="8"/> <bottomPen lineWidth="0.25"/>
<paragraph leftIndent="10"/> <rightPen lineWidth="0.25"/>
</textElement> </box>
<textFieldExpression><![CDATA[$F{naturedomaine}]]></textFieldExpression> <textElement verticalAlignment="Middle">
</textField> <font size="8"/>
<textField > <paragraph leftIndent="10"/>
<reportElement stretchType="ElementGroupHeight" x="590" y="0" width="110" height="20" uuid="34bb5d2b-4841-49b0-a7fa-83217ce30dda"> </textElement>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <textFieldExpression><![CDATA[$F{structurenom}== null ? "" : $F{structurenom}]]></textFieldExpression>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> </textField>
</reportElement> <textField>
<box> <reportElement stretchType="ElementGroupHeight" x="140" y="0" width="60" height="20"
<leftPen lineWidth="0.25"/> uuid="5d6015a1-12af-4979-9b77-576cb6c99c05">
<bottomPen lineWidth="0.25"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<rightPen lineWidth="0.25"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</box> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<textElement verticalAlignment="Middle"> </reportElement>
<font size="8"/> <box>
<paragraph leftIndent="10"/> <leftPen lineWidth="0.25"/>
</textElement> <bottomPen lineWidth="0.25"/>
<textFieldExpression><![CDATA[$F{prenomraisonsociale} +" "+ $F{nomsigle}]]></textFieldExpression> <rightPen lineWidth="0.25"/>
</textField> </box>
<textField > <textElement verticalAlignment="Middle">
<reportElement stretchType="ElementGroupHeight" x="700" y="0" width="100" height="20" uuid="beeb4530-5e7b-4759-a5ff-b8f2a4115d6d"> <font size="8"/>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <paragraph leftIndent="10"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> </textElement>
</reportElement> <textFieldExpression><![CDATA[$F{litige}]]></textFieldExpression>
<box> </textField>
<leftPen lineWidth="0.25"/> <textField>
<bottomPen lineWidth="0.25"/> <reportElement stretchType="ElementGroupHeight" x="70" y="0" width="70" height="20"
<rightPen lineWidth="0.25"/> uuid="5880e9de-e658-4cda-b737-0d1e791fff8c">
</box> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<textElement verticalAlignment="Middle"> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<font size="8"/> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<paragraph leftIndent="10"/> </reportElement>
</textElement> <box>
<textFieldExpression><![CDATA[$F{statusenquete} == null ? "" : $F{statusenquete}]]></textFieldExpression> <leftPen lineWidth="0.25"/>
</textField> <bottomPen lineWidth="0.25"/>
<textField > <rightPen lineWidth="0.25"/>
<reportElement stretchType="ElementGroupHeight" x="500" y="0" width="90" height="20" uuid="28eac03c-0024-4451-9e95-b755a6cb6cb7"> </box>
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/> <textElement verticalAlignment="Middle">
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <font size="8"/>
</reportElement> <paragraph leftIndent="10"/>
<box> </textElement>
<leftPen lineWidth="0.25"/> <textFieldExpression><![CDATA[$F{naturedomaine}]]></textFieldExpression>
<bottomPen lineWidth="0.25"/> </textField>
<rightPen lineWidth="0.25"/> <textField>
</box> <reportElement stretchType="ElementGroupHeight" x="590" y="0" width="110" height="20"
<textElement verticalAlignment="Middle"> uuid="34bb5d2b-4841-49b0-a7fa-83217ce30dda">
<font size="8"/> <property name="com.jaspersoft.studio.spreadsheet.connectionID"
<paragraph leftIndent="10"/> value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
</textElement> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
<textFieldExpression><![CDATA[$F{typepersonne}== null ? "" : $F{typepersonne}]]></textFieldExpression> </reportElement>
</textField> <box>
</band> <leftPen lineWidth="0.25"/>
</detail> <bottomPen lineWidth="0.25"/>
<columnFooter> <rightPen lineWidth="0.25"/>
<band height="45" splitType="Stretch"/> </box>
</columnFooter> <textElement verticalAlignment="Middle">
<pageFooter> <font size="8"/>
<band height="54" splitType="Stretch"/> <paragraph leftIndent="10"/>
</pageFooter> </textElement>
<summary> <textFieldExpression><![CDATA[$F{prenomraisonsociale} +" "+ $F{nomsigle}]]></textFieldExpression>
<band height="42" splitType="Stretch"/> </textField>
</summary> <textField>
<reportElement stretchType="ElementGroupHeight" x="700" y="0" width="100" height="20"
uuid="beeb4530-5e7b-4759-a5ff-b8f2a4115d6d">
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</reportElement>
<box>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle">
<font size="8"/>
<paragraph leftIndent="10"/>
</textElement>
<textFieldExpression>
<![CDATA[$F{statusenquete} == null ? "" : $F{statusenquete}]]></textFieldExpression>
</textField>
<textField>
<reportElement stretchType="ElementGroupHeight" x="500" y="0" width="90" height="20"
uuid="28eac03c-0024-4451-9e95-b755a6cb6cb7">
<property name="com.jaspersoft.studio.spreadsheet.connectionID"
value="bbc2af97-f9e1-4d01-8bda-9ea636f952d0"/>
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</reportElement>
<box>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textElement verticalAlignment="Middle">
<font size="8"/>
<paragraph leftIndent="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{typepersonne}== null ? "" : $F{typepersonne}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport> </jasperReport>

261
pom.xml
View File

@@ -1,149 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.2</version> <version>3.4.2</version>
<relativePath/> <relativePath/>
</parent> </parent>
<groupId>io.gmss</groupId> <groupId>io.gmss</groupId>
<artifactId>Fiscad</artifactId> <artifactId>Fiscad</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>fiscad</name> <name>fiscad</name>
<description>Application de collecte des données socio-foncières</description> <description>Application de collecte des données socio-foncières</description>
<properties> <properties>
<java.version>11</java.version> <java.version>11</java.version>
<spring-cloud.version>2020.0.3</spring-cloud.version> <spring-cloud.version>2020.0.3</spring-cloud.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.30</version> <version>1.18.30</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId> <artifactId>spring-boot-starter-validation</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.modelmapper</groupId> <groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId> <artifactId>modelmapper</artifactId>
<version>3.1.1</version> <version>3.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId> <artifactId>jjwt</artifactId>
<version>0.9.1</version> <version>0.9.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sf.jasperreports</groupId> <groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId> <artifactId>jasperreports</artifactId>
<version>6.21.3</version> <version>6.21.3</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>com.lowagie</groupId> <groupId>com.lowagie</groupId>
<artifactId>itext</artifactId> <artifactId>itext</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.lowagie</groupId> <groupId>com.lowagie</groupId>
<artifactId>itext</artifactId> <artifactId>itext</artifactId>
<version>2.1.7</version> <version>2.1.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<version>2.4.5</version> <version>2.4.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId> <artifactId>spring-boot-starter-mail</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springdoc</groupId> <groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version> <version>2.6.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.xml.bind</groupId> <groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId> <artifactId>jaxb-api</artifactId>
<version>2.3.0</version> <version>2.3.0</version>
</dependency> </dependency>
<dependency>
<dependency> <groupId>org.locationtech.jts</groupId>
<groupId>org.locationtech.jts</groupId> <artifactId>jts-core</artifactId>
<artifactId>jts-core</artifactId> <version>1.19.0</version>
<version>1.19.0</version> </dependency>
</dependency>
<dependency> <dependency>
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId> <artifactId>hibernate-spatial</artifactId>
<version>${hibernate.version}</version> <version>${hibernate.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.n52.jackson</groupId> <groupId>org.n52.jackson</groupId>
<artifactId>jackson-datatype-jts</artifactId> <artifactId>jackson-datatype-jts</artifactId>
<version>1.2.4</version> <version>1.2.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.teiid</groupId> <groupId>org.teiid</groupId>
<artifactId>teiid-optional-geo</artifactId> <artifactId>teiid-optional-geo</artifactId>
<version>16.0.0</version> <version>16.0.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId> <artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version> <version>${spring-cloud.version}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@@ -9,12 +9,12 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
@ConfigurationPropertiesScan @ConfigurationPropertiesScan
public class FiscadApplication implements CommandLineRunner { public class FiscadApplication implements CommandLineRunner {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(FiscadApplication.class, args); SpringApplication.run(FiscadApplication.class, args);
} }
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
System.out.println("InfoCad Application start completed"); System.out.println("InfoCad Application start completed");
} }
} }

View File

@@ -14,7 +14,7 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
@Component @Component
public class DataLoadConfig { public class DataLoadConfig {
private final RoleRepository roleRepository; private final RoleRepository roleRepository;
private final UserRepository userRepository; private final UserRepository userRepository;
@@ -31,16 +31,15 @@ public class DataLoadConfig {
@PostConstruct @PostConstruct
public void loadData(){ public void loadData() {
loadRoles(); loadRoles();
loadUsers(); loadUsers();
} }
public void loadRoles() {
public void loadRoles(){ if (roleRepository.count() > 0) return;
if(roleRepository.count() > 0) return;
Set<Role> roles = new HashSet<>(); Set<Role> roles = new HashSet<>();
roles.add(new Role(UserRole.ROLE_USER, "Role attribué aux utilisateurs simples.")); roles.add(new Role(UserRole.ROLE_USER, "Role attribué aux utilisateurs simples."));
roles.add(new Role(UserRole.ROLE_ADMIN, "Role attribué aux administrateurs du système.")); roles.add(new Role(UserRole.ROLE_ADMIN, "Role attribué aux administrateurs du système."));
@@ -52,8 +51,8 @@ public class DataLoadConfig {
} }
public void loadUsers(){ public void loadUsers() {
if(userRepository.countAllByUsernameIsNotNull() == 0) { if (userRepository.countAllByUsernameIsNotNull() == 0) {
User admin = new User(); User admin = new User();
admin.setUsername("administrateur@infocad.bj"); admin.setUsername("administrateur@infocad.bj");
admin.setEmail("administrateur@infocad.bj"); admin.setEmail("administrateur@infocad.bj");

View File

@@ -9,7 +9,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
@@ -18,6 +21,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
public class ApplicationConfig { public class ApplicationConfig {
private final CustomUserDetailsService customUserDetailsService; private final CustomUserDetailsService customUserDetailsService;
private final UserDetailsService userDetailsService;
@Bean @Bean
public AuthenticationProvider authenticationProvider() { public AuthenticationProvider authenticationProvider() {
@@ -37,13 +41,27 @@ public class ApplicationConfig {
return new JwtAuthenticationFilter(); return new JwtAuthenticationFilter();
} }
@Bean // @Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception { // public AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception {
return config.getAuthenticationManager(); // return config.getAuthenticationManager();
} // }
@Bean @Bean
public ModelMapper modelMapper() { public ModelMapper modelMapper() {
return new ModelMapper(); return new ModelMapper();
} }
@Bean
public AuthenticationManager authenticationManager(HttpSecurity http) throws Exception {
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
daoAuthenticationProvider.setUserDetailsService(customUserDetailsService);
daoAuthenticationProvider.setPasswordEncoder(passwordEncoder());
AuthenticationManagerBuilder authenticationManagerBuilder =
http.getSharedObject(AuthenticationManagerBuilder.class);
authenticationManagerBuilder.authenticationProvider(daoAuthenticationProvider);
return authenticationManagerBuilder.build();
}
} }

View File

@@ -22,7 +22,7 @@ public class AuditorAwareImpl implements AuditorAware<Long> {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(authentication == null || !authentication.isAuthenticated() || authentication instanceof AnonymousAuthenticationToken){ if (authentication == null || !authentication.isAuthenticated() || authentication instanceof AnonymousAuthenticationToken) {
return Optional.empty(); return Optional.empty();
} }
UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal(); UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();

View File

@@ -9,8 +9,7 @@ import javax.sql.DataSource;
@Configuration @Configuration
public class JdbcConfig { public class JdbcConfig {
@Bean @Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) public JdbcTemplate jdbcTemplate(DataSource dataSource) {
{
return new JdbcTemplate(dataSource); return new JdbcTemplate(dataSource);
} }
} }

View File

@@ -55,6 +55,7 @@ public class SpringSecurityConfig {
// .csrf(csrf -> { // .csrf(csrf -> {
// csrf.ignoringRequestMatchers("/api/**"); // csrf.ignoringRequestMatchers("/api/**");
// }) // })
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
.authorizeHttpRequests(req -> .authorizeHttpRequests(req ->
req req
//.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() //.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
@@ -65,10 +66,11 @@ public class SpringSecurityConfig {
.authenticationProvider(authenticationProvider) .authenticationProvider(authenticationProvider)
.sessionManagement(session -> session.sessionCreationPolicy(STATELESS)) .sessionManagement(session -> session.sessionCreationPolicy(STATELESS))
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
; ;
return http.build(); return http.build();
} }
} }

View File

@@ -23,18 +23,18 @@ public class SwaggerOAS3Config {
private static final String[] DECOUPAGE = { private static final String[] DECOUPAGE = {
"/api/arrondissement/**", "/api/commune/**", "/api/departement/**", "/api/nationalite/**", "/api/quartier/**", "/api/arrondissement/**", "/api/commune/**", "/api/departement/**", "/api/nationalite/**", "/api/quartier/**",
"/api/secteur/**","/api/secteur-decoupage/**" "/api/secteur/**", "/api/secteur-decoupage/**"
}; };
private static final String[] INFOCAD_METIER = { private static final String[] INFOCAD_METIER = {
//metier //metier
"/api/acteur-concerne/**","/api/commentaire/**","/api/enquete/**","/api/tpe/**","/api/upload/**", "/api/acteur-concerne/**", "/api/commentaire/**", "/api/enquete/**", "/api/tpe/**", "/api/upload/**",
}; };
private static final String[] INFOCAD_PARAMETERS = { private static final String[] INFOCAD_PARAMETERS = {
"/api/bloc/**","/api/mode-acquisition/**","/api/nature-domaine/**","/api/position-representation/**", "/api/bloc/**", "/api/mode-acquisition/**", "/api/nature-domaine/**", "/api/position-representation/**",
"/api/profession/**","/api/situation-geographique/**","/api/situation-matrimoniale/**","/api/source-droit/**", "/api/profession/**", "/api/situation-geographique/**", "/api/situation-matrimoniale/**", "/api/source-droit/**",
"/api/structure/**","/api/type-contestation/**","/api/type-domaine/**","/api/type-personne/**","/api/type-piece/**", "/api/structure/**", "/api/type-contestation/**", "/api/type-domaine/**", "/api/type-personne/**", "/api/type-piece/**",
"/api/type-representation/**" "/api/type-representation/**"
}; };
@@ -84,7 +84,6 @@ public class SwaggerOAS3Config {
} }
@Bean @Bean
public GroupedOpenApi infocadMetierApi() { public GroupedOpenApi infocadMetierApi() {
return GroupedOpenApi.builder() return GroupedOpenApi.builder()

View File

@@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRSaver; import net.sf.jasperreports.engine.util.JRSaver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -23,14 +25,16 @@ public class OpenController {
@Value("${file.jasper-reports}") @Value("${file.jasper-reports}")
private String jaspersDir; private String jaspersDir;
private static final Logger logger = LoggerFactory.getLogger(OpenController.class);
@GetMapping("/compile-report") @GetMapping("/compile-report")
public ResponseEntity<?> compile(@RequestParam String jrxmlFileName) { public ResponseEntity<?> compile(@RequestParam String jrxmlFileName) {
try{ try {
InputStream quitusReportStream = getStream(jaspersDir + "/" + jrxmlFileName + ".jrxml"); InputStream quitusReportStream = getStream(jaspersDir + "/" + jrxmlFileName + ".jrxml");
JasperReport jasperReport = JasperCompileManager.compileReport(quitusReportStream); JasperReport jasperReport = JasperCompileManager.compileReport(quitusReportStream);
JRSaver.saveObject(jasperReport, jaspersDir + "/" + jrxmlFileName + ".jasper"); JRSaver.saveObject(jasperReport, jaspersDir + "/" + jrxmlFileName + ".jasper");
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
@@ -43,5 +47,4 @@ public class OpenController {
} }
} }

View File

@@ -2,13 +2,15 @@ package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.entities.decoupage.Arrondissement; import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService; import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -16,7 +18,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
public class ArrondissementController { public class ArrondissementController {
private final ArrondissementService arrondissementService; private final ArrondissementService arrondissementService;
private static final Logger logger = LoggerFactory.getLogger(ArrondissementController.class);
public ArrondissementController(ArrondissementService arrondissementService) { public ArrondissementController(ArrondissementService arrondissementService) {
this.arrondissementService = arrondissementService; this.arrondissementService = arrondissementService;
@@ -40,18 +43,26 @@ public class ArrondissementController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(description = "Unauthorized / Invalid Token", responseCode = "403")} @io.swagger.v3.oas.annotations.responses.ApiResponse(description = "Unauthorized / Invalid Token", responseCode = "403")}
) )
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createArrondissement(@RequestBody @Valid @Validated Arrondissement arrondissement) { public ResponseEntity<?> createArrondissement(@RequestBody @Valid @Validated Arrondissement arrondissement) {
try{ try {
arrondissement = arrondissementService.createArrondissement(arrondissement); arrondissement = arrondissementService.createArrondissement(arrondissement);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, arrondissement, "Arrondissement créé avec succès."), new ApiResponse<>(true, arrondissement, "Arrondissement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@@ -64,73 +75,144 @@ public class ArrondissementController {
) )
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateArrondissement(@PathVariable Long id, @RequestBody Arrondissement arrondissement) { public ResponseEntity<?> updateArrondissement(@PathVariable Long id, @RequestBody Arrondissement arrondissement) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.updateArrondissement(id, arrondissement), "Arrondissement mis à jour avec succès."), new ApiResponse<>(true, arrondissementService.updateArrondissement(id, arrondissement), "Arrondissement mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteArrondissement(@PathVariable Long id) { public ResponseEntity<?> deleteArrondissement(@PathVariable Long id) {
try{ try {
arrondissementService.deleteArrondissement(id); arrondissementService.deleteArrondissement(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Arrondissement supprimée avec succès."), new ApiResponse<>(true, "Arrondissement supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllArrondissementList() { public ResponseEntity<?> getAllArrondissementList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, arrondissementService.getArrondissementList(), "Liste des arrondissements chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, arrondissementService.getArrondissementList(), "Liste des arrondissements chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllArrondissementPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllArrondissementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, arrondissementService.getArrondissementList(pageable), "Liste des arrondissements chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, arrondissementService.getArrondissementList(pageable), "Liste des arrondissements chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) { public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, arrondissementService.getArrondissementById(id), "Arrondissement trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, arrondissementService.getArrondissementById(id), "Arrondissement trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/commune/{communeId}") @GetMapping("/commune/{communeId}")
public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) { public ResponseEntity<?> getArrondissementByCommune(@PathVariable Long communeId) {
try {
try{
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, arrondissementService.getArrondissementByComune(communeId), "Liste des arrondissements par commune chargée avec succès."), new ApiResponse<>(true, arrondissementService.getArrondissementByComune(communeId), "Liste des arrondissements par commune chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (NotFoundException e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
} }

View File

@@ -2,12 +2,14 @@ package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.entities.decoupage.Commune; import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.CommuneService; import io.gmss.fiscad.interfaces.decoupage.CommuneService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -15,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -27,95 +29,176 @@ public class CommuneController {
private final CommuneService communeService; private final CommuneService communeService;
private static final Logger logger = LoggerFactory.getLogger(CommuneController.class);
public CommuneController(CommuneService communeService) { public CommuneController(CommuneService communeService) {
this.communeService = communeService; this.communeService = communeService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCommune(@RequestBody @Valid @Validated Commune commune) { public ResponseEntity<?> createCommune(@RequestBody @Valid @Validated Commune commune) {
try{ try {
commune = communeService.createCommune(commune); commune = communeService.createCommune(commune);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, commune, "Commune créé avec succès."), new ApiResponse<>(true, commune, "Commune créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCommune(@PathVariable Long id, @RequestBody Commune commune) { public ResponseEntity<?> updateCommune(@PathVariable Long id, @RequestBody Commune commune) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, communeService.updateCommune(id, commune), "Commune mis à jour avec succès."), new ApiResponse<>(true, communeService.updateCommune(id, commune), "Commune mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteCommuner(@PathVariable Long id) { public ResponseEntity<?> deleteCommuner(@PathVariable Long id) {
try{ try {
communeService.deleteCommune(id); communeService.deleteCommune(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Commune supprimée avec succès."), new ApiResponse<>(true, "Commune supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllCommuneList() { public ResponseEntity<?> getAllCommuneList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, communeService.getCommuneList(), "Liste des communes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, communeService.getCommuneList(), "Liste des communes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllCommunePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllCommunePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, communeService.getCommuneList(pageable), "Liste des communes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, communeService.getCommuneList(pageable), "Liste des communes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getCommuneById(@PathVariable Long id) { public ResponseEntity<?> getCommuneById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, communeService.getCommuneById(id), "Commune trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, communeService.getCommuneById(id), "Commune trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/departement/{departementId}") @GetMapping("/departement/{departementId}")
public ResponseEntity<?> getCommuneByDepartement(@PathVariable Long departementId) { public ResponseEntity<?> getCommuneByDepartement(@PathVariable Long departementId) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, communeService.getCommunesByDepartement(departementId), "Liste des communes par département chargée avec succès."), new ApiResponse<>(true, communeService.getCommunesByDepartement(departementId), "Liste des communes par département chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (NotFoundException e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.entities.decoupage.Departement; import io.gmss.fiscad.entities.decoupage.Departement;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.DepartementService; import io.gmss.fiscad.interfaces.decoupage.DepartementService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,152 @@ import org.springframework.web.bind.annotation.*;
public class DepartementController { public class DepartementController {
private final DepartementService departementService; private final DepartementService departementService;
private static final Logger logger = LoggerFactory.getLogger(DepartementController.class);
public DepartementController(DepartementService departementService) { public DepartementController(DepartementService departementService) {
this.departementService = departementService; this.departementService = departementService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createDepartement(@RequestBody @Valid @Validated Departement departement) { public ResponseEntity<?> createDepartement(@RequestBody @Valid @Validated Departement departement) {
try{ try {
departement = departementService.createDepartement(departement); departement = departementService.createDepartement(departement);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, departement, "Departement créé avec succès."), new ApiResponse<>(true, departement, "Departement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateDepartement(@PathVariable Long id, @RequestBody Departement departement) { public ResponseEntity<?> updateDepartement(@PathVariable Long id, @RequestBody Departement departement) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, departementService.updateDepartement(id, departement), "Département mis à jour avec succès."), new ApiResponse<>(true, departementService.updateDepartement(id, departement), "Département mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteDepartementr(@PathVariable Long id) { public ResponseEntity<?> deleteDepartementr(@PathVariable Long id) {
try{ try {
departementService.deleteDepartement(id); departementService.deleteDepartement(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Département supprimé avec succès."), new ApiResponse<>(true, "Département supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllDepartementList() { public ResponseEntity<?> getAllDepartementList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, departementService.getDepartementList(), "Liste des département chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, departementService.getDepartementList(), "Liste des département chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllDepartementPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllDepartementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, departementService.getDepartementList(pageable), "Liste des département chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, departementService.getDepartementList(pageable), "Liste des département chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getDepartementById(@PathVariable Long id) { public ResponseEntity<?> getDepartementById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, departementService.getDepartementById(id), "Département trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, departementService.getDepartementById(id), "Département trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.entities.decoupage.Nationalite; import io.gmss.fiscad.entities.decoupage.Nationalite;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.NationaliteService; import io.gmss.fiscad.interfaces.decoupage.NationaliteService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,151 @@ import org.springframework.web.bind.annotation.*;
public class NationaliteController { public class NationaliteController {
private final NationaliteService nationaliteService; private final NationaliteService nationaliteService;
private static final Logger logger = LoggerFactory.getLogger(NationaliteController.class);
public NationaliteController(NationaliteService nationaliteService) { public NationaliteController(NationaliteService nationaliteService) {
this.nationaliteService = nationaliteService; this.nationaliteService = nationaliteService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createNationalite(@RequestBody @Valid @Validated Nationalite nationalite) { public ResponseEntity<?> createNationalite(@RequestBody @Valid @Validated Nationalite nationalite) {
try{ try {
nationalite = nationaliteService.createNationalite(nationalite); nationalite = nationaliteService.createNationalite(nationalite);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, nationalite, "Nationalite créé avec succès."), new ApiResponse<>(true, nationalite, "Nationalite créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateNationalite(@PathVariable Long id, @RequestBody Nationalite nationalite) { public ResponseEntity<?> updateNationalite(@PathVariable Long id, @RequestBody Nationalite nationalite) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, nationaliteService.updateNationalite(id, nationalite), "Nationalités mis à jour avec succès."), new ApiResponse<>(true, nationaliteService.updateNationalite(id, nationalite), "Nationalités mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteNationaliter(@PathVariable Long id) { public ResponseEntity<?> deleteNationaliter(@PathVariable Long id) {
try{ try {
nationaliteService.deleteNationalite(id); nationaliteService.deleteNationalite(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Nationalités supprimé avec succès."), new ApiResponse<>(true, "Nationalités supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllNationaliteList() { public ResponseEntity<?> getAllNationaliteList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, nationaliteService.getNationaliteList(), "Liste des nationalités chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, nationaliteService.getNationaliteList(), "Liste des nationalités chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllNationalitePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllNationalitePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, nationaliteService.getNationaliteList(pageable), "Liste des nationalités chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, nationaliteService.getNationaliteList(pageable), "Liste des nationalités chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getNationaliteById(@PathVariable Long id) { public ResponseEntity<?> getNationaliteById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, nationaliteService.getNationaliteById(id), "Nationalités trouvées avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, nationaliteService.getNationaliteById(id), "Nationalités trouvées avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,12 +2,14 @@ package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.entities.decoupage.Quartier; import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.QuartierService; import io.gmss.fiscad.interfaces.decoupage.QuartierService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -15,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,96 +28,174 @@ import org.springframework.web.bind.annotation.*;
public class QuartierController { public class QuartierController {
private final QuartierService quartierService; private final QuartierService quartierService;
private static final Logger logger = LoggerFactory.getLogger(QuartierController.class);
public QuartierController(QuartierService quartierService) { public QuartierController(QuartierService quartierService) {
this.quartierService = quartierService; this.quartierService = quartierService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createQuartier(@RequestBody @Valid @Validated Quartier quartier) { public ResponseEntity<?> createQuartier(@RequestBody @Valid @Validated Quartier quartier) {
try{ try {
quartier = quartierService.createQuartier(quartier); quartier = quartierService.createQuartier(quartier);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, quartier, "Quartier créé avec succès."), new ApiResponse<>(true, quartier, "Quartier créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateQuartier(@PathVariable Long id, @RequestBody Quartier quartier) { public ResponseEntity<?> updateQuartier(@PathVariable Long id, @RequestBody Quartier quartier) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.updateQuartier(id, quartier), "Quartier mis à jour avec succès."), new ApiResponse<>(true, quartierService.updateQuartier(id, quartier), "Quartier mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteQuartier(@PathVariable Long id) { public ResponseEntity<?> deleteQuartier(@PathVariable Long id) {
try{ try {
quartierService.deleteQuartier(id); quartierService.deleteQuartier(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Quartier supprimé avec succès."), new ApiResponse<>(true, "Quartier supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllQuartierList() { public ResponseEntity<?> getAllQuartierList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, quartierService.getQuartierList(), "Liste des quartiers chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, quartierService.getQuartierList(), "Liste des quartiers chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllQuartierPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllQuartierPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, quartierService.getQuartierList(pageable), "Liste des quartiers chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, quartierService.getQuartierList(pageable), "Liste des quartiers chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getQuartierById(@PathVariable Long id) { public ResponseEntity<?> getQuartierById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, quartierService.getQuartierById(id), "Quartier trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, quartierService.getQuartierById(id), "Quartier trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/arrondissement/{arrondissementId}") @GetMapping("/arrondissement/{arrondissementId}")
public ResponseEntity<?> getQuartierByArrondissement(@PathVariable Long arrondissementId) { public ResponseEntity<?> getQuartierByArrondissement(@PathVariable Long arrondissementId) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, quartierService.getQuartierByArrondissement(arrondissementId), "Liste des quartiers par commune chargée avec succès."), new ApiResponse<>(true, quartierService.getQuartierByArrondissement(arrondissementId), "Liste des quartiers par commune chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (NotFoundException e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
} }

View File

@@ -1,12 +1,15 @@
package io.gmss.fiscad.controllers.decoupage; package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.entities.decoupage.Secteur; import io.gmss.fiscad.entities.decoupage.Secteur;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.SecteurService; import io.gmss.fiscad.interfaces.decoupage.SecteurService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.SecteurPayload; import io.gmss.fiscad.paylaods.request.SecteurPayload;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -23,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
public class SecteurController { public class SecteurController {
private final SecteurService secteurService; private final SecteurService secteurService;
private static final Logger logger = LoggerFactory.getLogger(SecteurController.class);
public SecteurController(SecteurService secteurService) { public SecteurController(SecteurService secteurService) {
this.secteurService = secteurService; this.secteurService = secteurService;
@@ -30,87 +35,170 @@ public class SecteurController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPayload secteurPayload) { public ResponseEntity<?> createSecteur(@RequestBody @Valid @Validated SecteurPayload secteurPayload) {
try{ try {
// Secteur secteur=getSecteurFromPayload(secteurPayload); // Secteur secteur=getSecteurFromPayload(secteurPayload);
Secteur secteur = secteurService.createSecteur(secteurPayload); Secteur secteur = secteurService.createSecteur(secteurPayload);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteur, "Secteur créé avec succès."), new ApiResponse<>(true, secteur, "Secteur créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPayload secteurPayload) { public ResponseEntity<?> updateSecteur(@PathVariable Long id, @RequestBody SecteurPayload secteurPayload) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurService.updateSecteur(id, secteurPayload), "Secteur mis à jour avec succès."), new ApiResponse<>(true, secteurService.updateSecteur(id, secteurPayload), "Secteur mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) { public ResponseEntity<?> deleteSecteurr(@PathVariable Long id) {
try{ try {
secteurService.deleteSecteur(id); secteurService.deleteSecteur(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Secteur supprimée avec succès."), new ApiResponse<>(true, "Secteur supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllSecteurList() { public ResponseEntity<?> getAllSecteurList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, secteurService.getSecteurList(), "Liste des secteurs chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, secteurService.getSecteurList(), "Liste des secteurs chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllSecteurPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, secteurService.getSecteurList(pageable), "Liste des secteurs chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, secteurService.getSecteurList(pageable), "Liste des secteurs chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getSecteurById(@PathVariable Long id) { public ResponseEntity<?> getSecteurById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, secteurService.getSecteurById(id), "Secteur trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, secteurService.getSecteurById(id), "Secteur trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/by-structure-id/{structureId}") @GetMapping("/by-structure-id/{structureId}")
public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) { public ResponseEntity<?> getSecteurByStructureId(@PathVariable Long structureId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, secteurService.getSecteurById(structureId), "Secteur trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, secteurService.getSecteurById(structureId), "Secteur trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }

View File

@@ -1,11 +1,14 @@
package io.gmss.fiscad.controllers.decoupage; package io.gmss.fiscad.controllers.decoupage;
import io.gmss.fiscad.entities.decoupage.SecteurDecoupage; import io.gmss.fiscad.entities.decoupage.SecteurDecoupage;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService; import io.gmss.fiscad.interfaces.decoupage.SecteurDecoupageService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -13,6 +16,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -22,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
public class SecteurDecoupageController { public class SecteurDecoupageController {
private final SecteurDecoupageService secteurDecoupageService; private final SecteurDecoupageService secteurDecoupageService;
private static final Logger logger = LoggerFactory.getLogger(SecteurDecoupageController.class);
public SecteurDecoupageController(SecteurDecoupageService secteurDecoupageService) { public SecteurDecoupageController(SecteurDecoupageService secteurDecoupageService) {
this.secteurDecoupageService = secteurDecoupageService; this.secteurDecoupageService = secteurDecoupageService;
@@ -29,75 +34,144 @@ public class SecteurDecoupageController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) { public ResponseEntity<?> createSecteurDecoupage(@RequestBody @Valid @Validated SecteurDecoupage secteurDecoupage) {
try{ try {
secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage); secteurDecoupage = secteurDecoupageService.createSecteurDecoupage(secteurDecoupage);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."), new ApiResponse<>(true, secteurDecoupage, "SecteurDecoupage créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) { public ResponseEntity<?> updateSecteurDecoupage(@PathVariable Long id, @RequestBody SecteurDecoupage secteurDecoupage) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."), new ApiResponse<>(true, secteurDecoupageService.updateSecteurDecoupage(id, secteurDecoupage), "SecteurDecoupage mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteSecteurDecoupager(@PathVariable Long id) { public ResponseEntity<?> deleteSecteurDecoupager(@PathVariable Long id) {
try{ try {
secteurDecoupageService.deleteSecteurDecoupage(id); secteurDecoupageService.deleteSecteurDecoupage(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Secteur découpage supprimée avec succès."), new ApiResponse<>(true, "Secteur découpage supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllSecteurDecoupageList() { public ResponseEntity<?> getAllSecteurDecoupageList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageList(), "Liste des secteurDecoupages chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageList(), "Liste des secteurDecoupages chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllSecteurDecoupagePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllSecteurDecoupagePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageList(pageable), "Liste des secteurDecoupages chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageList(pageable), "Liste des secteurDecoupages chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) { public ResponseEntity<?> getSecteurDecoupageById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, secteurDecoupageService.getSecteurDecoupageById(id), "SecteurDecoupage trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }

View File

@@ -1,13 +1,17 @@
package io.gmss.fiscad.controllers.infocad.metier; package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.ActeurConcerneService; import io.gmss.fiscad.interfaces.infocad.metier.ActeurConcerneService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/acteur-concerne", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/acteur-concerne", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -18,6 +22,8 @@ public class ActeurConcerneController {
private final ActeurConcerneService acteurConcerneService; private final ActeurConcerneService acteurConcerneService;
private static final Logger logger = LoggerFactory.getLogger(ActeurConcerneController.class);
public ActeurConcerneController(ActeurConcerneService acteurConcerneService) { public ActeurConcerneController(ActeurConcerneService acteurConcerneService) {
this.acteurConcerneService = acteurConcerneService; this.acteurConcerneService = acteurConcerneService;
} }
@@ -25,10 +31,25 @@ public class ActeurConcerneController {
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getArrondissementById(@PathVariable Long id) { public ResponseEntity<?> getArrondissementById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, acteurConcerneService.getActeurConcerneById(id).get(), "Arrondissement trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, acteurConcerneService.getActeurConcerneById(id).get(), "Arrondissement trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,6 +2,7 @@ package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Commentaire; import io.gmss.fiscad.entities.infocad.metier.Commentaire;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.CommentaireService; import io.gmss.fiscad.interfaces.infocad.metier.CommentaireService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.CommentaireRequest; import io.gmss.fiscad.paylaods.request.CommentaireRequest;
@@ -9,11 +10,14 @@ import io.gmss.fiscad.paylaods.request.SyncCommentaireRequest;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@@ -27,134 +31,295 @@ public class CommentaireController {
private final CommentaireService commentaireService; private final CommentaireService commentaireService;
private static final Logger logger = LoggerFactory.getLogger(CommentaireController.class);
public CommentaireController(CommentaireService commentaireService) { public CommentaireController(CommentaireService commentaireService) {
this.commentaireService = commentaireService; this.commentaireService = commentaireService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createcommentaire(@RequestBody @Valid @Validated Commentaire commentaire) { public ResponseEntity<?> createcommentaire(@RequestBody @Valid @Validated Commentaire commentaire) {
try{ try {
commentaire.setDateCommentaire(LocalDateTime.now()); commentaire.setDateCommentaire(LocalDateTime.now());
commentaire = commentaireService.createCommentaire(commentaire); commentaire = commentaireService.createCommentaire(commentaire);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, commentaire, "Commentaire créé avec succès."), new ApiResponse<>(true, commentaire, "Commentaire créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updatecommentaire(@PathVariable Long id, @RequestBody Commentaire commentaire) { public ResponseEntity<?> updatecommentaire(@PathVariable Long id, @RequestBody Commentaire commentaire) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, commentaireService.updateCommentaire(id, commentaire), "commentaire mis à jour avec succès."), new ApiResponse<>(true, commentaireService.updateCommentaire(id, commentaire), "commentaire mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deletecommentaire(@PathVariable Long id) { public ResponseEntity<?> deletecommentaire(@PathVariable Long id) {
try{ try {
commentaireService.deleteCommentaire(id); commentaireService.deleteCommentaire(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Commentaire supprimé avec succès."), new ApiResponse<>(true, "Commentaire supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllcommentaireList() { public ResponseEntity<?> getAllcommentaireList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.getCommentaireList(), "Liste des commentaires chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.getCommentaireList(), "Liste des commentaires chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getcommentaireById(@PathVariable Long id) { public ResponseEntity<?> getcommentaireById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.getCommentaireById(id), "commentaire trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.getCommentaireById(id), "commentaire trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/nup/{nup}") @GetMapping("/nup/{nup}")
public ResponseEntity<?> getcommentaireByNup(@PathVariable String nup) { public ResponseEntity<?> getcommentaireByNup(@PathVariable String nup) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.getCommentaireByNup(nup), "commentaire trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.getCommentaireByNup(nup), "commentaire trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/enquete") @PostMapping("/enquete")
public ResponseEntity<?> getcommentaireByEnquete(@RequestBody Commentaire commentaire) { public ResponseEntity<?> getcommentaireByEnquete(@RequestBody Commentaire commentaire) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.getCommentairesByEnqueteAndTerminal(commentaire.getIdEnquete(), commentaire.getTerminalId()), "Liste des commentaires chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.getCommentairesByEnqueteAndTerminal(commentaire.getIdEnquete(), commentaire.getTerminalId()), "Liste des commentaires chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/enquete-and-state") @PostMapping("/enquete-and-state")
//@ApiOperation(value = "Cette ressource permet d'avoir la liste de tous les commentaires d'une enquête avec le statut (lu ou non lu). Les champs a renseigner pour le payload sont idEnquete et lu") //@ApiOperation(value = "Cette ressource permet d'avoir la liste de tous les commentaires d'une enquête avec le statut (lu ou non lu). Les champs a renseigner pour le payload sont idEnquete et lu")
public ResponseEntity<?> getcommentaireByEnqueteAndStatut(@RequestBody Commentaire commentaire) { public ResponseEntity<?> getcommentaireByEnqueteAndStatut(@RequestBody Commentaire commentaire) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.getCommentairesByEnqueteAndLu(commentaire.getIdEnquete(), commentaire.isLu()), "Liste des commentaires chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.getCommentairesByEnqueteAndLu(commentaire.getIdEnquete(), commentaire.isLu()), "Liste des commentaires chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/all-by-params") @PostMapping("/all-by-params")
//@ApiOperation(value = "Cette ressource permet d'avoir 4 résultats différents. \n 1 - Liste des commentaires non lus provenant du Web. \n 2 - Liste des commentaires lus provenant du Web \n 3 - Liste des commentaires non lus provenant du mobile. \n 4 - Liste des commentaires lus provenant du mobile. \n A savoir : Les variables Origine et lu sont à varier pour avoir le résultat") //@ApiOperation(value = "Cette ressource permet d'avoir 4 résultats différents. \n 1 - Liste des commentaires non lus provenant du Web. \n 2 - Liste des commentaires lus provenant du Web \n 3 - Liste des commentaires non lus provenant du mobile. \n 4 - Liste des commentaires lus provenant du mobile. \n A savoir : Les variables Origine et lu sont à varier pour avoir le résultat")
public ResponseEntity<?> getcommentaireByParams(@RequestBody CommentaireRequest commentaireRequest) { public ResponseEntity<?> getcommentaireByParams(@RequestBody CommentaireRequest commentaireRequest) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.getCommentairesByOrigineAndStateReadAndTerminalId(commentaireRequest.getOrigine(), commentaireRequest.isLu(), commentaireRequest.getTerminalId()), "Liste des commentaires chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.getCommentairesByOrigineAndStateReadAndTerminalId(commentaireRequest.getOrigine(), commentaireRequest.isLu(), commentaireRequest.getTerminalId()), "Liste des commentaires chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("synchronise/from-mobile") @PostMapping("synchronise/from-mobile")
//@ApiOperation(value = "Cette ressource permet de synchroniser tous les commentaires effectués sur le mobile vers le backend.") //@ApiOperation(value = "Cette ressource permet de synchroniser tous les commentaires effectués sur le mobile vers le backend.")
public ResponseEntity<?> synchroniseCommentairesFromMobile(@RequestBody List<Commentaire> commentaires) { public ResponseEntity<?> synchroniseCommentairesFromMobile(@RequestBody List<Commentaire> commentaires) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.saveAllCommentairesFromMobile(commentaires), "Liste des commentaires synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.saveAllCommentairesFromMobile(commentaires), "Liste des commentaires synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("synchronise/from-web") @PostMapping("synchronise/from-web")
//@ApiOperation(value = "Cette ressource permet d'avoir 4 résultats différents. \n 1 - Liste des commentaires non synchronisés provenant du Web. \n 2 - Liste des commentaires synchronisés provenant du Web \n 3 - Liste des commentaires non synchronisés provenant du mobile. \n 4 - Liste des commentaires synchronisés provenant du mobile. \n A savoir : Les variables Origine et Synchronise sont à varier pour avoir le résultat") //@ApiOperation(value = "Cette ressource permet d'avoir 4 résultats différents. \n 1 - Liste des commentaires non synchronisés provenant du Web. \n 2 - Liste des commentaires synchronisés provenant du Web \n 3 - Liste des commentaires non synchronisés provenant du mobile. \n 4 - Liste des commentaires synchronisés provenant du mobile. \n A savoir : Les variables Origine et Synchronise sont à varier pour avoir le résultat")
public ResponseEntity<?> synchroniseCommentairesFromWeb(@RequestBody CommentaireRequest commentaireRequest) { public ResponseEntity<?> synchroniseCommentairesFromWeb(@RequestBody CommentaireRequest commentaireRequest) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.getCommentairesByOrigineAndStateSynchronizedAndTerminalId(commentaireRequest.getOrigine(), commentaireRequest.isSynchronise(), commentaireRequest.getTerminalId()), "Liste des commentaires chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.getCommentairesByOrigineAndStateSynchronizedAndTerminalId(commentaireRequest.getOrigine(), commentaireRequest.isSynchronise(), commentaireRequest.getTerminalId()), "Liste des commentaires chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("synchronise/notify-done-from-mobile") @PostMapping("synchronise/notify-done-from-mobile")
//@ApiOperation(value = "Cette ressource permet matérialiser coté backend les commentaires du WEB déjà synchronisé avec le MOBILE pour que les prochaines extractions ne prennent pas en compte cela. ") //@ApiOperation(value = "Cette ressource permet matérialiser coté backend les commentaires du WEB déjà synchronisé avec le MOBILE pour que les prochaines extractions ne prennent pas en compte cela. ")
public ResponseEntity<?> notifyDoneSynchronizedFromMobile(@RequestBody List<SyncCommentaireRequest> syncCommentaireRequests) { public ResponseEntity<?> notifyDoneSynchronizedFromMobile(@RequestBody List<SyncCommentaireRequest> syncCommentaireRequests) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, commentaireService.notifySynchronizedDoneFromMobile(syncCommentaireRequests), "Synchronisation terminée."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, commentaireService.notifySynchronizedDoneFromMobile(syncCommentaireRequests), "Synchronisation terminée."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -1,5 +1,6 @@
package io.gmss.fiscad.controllers.infocad.metier; package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService; import io.gmss.fiscad.interfaces.infocad.metier.EnqueteService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.EnquetePayLoad; import io.gmss.fiscad.paylaods.request.EnquetePayLoad;
@@ -8,6 +9,8 @@ import io.gmss.fiscad.paylaods.request.FiltreEnquetePayLoad;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -15,6 +18,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
import java.util.List; import java.util.List;
@@ -25,7 +29,9 @@ import java.util.List;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class EnqueteController { public class EnqueteController {
private final EnqueteService enqueteService ; private final EnqueteService enqueteService;
private static final Logger logger = LoggerFactory.getLogger(EnqueteController.class);
public EnqueteController(EnqueteService enqueteService) { public EnqueteController(EnqueteService enqueteService) {
this.enqueteService = enqueteService; this.enqueteService = enqueteService;
@@ -33,7 +39,7 @@ public class EnqueteController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated EnquetePayLoad enquetePayLoad) { public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated EnquetePayLoad enquetePayLoad) {
// try{ // try{
// enquete = enqueteService.createEnquete(enquete); // enquete = enqueteService.createEnquete(enquete);
// return new ResponseEntity<>( // return new ResponseEntity<>(
@@ -51,144 +57,304 @@ public class EnqueteController {
@PutMapping("/validation") @PutMapping("/validation")
public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) { public ResponseEntity<?> validerEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.validerEnquete(enqueteTraitementPayLoad), "Validation effectuée avec succès."), new ApiResponse<>(true, enqueteService.validerEnquete(enqueteTraitementPayLoad), "Validation effectuée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false,"Impossible de valider l'enquête : "+e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/rejet") @PutMapping("/rejet")
public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) { public ResponseEntity<?> rejeterEnquete(@RequestBody EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."), new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoad), "Rejet effectuée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false,"Impossible de valider l'enquête : "+e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/validation-lot") @PutMapping("/validation-lot")
public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) { public ResponseEntity<?> validerEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.validerEnquete(enqueteTraitementPayLoads), "Validation effectuée avec succès."), new ApiResponse<>(true, enqueteService.validerEnquete(enqueteTraitementPayLoads), "Validation effectuée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false,"Impossible de valider l'enquête : " + e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/rejet-lot") @PutMapping("/rejet-lot")
public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) { public ResponseEntity<?> rejeterEnqueteParLot(@RequestBody List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoads), "Rejet effectuée avec succès."), new ApiResponse<>(true, enqueteService.rejeterEnquete(enqueteTraitementPayLoads), "Rejet effectuée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false,"Impossible de valider l'enquête : "+e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all/decoupage-admin-for-enquete") @GetMapping("/all/decoupage-admin-for-enquete")
public ResponseEntity<?> getAllByEnqueteDecoupageAdmin() { public ResponseEntity<?> getAllByEnqueteDecoupageAdmin() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteService.getDecoupageAdminUserConnecterAndStat(), "Liste des enquetes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteService.getDecoupageAdminUserConnecterAndStat(), "Liste des enquetes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) { public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
try{ try {
enqueteService.deleteEnquete(id); enqueteService.deleteEnquete(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"enquete supprimée avec succès."), new ApiResponse<>(true, "enquete supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllStructureList() { public ResponseEntity<?> getAllStructureList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteService.getEnqueteList(), "Liste des enquetes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteService.getEnqueteList(), "Liste des enquetes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all/com-arrond-bloc") @GetMapping("/all/com-arrond-bloc")
public ResponseEntity<?> getAllByCommuneArrondBloc() { public ResponseEntity<?> getAllByCommuneArrondBloc() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBloc(), "Liste des enquetes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/all/com-arrond-bloc/filtre") @PostMapping("/all/com-arrond-bloc/filtre")
public ResponseEntity<?> getAllByCommuneArrondBlocFiltre(@RequestBody FiltreEnquetePayLoad filtreEnquetePayLoad) { public ResponseEntity<?> getAllByCommuneArrondBlocFiltre(@RequestBody FiltreEnquetePayLoad filtreEnquetePayLoad) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBlocFiltre(filtreEnquetePayLoad), "Liste des enquetes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteService.getEnqueteCommuneArrondBlocFiltre(filtreEnquetePayLoad), "Liste des enquetes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllEnquetePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, enqueteService.getEnqueteList(pageable), "Liste des enquetes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteService.getEnqueteList(pageable), "Liste des enquetes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/fiche/id/{id}") @GetMapping("/fiche/id/{id}")
public ResponseEntity<?> getFicheEnqueteById(@PathVariable Long id) { public ResponseEntity<?> getFicheEnqueteById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteService.getFicheEnquete(id), "enquete trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteService.getFicheEnquete(id), "enquete trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getStructureById(@PathVariable Long id) { public ResponseEntity<?> getStructureById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteService.getEnqueteById(id), "enquete trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteService.getEnqueteById(id), "enquete trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/traiter-non-synch-to-mobile/{terminalId}") @GetMapping("/traiter-non-synch-to-mobile/{terminalId}")
public ResponseEntity<?> getEnqueteValideNonSynch(@PathVariable Long terminalId) { public ResponseEntity<?> getEnqueteValideNonSynch(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteService.getEnqueteValideNonSynch(terminalId), "Liste des enquetes traitées non synchronisées sur le termianl."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteService.getEnqueteValideNonSynch(terminalId), "Liste des enquetes traitées non synchronisées sur le termianl."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.metier;
import io.gmss.fiscad.entities.infocad.metier.Tpe; import io.gmss.fiscad.entities.infocad.metier.Tpe;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.metier.TpeService; import io.gmss.fiscad.interfaces.infocad.metier.TpeService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,105 +28,220 @@ import org.springframework.web.bind.annotation.*;
public class TpeController { public class TpeController {
private final TpeService tpeService; private final TpeService tpeService;
private static final Logger logger = LoggerFactory.getLogger(TpeController.class);
public TpeController(TpeService tpeService) { public TpeController(TpeService tpeService) {
this.tpeService = tpeService; this.tpeService = tpeService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createTpe(@RequestBody @Valid @Validated Tpe tpe) { public ResponseEntity<?> createTpe(@RequestBody @Valid @Validated Tpe tpe) {
try{ try {
tpe = tpeService.createTpe(tpe); tpe = tpeService.createTpe(tpe);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, tpe, "Tpe créé avec succès."), new ApiResponse<>(true, tpe, "Tpe créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateTpe(@PathVariable Long id, @RequestBody Tpe tpe) { public ResponseEntity<?> updateTpe(@PathVariable Long id, @RequestBody Tpe tpe) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, tpeService.updateTpe(id, tpe), "Tpe mis à jour avec succès."), new ApiResponse<>(true, tpeService.updateTpe(id, tpe), "Tpe mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteTper(@PathVariable Long id) { public ResponseEntity<?> deleteTper(@PathVariable Long id) {
try{ try {
tpeService.deleteTpe(id); tpeService.deleteTpe(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Tpe supprimé avec succès."), new ApiResponse<>(true, "Tpe supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllTpeList() { public ResponseEntity<?> getAllTpeList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, tpeService.getTpeList(), "Liste des tpe chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, tpeService.getTpeList(), "Liste des tpe chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-by-model/{model}") @GetMapping("/all-by-model/{model}")
public ResponseEntity<?> getAllTpeListByModel(@PathVariable String model) { public ResponseEntity<?> getAllTpeListByModel(@PathVariable String model) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, tpeService.getTpeListByModel(model), "Liste des tpe chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, tpeService.getTpeListByModel(model), "Liste des tpe chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-by-userId/{userId}") @GetMapping("/all-by-userId/{userId}")
public ResponseEntity<?> getAllTpeListByUserId(@PathVariable Long userId) { public ResponseEntity<?> getAllTpeListByUserId(@PathVariable Long userId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, tpeService.getTpeListByUserId(userId), "Liste des tpe de l'utilisateurs."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, tpeService.getTpeListByUserId(userId), "Liste des tpe de l'utilisateurs."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllTpePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, tpeService.getTpeList(pageable), "Liste des tpe chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, tpeService.getTpeList(pageable), "Liste des tpe chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getTpeById(@PathVariable Long id) { public ResponseEntity<?> getTpeById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, tpeService.getTpeById(id), "Tpe trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, tpeService.getTpeById(id), "Tpe trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/identifier/{identifier}") @GetMapping("/identifier/{identifier}")
public ResponseEntity<?> getTpeByIdentifier(@PathVariable String identifier) { public ResponseEntity<?> getTpeByIdentifier(@PathVariable String identifier) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, tpeService.getTepByIdentifier(identifier), "Tpe trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, tpeService.getTepByIdentifier(identifier), "Tpe trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -36,7 +36,7 @@ import java.time.format.DateTimeFormatter;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class UploadController { public class UploadController {
boolean headIsValid=false; boolean headIsValid = false;
private static final Logger logger = LoggerFactory.getLogger(UploadController.class); private static final Logger logger = LoggerFactory.getLogger(UploadController.class);
@@ -44,7 +44,6 @@ public class UploadController {
private UploadRepository uploadRepository; private UploadRepository uploadRepository;
@Autowired @Autowired
private FileStorageService fileStorageService; private FileStorageService fileStorageService;
@@ -55,9 +54,6 @@ public class UploadController {
// private ActeurRepository proprietaireRepository; // private ActeurRepository proprietaireRepository;
private int firstLineColumnNumber = 0; private int firstLineColumnNumber = 0;
private String fileHeader; private String fileHeader;
private String fileHeaderType; private String fileHeaderType;
@@ -65,30 +61,26 @@ public class UploadController {
private int indiceOfFile = 0; private int indiceOfFile = 0;
private SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMDD"); private SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMDD");
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYYMMDD"); private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYYMMDD");
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> all() { public ResponseEntity<?> all() {
try { try {
if (uploadRepository.findAll().isEmpty()) { if (uploadRepository.findAll().isEmpty()) {
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findAll(), "Empty list. No values present."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findAll(), "Empty list. No values present."), HttpStatus.OK);
} else { } else {
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findAll(), "All uploads files founded."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, uploadRepository.findAll(), "All uploads files founded."), HttpStatus.OK);
} }
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>(new ApiResponse(false,null, "Method POST/GET is required."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NullPointerException e) { } catch (NullPointerException e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false,null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false,null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@@ -114,8 +106,6 @@ public class UploadController {
// } // }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> one(@PathVariable Long id) { public ResponseEntity<?> one(@PathVariable Long id) {
@@ -123,21 +113,20 @@ public class UploadController {
if (uploadRepository.findById(id).isPresent()) { if (uploadRepository.findById(id).isPresent()) {
return new ResponseEntity<>(new ApiResponse(true, uploadRepository.getOne(id), "File with id {" + id + "} is found."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, uploadRepository.getOne(id), "File with id {" + id + "} is found."), HttpStatus.OK);
} else { } else {
return new ResponseEntity<>(new ApiResponse(true, null,"The upload with id {" + id + "} you request for is not found."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, null, "The upload with id {" + id + "} you request for is not found."), HttpStatus.OK);
} }
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>(new ApiResponse(false,null, "Method POST/GET is required."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NullPointerException e) { } catch (NullPointerException e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false,null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null,"An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
/** /**
* @param fileName * @param fileName
* @param request * @param request
@@ -168,7 +157,7 @@ public class UploadController {
} }
@PostMapping("/save") @PostMapping("/save")
public ResponseEntity<?> save(@RequestPart(required = true) MultipartFile file , @RequestParam String reference,@RequestParam String description /*, @RequestParam Long idTypeUpload*/) { public ResponseEntity<?> save(@RequestPart(required = true) MultipartFile file, @RequestParam String reference, @RequestParam String description /*, @RequestParam Long idTypeUpload*/) {
try { try {
Upload upload = new Upload(); Upload upload = new Upload();
@@ -187,22 +176,20 @@ public class UploadController {
upload.setMimeType(file.getContentType()); upload.setMimeType(file.getContentType());
upload.setSize(file.getSize()); upload.setSize(file.getSize());
upload.setOriginalFileName(file.getOriginalFilename()); upload.setOriginalFileName(file.getOriginalFilename());
return new ResponseEntity<>(new ApiResponse(true,uploadRepository.save(upload), "File has been created successfully."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, uploadRepository.save(upload), "File has been created successfully."), HttpStatus.OK);
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>(new ApiResponse(false,null, "Method POST/GET is required."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false,null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false,null,"An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/id/{id}") @DeleteMapping("/delete/id/{id}")
public ResponseEntity<?> delete(@PathVariable Long id) { public ResponseEntity<?> delete(@PathVariable Long id) {
try { try {
@@ -210,18 +197,18 @@ public class UploadController {
String name = uploadRepository.getOne(id).getFileName(); String name = uploadRepository.getOne(id).getFileName();
fileStorageService.deleteFile(name); fileStorageService.deleteFile(name);
uploadRepository.deleteById(id); uploadRepository.deleteById(id);
return new ResponseEntity<>(new ApiResponse(true,null, "File with name {" + name + "} has been deleted successfully."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, null, "File with name {" + name + "} has been deleted successfully."), HttpStatus.OK);
} else { } else {
return new ResponseEntity<>(new ApiResponse(true,null, "The upload specified in your request body is not found."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(true, null, "The upload specified in your request body is not found."), HttpStatus.OK);
} }
} catch (HttpClientErrorException.MethodNotAllowed e) { } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>(new ApiResponse(false,null, "Method POST/GET is required."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NullPointerException e) { } catch (NullPointerException e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false,null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false,null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK); return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }

View File

@@ -2,13 +2,15 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.Bloc; import io.gmss.fiscad.entities.infocad.parametre.Bloc;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.BlocService; import io.gmss.fiscad.interfaces.infocad.parametre.BlocService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.security.CurrentUser; import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal; import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -16,7 +18,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -27,106 +29,226 @@ import org.springframework.web.bind.annotation.*;
public class BlocController { public class BlocController {
private final BlocService blocService; private final BlocService blocService;
private static final Logger logger = LoggerFactory.getLogger(BlocController.class);
public BlocController(BlocService blocService) { public BlocController(BlocService blocService) {
this.blocService = blocService; this.blocService = blocService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createBloc(@RequestBody @Valid @Validated Bloc bloc, @CurrentUser UserPrincipal userPrincipal) { public ResponseEntity<?> createBloc(@RequestBody @Valid @Validated Bloc bloc, @CurrentUser UserPrincipal userPrincipal) {
try{ try {
bloc = blocService.createBloc(bloc); bloc = blocService.createBloc(bloc);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, bloc, "Bloc créé avec succès."), new ApiResponse<>(true, bloc, "Bloc créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateBloc(@PathVariable Long id, @RequestBody Bloc bloc) { public ResponseEntity<?> updateBloc(@PathVariable Long id, @RequestBody Bloc bloc) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, blocService.updateBloc(id, bloc), "Bloc mis à jour avec succès."), new ApiResponse<>(true, blocService.updateBloc(id, bloc), "Bloc mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteBlocr(@PathVariable Long id) { public ResponseEntity<?> deleteBlocr(@PathVariable Long id) {
try{ try {
blocService.deleteBloc(id); blocService.deleteBloc(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Bloc supprimé avec succès."), new ApiResponse<>(true, "Bloc supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllBlocList() { public ResponseEntity<?> getAllBlocList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, blocService.getBlocList(), "Liste des blocs chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, blocService.getBlocList(), "Liste des blocs chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/list-by-arrondissement") @GetMapping("/list-by-arrondissement")
public ResponseEntity<?> getAllBlocListByArrondissement(@RequestParam Long idArrondissement) { public ResponseEntity<?> getAllBlocListByArrondissement(@RequestParam Long idArrondissement) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, blocService.getBlocsByArrondissement(idArrondissement), "Liste des blocs chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, blocService.getBlocsByArrondissement(idArrondissement), "Liste des blocs chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/list-by-structure") @GetMapping("/list-by-structure")
public ResponseEntity<?> getAllBlocListByStructure(@RequestParam Long idStructure) { public ResponseEntity<?> getAllBlocListByStructure(@RequestParam Long idStructure) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, blocService.getBlocsByStructure(idStructure), "Liste des blocs chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, blocService.getBlocsByStructure(idStructure), "Liste des blocs chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/list-by-secteur") @GetMapping("/list-by-secteur")
@Tag(name = "Liste blocs",description = "Liste des blocs d'un secteur") @Tag(name = "Liste blocs", description = "Liste des blocs d'un secteur")
public ResponseEntity<?> getAllBlocListBySecteur(@RequestParam Long idSecteur) { public ResponseEntity<?> getAllBlocListBySecteur(@RequestParam Long idSecteur) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, blocService.getBlocsBySecteur(idSecteur), "Liste des blocs chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, blocService.getBlocsBySecteur(idSecteur), "Liste des blocs chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllBlocPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllBlocPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize);
return new ResponseEntity<>( try {
new ApiResponse<>(true, blocService.getBlocList(pageable), "Liste des blocs chargée avec succès."), Pageable pageable = PageRequest.of(pageNo, pageSize);
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, blocService.getBlocList(pageable), "Liste des blocs chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getBlocById(@PathVariable Long id) { public ResponseEntity<?> getBlocById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, blocService.getBlocById(id), "Bloc trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, blocService.getBlocById(id), "Bloc trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.ModeAcquisition; import io.gmss.fiscad.entities.infocad.parametre.ModeAcquisition;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.ModeAcquisitionService; import io.gmss.fiscad.interfaces.infocad.parametre.ModeAcquisitionService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -26,79 +29,150 @@ public class ModeAcquisitionController {
private final ModeAcquisitionService modeAcquisitionService; private final ModeAcquisitionService modeAcquisitionService;
private static final Logger logger = LoggerFactory.getLogger(ModeAcquisitionController.class);
public ModeAcquisitionController(ModeAcquisitionService modeAcquisitionService) { public ModeAcquisitionController(ModeAcquisitionService modeAcquisitionService) {
this.modeAcquisitionService = modeAcquisitionService; this.modeAcquisitionService = modeAcquisitionService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createModeAcquisition(@RequestBody @Valid @Validated ModeAcquisition modeAcquisition) { public ResponseEntity<?> createModeAcquisition(@RequestBody @Valid @Validated ModeAcquisition modeAcquisition) {
try{ try {
modeAcquisition = modeAcquisitionService.createModeAcquisition(modeAcquisition); modeAcquisition = modeAcquisitionService.createModeAcquisition(modeAcquisition);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, modeAcquisition, "Mode acquisition créé avec succès."), new ApiResponse<>(true, modeAcquisition, "Mode acquisition créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateModeAcquisition(@PathVariable Long id, @RequestBody ModeAcquisition modeAcquisition) { public ResponseEntity<?> updateModeAcquisition(@PathVariable Long id, @RequestBody ModeAcquisition modeAcquisition) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, modeAcquisitionService.updateModeAcquisition(id, modeAcquisition), "Mode d'acquisition mis à jour avec succès."), new ApiResponse<>(true, modeAcquisitionService.updateModeAcquisition(id, modeAcquisition), "Mode d'acquisition mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteModeAcquisitionr(@PathVariable Long id) { public ResponseEntity<?> deleteModeAcquisitionr(@PathVariable Long id) {
try{ try {
modeAcquisitionService.deleteModeAcquisition(id); modeAcquisitionService.deleteModeAcquisition(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Mode d'acquisition supprimé avec succès."), new ApiResponse<>(true, "Mode d'acquisition supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllModeAcquisitionList() { public ResponseEntity<?> getAllModeAcquisitionList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionList(), "Liste des modes d'acquisitions chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionList(), "Liste des modes d'acquisitions chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllModeAcquisitionPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllModeAcquisitionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionList(pageable), "Liste des modes d'acquisitions chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionList(pageable), "Liste des modes d'acquisitions chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getModeAcquisitionById(@PathVariable Long id) { public ResponseEntity<?> getModeAcquisitionById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionById(id), "Mode d'acquisition trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, modeAcquisitionService.getModeAcquisitionById(id), "Mode d'acquisition trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine; import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.NatureDomaineService; import io.gmss.fiscad.interfaces.infocad.parametre.NatureDomaineService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class NatureDomaineController { public class NatureDomaineController {
private final NatureDomaineService natureDomaineService; private final NatureDomaineService natureDomaineService;
private static final Logger logger = LoggerFactory.getLogger(NatureDomaineController.class);
public NatureDomaineController(NatureDomaineService natureDomaineService) { public NatureDomaineController(NatureDomaineService natureDomaineService) {
this.natureDomaineService = natureDomaineService; this.natureDomaineService = natureDomaineService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createNatureDomaine(@RequestBody @Valid @Validated NatureDomaine natureDomaine) { public ResponseEntity<?> createNatureDomaine(@RequestBody @Valid @Validated NatureDomaine natureDomaine) {
try{ try {
natureDomaine = natureDomaineService.createNatureDomaine(natureDomaine); natureDomaine = natureDomaineService.createNatureDomaine(natureDomaine);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, natureDomaine, "Nature Domaine créé avec succès."), new ApiResponse<>(true, natureDomaine, "Nature Domaine créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateNatureDomaine(@PathVariable Long id, @RequestBody NatureDomaine natureDomaine) { public ResponseEntity<?> updateNatureDomaine(@PathVariable Long id, @RequestBody NatureDomaine natureDomaine) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, natureDomaineService.updateNatureDomaine(id, natureDomaine), "Nature Domaine mise à jour avec succès."), new ApiResponse<>(true, natureDomaineService.updateNatureDomaine(id, natureDomaine), "Nature Domaine mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteNatureDomainer(@PathVariable Long id) { public ResponseEntity<?> deleteNatureDomainer(@PathVariable Long id) {
try{ try {
natureDomaineService.deleteNatureDomaine(id); natureDomaineService.deleteNatureDomaine(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Nature Domaine supprimée avec succès."), new ApiResponse<>(true, "Nature Domaine supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllNatureDomaineList() { public ResponseEntity<?> getAllNatureDomaineList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, natureDomaineService.getNatureDomaineList(), "Liste des natures de domaine chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, natureDomaineService.getNatureDomaineList(), "Liste des natures de domaine chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllNatureDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllNatureDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, natureDomaineService.getNatureDomaineList(pageable), "Liste des natures de domaine chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, natureDomaineService.getNatureDomaineList(pageable), "Liste des natures de domaine chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getNatureDomaineById(@PathVariable Long id) { public ResponseEntity<?> getNatureDomaineById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, natureDomaineService.getNatureDomaineById(id), "Nature Domaine trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, natureDomaineService.getNatureDomaineById(id), "Nature Domaine trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.PositionRepresentation; import io.gmss.fiscad.entities.infocad.parametre.PositionRepresentation;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.PositionRepresentationService; import io.gmss.fiscad.interfaces.infocad.parametre.PositionRepresentationService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,80 +28,152 @@ import org.springframework.web.bind.annotation.*;
public class PositionRepresentationController { public class PositionRepresentationController {
private final PositionRepresentationService positionRepresentationService; private final PositionRepresentationService positionRepresentationService;
private static final Logger logger = LoggerFactory.getLogger(PositionRepresentationController.class);
public PositionRepresentationController(PositionRepresentationService positionRepresentationService) { public PositionRepresentationController(PositionRepresentationService positionRepresentationService) {
this.positionRepresentationService = positionRepresentationService; this.positionRepresentationService = positionRepresentationService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createPositionRepresentation(@RequestBody @Valid @Validated PositionRepresentation positionRepresentation) { public ResponseEntity<?> createPositionRepresentation(@RequestBody @Valid @Validated PositionRepresentation positionRepresentation) {
try{ try {
positionRepresentation = positionRepresentationService.createPositionRepresentation(positionRepresentation); positionRepresentation = positionRepresentationService.createPositionRepresentation(positionRepresentation);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, positionRepresentation, "Position de representation créé avec succès."), new ApiResponse<>(true, positionRepresentation, "Position de representation créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updatePositionRepresentation(@PathVariable Long id, @RequestBody PositionRepresentation positionRepresentation) { public ResponseEntity<?> updatePositionRepresentation(@PathVariable Long id, @RequestBody PositionRepresentation positionRepresentation) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, positionRepresentationService.updatePositionRepresentation(id, positionRepresentation), "Position de representation mise à jour avec succès."), new ApiResponse<>(true, positionRepresentationService.updatePositionRepresentation(id, positionRepresentation), "Position de representation mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deletePositionRepresentation(@PathVariable Long id) { public ResponseEntity<?> deletePositionRepresentation(@PathVariable Long id) {
try{ try {
positionRepresentationService.deletePositionRepresentation(id); positionRepresentationService.deletePositionRepresentation(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Position de representation supprimée avec succès."), new ApiResponse<>(true, "Position de representation supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllPositionRepresentationList() { public ResponseEntity<?> getAllPositionRepresentationList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationList(), "Liste des positions de representation chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationList(), "Liste des positions de representation chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllPositionRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllPositionRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationList(pageable), "Liste des positions de representation chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationList(pageable), "Liste des positions de representation chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getPositionRepresentationById(@PathVariable Long id) { public ResponseEntity<?> getPositionRepresentationById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationById(id), "Position de representation trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, positionRepresentationService.getPositionRepresentationById(id), "Position de representation trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.Profession; import io.gmss.fiscad.entities.infocad.parametre.Profession;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.ProfessionService; import io.gmss.fiscad.interfaces.infocad.parametre.ProfessionService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,79 +29,152 @@ public class ProfessionController {
private final ProfessionService professionService; private final ProfessionService professionService;
private static final Logger logger = LoggerFactory.getLogger(ProfessionController.class);
public ProfessionController(ProfessionService professionService) { public ProfessionController(ProfessionService professionService) {
this.professionService = professionService; this.professionService = professionService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createProfession(@RequestBody @Valid @Validated Profession profession) { public ResponseEntity<?> createProfession(@RequestBody @Valid @Validated Profession profession) {
try{ try {
profession = professionService.createProfession(profession); profession = professionService.createProfession(profession);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, profession, "Profession créé avec succès."), new ApiResponse<>(true, profession, "Profession créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateProfession(@PathVariable Long id, @RequestBody Profession profession) { public ResponseEntity<?> updateProfession(@PathVariable Long id, @RequestBody Profession profession) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, professionService.updateProfession(id, profession), "Profession mise à jour avec succès."), new ApiResponse<>(true, professionService.updateProfession(id, profession), "Profession mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteProfessionr(@PathVariable Long id) { public ResponseEntity<?> deleteProfessionr(@PathVariable Long id) {
try{ try {
professionService.deleteProfession(id); professionService.deleteProfession(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Profession supprimée avec succès."), new ApiResponse<>(true, "Profession supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllProfessionList() { public ResponseEntity<?> getAllProfessionList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, professionService.getProfessionList(), "Liste des professions chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, professionService.getProfessionList(), "Liste des professions chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllProfessionPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllProfessionPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, professionService.getProfessionList(pageable), "Liste des professions chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, professionService.getProfessionList(pageable), "Liste des professions chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getProfessionById(@PathVariable Long id) { public ResponseEntity<?> getProfessionById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, professionService.getProfessionById(id), "Profession trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, professionService.getProfessionById(id), "Profession trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.SituationGeographique; import io.gmss.fiscad.entities.infocad.parametre.SituationGeographique;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.SituationGeographiqueService; import io.gmss.fiscad.interfaces.infocad.parametre.SituationGeographiqueService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class SituationGeographiqueController { public class SituationGeographiqueController {
private final SituationGeographiqueService situationGeographiqueService; private final SituationGeographiqueService situationGeographiqueService;
private static final Logger logger = LoggerFactory.getLogger(SituationGeographiqueController.class);
public SituationGeographiqueController(SituationGeographiqueService situationGeographiqueService) { public SituationGeographiqueController(SituationGeographiqueService situationGeographiqueService) {
this.situationGeographiqueService = situationGeographiqueService; this.situationGeographiqueService = situationGeographiqueService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createSituationGeographique(@RequestBody @Valid @Validated SituationGeographique situationGeographique) { public ResponseEntity<?> createSituationGeographique(@RequestBody @Valid @Validated SituationGeographique situationGeographique) {
try{ try {
situationGeographique = situationGeographiqueService.createSituationGeographique(situationGeographique); situationGeographique = situationGeographiqueService.createSituationGeographique(situationGeographique);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, situationGeographique, "Situation géographique créé avec succès."), new ApiResponse<>(true, situationGeographique, "Situation géographique créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateSituationGeographique(@PathVariable Long id, @RequestBody SituationGeographique situationGeographique) { public ResponseEntity<?> updateSituationGeographique(@PathVariable Long id, @RequestBody SituationGeographique situationGeographique) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, situationGeographiqueService.updateSituationGeographique(id, situationGeographique), "Situation géographique mis à jour avec succès."), new ApiResponse<>(true, situationGeographiqueService.updateSituationGeographique(id, situationGeographique), "Situation géographique mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteSituationGeographiquer(@PathVariable Long id) { public ResponseEntity<?> deleteSituationGeographiquer(@PathVariable Long id) {
try{ try {
situationGeographiqueService.deleteSituationGeographique(id); situationGeographiqueService.deleteSituationGeographique(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Situation géographique supprimée avec succès."), new ApiResponse<>(true, "Situation géographique supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllSituationGeographiqueList() { public ResponseEntity<?> getAllSituationGeographiqueList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueList(), "Liste des situations géographiques chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueList(), "Liste des situations géographiques chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllSituationGeographiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllSituationGeographiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueList(pageable), "Liste des situations géographiques chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueList(pageable), "Liste des situations géographiques chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getSituationGeographiqueById(@PathVariable Long id) { public ResponseEntity<?> getSituationGeographiqueById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueById(id), "Situation géographique trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, situationGeographiqueService.getSituationGeographiqueById(id), "Situation géographique trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.SituationMatrimoniale; import io.gmss.fiscad.entities.infocad.parametre.SituationMatrimoniale;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.SituationMatrimonialeService; import io.gmss.fiscad.interfaces.infocad.parametre.SituationMatrimonialeService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class SituationMatrimonialeController { public class SituationMatrimonialeController {
private final SituationMatrimonialeService situationMatrimonialeService; private final SituationMatrimonialeService situationMatrimonialeService;
private static final Logger logger = LoggerFactory.getLogger(SituationMatrimonialeController.class);
public SituationMatrimonialeController(SituationMatrimonialeService situationMatrimonialeService) { public SituationMatrimonialeController(SituationMatrimonialeService situationMatrimonialeService) {
this.situationMatrimonialeService = situationMatrimonialeService; this.situationMatrimonialeService = situationMatrimonialeService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createSituationMatrimoniale(@RequestBody @Valid @Validated SituationMatrimoniale situationMatrimoniale) { public ResponseEntity<?> createSituationMatrimoniale(@RequestBody @Valid @Validated SituationMatrimoniale situationMatrimoniale) {
try{ try {
situationMatrimoniale = situationMatrimonialeService.createSituationMatrimoniale(situationMatrimoniale); situationMatrimoniale = situationMatrimonialeService.createSituationMatrimoniale(situationMatrimoniale);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, situationMatrimoniale, "Situation matrimoniale créé avec succès."), new ApiResponse<>(true, situationMatrimoniale, "Situation matrimoniale créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateSituationMatrimoniale(@PathVariable Long id, @RequestBody SituationMatrimoniale situationMatrimoniale) { public ResponseEntity<?> updateSituationMatrimoniale(@PathVariable Long id, @RequestBody SituationMatrimoniale situationMatrimoniale) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, situationMatrimonialeService.updateSituationMatrimoniale(id, situationMatrimoniale), "Situation matrimoniale mise à jour avec succès."), new ApiResponse<>(true, situationMatrimonialeService.updateSituationMatrimoniale(id, situationMatrimoniale), "Situation matrimoniale mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteSituationMatrimonialer(@PathVariable Long id) { public ResponseEntity<?> deleteSituationMatrimonialer(@PathVariable Long id) {
try{ try {
situationMatrimonialeService.deleteSituationMatrimoniale(id); situationMatrimonialeService.deleteSituationMatrimoniale(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Situation matrimoniale supprimé avec succès."), new ApiResponse<>(true, "Situation matrimoniale supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllSituationMatrimonialeList() { public ResponseEntity<?> getAllSituationMatrimonialeList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeList(), "Liste des situations matrimoniales chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeList(), "Liste des situations matrimoniales chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllSituationMatrimonialePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllSituationMatrimonialePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeList(pageable), "Liste des situations matrimoniales chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeList(pageable), "Liste des situations matrimoniales chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getSituationMatrimonialeById(@PathVariable Long id) { public ResponseEntity<?> getSituationMatrimonialeById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeById(id), "Situation matrimoniale trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, situationMatrimonialeService.getSituationMatrimonialeById(id), "Situation matrimoniale trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.SourceDroit; import io.gmss.fiscad.entities.infocad.parametre.SourceDroit;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.SourceDroitService; import io.gmss.fiscad.interfaces.infocad.parametre.SourceDroitService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class SourceDroitController { public class SourceDroitController {
private final SourceDroitService sourceDroitService; private final SourceDroitService sourceDroitService;
private static final Logger logger = LoggerFactory.getLogger(SourceDroitController.class);
public SourceDroitController(SourceDroitService sourceDroitService) { public SourceDroitController(SourceDroitService sourceDroitService) {
this.sourceDroitService = sourceDroitService; this.sourceDroitService = sourceDroitService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createSourceDroit(@RequestBody @Valid @Validated SourceDroit sourceDroit) { public ResponseEntity<?> createSourceDroit(@RequestBody @Valid @Validated SourceDroit sourceDroit) {
try{ try {
sourceDroit = sourceDroitService.createSourceDroit(sourceDroit); sourceDroit = sourceDroitService.createSourceDroit(sourceDroit);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, sourceDroit, "Source de droit créé avec succès."), new ApiResponse<>(true, sourceDroit, "Source de droit créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateSourceDroit(@PathVariable Long id, @RequestBody SourceDroit sourceDroit) { public ResponseEntity<?> updateSourceDroit(@PathVariable Long id, @RequestBody SourceDroit sourceDroit) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, sourceDroitService.updateSourceDroit(id, sourceDroit), "Source de droit mise à jour avec succès."), new ApiResponse<>(true, sourceDroitService.updateSourceDroit(id, sourceDroit), "Source de droit mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteSourceDroitr(@PathVariable Long id) { public ResponseEntity<?> deleteSourceDroitr(@PathVariable Long id) {
try{ try {
sourceDroitService.deleteSourceDroit(id); sourceDroitService.deleteSourceDroit(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Source de droit supprimée avec succès."), new ApiResponse<>(true, "Source de droit supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllSourceDroitList() { public ResponseEntity<?> getAllSourceDroitList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, sourceDroitService.getSourceDroitList(), "Liste des sources de droit chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, sourceDroitService.getSourceDroitList(), "Liste des sources de droit chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllSourceDroitPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllSourceDroitPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, sourceDroitService.getSourceDroitList(pageable), "Liste des sources de droit chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, sourceDroitService.getSourceDroitList(pageable), "Liste des sources de droit chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getSourceDroitById(@PathVariable Long id) { public ResponseEntity<?> getSourceDroitById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, sourceDroitService.getSourceDroitById(id), "Source de droit trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, sourceDroitService.getSourceDroitById(id), "Source de droit trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,12 +2,15 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.Structure; import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.decoupage.ArrondissementService; import io.gmss.fiscad.interfaces.decoupage.ArrondissementService;
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService; import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -15,6 +18,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -26,6 +30,7 @@ public class StructureController {
private final StructureService structureService; private final StructureService structureService;
private final ArrondissementService arrondissementService; private final ArrondissementService arrondissementService;
private static final Logger logger = LoggerFactory.getLogger(StructureController.class);
public StructureController(StructureService structureService, ArrondissementService arrondissementService) { public StructureController(StructureService structureService, ArrondissementService arrondissementService) {
this.structureService = structureService; this.structureService = structureService;
@@ -33,91 +38,175 @@ public class StructureController {
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated Structure structure) { public ResponseEntity<?> createStructure(@RequestBody @Valid @Validated Structure structure) {
try{ try {
structure = structureService.createStructure(structure); structure = structureService.createStructure(structure);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, structure, "Structure créé avec succès."), new ApiResponse<>(true, structure, "Structure créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody Structure structure) { public ResponseEntity<?> updateStructure(@PathVariable Long id, @RequestBody Structure structure) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, structureService.updateStructure(id, structure), "Structure mise à jour avec succès."), new ApiResponse<>(true, structureService.updateStructure(id, structure), "Structure mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteStructurer(@PathVariable Long id) { public ResponseEntity<?> deleteStructurer(@PathVariable Long id) {
try{ try {
structureService.deleteStructure(id); structureService.deleteStructure(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Structure supprimée avec succès."), new ApiResponse<>(true, "Structure supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllStructureList() { public ResponseEntity<?> getAllStructureList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, structureService.getStructureList(), "Liste des structures chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, structureService.getStructureList(), "Liste des structures chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-by-arrondissement") @GetMapping("/all-by-arrondissement")
public ResponseEntity<?> getAllStructureListByArrondissement(@RequestParam Long arrondissementId) { public ResponseEntity<?> getAllStructureListByArrondissement(@RequestParam Long arrondissementId) {
try {
if(arrondissementService.getArrondissementById(arrondissementId).isPresent()){ if (arrondissementService.getArrondissementById(arrondissementId).isPresent()) {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, structureService.getStructuresByArrondissement(arrondissementId), "Liste des structures chargée avec succès."), new ApiResponse<>(true, structureService.getStructuresByArrondissement(arrondissementId), "Liste des structures chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}else{ } else {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false,"Impossible de trouver l'arrondissement spécifiée."), new ApiResponse<>(false, "Impossible de trouver l'arrondissement spécifiée."),
HttpStatus.OK HttpStatus.OK
); );
}
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllStructurePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, structureService.getStructureList(pageable), "Liste des structures chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, structureService.getStructureList(pageable), "Liste des structures chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getStructureById(@PathVariable Long id) { public ResponseEntity<?> getStructureById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, structureService.getStructureById(id), "Structure trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, structureService.getStructureById(id), "Structure trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.TypeContestation; import io.gmss.fiscad.entities.infocad.parametre.TypeContestation;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.TypeContestationService; import io.gmss.fiscad.interfaces.infocad.parametre.TypeContestationService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class TypeContestationController { public class TypeContestationController {
private final TypeContestationService typeContestationService; private final TypeContestationService typeContestationService;
private static final Logger logger = LoggerFactory.getLogger(TypeContestationController.class);
public TypeContestationController(TypeContestationService typeContestationService) { public TypeContestationController(TypeContestationService typeContestationService) {
this.typeContestationService = typeContestationService; this.typeContestationService = typeContestationService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createTypeContestation(@RequestBody @Valid @Validated TypeContestation typeContestation) { public ResponseEntity<?> createTypeContestation(@RequestBody @Valid @Validated TypeContestation typeContestation) {
try{ try {
typeContestation = typeContestationService.createTypeContestation(typeContestation); typeContestation = typeContestationService.createTypeContestation(typeContestation);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typeContestation, "Type de contestation créé avec succès."), new ApiResponse<>(true, typeContestation, "Type de contestation créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateTypeContestation(@PathVariable Long id, @RequestBody TypeContestation typeContestation) { public ResponseEntity<?> updateTypeContestation(@PathVariable Long id, @RequestBody TypeContestation typeContestation) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typeContestationService.updateTypeContestation(id, typeContestation), "Type de contestation mis à jour avec succès."), new ApiResponse<>(true, typeContestationService.updateTypeContestation(id, typeContestation), "Type de contestation mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteTypeContestationr(@PathVariable Long id) { public ResponseEntity<?> deleteTypeContestationr(@PathVariable Long id) {
try{ try {
typeContestationService.deleteTypeContestation(id); typeContestationService.deleteTypeContestation(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Type de contestation supprimé avec succès."), new ApiResponse<>(true, "Type de contestation supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllTypeContestationList() { public ResponseEntity<?> getAllTypeContestationList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typeContestationService.getTypeContestationList(), "Liste des types de contestation chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeContestationService.getTypeContestationList(), "Liste des types de contestation chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllTypeContestationPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllTypeContestationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, typeContestationService.getTypeContestationList(pageable), "Liste des types de contestation chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeContestationService.getTypeContestationList(pageable), "Liste des types de contestation chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getTypeContestationById(@PathVariable Long id) { public ResponseEntity<?> getTypeContestationById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typeContestationService.getTypeContestationById(id), "Type de contestation trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeContestationService.getTypeContestationById(id), "Type de contestation trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine; import io.gmss.fiscad.entities.infocad.parametre.TypeDomaine;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.TypeDomaineService; import io.gmss.fiscad.interfaces.infocad.parametre.TypeDomaineService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class TypeDomaineController { public class TypeDomaineController {
private final TypeDomaineService typeDomaineService; private final TypeDomaineService typeDomaineService;
private static final Logger logger = LoggerFactory.getLogger(TypeDomaineController.class);
public TypeDomaineController(TypeDomaineService typeDomaineService) { public TypeDomaineController(TypeDomaineService typeDomaineService) {
this.typeDomaineService = typeDomaineService; this.typeDomaineService = typeDomaineService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createTypeDomaine(@RequestBody @Valid @Validated TypeDomaine typeDomaine) { public ResponseEntity<?> createTypeDomaine(@RequestBody @Valid @Validated TypeDomaine typeDomaine) {
try{ try {
typeDomaine = typeDomaineService.createTypeDomaine(typeDomaine); typeDomaine = typeDomaineService.createTypeDomaine(typeDomaine);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typeDomaine, "Type de domaine créé avec succès."), new ApiResponse<>(true, typeDomaine, "Type de domaine créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateTypeDomaine(@PathVariable Long id, @RequestBody TypeDomaine typeDomaine) { public ResponseEntity<?> updateTypeDomaine(@PathVariable Long id, @RequestBody TypeDomaine typeDomaine) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typeDomaineService.updateTypeDomaine(id, typeDomaine), "Type de domaine mis à jour avec succès."), new ApiResponse<>(true, typeDomaineService.updateTypeDomaine(id, typeDomaine), "Type de domaine mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteTypeDomainer(@PathVariable Long id) { public ResponseEntity<?> deleteTypeDomainer(@PathVariable Long id) {
try{ try {
typeDomaineService.deleteTypeDomaine(id); typeDomaineService.deleteTypeDomaine(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Type de domaine supprimé avec succès."), new ApiResponse<>(true, "Type de domaine supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllTypeDomaineList() { public ResponseEntity<?> getAllTypeDomaineList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typeDomaineService.getTypeDomaineList(), "Liste des types de domaine chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeDomaineService.getTypeDomaineList(), "Liste des types de domaine chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllTypeDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllTypeDomainePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, typeDomaineService.getTypeDomaineList(pageable), "Liste des types de domaine chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeDomaineService.getTypeDomaineList(pageable), "Liste des types de domaine chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getTypeDomaineById(@PathVariable Long id) { public ResponseEntity<?> getTypeDomaineById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typeDomaineService.getTypeDomaineById(id), "Type de domaine trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeDomaineService.getTypeDomaineById(id), "Type de domaine trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.TypePersonne; import io.gmss.fiscad.entities.infocad.parametre.TypePersonne;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.TypePersonneService; import io.gmss.fiscad.interfaces.infocad.parametre.TypePersonneService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class TypePersonneController { public class TypePersonneController {
private final TypePersonneService typePersonneService; private final TypePersonneService typePersonneService;
private static final Logger logger = LoggerFactory.getLogger(TypePersonneController.class);
public TypePersonneController(TypePersonneService typePersonneService) { public TypePersonneController(TypePersonneService typePersonneService) {
this.typePersonneService = typePersonneService; this.typePersonneService = typePersonneService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createTypePersonne(@RequestBody @Valid @Validated TypePersonne typePersonne) { public ResponseEntity<?> createTypePersonne(@RequestBody @Valid @Validated TypePersonne typePersonne) {
try{ try {
typePersonne = typePersonneService.createTypePersonne(typePersonne); typePersonne = typePersonneService.createTypePersonne(typePersonne);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typePersonne, "Type de personne créé avec succès."), new ApiResponse<>(true, typePersonne, "Type de personne créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateTypePersonne(@PathVariable Long id, @RequestBody TypePersonne typePersonne) { public ResponseEntity<?> updateTypePersonne(@PathVariable Long id, @RequestBody TypePersonne typePersonne) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typePersonneService.updateTypePersonne(id, typePersonne), "Type de personne mis à jour avec succès."), new ApiResponse<>(true, typePersonneService.updateTypePersonne(id, typePersonne), "Type de personne mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteTypePersonner(@PathVariable Long id) { public ResponseEntity<?> deleteTypePersonner(@PathVariable Long id) {
try{ try {
typePersonneService.deleteTypePersonne(id); typePersonneService.deleteTypePersonne(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Type de personne supprimé avec succès."), new ApiResponse<>(true, "Type de personne supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllTypePersonneList() { public ResponseEntity<?> getAllTypePersonneList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typePersonneService.getTypePersonneList(), "Liste des types de personne chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typePersonneService.getTypePersonneList(), "Liste des types de personne chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllTypePersonnePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllTypePersonnePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, typePersonneService.getTypePersonneList(pageable), "Liste des types de personne chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typePersonneService.getTypePersonneList(pageable), "Liste des types de personne chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getTypePersonneById(@PathVariable Long id) { public ResponseEntity<?> getTypePersonneById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typePersonneService.getTypePersonneById(id), "Type de personne trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typePersonneService.getTypePersonneById(id), "Type de personne trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.TypePiece; import io.gmss.fiscad.entities.infocad.parametre.TypePiece;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.TypePieceService; import io.gmss.fiscad.interfaces.infocad.parametre.TypePieceService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class TypePieceController { public class TypePieceController {
private final TypePieceService typePieceService; private final TypePieceService typePieceService;
private static final Logger logger = LoggerFactory.getLogger(TypePieceController.class);
public TypePieceController(TypePieceService typePieceService) { public TypePieceController(TypePieceService typePieceService) {
this.typePieceService = typePieceService; this.typePieceService = typePieceService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createTypePiece(@RequestBody @Valid @Validated TypePiece typePiece) { public ResponseEntity<?> createTypePiece(@RequestBody @Valid @Validated TypePiece typePiece) {
try{ try {
typePiece = typePieceService.createTypePiece(typePiece); typePiece = typePieceService.createTypePiece(typePiece);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typePiece, "Type de piece créé avec succès."), new ApiResponse<>(true, typePiece, "Type de piece créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateTypePiece(@PathVariable Long id, @RequestBody TypePiece typePiece) { public ResponseEntity<?> updateTypePiece(@PathVariable Long id, @RequestBody TypePiece typePiece) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typePieceService.updateTypePiece(id, typePiece), "Type de piece mis à jour avec succès."), new ApiResponse<>(true, typePieceService.updateTypePiece(id, typePiece), "Type de piece mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteTypePiecer(@PathVariable Long id) { public ResponseEntity<?> deleteTypePiecer(@PathVariable Long id) {
try{ try {
typePieceService.deleteTypePiece(id); typePieceService.deleteTypePiece(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Type de piece supprimé avec succès."), new ApiResponse<>(true, "Type de piece supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllTypePieceList() { public ResponseEntity<?> getAllTypePieceList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typePieceService.getTypePieceList(), "Liste des types de piece chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typePieceService.getTypePieceList(), "Liste des types de piece chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllTypePiecePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllTypePiecePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, typePieceService.getTypePieceList(pageable), "Liste des types de piece chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typePieceService.getTypePieceList(pageable), "Liste des types de piece chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getTypePieceById(@PathVariable Long id) { public ResponseEntity<?> getTypePieceById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typePieceService.getTypePieceById(id), "Type de piece trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typePieceService.getTypePieceById(id), "Type de piece trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.infocad.parametre;
import io.gmss.fiscad.entities.infocad.parametre.TypeRepresentation; import io.gmss.fiscad.entities.infocad.parametre.TypeRepresentation;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.TypeRepresentationService; import io.gmss.fiscad.interfaces.infocad.parametre.TypeRepresentationService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class TypeRepresentationController { public class TypeRepresentationController {
private final TypeRepresentationService typeRepresentationService; private final TypeRepresentationService typeRepresentationService;
private static final Logger logger = LoggerFactory.getLogger(TypeRepresentationController.class);
public TypeRepresentationController(TypeRepresentationService typeRepresentationService) { public TypeRepresentationController(TypeRepresentationService typeRepresentationService) {
this.typeRepresentationService = typeRepresentationService; this.typeRepresentationService = typeRepresentationService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createTypeRepresentation(@RequestBody @Valid @Validated TypeRepresentation typeRepresentation) { public ResponseEntity<?> createTypeRepresentation(@RequestBody @Valid @Validated TypeRepresentation typeRepresentation) {
try{ try {
typeRepresentation = typeRepresentationService.createTypeRepresentation(typeRepresentation); typeRepresentation = typeRepresentationService.createTypeRepresentation(typeRepresentation);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typeRepresentation, "Type de representation créé avec succès."), new ApiResponse<>(true, typeRepresentation, "Type de representation créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateTypeRepresentation(@PathVariable Long id, @RequestBody TypeRepresentation typeRepresentation) { public ResponseEntity<?> updateTypeRepresentation(@PathVariable Long id, @RequestBody TypeRepresentation typeRepresentation) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typeRepresentationService.updateTypeRepresentation(id, typeRepresentation), "Type de representation mis à jour avec succès."), new ApiResponse<>(true, typeRepresentationService.updateTypeRepresentation(id, typeRepresentation), "Type de representation mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteTypeRepresentationr(@PathVariable Long id) { public ResponseEntity<?> deleteTypeRepresentationr(@PathVariable Long id) {
try{ try {
typeRepresentationService.deleteTypeRepresentation(id); typeRepresentationService.deleteTypeRepresentation(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Type de representation supprimé avec succès."), new ApiResponse<>(true, "Type de representation supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllTypeRepresentationList() { public ResponseEntity<?> getAllTypeRepresentationList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationList(), "Liste des types de representation chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationList(), "Liste des types de representation chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllTypeRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllTypeRepresentationPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationList(pageable), "Liste des types de representation chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationList(pageable), "Liste des types de representation chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getTypeRepresentationById(@PathVariable Long id) { public ResponseEntity<?> getTypeRepresentationById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationById(id), "Type de representation trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeRepresentationService.getTypeRepresentationById(id), "Type de representation trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -4,6 +4,8 @@ import io.gmss.fiscad.interfaces.notification.EmailService;
import io.gmss.fiscad.paylaods.EmailDetails; import io.gmss.fiscad.paylaods.EmailDetails;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
public class EmailController { public class EmailController {
private final EmailService emailService; private final EmailService emailService;
private static final Logger logger = LoggerFactory.getLogger(EmailController.class);
public EmailController(EmailService emailService) { public EmailController(EmailService emailService) {
this.emailService = emailService; this.emailService = emailService;
@@ -22,16 +25,14 @@ public class EmailController {
// Sending a simple Email // Sending a simple Email
@PostMapping("/sendMail") @PostMapping("/sendMail")
public String sendMail(@RequestBody EmailDetails details) public String sendMail(@RequestBody EmailDetails details) {
{
return emailService.sendSimpleMail(details); return emailService.sendSimpleMail(details);
} }
// Sending email with attachment // Sending email with attachment
@PostMapping("/sendMailWithAttachment") @PostMapping("/sendMailWithAttachment")
public String sendMailWithAttachment( public String sendMailWithAttachment(
@RequestBody EmailDetails details) @RequestBody EmailDetails details) {
{
String status String status
= emailService.sendMailWithAttachment(details); = emailService.sendMailWithAttachment(details);

View File

@@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class ReportingController { public class ReportingController {
private final ReportService reportService; private final ReportService reportService;
private final BlocRepository blocRepository; private final BlocRepository blocRepository;
private final StructureRepository structureRepository; private final StructureRepository structureRepository;
private static final Logger logger = LoggerFactory.getLogger(ReportingController.class); private static final Logger logger = LoggerFactory.getLogger(ReportingController.class);
@@ -43,7 +44,7 @@ public class ReportingController {
@GetMapping("/structure/blocs/{formatRapport}/{structureId}") @GetMapping("/structure/blocs/{formatRapport}/{structureId}")
public void imprimerBlocsParStructure(HttpServletResponse response, @PathVariable FormatRapport formatRapport, @PathVariable Long structureId) { public void imprimerBlocsParStructure(HttpServletResponse response, @PathVariable FormatRapport formatRapport, @PathVariable Long structureId) {
try { try {
reportService.imprimerBlocsStructure(response,formatRapport,structureId); reportService.imprimerBlocsStructure(response, formatRapport, structureId);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -52,7 +53,7 @@ public class ReportingController {
@GetMapping("/bloc/enquetes/{formatRapport}/{blocId}") @GetMapping("/bloc/enquetes/{formatRapport}/{blocId}")
public void imprimerEnqueteParBloc(HttpServletResponse response, @PathVariable FormatRapport formatRapport, @PathVariable Long blocId) { public void imprimerEnqueteParBloc(HttpServletResponse response, @PathVariable FormatRapport formatRapport, @PathVariable Long blocId) {
try { try {
reportService.imprimerEnqueteParBloc(response,formatRapport,blocId); reportService.imprimerEnqueteParBloc(response, formatRapport, blocId);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -61,7 +62,7 @@ public class ReportingController {
@PostMapping("/filtre/enquetes/{formatRapport}") @PostMapping("/filtre/enquetes/{formatRapport}")
public void imprimerEnqueteParFiltre(HttpServletResponse response, @RequestBody FiltreEnquetePayLoad filtreEnquetePayLoad, @PathVariable FormatRapport formatRapport) { public void imprimerEnqueteParFiltre(HttpServletResponse response, @RequestBody FiltreEnquetePayLoad filtreEnquetePayLoad, @PathVariable FormatRapport formatRapport) {
try { try {
reportService.imprimerEnqueteParFiltre(response,filtreEnquetePayLoad,formatRapport); reportService.imprimerEnqueteParFiltre(response, filtreEnquetePayLoad, formatRapport);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.Batiment; import io.gmss.fiscad.entities.rfu.metier.Batiment;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.BatimentService; import io.gmss.fiscad.interfaces.rfu.metier.BatimentService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -26,79 +29,150 @@ public class BatimentController {
private final BatimentService batimentService; private final BatimentService batimentService;
private static final Logger logger = LoggerFactory.getLogger(BatimentController.class);
public BatimentController(BatimentService batimentService) { public BatimentController(BatimentService batimentService) {
this.batimentService = batimentService; this.batimentService = batimentService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated Batiment batiment) { public ResponseEntity<?> createBatiment(@RequestBody @Valid @Validated Batiment batiment) {
try{ try {
batiment = batimentService.createBatiment(batiment); batiment = batimentService.createBatiment(batiment);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, batiment, "Batiment créé avec succès."), new ApiResponse<>(true, batiment, "Batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateBatiment(@PathVariable Long id, @RequestBody Batiment batiment) { public ResponseEntity<?> updateBatiment(@PathVariable Long id, @RequestBody Batiment batiment) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, batimentService.updateBatiment(id, batiment), "Batiment mise à jour avec succès."), new ApiResponse<>(true, batimentService.updateBatiment(id, batiment), "Batiment mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteBatiment(@PathVariable Long id) { public ResponseEntity<?> deleteBatiment(@PathVariable Long id) {
try{ try {
batimentService.deleteBatiment(id); batimentService.deleteBatiment(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Batiment supprimée avec succès."), new ApiResponse<>(true, "Batiment supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllBatimentList() { public ResponseEntity<?> getAllBatimentList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, batimentService.getBatimentList(), "Liste des caractéristiques chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, batimentService.getBatimentList(), "Liste des caractéristiques chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, batimentService.getBatimentList(pageable), "Liste des caractéristiques chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, batimentService.getBatimentList(pageable), "Liste des caractéristiques chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getBatimentById(@PathVariable Long id) { public ResponseEntity<?> getBatimentById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, batimentService.getBatimentById(id), "Batiment trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, batimentService.getBatimentById(id), "Batiment trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueBatiment;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueBatimentService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class CaracteristiqueBatimentController { public class CaracteristiqueBatimentController {
private final CaracteristiqueBatimentService caracteristiqueBatimentService; private final CaracteristiqueBatimentService caracteristiqueBatimentService;
private static final Logger logger = LoggerFactory.getLogger(CaracteristiqueBatimentController.class);
public CaracteristiqueBatimentController(CaracteristiqueBatimentService caracteristiqueBatimentService) { public CaracteristiqueBatimentController(CaracteristiqueBatimentService caracteristiqueBatimentService) {
this.caracteristiqueBatimentService = caracteristiqueBatimentService; this.caracteristiqueBatimentService = caracteristiqueBatimentService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatiment caracteristiqueBatiment) { public ResponseEntity<?> createCaracteristiqueBatiment(@RequestBody @Valid @Validated CaracteristiqueBatiment caracteristiqueBatiment) {
try{ try {
caracteristiqueBatiment = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatiment); caracteristiqueBatiment = caracteristiqueBatimentService.createCaracteristiqueBatiment(caracteristiqueBatiment);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatiment, "Caracteristique du batiment créé avec succès."), new ApiResponse<>(true, caracteristiqueBatiment, "Caracteristique du batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatiment caracteristiqueBatiment) { public ResponseEntity<?> updateCaracteristiqueBatiment(@PathVariable Long id, @RequestBody CaracteristiqueBatiment caracteristiqueBatiment) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatiment), "Caracteristique du batiment mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueBatimentService.updateCaracteristiqueBatiment(id, caracteristiqueBatiment), "Caracteristique du batiment mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteCaracteristiqueBatiment(@PathVariable Long id) { public ResponseEntity<?> deleteCaracteristiqueBatiment(@PathVariable Long id) {
try{ try {
caracteristiqueBatimentService.deleteCaracteristiqueBatiment(id); caracteristiqueBatimentService.deleteCaracteristiqueBatiment(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"CaracteristiqueBatiment supprimée avec succès."), new ApiResponse<>(true, "CaracteristiqueBatiment supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllCaracteristiqueBatimentList() { public ResponseEntity<?> getAllCaracteristiqueBatimentList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentList(), "Liste des Caracteristiques du batiment chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentList(), "Liste des Caracteristiques du batiment chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllCaracteristiqueBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllCaracteristiqueBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentList(pageable), "Liste des Caracteristiques du batiment chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentList(pageable), "Liste des Caracteristiques du batiment chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) { public ResponseEntity<?> getCaracteristiqueBatimentById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentById(id), "Caracteristique du batiment trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueBatimentService.getCaracteristiqueBatimentById(id), "Caracteristique du batiment trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueParcelle;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueParcelleService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class CaracteristiqueParcelleController { public class CaracteristiqueParcelleController {
private final CaracteristiqueParcelleService caracteristiqueParcelleService; private final CaracteristiqueParcelleService caracteristiqueParcelleService;
private static final Logger logger = LoggerFactory.getLogger(CaracteristiqueParcelleController.class);
public CaracteristiqueParcelleController(CaracteristiqueParcelleService caracteristiqueParcelleService) { public CaracteristiqueParcelleController(CaracteristiqueParcelleService caracteristiqueParcelleService) {
this.caracteristiqueParcelleService = caracteristiqueParcelleService; this.caracteristiqueParcelleService = caracteristiqueParcelleService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcelle caracteristiqueParcelle) { public ResponseEntity<?> createCaracteristiqueParcelle(@RequestBody @Valid @Validated CaracteristiqueParcelle caracteristiqueParcelle) {
try{ try {
caracteristiqueParcelle = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle); caracteristiqueParcelle = caracteristiqueParcelleService.createCaracteristiqueParcelle(caracteristiqueParcelle);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelle, "Caracteristique parcelle créé avec succès."), new ApiResponse<>(true, caracteristiqueParcelle, "Caracteristique parcelle créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcelle caracteristiqueParcelle) { public ResponseEntity<?> updateCaracteristiqueParcelle(@PathVariable Long id, @RequestBody CaracteristiqueParcelle caracteristiqueParcelle) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcelle), "Caracteristique parcelle mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueParcelleService.updateCaracteristiqueParcelle(id, caracteristiqueParcelle), "Caracteristique parcelle mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteCaracteristiqueParcelle(@PathVariable Long id) { public ResponseEntity<?> deleteCaracteristiqueParcelle(@PathVariable Long id) {
try{ try {
caracteristiqueParcelleService.deleteCaracteristiqueParcelle(id); caracteristiqueParcelleService.deleteCaracteristiqueParcelle(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Caracteristique parcelle supprimée avec succès."), new ApiResponse<>(true, "Caracteristique parcelle supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllCaracteristiqueParcelleList() { public ResponseEntity<?> getAllCaracteristiqueParcelleList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleList(), "Liste des Caracteristiques parcelles chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleList(), "Liste des Caracteristiques parcelles chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllCaracteristiqueParcellePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllCaracteristiqueParcellePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleList(pageable), "Liste des Caracteristiques parcelles chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleList(pageable), "Liste des Caracteristiques parcelles chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getCaracteristiqueParcelleById(@PathVariable Long id) { public ResponseEntity<?> getCaracteristiqueParcelleById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleById(id), "Caracteristiques parcelles trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueParcelleService.getCaracteristiqueParcelleById(id), "Caracteristiques parcelles trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement; import io.gmss.fiscad.entities.rfu.metier.CaracteristiqueUniteLogement;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.CaracteristiqueUniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,150 @@ import org.springframework.web.bind.annotation.*;
public class CaracteristiqueUniteLogementController { public class CaracteristiqueUniteLogementController {
private final CaracteristiqueUniteLogementService caracteristiqueUniteLogementService; private final CaracteristiqueUniteLogementService caracteristiqueUniteLogementService;
private static final Logger logger = LoggerFactory.getLogger(CaracteristiqueUniteLogementController.class);
public CaracteristiqueUniteLogementController(CaracteristiqueUniteLogementService caracteristiqueUniteLogementService) { public CaracteristiqueUniteLogementController(CaracteristiqueUniteLogementService caracteristiqueUniteLogementService) {
this.caracteristiqueUniteLogementService = caracteristiqueUniteLogementService; this.caracteristiqueUniteLogementService = caracteristiqueUniteLogementService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogement caracteristiqueUniteLogement) { public ResponseEntity<?> createCaracteristiqueUniteLogement(@RequestBody @Valid @Validated CaracteristiqueUniteLogement caracteristiqueUniteLogement) {
try{ try {
caracteristiqueUniteLogement = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogement); caracteristiqueUniteLogement = caracteristiqueUniteLogementService.createCaracteristiqueUniteLogement(caracteristiqueUniteLogement);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogement, "Caracteristique Unite Logement créé avec succès."), new ApiResponse<>(true, caracteristiqueUniteLogement, "Caracteristique Unite Logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogement caracteristiqueUniteLogement) { public ResponseEntity<?> updateCaracteristiqueUniteLogement(@PathVariable Long id, @RequestBody CaracteristiqueUniteLogement caracteristiqueUniteLogement) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogement), "Caracteristique Unite Logement mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueUniteLogementService.updateCaracteristiqueUniteLogement(id, caracteristiqueUniteLogement), "Caracteristique Unite Logement mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteCaracteristiqueUniteLogement(@PathVariable Long id) { public ResponseEntity<?> deleteCaracteristiqueUniteLogement(@PathVariable Long id) {
try{ try {
caracteristiqueUniteLogementService.deleteCaracteristiqueUniteLogement(id); caracteristiqueUniteLogementService.deleteCaracteristiqueUniteLogement(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"CaracteristiqueUniteLogement supprimée avec succès."), new ApiResponse<>(true, "CaracteristiqueUniteLogement supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllCaracteristiqueUniteLogementList() { public ResponseEntity<?> getAllCaracteristiqueUniteLogementList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementList(), "Liste des Caracteristiques Unite Logement chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementList(), "Liste des Caracteristiques Unite Logement chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllCaracteristiqueUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllCaracteristiqueUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementList(pageable), "Liste des Caracteristiques Unite Logement chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementList(pageable), "Liste des Caracteristiques Unite Logement chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getCaracteristiqueUniteLogementById(@PathVariable Long id) { public ResponseEntity<?> getCaracteristiqueUniteLogementById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementById(id), "Caracteristique Unite Logement trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueUniteLogementService.getCaracteristiqueUniteLogementById(id), "Caracteristique Unite Logement trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment; import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService; import io.gmss.fiscad.interfaces.rfu.metier.EnqueteBatimentService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,151 @@ import org.springframework.web.bind.annotation.*;
public class EnqueteBatimentController { public class EnqueteBatimentController {
private final EnqueteBatimentService enqueteBatimentService; private final EnqueteBatimentService enqueteBatimentService;
private static final Logger logger = LoggerFactory.getLogger(EnqueteBatimentController.class);
public EnqueteBatimentController(EnqueteBatimentService enqueteBatimentService) { public EnqueteBatimentController(EnqueteBatimentService enqueteBatimentService) {
this.enqueteBatimentService = enqueteBatimentService; this.enqueteBatimentService = enqueteBatimentService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatiment enqueteBatiment) { public ResponseEntity<?> createEnqueteBatiment(@RequestBody @Valid @Validated EnqueteBatiment enqueteBatiment) {
try{ try {
enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatiment); enqueteBatiment = enqueteBatimentService.createEnqueteBatiment(enqueteBatiment);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."), new ApiResponse<>(true, enqueteBatiment, "Enquete batiment créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody EnqueteBatiment enqueteBatiment) { public ResponseEntity<?> updateEnqueteBatiment(@PathVariable Long id, @RequestBody EnqueteBatiment enqueteBatiment) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteBatimentService.updateEnqueteBatiment(id, enqueteBatiment), "Enquete batiment mise à jour avec succès."), new ApiResponse<>(true, enqueteBatimentService.updateEnqueteBatiment(id, enqueteBatiment), "Enquete batiment mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteEnqueteBatiment(@PathVariable Long id) { public ResponseEntity<?> deleteEnqueteBatiment(@PathVariable Long id) {
try{ try {
enqueteBatimentService.deleteEnqueteBatiment(id); enqueteBatimentService.deleteEnqueteBatiment(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"EnqueteBatiment supprimée avec succès."), new ApiResponse<>(true, "EnqueteBatiment supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllEnqueteBatimentList() { public ResponseEntity<?> getAllEnqueteBatimentList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentList(), "Liste des Enquetes batiments chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentList(), "Liste des Enquetes batiments chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllEnqueteBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllEnqueteBatimentPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentList(pageable), "Liste des Enquetes batiments chargée avec succès."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentList(pageable), "Liste des Enquetes batiments chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getEnqueteBatimentById(@PathVariable Long id) { public ResponseEntity<?> getEnqueteBatimentById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentById(id), "Enquete batiment trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteBatimentService.getEnqueteBatimentById(id), "Enquete batiment trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement; import io.gmss.fiscad.entities.rfu.metier.EnqueteUniteLogement;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.EnqueteUniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,151 @@ import org.springframework.web.bind.annotation.*;
public class EnqueteUniteLogementController { public class EnqueteUniteLogementController {
private final EnqueteUniteLogementService enqueteUniteLogementService; private final EnqueteUniteLogementService enqueteUniteLogementService;
private static final Logger logger = LoggerFactory.getLogger(EnqueteUniteLogementController.class);
public EnqueteUniteLogementController(EnqueteUniteLogementService enqueteUniteLogementService) { public EnqueteUniteLogementController(EnqueteUniteLogementService enqueteUniteLogementService) {
this.enqueteUniteLogementService = enqueteUniteLogementService; this.enqueteUniteLogementService = enqueteUniteLogementService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogement enqueteUniteLogement) { public ResponseEntity<?> createEnqueteUniteLogement(@RequestBody @Valid @Validated EnqueteUniteLogement enqueteUniteLogement) {
try{ try {
enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogement); enqueteUniteLogement = enqueteUniteLogementService.createEnqueteUniteLogement(enqueteUniteLogement);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."), new ApiResponse<>(true, enqueteUniteLogement, "Enquete unite logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateEnqueteUniteLogement(@PathVariable Long id, @RequestBody EnqueteUniteLogement enqueteUniteLogement) { public ResponseEntity<?> updateEnqueteUniteLogement(@PathVariable Long id, @RequestBody EnqueteUniteLogement enqueteUniteLogement) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.updateEnqueteUniteLogement(id, enqueteUniteLogement), "Enquete unite logement mise à jour avec succès."), new ApiResponse<>(true, enqueteUniteLogementService.updateEnqueteUniteLogement(id, enqueteUniteLogement), "Enquete unite logement mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteEnqueteUniteLogement(@PathVariable Long id) { public ResponseEntity<?> deleteEnqueteUniteLogement(@PathVariable Long id) {
try{ try {
enqueteUniteLogementService.deleteEnqueteUniteLogement(id); enqueteUniteLogementService.deleteEnqueteUniteLogement(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Enquete Unite Logement supprimée avec succès."), new ApiResponse<>(true, "Enquete Unite Logement supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllEnqueteUniteLogementList() { public ResponseEntity<?> getAllEnqueteUniteLogementList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementList(), "Liste des Enquetes des unites Logements chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementList(), "Liste des Enquetes des unites Logements chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllEnqueteUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllEnqueteUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementList(pageable), "Liste des enquetes des unites de logements chargée avec succès."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementList(pageable), "Liste des enquetes des unites de logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getEnqueteUniteLogementById(@PathVariable Long id) { public ResponseEntity<?> getEnqueteUniteLogementById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementById(id), "Enquete unite de logement trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteUniteLogementService.getEnqueteUniteLogementById(id), "Enquete unite de logement trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.metier;
import io.gmss.fiscad.entities.rfu.metier.UniteLogement; import io.gmss.fiscad.entities.rfu.metier.UniteLogement;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService; import io.gmss.fiscad.interfaces.rfu.metier.UniteLogementService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,80 +28,151 @@ import org.springframework.web.bind.annotation.*;
public class UniteLogementController { public class UniteLogementController {
private final UniteLogementService enqueteUniteLogementService; private final UniteLogementService enqueteUniteLogementService;
private static final Logger logger = LoggerFactory.getLogger(UniteLogementController.class);
public UniteLogementController(UniteLogementService enqueteUniteLogementService) { public UniteLogementController(UniteLogementService enqueteUniteLogementService) {
this.enqueteUniteLogementService = enqueteUniteLogementService; this.enqueteUniteLogementService = enqueteUniteLogementService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogement enqueteUniteLogement) { public ResponseEntity<?> createUniteLogement(@RequestBody @Valid @Validated UniteLogement enqueteUniteLogement) {
try{ try {
enqueteUniteLogement = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogement); enqueteUniteLogement = enqueteUniteLogementService.createUniteLogement(enqueteUniteLogement);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogement, "Unite de logement créé avec succès."), new ApiResponse<>(true, enqueteUniteLogement, "Unite de logement créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogement enqueteUniteLogement) { public ResponseEntity<?> updateUniteLogement(@PathVariable Long id, @RequestBody UniteLogement enqueteUniteLogement) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogement), "Unite de logement mise à jour avec succès."), new ApiResponse<>(true, enqueteUniteLogementService.updateUniteLogement(id, enqueteUniteLogement), "Unite de logement mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteUniteLogement(@PathVariable Long id) { public ResponseEntity<?> deleteUniteLogement(@PathVariable Long id) {
try{ try {
enqueteUniteLogementService.deleteUniteLogement(id); enqueteUniteLogementService.deleteUniteLogement(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Unite Logement supprimée avec succès."), new ApiResponse<>(true, "Unite Logement supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllUniteLogementList() { public ResponseEntity<?> getAllUniteLogementList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementList(), "Liste des Enquetes des unites Logements chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementList(), "Liste des Enquetes des unites Logements chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllUniteLogementPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementList(pageable), "Liste des enquetes des unites de logements chargée avec succès."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementList(pageable), "Liste des enquetes des unites de logements chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) { public ResponseEntity<?> getUniteLogementById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementById(id), "Unite de de logement trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, enqueteUniteLogementService.getUniteLogementById(id), "Unite de de logement trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,12 +2,14 @@ package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.Campagne; import io.gmss.fiscad.entities.rfu.parametre.Campagne;
import io.gmss.fiscad.enums.TypeCampagne; import io.gmss.fiscad.enums.TypeCampagne;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.CampagneService; import io.gmss.fiscad.interfaces.rfu.parametre.CampagneService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -15,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
public class CampagneController { public class CampagneController {
private final CampagneService campagneService; private final CampagneService campagneService;
private static final Logger logger = LoggerFactory.getLogger(CampagneController.class);
public CampagneController(CampagneService campagneService) { public CampagneController(CampagneService campagneService) {
this.campagneService = campagneService; this.campagneService = campagneService;
@@ -32,90 +35,168 @@ public class CampagneController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCampagne(@RequestBody @Valid @Validated Campagne campagne) { public ResponseEntity<?> createCampagne(@RequestBody @Valid @Validated Campagne campagne) {
try{ try {
campagne = campagneService.createCampagne(campagne); campagne = campagneService.createCampagne(campagne);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, campagne, "Campagne créé avec succès."), new ApiResponse<>(true, campagne, "Campagne créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCampagne(@PathVariable Long id, @RequestBody Campagne campagne) { public ResponseEntity<?> updateCampagne(@PathVariable Long id, @RequestBody Campagne campagne) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, campagneService.updateCampagne(id, campagne), "Campagne mis à jour avec succès."), new ApiResponse<>(true, campagneService.updateCampagne(id, campagne), "Campagne mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteCampagner(@PathVariable Long id) { public ResponseEntity<?> deleteCampagner(@PathVariable Long id) {
try{ try {
campagneService.deleteCampagne(id); campagneService.deleteCampagne(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Campagne supprimée avec succès."), new ApiResponse<>(true, "Campagne supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllCampagneList() { public ResponseEntity<?> getAllCampagneList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, campagneService.getCampagneList(), "Liste des campagnes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, campagneService.getCampagneList(), "Liste des campagnes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllCampagnePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllCampagnePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, campagneService.getCampagneList(pageable), "Liste des campagnes chargée avec succès."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, campagneService.getCampagneList(pageable), "Liste des campagnes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getCampagneById(@PathVariable Long id) { public ResponseEntity<?> getCampagneById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, campagneService.getCampagneById(id), "Campagne trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, campagneService.getCampagneById(id), "Campagne trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/type-campagne/{typeCampagne}") @GetMapping("/type-campagne/{typeCampagne}")
public ResponseEntity<?> getCampagneByType(@PathVariable TypeCampagne typeCampagne) { public ResponseEntity<?> getCampagneByType(@PathVariable TypeCampagne typeCampagne) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, campagneService.getCampagnesByType(typeCampagne), "Liste des campagne par type chargée avec succès."), new ApiResponse<>(true, campagneService.getCampagnesByType(typeCampagne), "Liste des campagne par type chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (NotFoundException e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.Caracteristique; import io.gmss.fiscad.entities.rfu.parametre.Caracteristique;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.CaracteristiqueService; import io.gmss.fiscad.interfaces.rfu.parametre.CaracteristiqueService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,80 +27,152 @@ import org.springframework.web.bind.annotation.*;
public class CaracteristiqueController { public class CaracteristiqueController {
private final CaracteristiqueService caracteristiqueService; private final CaracteristiqueService caracteristiqueService;
private static final Logger logger = LoggerFactory.getLogger(CaracteristiqueController.class);
public CaracteristiqueController(CaracteristiqueService caracteristiqueService) { public CaracteristiqueController(CaracteristiqueService caracteristiqueService) {
this.caracteristiqueService = caracteristiqueService; this.caracteristiqueService = caracteristiqueService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createCaracteristique(@RequestBody @Valid @Validated Caracteristique caracteristique) { public ResponseEntity<?> createCaracteristique(@RequestBody @Valid @Validated Caracteristique caracteristique) {
try{ try {
caracteristique = caracteristiqueService.createCaracteristique(caracteristique); caracteristique = caracteristiqueService.createCaracteristique(caracteristique);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristique, "Caracteristique créé avec succès."), new ApiResponse<>(true, caracteristique, "Caracteristique créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateCaracteristique(@PathVariable Long id, @RequestBody Caracteristique caracteristique) { public ResponseEntity<?> updateCaracteristique(@PathVariable Long id, @RequestBody Caracteristique caracteristique) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, caracteristiqueService.updateCaracteristique(id, caracteristique), "Caracteristique mise à jour avec succès."), new ApiResponse<>(true, caracteristiqueService.updateCaracteristique(id, caracteristique), "Caracteristique mise à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteCaracteristique(@PathVariable Long id) { public ResponseEntity<?> deleteCaracteristique(@PathVariable Long id) {
try{ try {
caracteristiqueService.deleteCaracteristique(id); caracteristiqueService.deleteCaracteristique(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Caracteristique supprimée avec succès."), new ApiResponse<>(true, "Caracteristique supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllCaracteristiqueList() { public ResponseEntity<?> getAllCaracteristiqueList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueList(), "Liste des caractéristiques chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueList(), "Liste des caractéristiques chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueList(pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueList(pageable), "Liste des caractéristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getCaracteristiqueById(@PathVariable Long id) { public ResponseEntity<?> getCaracteristiqueById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueById(id), "Caracteristique trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, caracteristiqueService.getCaracteristiqueById(id), "Caracteristique trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -1,12 +1,15 @@
package io.gmss.fiscad.controllers.rfu.parametre; package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.Equipe; import io.gmss.fiscad.entities.rfu.parametre.Equipe;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.EquipeService; import io.gmss.fiscad.interfaces.rfu.parametre.EquipeService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.EquipePayload; import io.gmss.fiscad.paylaods.request.EquipePayload;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,7 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
public class EquipeController { public class EquipeController {
private final EquipeService equipeService; private final EquipeService equipeService;
private static final Logger logger = LoggerFactory.getLogger(EquipeController.class);
public EquipeController(EquipeService equipeService) { public EquipeController(EquipeService equipeService) {
this.equipeService = equipeService; this.equipeService = equipeService;
@@ -31,75 +35,145 @@ public class EquipeController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createEquipe(@RequestBody @Valid @Validated EquipePayload equipePayload) { public ResponseEntity<?> createEquipe(@RequestBody @Valid @Validated EquipePayload equipePayload) {
try{ try {
Equipe equipe = equipeService.createEquipe(equipePayload); Equipe equipe = equipeService.createEquipe(equipePayload);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, equipe, "Equipe créé avec succès."), new ApiResponse<>(true, equipe, "Equipe créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateEquipe(@PathVariable Long id, @RequestBody EquipePayload equipePayload) { public ResponseEntity<?> updateEquipe(@PathVariable Long id, @RequestBody EquipePayload equipePayload) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, equipeService.updateEquipe(id, equipePayload), "Equipe mis à jour avec succès."), new ApiResponse<>(true, equipeService.updateEquipe(id, equipePayload), "Equipe mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteEquiper(@PathVariable Long id) { public ResponseEntity<?> deleteEquiper(@PathVariable Long id) {
try{ try {
equipeService.deleteEquipe(id); equipeService.deleteEquipe(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Equipe supprimée avec succès."), new ApiResponse<>(true, "Equipe supprimée avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllEquipeList() { public ResponseEntity<?> getAllEquipeList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, equipeService.getEquipeList(), "Liste des equipes chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, equipeService.getEquipeList(), "Liste des equipes chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllEquipePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllEquipePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, equipeService.getEquipeList(pageable), "Liste des equipes chargée avec succès."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, equipeService.getEquipeList(pageable), "Liste des equipes chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getEquipeById(@PathVariable Long id) { public ResponseEntity<?> getEquipeById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, equipeService.getEquipeById(id), "Equipe trouvée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, equipeService.getEquipeById(id), "Equipe trouvée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.rfu.parametre;
import io.gmss.fiscad.entities.rfu.parametre.TypeCaracteristique; import io.gmss.fiscad.entities.rfu.parametre.TypeCaracteristique;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.rfu.parametre.TypeCaracteristiqueService; import io.gmss.fiscad.interfaces.rfu.parametre.TypeCaracteristiqueService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -23,80 +27,151 @@ import org.springframework.web.bind.annotation.*;
public class TypeCaracteristiqueController { public class TypeCaracteristiqueController {
private final TypeCaracteristiqueService typeCaracteristiqueService; private final TypeCaracteristiqueService typeCaracteristiqueService;
private static final Logger logger = LoggerFactory.getLogger(TypeCaracteristiqueController.class);
public TypeCaracteristiqueController(TypeCaracteristiqueService typeCaracteristiqueService) { public TypeCaracteristiqueController(TypeCaracteristiqueService typeCaracteristiqueService) {
this.typeCaracteristiqueService = typeCaracteristiqueService; this.typeCaracteristiqueService = typeCaracteristiqueService;
} }
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createTypeCaracteristique(@RequestBody @Valid @Validated TypeCaracteristique typeCaracteristique) { public ResponseEntity<?> createTypeCaracteristique(@RequestBody @Valid @Validated TypeCaracteristique typeCaracteristique) {
try{ try {
typeCaracteristique = typeCaracteristiqueService.createTypeCaracteristique(typeCaracteristique); typeCaracteristique = typeCaracteristiqueService.createTypeCaracteristique(typeCaracteristique);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typeCaracteristique, "Type de caracteristique créé avec succès."), new ApiResponse<>(true, typeCaracteristique, "Type de caracteristique créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateTypeCaracteristique(@PathVariable Long id, @RequestBody TypeCaracteristique typeCaracteristique) { public ResponseEntity<?> updateTypeCaracteristique(@PathVariable Long id, @RequestBody TypeCaracteristique typeCaracteristique) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, typeCaracteristiqueService.updateTypeCaracteristique(id, typeCaracteristique), "Type caracteristique mis à jour avec succès."), new ApiResponse<>(true, typeCaracteristiqueService.updateTypeCaracteristique(id, typeCaracteristique), "Type caracteristique mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteTypeCaracteristique(@PathVariable Long id) { public ResponseEntity<?> deleteTypeCaracteristique(@PathVariable Long id) {
try{ try {
typeCaracteristiqueService.deleteTypeCaracteristique(id); typeCaracteristiqueService.deleteTypeCaracteristique(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Type caracteristique supprimé avec succès."), new ApiResponse<>(true, "Type caracteristique supprimé avec succès."),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAllTypeCaracteristiqueList() { public ResponseEntity<?> getAllTypeCaracteristiqueList() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueList(), "Liste des types caracteristiques chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueList(), "Liste des types caracteristiques chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllTypeCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllTypeCaracteristiquePaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueList(pageable), "Liste des types caracteristiques chargée avec succès."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueList(pageable), "Liste des types caracteristiques chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getTypeCaracteristiqueById(@PathVariable Long id) { public ResponseEntity<?> getTypeCaracteristiqueById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueById(id), "Type caracteristique trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, typeCaracteristiqueService.getTypeCaracteristiqueById(id), "Type caracteristique trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -1,13 +1,17 @@
package io.gmss.fiscad.controllers.statistique; package io.gmss.fiscad.controllers.statistique;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.statistique.StatistiquesService; import io.gmss.fiscad.interfaces.statistique.StatistiquesService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/statistique", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/statistique", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -15,40 +19,103 @@ import org.springframework.web.bind.annotation.*;
@Tag(name = "Statistique") @Tag(name = "Statistique")
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class StatistiqueController { public class StatistiqueController {
private final StatistiquesService statistiquesService ; private final StatistiquesService statistiquesService;
private static final Logger logger = LoggerFactory.getLogger(StatistiqueController.class);
public StatistiqueController(StatistiquesService statistiquesService) { public StatistiqueController(StatistiquesService statistiquesService) {
this.statistiquesService = statistiquesService; this.statistiquesService = statistiquesService;
} }
@GetMapping(path = "/user/enquete-par-statut") @GetMapping(path = "/user/enquete-par-statut")
public ResponseEntity<?> getStatistiquesParStatut() { public ResponseEntity<?> getStatistiquesParStatut() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, statistiquesService.getStatEnqueteParStatut(), "Statistique des enquêtes par statut."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, statistiquesService.getStatEnqueteParStatut(), "Statistique des enquêtes par statut."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/enquete-par-arrondissement/{commune_id}") @GetMapping(path = "/enquete-par-arrondissement/{commune_id}")
public ResponseEntity<?> getStatistiquesParArrondissement(@PathVariable Long commune_id) { public ResponseEntity<?> getStatistiquesParArrondissement(@PathVariable Long commune_id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, statistiquesService.getStatEnqueteAdminDecoupage(commune_id), "Statistique des enquêtes par arrondissement."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, statistiquesService.getStatEnqueteAdminDecoupage(commune_id), "Statistique des enquêtes par arrondissement."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/user/enquete-par-structure") @GetMapping(path = "/user/enquete-par-structure")
public ResponseEntity<?> getStatistiquesParStructure() { public ResponseEntity<?> getStatistiquesParStructure() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, statistiquesService.getStatEnqueteAdminStructure(), "Statistique des enquêtes par structure."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, statistiquesService.getStatEnqueteAdminStructure(), "Statistique des enquêtes par structure."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/user/enquete-par-bloc") @GetMapping(path = "/user/enquete-par-bloc")
public ResponseEntity<?> getStatistiquesParBloc() { public ResponseEntity<?> getStatistiquesParBloc() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, statistiquesService.getStatBloc(), "Statistique des enquêtes par bloc."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, statistiquesService.getStatBloc(), "Statistique des enquêtes par bloc."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -1,13 +1,17 @@
package io.gmss.fiscad.controllers.synchronisation; package io.gmss.fiscad.controllers.synchronisation;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.synchronisation.RestaurationService; import io.gmss.fiscad.interfaces.synchronisation.RestaurationService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/restauration", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/restauration", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -17,107 +21,289 @@ import org.springframework.web.bind.annotation.*;
public class RestaurationController { public class RestaurationController {
public final RestaurationService restaurationService; public final RestaurationService restaurationService;
private static final Logger logger = LoggerFactory.getLogger(RestaurationController.class);
public RestaurationController(RestaurationService restaurationService) { public RestaurationController(RestaurationService restaurationService) {
this.restaurationService = restaurationService; this.restaurationService = restaurationService;
} }
@GetMapping(path = "/enquete/{terminalId}") @GetMapping(path = "/enquete/{terminalId}")
public ResponseEntity<?> getEnquetes(@PathVariable Long terminalId) { public ResponseEntity<?> getEnquetes(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getEnquete(terminalId), "liste des enquetes avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getEnquete(terminalId), "liste des enquetes avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/acteur-concerne/{terminalId}") @GetMapping(path = "/acteur-concerne/{terminalId}")
public ResponseEntity<?> getActeurConcerne(@PathVariable Long terminalId) { public ResponseEntity<?> getActeurConcerne(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getActeurConcernes(terminalId), "liste des acteurs concernés avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getActeurConcernes(terminalId), "liste des acteurs concernés avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/personne/{terminalId}") // ok @GetMapping(path = "/personne/{terminalId}") // ok
public ResponseEntity<?> getPersonnes(@PathVariable Long terminalId) { public ResponseEntity<?> getPersonnes(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getPersonne(terminalId), "liste des personnes avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getPersonne(terminalId), "liste des personnes avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/membre-groupe/{terminalId}") @GetMapping(path = "/membre-groupe/{terminalId}")
public ResponseEntity<?> getMembrePersonnes(@PathVariable Long terminalId) { public ResponseEntity<?> getMembrePersonnes(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getMembreGroupe(terminalId), "liste des membres groupe avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getMembreGroupe(terminalId), "liste des membres groupe avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/parcelle/{terminalId}") @GetMapping(path = "/parcelle/{terminalId}")
public ResponseEntity<?> getParcelle(@PathVariable Long terminalId) { public ResponseEntity<?> getParcelle(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getParcelle(terminalId), "liste des parcelle avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getParcelle(terminalId), "liste des parcelle avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/piece/{terminalId}") @GetMapping(path = "/piece/{terminalId}")
public ResponseEntity<?> getPieces(@PathVariable Long terminalId) { public ResponseEntity<?> getPieces(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getPieces(terminalId), "liste des enquetes avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getPieces(terminalId), "liste des enquetes avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/upload/{terminalId}") @GetMapping(path = "/upload/{terminalId}")
public ResponseEntity<?> getUpload(@PathVariable Long terminalId) { public ResponseEntity<?> getUpload(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getUpload(terminalId), "liste des enquetes avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getUpload(terminalId), "liste des enquetes avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/current-user-tpes") @GetMapping(path = "/current-user-tpes")
public ResponseEntity<?> getCurrentUserTpe() { public ResponseEntity<?> getCurrentUserTpe() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getTpeListByCurrentUser(), "liste des enquetes avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getTpeListByCurrentUser(), "liste des enquetes avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/batiment/{terminalId}") @GetMapping(path = "/batiment/{terminalId}")
public ResponseEntity<?> getBatiments(@PathVariable Long terminalId) { public ResponseEntity<?> getBatiments(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getBatiment(terminalId), "liste des batiments avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getBatiment(terminalId), "liste des batiments avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/enquete-batiment/{terminalId}") @GetMapping(path = "/enquete-batiment/{terminalId}")
public ResponseEntity<?> getEnqueteBatiment(@PathVariable Long terminalId) { public ResponseEntity<?> getEnqueteBatiment(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getEnqueteBatiment(terminalId), "liste des enquetes batiments avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getEnqueteBatiment(terminalId), "liste des enquetes batiments avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/caracteristique-batiment/{terminalId}") @GetMapping(path = "/caracteristique-batiment/{terminalId}")
public ResponseEntity<?> getCaracteristiqueBatiment(@PathVariable Long terminalId) { public ResponseEntity<?> getCaracteristiqueBatiment(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getCaracateristiqueBatiment(terminalId), "liste des caractéristiques batiments avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getCaracateristiqueBatiment(terminalId), "liste des caractéristiques batiments avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping(path = "/caracteristique-unite-logement/{terminalId}") @GetMapping(path = "/caracteristique-unite-logement/{terminalId}")
public ResponseEntity<?> getCaracteristiqueUniteLogement(@PathVariable Long terminalId) { public ResponseEntity<?> getCaracteristiqueUniteLogement(@PathVariable Long terminalId) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, restaurationService.getCaracateristiqueUniteLogement(terminalId), "liste des caractéristiques des unités de logement avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, restaurationService.getCaracateristiqueUniteLogement(terminalId), "liste des caractéristiques des unités de logement avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }

View File

@@ -1,14 +1,18 @@
package io.gmss.fiscad.controllers.synchronisation; package io.gmss.fiscad.controllers.synchronisation;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.synchronisation.SynchronisationService; import io.gmss.fiscad.interfaces.synchronisation.SynchronisationService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.request.*; import io.gmss.fiscad.paylaods.request.*;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
@@ -20,6 +24,7 @@ import java.util.List;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class SynchronisationController { public class SynchronisationController {
private final SynchronisationService synchronisationService; private final SynchronisationService synchronisationService;
private static final Logger logger = LoggerFactory.getLogger(SynchronisationController.class);
public SynchronisationController(SynchronisationService synchronisationService) { public SynchronisationController(SynchronisationService synchronisationService) {
this.synchronisationService = synchronisationService; this.synchronisationService = synchronisationService;
@@ -27,111 +32,281 @@ public class SynchronisationController {
@GetMapping("/user-decoupage-territorial") @GetMapping("/user-decoupage-territorial")
public ResponseEntity<?> getUserDecoupageTerritorial() { public ResponseEntity<?> getUserDecoupageTerritorial() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.getDecoupageAdminUserConnecter(), "Liste des découpages territoriaux chargés avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.getDecoupageAdminUserConnecter(), "Liste des découpages territoriaux chargés avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/references") @GetMapping("/references")
public ResponseEntity<?> getAllReferences() { public ResponseEntity<?> getAllReferences() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.getReferencesSyncResponses(), "Liste des données de référence chargée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.getReferencesSyncResponses(), "Liste des données de référence chargée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/personnes") @PostMapping("/personnes")
public ResponseEntity<?> syncPersonne(@RequestBody List<PersonnePayLoad> personnePayLoads) { public ResponseEntity<?> syncPersonne(@RequestBody List<PersonnePayLoad> personnePayLoads) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncPersonnes(personnePayLoads), "Liste des personnes synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncPersonnes(personnePayLoads), "Liste des personnes synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/membre-groupe") @PostMapping("/membre-groupe")
public ResponseEntity<?> syncMembreGroupe(@RequestBody List<MembreGroupePayLoad> membreGroupePayLoads) { public ResponseEntity<?> syncMembreGroupe(@RequestBody List<MembreGroupePayLoad> membreGroupePayLoads) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncMembreGroupe(membreGroupePayLoads), "Liste des membres de groupes de personnes synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncMembreGroupe(membreGroupePayLoads), "Liste des membres de groupes de personnes synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/enquete") @PostMapping("/enquete")
public ResponseEntity<?> syncEnquete(@RequestBody List<EnquetePayLoad> enquetePayLoads) { public ResponseEntity<?> syncEnquete(@RequestBody List<EnquetePayLoad> enquetePayLoads) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncEnquete(enquetePayLoads), "Liste des enquêtes synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncEnquete(enquetePayLoads), "Liste des enquêtes synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/parcelle") @PostMapping("/parcelle")
public ResponseEntity<?> syncParcelle(@RequestBody List<ParcellePayLoad> parcellePayLoads) { public ResponseEntity<?> syncParcelle(@RequestBody List<ParcellePayLoad> parcellePayLoads) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncParcelle(parcellePayLoads), "Liste des parceclles synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncParcelle(parcellePayLoads), "Liste des parceclles synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/piece") @PostMapping("/piece")
public ResponseEntity<?> syncPiece(@RequestBody List<PiecePayLoad> piecePayLoads) { public ResponseEntity<?> syncPiece(@RequestBody List<PiecePayLoad> piecePayLoads) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncPiece(piecePayLoads), "Liste des pièces synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncPiece(piecePayLoads), "Liste des pièces synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/acteur-concerne") @PostMapping("/acteur-concerne")
public ResponseEntity<?> syncActeurConcerne(@RequestBody List<ActeurConcernePayLoad> piecePayLoads) { public ResponseEntity<?> syncActeurConcerne(@RequestBody List<ActeurConcernePayLoad> piecePayLoads) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncActeurConcerne(piecePayLoads), "Liste des acteurs concernes synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncActeurConcerne(piecePayLoads), "Liste des acteurs concernes synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
//@PostMapping("/files") //@PostMapping("/files")
@PostMapping(path = "/files") @PostMapping(path = "/files")
public ResponseEntity<?> syncFiles(@RequestPart(required = true) MultipartFile file, public ResponseEntity<?> syncFiles(@RequestPart(required = true) MultipartFile file,
@RequestParam(required=false) Long idBackend, @RequestParam(required = false) Long idBackend,
@RequestParam Long externalKey, @RequestParam Long externalKey,
@RequestParam(required=false) Long pieceId, @RequestParam(required = false) Long pieceId,
@RequestParam(required=false) Long membreGroupeId, @RequestParam(required = false) Long membreGroupeId,
@RequestParam(required=false) Long terminalId, @RequestParam(required = false) Long terminalId,
@RequestParam(required=false) String name, @RequestParam(required = false) String name,
@RequestParam(required=false) String filePath, @RequestParam(required = false) String filePath,
@RequestParam(required=false) Long max_numero_piece_id, @RequestParam(required = false) Long max_numero_piece_id,
@RequestParam(required=false) Long max_numero_upload_id, @RequestParam(required = false) Long max_numero_upload_id,
@RequestParam(required=false) Long max_numero_acteur_concerne_id, @RequestParam(required = false) Long max_numero_acteur_concerne_id,
@RequestParam(required=false) Long enqueteId, @RequestParam(required = false) Long enqueteId,
@RequestParam(required=false) Long enqueteBatimentId, @RequestParam(required = false) Long enqueteBatimentId,
@RequestParam(required=false) Long enqueteUniteLogementId @RequestParam(required = false) Long enqueteUniteLogementId
) { ) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncFiles(file, return new ResponseEntity<>(
idBackend, new ApiResponse<>(true, synchronisationService.syncFiles(file,
externalKey, idBackend,
pieceId, externalKey,
membreGroupeId, pieceId,
terminalId, membreGroupeId,
name, terminalId,
filePath, name,
max_numero_piece_id, filePath,
max_numero_upload_id, max_numero_piece_id,
max_numero_acteur_concerne_id, max_numero_upload_id,
enqueteId, enqueteBatimentId, enqueteUniteLogementId), "Liste des fichiers synchronisée avec succès."), max_numero_acteur_concerne_id,
HttpStatus.OK enqueteId, enqueteBatimentId, enqueteUniteLogementId), "Liste des fichiers synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping(path = "/synchronise/all-enquete-data") @PostMapping(path = "/synchronise/all-enquete-data")
public ResponseEntity<?> syncAllEnqueteData(@ModelAttribute EnqueteAllDataPayload enqueteAllDataPayload) { public ResponseEntity<?> syncAllEnqueteData(@ModelAttribute EnqueteAllDataPayload enqueteAllDataPayload) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncEnqueteAllData(enqueteAllDataPayload), "Les enquetes sont synchronisées avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncEnqueteAllData(enqueteAllDataPayload), "Les enquetes sont synchronisées avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping(path = "/synchronise/enquete/confirme-from-mobile") @PostMapping(path = "/synchronise/enquete/confirme-from-mobile")
public ResponseEntity<?> syncAllEnqueteData(@RequestBody List<BatimentPaylaod> batimentPaylaods) { public ResponseEntity<?> syncAllEnqueteData(@RequestBody List<BatimentPaylaod> batimentPaylaods) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncBatiment(batimentPaylaods), "Synchronisation confirmée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncBatiment(batimentPaylaods), "Synchronisation confirmée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@@ -143,58 +318,163 @@ public class SynchronisationController {
@PostMapping(path = "/batiment") @PostMapping(path = "/batiment")
public ResponseEntity<?> syncBatiment(@RequestBody List<BatimentPaylaod> batimentPaylaods) { public ResponseEntity<?> syncBatiment(@RequestBody List<BatimentPaylaod> batimentPaylaods) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncBatiment(batimentPaylaods), "Liste des batiments synchronisées avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncBatiment(batimentPaylaods), "Liste des batiments synchronisées avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping(path = "/unite-logement") @PostMapping(path = "/unite-logement")
public ResponseEntity<?> syncUniteLogement(@RequestBody List<UniteLogementPaylaod> uniteLogementPaylaods) { public ResponseEntity<?> syncUniteLogement(@RequestBody List<UniteLogementPaylaod> uniteLogementPaylaods) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncUniteLogement(uniteLogementPaylaods), "Liste des unités de logement synchronisées avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncUniteLogement(uniteLogementPaylaods), "Liste des unités de logement synchronisées avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping(path = "/caracteristique-batiment") @PostMapping(path = "/caracteristique-batiment")
public ResponseEntity<?> syncCaracteristiqueBatiment(@RequestBody List<CaracteristiqueBatimentPaylod> caracteristiqueBatimentPaylods) { public ResponseEntity<?> syncCaracteristiqueBatiment(@RequestBody List<CaracteristiqueBatimentPaylod> caracteristiqueBatimentPaylods) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueBatiment(caracteristiqueBatimentPaylods), "Liste des caractéristiques des bâtiments synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncCaracteristiqueBatiment(caracteristiqueBatimentPaylods), "Liste des caractéristiques des bâtiments synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping(path = "/caracteristique-parcelle") @PostMapping(path = "/caracteristique-parcelle")
public ResponseEntity<?> syncCaracteristiqueParcelle(@RequestBody List<CaracteristiqueParcellePaylod> caracteristiqueParcellePaylods) { public ResponseEntity<?> syncCaracteristiqueParcelle(@RequestBody List<CaracteristiqueParcellePaylod> caracteristiqueParcellePaylods) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueParcelle(caracteristiqueParcellePaylods), "Liste des caractéristiques des parcelles synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncCaracteristiqueParcelle(caracteristiqueParcellePaylods), "Liste des caractéristiques des parcelles synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping(path = "/caracteristique-unite-logement") @PostMapping(path = "/caracteristique-unite-logement")
public ResponseEntity<?> syncCaracteristiqueUniteLogement(@RequestBody List<CaracteristiqueUniteLogementPaylod> caracteristiqueUniteLogementPaylods) { public ResponseEntity<?> syncCaracteristiqueUniteLogement(@RequestBody List<CaracteristiqueUniteLogementPaylod> caracteristiqueUniteLogementPaylods) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncCaracteristiqueUniteLogement(caracteristiqueUniteLogementPaylods), "Liste des caractéristiques des unités de logement synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncCaracteristiqueUniteLogement(caracteristiqueUniteLogementPaylods), "Liste des caractéristiques des unités de logement synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/enquete-batiment") @PostMapping("/enquete-batiment")
public ResponseEntity<?> syncEnqueteBatiment(@RequestBody List<EnqueteBatimentPayload> enqueteBatimentPayloads) { public ResponseEntity<?> syncEnqueteBatiment(@RequestBody List<EnqueteBatimentPayload> enqueteBatimentPayloads) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncEnqueteBatiment(enqueteBatimentPayloads), "Liste des enquêtes des batiments synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncEnqueteBatiment(enqueteBatimentPayloads), "Liste des enquêtes des batiments synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@PostMapping("/enquete-unite-logement") @PostMapping("/enquete-unite-logement")
public ResponseEntity<?> syncEnqueteUniteLogement(@RequestBody List<EnqueteUniteLogementPayload> enqueteUniteLogementPayloads) { public ResponseEntity<?> syncEnqueteUniteLogement(@RequestBody List<EnqueteUniteLogementPayload> enqueteUniteLogementPayloads) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, synchronisationService.syncEnqueteUniteLogement(enqueteUniteLogementPayloads), "Liste des enquêtes des unités de logement synchronisée avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, synchronisationService.syncEnqueteUniteLogement(enqueteUniteLogementPayloads), "Liste des enquêtes des unités de logement synchronisée avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -3,6 +3,7 @@ package io.gmss.fiscad.controllers.user;
import io.gmss.fiscad.entities.user.Role; import io.gmss.fiscad.entities.user.Role;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.UserRole; import io.gmss.fiscad.enums.UserRole;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.infocad.parametre.StructureService; import io.gmss.fiscad.interfaces.infocad.parametre.StructureService;
import io.gmss.fiscad.interfaces.user.RoleService; import io.gmss.fiscad.interfaces.user.RoleService;
import io.gmss.fiscad.interfaces.user.UserService; import io.gmss.fiscad.interfaces.user.UserService;
@@ -13,11 +14,14 @@ import io.gmss.fiscad.paylaods.UserRequest;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -32,6 +36,7 @@ public class AuthController {
private final UserService userService; private final UserService userService;
private final RoleService roleService; private final RoleService roleService;
private final StructureService structureService; private final StructureService structureService;
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
public AuthController(UserService userService, RoleService roleService, StructureService structureService) { public AuthController(UserService userService, RoleService roleService, StructureService structureService) {
this.userService = userService; this.userService = userService;
@@ -41,40 +46,47 @@ public class AuthController {
@PostMapping(value = "/login") @PostMapping(value = "/login")
public ResponseEntity<?> login(@RequestBody @Validated @Valid Login login) { public ResponseEntity<?> login(@RequestBody @Validated @Valid Login login) {
try{ try {
JwtAuthenticationResponse jwtAuthenticationResponse = userService.loginUser(login); JwtAuthenticationResponse jwtAuthenticationResponse = userService.loginUser(login);
if(!jwtAuthenticationResponse.getToken().isEmpty()){ if (!jwtAuthenticationResponse.getToken().isEmpty()) {
User user = userService.getUserByUsername(login.getUsername()); User user = userService.getUserByUsername(login.getUsername());
if(user.isResetPassword()){ if (user.isResetPassword()) {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, jwtAuthenticationResponse, "Vous devez impérativement changer son mot de passe avant de pouvoir continuer toute action dans le logiciel infocad."), new ApiResponse<>(false, jwtAuthenticationResponse, "Vous devez impérativement changer son mot de passe avant de pouvoir continuer toute action dans le logiciel infocad."),
HttpStatus.OK HttpStatus.OK
); );
}else{ } else {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, jwtAuthenticationResponse, "Authentification réussie avec succès."), new ApiResponse<>(true, jwtAuthenticationResponse, "Authentification réussie avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} }
}else{ } else {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, "Authentification échouée."), new ApiResponse<>(false, "Authentification échouée."),
HttpStatus.OK HttpStatus.OK
); );
} }
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
e.printStackTrace(); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>( return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
new ApiResponse<User>(false, e.getMessage()), } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
HttpStatus.OK FileStorageException e) {
); logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PostMapping("/signup") @PostMapping("/signup")
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserRequest userRequest) { public ResponseEntity<?> createUser(@RequestBody @Valid @Validated UserRequest userRequest) {
try{ try {
User user = getUser(userRequest); User user = getUser(userRequest);
user.setUsername(userRequest.getEmail()); user.setUsername(userRequest.getEmail());
user = userService.createUser(user, false); user = userService.createUser(user, false);
@@ -82,11 +94,19 @@ public class AuthController {
new ApiResponse<>(true, user, "User created successully."), new ApiResponse<>(true, user, "User created successully."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }

View File

@@ -4,6 +4,7 @@ package io.gmss.fiscad.controllers.user;
import io.gmss.fiscad.entities.user.DemandeReinitialisationMP; import io.gmss.fiscad.entities.user.DemandeReinitialisationMP;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.UserRole; import io.gmss.fiscad.enums.UserRole;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.user.DemandeReinitialisationMPService; import io.gmss.fiscad.interfaces.user.DemandeReinitialisationMPService;
import io.gmss.fiscad.interfaces.user.RoleService; import io.gmss.fiscad.interfaces.user.RoleService;
import io.gmss.fiscad.interfaces.user.UserService; import io.gmss.fiscad.interfaces.user.UserService;
@@ -13,12 +14,15 @@ import io.gmss.fiscad.security.CurrentUser;
import io.gmss.fiscad.security.UserPrincipal; import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@RequestMapping(value = "api/demande-reinitialisation-mp", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "api/demande-reinitialisation-mp", produces = MediaType.APPLICATION_JSON_VALUE)
@@ -28,6 +32,7 @@ import org.springframework.web.bind.annotation.*;
public class DemandeReinitialisationMPController { public class DemandeReinitialisationMPController {
private final DemandeReinitialisationMPService demandeReinitialisationMPService; private final DemandeReinitialisationMPService demandeReinitialisationMPService;
private static final Logger logger = LoggerFactory.getLogger(DemandeReinitialisationMPController.class);
private final UserService userService; private final UserService userService;
private final RoleService roleService; private final RoleService roleService;
@@ -45,11 +50,19 @@ public class DemandeReinitialisationMPController {
new ApiResponse<>(true, "DemandeReinitialisation MP créé avec succès."), new ApiResponse<>(true, "DemandeReinitialisation MP créé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
HttpStatus.OK
);
} }
} }
@@ -60,11 +73,19 @@ public class DemandeReinitialisationMPController {
new ApiResponse<>(true, demandeReinitialisationMPService.updateDemandeReinitialisationMP(id, demandeReinitialisationMP), "DemandeReinitialisationMP mis à jour avec succès."), new ApiResponse<>(true, demandeReinitialisationMPService.updateDemandeReinitialisationMP(id, demandeReinitialisationMP), "DemandeReinitialisationMP mis à jour avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
HttpStatus.OK
);
} }
} }
@@ -76,11 +97,19 @@ public class DemandeReinitialisationMPController {
new ApiResponse<>(true, "Demande de Reinitialisation de mot de passe supprimé avec succès."), new ApiResponse<>(true, "Demande de Reinitialisation de mot de passe supprimé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
HttpStatus.OK
);
} }
} }
@@ -90,24 +119,24 @@ public class DemandeReinitialisationMPController {
User user = userPrincipal.getUser(); User user = userPrincipal.getUser();
if(user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))){ if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
return new ResponseEntity<>(
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(), "Liste des demande de Reinitialisation chargée avec succès."),
HttpStatus.OK
);
} else {
if (user.getStructure() == null) {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(), "Liste des demande de Reinitialisation chargée avec succès."), new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de initialisation de mot de passe."),
HttpStatus.OK
);
} else {
return new ResponseEntity<>(
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPNonTraiteList(user.getStructure()), "Liste des demande de Reinitialisation chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}else{
if (user.getStructure() == null) {
return new ResponseEntity<>(
new ApiResponse<>(false, "Cet utilisateur n'est pas dans une structure; on ne peut donc pas afficher les demandes de réinitialisation de mot de passe."),
HttpStatus.OK
);
} else {
return new ResponseEntity<>(
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPNonTraiteList(user.getStructure()), "Liste des demande de Reinitialisation chargée avec succès."),
HttpStatus.OK
);
}
} }
}
// }else { // }else {
// if (user.getStructure() == null) { // if (user.getStructure() == null) {
// return new ResponseEntity<>( // return new ResponseEntity<>(
@@ -121,43 +150,98 @@ public class DemandeReinitialisationMPController {
// ); // );
// } // }
// } // }
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
HttpStatus.OK
);
} }
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllDemandeReinitialisationMPPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(pageable), "Liste des demandeReinitialisationMP chargée avec succès."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPList(pageable), "Liste des demandeReinitialisationMP chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getDemandeReinitialisationMPById(@PathVariable Long id) { public ResponseEntity<?> getDemandeReinitialisationMPById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPById(id), "DemandeReinitialisationMP trouvé avec succès."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, demandeReinitialisationMPService.getDemandeReinitialisationMPById(id), "DemandeReinitialisationMP trouvé avec succès."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/reset") @GetMapping("/reset")
public ResponseEntity<?> traiterDemande(@RequestParam Long id, @RequestParam String password) { public ResponseEntity<?> traiterDemande(@RequestParam Long id, @RequestParam String password) {
DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPService.traiterDemandeReinitialisation(id, password); try {
return new ResponseEntity<>( DemandeReinitialisationMP demandeReinitialisationMP = demandeReinitialisationMPService.traiterDemandeReinitialisation(id, password);
new ApiResponse<>(true,
new DemandeReinitialisationMPResponse( return new ResponseEntity<>(
userService.getUserResponseFromUser(demandeReinitialisationMP.getUser()), new ApiResponse<>(true,
demandeReinitialisationMP.getEtatDemande() new DemandeReinitialisationMPResponse(
), userService.getUserResponseFromUser(demandeReinitialisationMP.getUser()),
"Traitement effectué avec succès."), demandeReinitialisationMP.getEtatDemande()
HttpStatus.OK ),
); "Traitement effectué avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -2,11 +2,14 @@ package io.gmss.fiscad.controllers.user;
import io.gmss.fiscad.entities.user.Role; import io.gmss.fiscad.entities.user.Role;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.user.RoleService; import io.gmss.fiscad.interfaces.user.RoleService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -14,6 +17,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
public class RoleController { public class RoleController {
private final RoleService roleService; private final RoleService roleService;
private static final Logger logger = LoggerFactory.getLogger(RoleController.class);
public RoleController(RoleService roleService) { public RoleController(RoleService roleService) {
this.roleService = roleService; this.roleService = roleService;
@@ -32,67 +37,122 @@ public class RoleController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createRole(@RequestBody @Valid @Validated Role role) { public ResponseEntity<?> createRole(@RequestBody @Valid @Validated Role role) {
try{ try {
role = roleService.createRole(role); role = roleService.createRole(role);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, role, "Role created successully."), new ApiResponse<>(true, role, "Role created successully."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateRole(@PathVariable Long id, @RequestBody Role role) { public ResponseEntity<?> updateRole(@PathVariable Long id, @RequestBody Role role) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, roleService.updateRole(id, role), "Role updated successully."), new ApiResponse<>(true, roleService.updateRole(id, role), "Role updated successully."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteRole(@PathVariable Long id) { public ResponseEntity<?> deleteRole(@PathVariable Long id) {
try{ try {
roleService.deleteRole(id); roleService.deleteRole(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"Role deleted successully"), new ApiResponse<>(true, "Role deleted successully"),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAll() { public ResponseEntity<?> getAll() {
return new ResponseEntity<>( try {
new ApiResponse<>(true, roleService.getRoleList(), "Liste des roles."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, roleService.getRoleList(), "Liste des roles."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-paged") @GetMapping("/all-paged")
public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) { public ResponseEntity<?> getAllPaged(@RequestParam int pageNo, @RequestParam int pageSize) {
Pageable pageable = PageRequest.of(pageNo, pageSize); try {
return new ResponseEntity<>( Pageable pageable = PageRequest.of(pageNo, pageSize);
new ApiResponse<>(true, roleService.getRoleList(pageable), "Liste des roles."),
HttpStatus.OK return new ResponseEntity<>(
); new ApiResponse<>(true, roleService.getRoleList(pageable), "Liste des roles."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
} }

View File

@@ -3,6 +3,7 @@ package io.gmss.fiscad.controllers.user;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.UserRole; import io.gmss.fiscad.enums.UserRole;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.user.UserService; import io.gmss.fiscad.interfaces.user.UserService;
import io.gmss.fiscad.paylaods.ApiResponse; import io.gmss.fiscad.paylaods.ApiResponse;
import io.gmss.fiscad.paylaods.Login; import io.gmss.fiscad.paylaods.Login;
@@ -11,12 +12,14 @@ import io.gmss.fiscad.security.UserPrincipal;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
@@ -27,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
public class UserController { public class UserController {
private final UserService userService; private final UserService userService;
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
public UserController(UserService userService) { public UserController(UserService userService) {
@@ -35,155 +39,241 @@ public class UserController {
@PostMapping("/create") @PostMapping("/create")
public ResponseEntity<?> createUser(@RequestBody @Valid @Validated User user) { public ResponseEntity<?> createUser(@RequestBody @Valid @Validated User user) {
try{ try {
user.setUsername(user.getEmail()); user.setUsername(user.getEmail());
user = userService.createUser(user, true); user = userService.createUser(user, true);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, user, "Utilisateur créé avec succès"), new ApiResponse<>(true, user, "Utilisateur créé avec succès"),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PostMapping("/change-password") @PostMapping("/change-password")
public ResponseEntity<?> changeUserPassword(@RequestBody @Valid @Validated Login login) { public ResponseEntity<?> changeUserPassword(@RequestBody @Valid @Validated Login login) {
try{ try {
userService.updatePassword(login.getUsername(), login.getPassword()); userService.updatePassword(login.getUsername(), login.getPassword());
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, "Votre mot de passe à été modifiée avec succès."), new ApiResponse<>(true, "Votre mot de passe à été modifiée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PostMapping("/reset-password") @PostMapping("/reset-password")
public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) { public ResponseEntity<?> resetUserPassword(@RequestBody @Valid @Validated Login login) {
try{ try {
User user = userService.resetPassword(login.getUsername(), login.getPassword()); User user = userService.resetPassword(login.getUsername(), login.getPassword());
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, user, "Votre mot de passe à été réinitialisée avec succès."), new ApiResponse<>(true, user, "Votre mot de passe à été réinitialisée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PostMapping("/validate-user-account") @PostMapping("/validate-user-account")
public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) { public ResponseEntity<?> validateUserAccount(@RequestBody @Valid @Validated Login login) {
try{ try {
User user = userService.validateUserAccount(login.getUsername(), login.getUserRole()); User user = userService.validateUserAccount(login.getUsername(), login.getUserRole());
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, user, "Cet utilisateur à été activé avec succès."), new ApiResponse<>(true, user, "Cet utilisateur à été activé avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody User user) { public ResponseEntity<?> updateUser(@PathVariable Long id, @RequestBody User user) {
try{ try {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, userService.updateUser(id, user), "User updated successully."), new ApiResponse<>(true, userService.updateUser(id, user), "User updated successully."),
HttpStatus.OK HttpStatus.OK
); );
}catch (Exception e){ } catch (HttpClientErrorException.MethodNotAllowed e) {
return new ResponseEntity<>( logger.error(e.getLocalizedMessage());
new ApiResponse<>(false, e.getMessage()), return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
HttpStatus.OK } catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
); FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping ("/activate-or-not") @GetMapping("/activate-or-not")
public ResponseEntity<?> acitvateOrNotUser(@RequestParam Long id) { public ResponseEntity<?> acitvateOrNotUser(@RequestParam Long id) {
try{ try {
User user = userService.activateOrNotUser(id); User user = userService.activateOrNotUser(id);
String message = "Utilisateur activé avec succès"; String message = "Utilisateur activé avec succès";
if(!user.isActive()) { if (!user.isActive()) {
message = "Utilisateur désactivé avec succès"; message = "Utilisateur désactivé avec succès";
} }
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, user , message), new ApiResponse<>(true, user, message),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public ResponseEntity<?> deleteUser(@PathVariable Long id) { public ResponseEntity<?> deleteUser(@PathVariable Long id) {
try{ try {
userService.deleteUser(id); userService.deleteUser(id);
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true,"User deleted successully"), new ApiResponse<>(true, "User deleted successully"),
HttpStatus.OK
);
}catch (Exception e){
return new ResponseEntity<>(
new ApiResponse<>(false, e.getMessage()),
HttpStatus.OK HttpStatus.OK
); );
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) { public ResponseEntity<?> getAll(@CurrentUser UserPrincipal userPrincipal) {
try {
User user = userPrincipal.getUser(); User user = userPrincipal.getUser();
if(user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))){ if (user.getRoles().stream().anyMatch(r -> r.getNom().equals(UserRole.ROLE_ADMIN))) {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, userService.getAllUserListResponse(), "Liste des utilisateurs chargée avec succès."), new ApiResponse<>(true, userService.getAllUserListResponse(), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}else{ } else {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."), new ApiResponse<>(true, userService.getListUserResponseByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
@GetMapping("/all-by-structure") @GetMapping("/all-by-structure")
public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) { public ResponseEntity<?> getAllByStructure(@CurrentUser UserPrincipal userPrincipal) {
try {
if(userPrincipal.getUser().getStructure() != null) { if (userPrincipal.getUser().getStructure() != null) {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."), new ApiResponse<>(true, userService.getListUserByStructure(userPrincipal.getUser().getStructure().getId()), "Liste des utilisateurs chargée avec succès."),
HttpStatus.OK HttpStatus.OK
); );
}else{ } else {
return new ResponseEntity<>( return new ResponseEntity<>(
new ApiResponse<>(false, "Impossible de trouver la structure indiquée."), new ApiResponse<>(false, "Impossible de trouver la structure indiquée."),
HttpStatus.OK HttpStatus.OK
); );
}
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
} }
} }
// @GetMapping("/all-paged") // @GetMapping("/all-paged")
@@ -197,26 +287,71 @@ public class UserController {
@GetMapping("/id/{id}") @GetMapping("/id/{id}")
public ResponseEntity<?> getUserById(@PathVariable Long id) { public ResponseEntity<?> getUserById(@PathVariable Long id) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, userService.getUserById(id), "User found."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, userService.getUserById(id), "User found."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/username/{username}") @GetMapping("/username/{username}")
public ResponseEntity<?> getUserByUsername(@PathVariable String username) { public ResponseEntity<?> getUserByUsername(@PathVariable String username) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, userService.getUserByUsername(username), "User found."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, userService.getUserByUsername(username), "User found."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }
@GetMapping("/all-by-role/{userrole}") @GetMapping("/all-by-role/{userrole}")
public ResponseEntity<?> getUserByUserRole(@PathVariable UserRole userrole) { public ResponseEntity<?> getUserByUserRole(@PathVariable UserRole userrole) {
return new ResponseEntity<>( try {
new ApiResponse<>(true, userService.getUserByProfil(userrole), "Users found."), return new ResponseEntity<>(
HttpStatus.OK new ApiResponse<>(true, userService.getUserByProfil(userrole), "Users found."),
); HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
} }

View File

@@ -32,7 +32,7 @@ public class Secteur extends BaseEntity implements Serializable {
private Structure structure; private Structure structure;
//@JsonIgnore //@JsonIgnore
//@OneToMany(mappedBy = "secteur") //@OneToMany(mappedBy = "secteur")
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "secteur_id") @JoinColumn(name = "secteur_id")
private List<SecteurDecoupage> secteurDecoupages; private List<SecteurDecoupage> secteurDecoupages;
} }

View File

@@ -62,7 +62,7 @@ public class ActeurConcerne extends BaseEntity implements Serializable {
////////////////////////////// //////////////////////////////
private Long blocId; private Long blocId;
@ColumnDefault("0") @ColumnDefault("0")
private int haveDeclarant ; private int haveDeclarant;
private Long max_numero_acteur_concerne_id; private Long max_numero_acteur_concerne_id;

View File

@@ -156,74 +156,77 @@ public class Enquete extends BaseEntity implements Serializable {
private StatutEnregistrement statutEnregistrement; private StatutEnregistrement statutEnregistrement;
public Long getTerminalId(){ public Long getTerminalId() {
if(this.terminal!=null){ if (this.terminal != null) {
return this.terminal.getId(); return this.terminal.getId();
}else return null; } else return null;
} }
public String getNomPrenomEnqueteur() {
public String getNomPrenomEnqueteur(){ if (this.user != null) {
if(this.user!=null){ return this.user.getNom() + " " + this.user.getPrenom();
return this.user.getNom()+" "+this.user.getPrenom(); } else return "";
}else return "";
} }
public String getNomBloc(){
if(this.bloc!=null){ public String getNomBloc() {
if (this.bloc != null) {
return this.bloc.getNom(); return this.bloc.getNom();
}else return ""; } else return "";
} }
public String getCodeBloc(){ public String getCodeBloc() {
if(this.bloc!=null){ if (this.bloc != null) {
return this.bloc.getCote(); return this.bloc.getCote();
}else return ""; } else return "";
} }
public String getDepartement(){
if(this.bloc!=null){ public String getDepartement() {
Arrondissement arrondissement= this.bloc.getArrondissement(); if (this.bloc != null) {
if(arrondissement!=null){ Arrondissement arrondissement = this.bloc.getArrondissement();
if (arrondissement != null) {
return arrondissement.getCommune().getDepartement().getNom(); return arrondissement.getCommune().getDepartement().getNom();
}else return ""; } else return "";
}else return ""; } else return "";
} }
public String getCommune(){
if(this.bloc!=null){ public String getCommune() {
Arrondissement arrondissement= this.bloc.getArrondissement(); if (this.bloc != null) {
if(arrondissement!=null){ Arrondissement arrondissement = this.bloc.getArrondissement();
if (arrondissement != null) {
return arrondissement.getCommune().getNom(); return arrondissement.getCommune().getNom();
}else return ""; } else return "";
}else return ""; } else return "";
} }
public String getArrondissement(){ public String getArrondissement() {
if(this.bloc!=null) { if (this.bloc != null) {
Arrondissement arrondissement= this.bloc.getArrondissement(); Arrondissement arrondissement = this.bloc.getArrondissement();
if(arrondissement!=null){ if (arrondissement != null) {
return arrondissement.getNom(); return arrondissement.getNom();
}else return ""; } else return "";
}else return ""; } else return "";
} }
public String getTypeDomaine(){
if(this.parcelle!=null){ public String getTypeDomaine() {
NatureDomaine natureDomaine= this.parcelle.getNatureDomaine(); if (this.parcelle != null) {
if(natureDomaine!=null){ NatureDomaine natureDomaine = this.parcelle.getNatureDomaine();
if (natureDomaine != null) {
return natureDomaine.getTypeDomaine().getLibelle(); return natureDomaine.getTypeDomaine().getLibelle();
}else return ""; } else return "";
}else return ""; } else return "";
} }
public String getTelEnqueteur(){ public String getTelEnqueteur() {
if(this.user !=null){ if (this.user != null) {
return this.user.getTel(); return this.user.getTel();
}else return ""; } else return "";
} }
public String getStructureEnqueteur(){ public String getStructureEnqueteur() {
if(this.user !=null){ if (this.user != null) {
return this.user.getStructure().getNom(); return this.user.getStructure().getNom();
}else return ""; } else return "";
} }

View File

@@ -5,9 +5,10 @@ import jakarta.persistence.Id;
import lombok.Data; import lombok.Data;
import java.time.LocalDate; import java.time.LocalDate;
@Entity @Entity
@Data @Data
public class EnqueteFiltreResponse{ public class EnqueteFiltreResponse {
@Id @Id
private Long id; private Long id;
private String parcelleid; private String parcelleid;

View File

@@ -45,7 +45,7 @@ public class Parcelle extends BaseEntity implements Serializable {
@JsonIgnore @JsonIgnore
@OneToMany(mappedBy = "parcelle") @OneToMany(mappedBy = "parcelle")
private List<Enquete> enquetes; private List<Enquete> enquetes;
// @ManyToOne // @ManyToOne
// private SituationGeographique situationGeographique; // private SituationGeographique situationGeographique;
@ManyToOne @ManyToOne
//private TypeDomaine typeDomaine; //private TypeDomaine typeDomaine;
@@ -87,6 +87,4 @@ public class Parcelle extends BaseEntity implements Serializable {
// private Point geometry32631; // private Point geometry32631;
} }

View File

@@ -1,12 +1,8 @@
package io.gmss.fiscad.entities.infocad.metier; package io.gmss.fiscad.entities.infocad.metier;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.gmss.fiscad.entities.BaseEntity; import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.decoupage.Quartier;
import io.gmss.fiscad.entities.infocad.parametre.NatureDomaine;
import io.gmss.fiscad.entities.rfu.metier.Batiment;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -16,12 +12,10 @@ import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import org.locationtech.jts.geom.MultiPolygon; import org.locationtech.jts.geom.MultiPolygon;
import org.locationtech.jts.geom.Point;
import org.n52.jackson.datatype.jts.GeometryDeserializer; import org.n52.jackson.datatype.jts.GeometryDeserializer;
import org.n52.jackson.datatype.jts.GeometrySerializer; import org.n52.jackson.datatype.jts.GeometrySerializer;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Entity @Entity
@@ -42,24 +36,24 @@ public class ParcelleGeom extends BaseEntity implements Serializable {
private String ilot; private String ilot;
private String zone; private String zone;
private String p; private String p;
@Column(unique = true,nullable = true) @Column(unique = true, nullable = true)
private String nup; private String nup;
@Column(unique = true,nullable = true) @Column(unique = true, nullable = true)
private String nupProvisoire; private String nupProvisoire;
private String longitude; private String longitude;
private String latitude; private String latitude;
private String pointsPolygone; private String pointsPolygone;
@ColumnDefault("0") @ColumnDefault("0")
private int geomSrid; private int geomSrid;
@JsonSerialize(using = GeometrySerializer.class) @JsonSerialize(using = GeometrySerializer.class)
@JsonDeserialize(contentUsing = GeometryDeserializer.class) @JsonDeserialize(contentUsing = GeometryDeserializer.class)
@Column(name = "geom",columnDefinition = "geometry(MultiPolygon,4326)") @Column(name = "geom", columnDefinition = "geometry(MultiPolygon,4326)")
private MultiPolygon geometry ; private MultiPolygon geometry;
@JsonSerialize(using = GeometrySerializer.class) @JsonSerialize(using = GeometrySerializer.class)
@JsonDeserialize(contentUsing = GeometryDeserializer.class) @JsonDeserialize(contentUsing = GeometryDeserializer.class)
@Column(name = "geom_32631",columnDefinition = "geometry(MultiPolygon,32631)") @Column(name = "geom_32631", columnDefinition = "geometry(MultiPolygon,32631)")
private MultiPolygon geometry32631 ; private MultiPolygon geometry32631;
} }

View File

@@ -49,13 +49,13 @@ public class Piece extends BaseEntity implements Serializable {
private Personne personne; private Personne personne;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne
private ActeurConcerne acteurConcerne ; private ActeurConcerne acteurConcerne;
@ManyToOne @ManyToOne
private SourceDroit sourceDroit ; private SourceDroit sourceDroit;
@ManyToOne @ManyToOne
private ModeAcquisition modeAcquisition ; private ModeAcquisition modeAcquisition;
@OneToMany(mappedBy = "piece") @OneToMany(mappedBy = "piece")
private List<Upload> uploads ; private List<Upload> uploads;
@JsonIgnore @JsonIgnore
@ManyToOne @ManyToOne

View File

@@ -61,7 +61,7 @@ public class Upload extends BaseEntity implements Serializable {
return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null; return url != null ? url.toLowerCase().startsWith("https") ? url : url.toLowerCase().replaceFirst("http", "https") : null;
} }
private String serverContext(){ private String serverContext() {
return ServletUriComponentsBuilder.fromCurrentContextPath() return ServletUriComponentsBuilder.fromCurrentContextPath()
.path("/api/upload/downloadFile/") .path("/api/upload/downloadFile/")
.toUriString(); .toUriString();

View File

@@ -34,7 +34,7 @@ public class ModeAcquisition extends BaseEntity implements Serializable {
@JsonIgnore @JsonIgnore
@OneToMany(mappedBy = "modeAcquisition") @OneToMany(mappedBy = "modeAcquisition")
//private List<SourceDroitExerce> sourceDroitExerces; //private List<SourceDroitExerce> sourceDroitExerces;
private List<Piece> pieces ; private List<Piece> pieces;
@ManyToMany @ManyToMany
@JoinTable(name = "modeAcquisition_typePersonne", @JoinTable(name = "modeAcquisition_typePersonne",
joinColumns = @JoinColumn(name = "mode_acquisition_id"), joinColumns = @JoinColumn(name = "mode_acquisition_id"),

View File

@@ -84,6 +84,4 @@ public class Personne extends BaseEntity implements Serializable {
private boolean synchronise; private boolean synchronise;
} }

View File

@@ -48,7 +48,7 @@ public class SourceDroit extends BaseEntity implements Serializable {
@JsonIgnore @JsonIgnore
@OneToMany(mappedBy = "sourceDroit") @OneToMany(mappedBy = "sourceDroit")
//private List<SourceDroitExerce> sourceDroitExerces; //private List<SourceDroitExerce> sourceDroitExerces;
private List<Piece> pieces ; private List<Piece> pieces;
@Column(columnDefinition = "boolean default false") @Column(columnDefinition = "boolean default false")
private boolean titreFoncier; private boolean titreFoncier;

View File

@@ -29,7 +29,7 @@ public class TypeDomaine extends BaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
private String libelle; private String libelle;
// @JsonIgnore // @JsonIgnore
// @OneToMany(mappedBy = "typeDomaine") // @OneToMany(mappedBy = "typeDomaine")
// private List<Parcelle> parcelles; // private List<Parcelle> parcelles;
@JsonIgnore @JsonIgnore

View File

@@ -31,10 +31,10 @@ public class Equipe extends BaseEntity implements Serializable {
@ManyToOne @ManyToOne
private Bloc bloc; private Bloc bloc;
@ManyToOne @ManyToOne
private Secteur secteur ; private Secteur secteur;
@ManyToOne @ManyToOne
private Campagne campagne; private Campagne campagne;
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "equipe_id") @JoinColumn(name = "equipe_id")
private List<Participer> participers; private List<Participer> participers;

View File

@@ -62,7 +62,7 @@ public class User extends BaseEntity implements Serializable {
private List<Participer> participers; private List<Participer> participers;
@JsonIgnore @JsonIgnore
@OneToMany(mappedBy = "chefSecteur") @OneToMany(mappedBy = "chefSecteur")
private List<Secteur> secteurs ; private List<Secteur> secteurs;
@Transient @Transient
private Long idCampagneCourant; private Long idCampagneCourant;
@@ -73,9 +73,9 @@ public class User extends BaseEntity implements Serializable {
this.username = this.email; this.username = this.email;
} }
public boolean isAdmin(){ public boolean isAdmin() {
for(Role r:this.roles ){ for (Role r : this.roles) {
if(r.getNom().equals(UserRole.ROLE_ADMIN)){ if (r.getNom().equals(UserRole.ROLE_ADMIN)) {
return true; return true;
} }
} }
@@ -83,18 +83,18 @@ public class User extends BaseEntity implements Serializable {
} }
public Long getIdCampagneCourant(){ public Long getIdCampagneCourant() {
for (Participer p:participers){ for (Participer p : participers) {
if(p.getDateFin()==null){ if (p.getDateFin() == null) {
return p.getEquipe().getCampagne().getId(); return p.getEquipe().getCampagne().getId();
} }
} }
return null; return null;
} }
public Long getIdSecteurCourant(){ public Long getIdSecteurCourant() {
for (Participer p:participers){ for (Participer p : participers) {
if(p.getDateFin()==null){ if (p.getDateFin() == null) {
return p.getEquipe().getSecteur().getId(); return p.getEquipe().getSecteur().getId();
} }
} }

View File

@@ -4,8 +4,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
public class BadRequestException extends RuntimeException{ public class BadRequestException extends RuntimeException {
public BadRequestException(String message){ public BadRequestException(String message) {
super(message); super(message);
} }
} }

View File

@@ -1,4 +1,5 @@
package io.gmss.fiscad.exceptions; package io.gmss.fiscad.exceptions;
public class FileStorageException extends RuntimeException { public class FileStorageException extends RuntimeException {
public FileStorageException(String message) { public FileStorageException(String message) {
super(message); super(message);

View File

@@ -4,8 +4,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND) @ResponseStatus(HttpStatus.NOT_FOUND)
public class NotFoundException extends RuntimeException{ public class NotFoundException extends RuntimeException {
public NotFoundException(String message){ public NotFoundException(String message) {
super(message); super(message);
} }
} }

View File

@@ -27,29 +27,29 @@ public class ArrondissementServiceImpl implements ArrondissementService {
@Override @Override
public Arrondissement createArrondissement(Arrondissement arrondissement) throws BadRequestException { public Arrondissement createArrondissement(Arrondissement arrondissement) throws BadRequestException {
if(arrondissement.getId() != null ){ if (arrondissement.getId() != null) {
throw new BadRequestException("Impossible de créer un nouvel arrondissement ayant un id non null."); throw new BadRequestException("Impossible de créer un nouvel arrondissement ayant un id non null.");
} }
return arrondissementRepository.save(arrondissement); return arrondissementRepository.save(arrondissement);
} }
@Override @Override
public Arrondissement updateArrondissement(Long id, Arrondissement arrondissement) throws NotFoundException { public Arrondissement updateArrondissement(Long id, Arrondissement arrondissement) throws NotFoundException {
if(arrondissement.getId() == null ){ if (arrondissement.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouvel arrondissement ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouvel arrondissement ayant un id null.");
} }
if(!arrondissementRepository.existsById(arrondissement.getId())){ if (!arrondissementRepository.existsById(arrondissement.getId())) {
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver l'arrondissement spécifié dans notre base de données.");
} }
return arrondissementRepository.save(arrondissement); return arrondissementRepository.save(arrondissement);
} }
@Override @Override
public void deleteArrondissement(Long id) throws NotFoundException { public void deleteArrondissement(Long id) throws NotFoundException {
Optional<Arrondissement> arrondissementOptional = arrondissementRepository.findById(id); Optional<Arrondissement> arrondissementOptional = arrondissementRepository.findById(id);
if(arrondissementOptional.isPresent()){ if (arrondissementOptional.isPresent()) {
arrondissementRepository.deleteById(arrondissementOptional.get().getId()); arrondissementRepository.deleteById(arrondissementOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver l'arrondissement spécifié dans notre base de données.");
} }
} }
@@ -72,7 +72,7 @@ public class ArrondissementServiceImpl implements ArrondissementService {
@Override @Override
public List<Arrondissement> getArrondissementByComune(Long communeId) { public List<Arrondissement> getArrondissementByComune(Long communeId) {
Optional<Commune> communeOptional = communeService.getCommuneById(communeId); Optional<Commune> communeOptional = communeService.getCommuneById(communeId);
if(communeOptional.isEmpty()){ if (communeOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver la commune spécifiée."); throw new NotFoundException("Impossible de trouver la commune spécifiée.");
} }
return arrondissementRepository.findAllByCommune(communeOptional.get()); return arrondissementRepository.findAllByCommune(communeOptional.get());

View File

@@ -27,29 +27,29 @@ public class CommuneServiceImpl implements CommuneService {
@Override @Override
public Commune createCommune(Commune commune) throws BadRequestException { public Commune createCommune(Commune commune) throws BadRequestException {
if(commune.getId() != null ){ if (commune.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle commune ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle commune ayant un id non null.");
} }
return communeRepository.save(commune); return communeRepository.save(commune);
} }
@Override @Override
public Commune updateCommune(Long id, Commune commune) throws NotFoundException { public Commune updateCommune(Long id, Commune commune) throws NotFoundException {
if(commune.getId() == null ){ if (commune.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle commune ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle commune ayant un id null.");
} }
if(!communeRepository.existsById(commune.getId())){ if (!communeRepository.existsById(commune.getId())) {
throw new NotFoundException("Impossible de trouver la commune spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la commune spécifiée dans notre base de données.");
} }
return communeRepository.save(commune); return communeRepository.save(commune);
} }
@Override @Override
public void deleteCommune(Long id) throws NotFoundException { public void deleteCommune(Long id) throws NotFoundException {
Optional<Commune> communeOptional = communeRepository.findById(id); Optional<Commune> communeOptional = communeRepository.findById(id);
if(communeOptional.isPresent()){ if (communeOptional.isPresent()) {
communeRepository.deleteById(communeOptional.get().getId()); communeRepository.deleteById(communeOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la commune spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la commune spécifiée dans notre base de données.");
} }
} }
@@ -68,7 +68,7 @@ public class CommuneServiceImpl implements CommuneService {
@Override @Override
public List<Commune> getCommunesByDepartement(Long departementId) { public List<Commune> getCommunesByDepartement(Long departementId) {
Optional<Departement> departementOptional = departementService.getDepartementById(departementId); Optional<Departement> departementOptional = departementService.getDepartementById(departementId);
if(departementOptional.isEmpty()){ if (departementOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver le département spécifié."); throw new NotFoundException("Impossible de trouver le département spécifié.");
} }
return communeRepository.findAllByDepartement(departementOptional.get()); return communeRepository.findAllByDepartement(departementOptional.get());

View File

@@ -23,29 +23,29 @@ public class DepartementServiceImpl implements DepartementService {
@Override @Override
public Departement createDepartement(Departement departement) throws BadRequestException { public Departement createDepartement(Departement departement) throws BadRequestException {
if(departement.getId() != null ){ if (departement.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau département ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau département ayant un id non null.");
} }
return departementRepository.save(departement); return departementRepository.save(departement);
} }
@Override @Override
public Departement updateDepartement(Long id, Departement departement) throws NotFoundException { public Departement updateDepartement(Long id, Departement departement) throws NotFoundException {
if(departement.getId() == null ){ if (departement.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau département ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau département ayant un id null.");
} }
if(!departementRepository.existsById(departement.getId())){ if (!departementRepository.existsById(departement.getId())) {
throw new NotFoundException("Impossible de trouver le département spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le département spécifié dans notre base de données.");
} }
return departementRepository.save(departement); return departementRepository.save(departement);
} }
@Override @Override
public void deleteDepartement(Long id) throws NotFoundException { public void deleteDepartement(Long id) throws NotFoundException {
Optional<Departement> departementOptional = departementRepository.findById(id); Optional<Departement> departementOptional = departementRepository.findById(id);
if(departementOptional.isPresent()){ if (departementOptional.isPresent()) {
departementRepository.deleteById(departementOptional.get().getId()); departementRepository.deleteById(departementOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le département spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le département spécifié dans notre base de données.");
} }
} }
@@ -63,9 +63,9 @@ public class DepartementServiceImpl implements DepartementService {
@Override @Override
public Optional<Departement> getDepartementById(Long id) { public Optional<Departement> getDepartementById(Long id) {
if(departementRepository.existsById(id)){ if (departementRepository.existsById(id)) {
return departementRepository.findById(id); return departementRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données."); throw new NotFoundException("Impossible de trouver le département spécifié dans la base de données.");
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class NationaliteServiceImpl implements NationaliteService { public class NationaliteServiceImpl implements NationaliteService {
@@ -22,29 +23,29 @@ public class NationaliteServiceImpl implements NationaliteService {
@Override @Override
public Nationalite createNationalite(Nationalite nationalite) throws BadRequestException { public Nationalite createNationalite(Nationalite nationalite) throws BadRequestException {
if(nationalite.getId() != null ){ if (nationalite.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle nationalité ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle nationalité ayant un id non null.");
} }
return nationaliteRepository.save(nationalite); return nationaliteRepository.save(nationalite);
} }
@Override @Override
public Nationalite updateNationalite(Long id, Nationalite nationalite) throws NotFoundException { public Nationalite updateNationalite(Long id, Nationalite nationalite) throws NotFoundException {
if(nationalite.getId() == null ){ if (nationalite.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle nationalité ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle nationalité ayant un id null.");
} }
if(!nationaliteRepository.existsById(nationalite.getId())){ if (!nationaliteRepository.existsById(nationalite.getId())) {
throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans notre base de données.");
} }
return nationaliteRepository.save(nationalite); return nationaliteRepository.save(nationalite);
} }
@Override @Override
public void deleteNationalite(Long id) throws NotFoundException { public void deleteNationalite(Long id) throws NotFoundException {
Optional<Nationalite> nationaliteOptional = nationaliteRepository.findById(id); Optional<Nationalite> nationaliteOptional = nationaliteRepository.findById(id);
if(nationaliteOptional.isPresent()){ if (nationaliteOptional.isPresent()) {
nationaliteRepository.deleteById(nationaliteOptional.get().getId()); nationaliteRepository.deleteById(nationaliteOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans notre base de données.");
} }
} }
@@ -62,9 +63,9 @@ public class NationaliteServiceImpl implements NationaliteService {
@Override @Override
public Optional<Nationalite> getNationaliteById(Long id) { public Optional<Nationalite> getNationaliteById(Long id) {
if(nationaliteRepository.existsById(id)){ if (nationaliteRepository.existsById(id)) {
return nationaliteRepository.findById(id); return nationaliteRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la nationalité spécifiée dans la base de données.");
} }

View File

@@ -27,29 +27,29 @@ public class QuartierServiceImpl implements QuartierService {
@Override @Override
public Quartier createQuartier(Quartier quartier) throws BadRequestException { public Quartier createQuartier(Quartier quartier) throws BadRequestException {
if(quartier.getId() != null ){ if (quartier.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau quartier ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau quartier ayant un id non null.");
} }
return quartierRepository.save(quartier); return quartierRepository.save(quartier);
} }
@Override @Override
public Quartier updateQuartier(Long id, Quartier quartier) throws NotFoundException { public Quartier updateQuartier(Long id, Quartier quartier) throws NotFoundException {
if(quartier.getId() == null ){ if (quartier.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau quartier ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau quartier ayant un id null.");
} }
if(!quartierRepository.existsById(quartier.getId())){ if (!quartierRepository.existsById(quartier.getId())) {
throw new NotFoundException("Impossible de trouver le quartier spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le quartier spécifié dans notre base de données.");
} }
return quartierRepository.save(quartier); return quartierRepository.save(quartier);
} }
@Override @Override
public void deleteQuartier(Long id) throws NotFoundException { public void deleteQuartier(Long id) throws NotFoundException {
Optional<Quartier> quartierOptional = quartierRepository.findById(id); Optional<Quartier> quartierOptional = quartierRepository.findById(id);
if(quartierOptional.isPresent()){ if (quartierOptional.isPresent()) {
quartierRepository.deleteById(quartierOptional.get().getId()); quartierRepository.deleteById(quartierOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le quartier spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le quartier spécifié dans notre base de données.");
} }
} }
@@ -66,9 +66,9 @@ public class QuartierServiceImpl implements QuartierService {
@Override @Override
public Optional<Quartier> getQuartierById(Long id) { public Optional<Quartier> getQuartierById(Long id) {
if(quartierRepository.existsById(id)){ if (quartierRepository.existsById(id)) {
return quartierRepository.findById(id); return quartierRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver le quartier spécifié dans la base de données."); throw new NotFoundException("Impossible de trouver le quartier spécifié dans la base de données.");
} }
@@ -77,7 +77,7 @@ public class QuartierServiceImpl implements QuartierService {
@Override @Override
public List<Quartier> getQuartierByArrondissement(Long arrondissementId) { public List<Quartier> getQuartierByArrondissement(Long arrondissementId) {
Optional<Arrondissement> arrondissementOptional = arrondissementService.getArrondissementById(arrondissementId); Optional<Arrondissement> arrondissementOptional = arrondissementService.getArrondissementById(arrondissementId);
if(arrondissementOptional.isEmpty()){ if (arrondissementOptional.isEmpty()) {
throw new NotFoundException("Impossible de trouver l'arrondissement spécifié."); throw new NotFoundException("Impossible de trouver l'arrondissement spécifié.");
} }
return quartierRepository.getAllByArrondissement(arrondissementOptional.get()); return quartierRepository.getAllByArrondissement(arrondissementOptional.get());

View File

@@ -22,29 +22,29 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
@Override @Override
public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException { public SecteurDecoupage createSecteurDecoupage(SecteurDecoupage secteurDecoupage) throws BadRequestException {
if(secteurDecoupage.getId() != null ){ if (secteurDecoupage.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau secteur découpage ayant un id non null.");
} }
return secteurDecoupageRepository.save(secteurDecoupage); return secteurDecoupageRepository.save(secteurDecoupage);
} }
@Override @Override
public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException { public SecteurDecoupage updateSecteurDecoupage(Long id, SecteurDecoupage secteurDecoupage) throws NotFoundException {
if(secteurDecoupage.getId() == null ){ if (secteurDecoupage.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau secteur découpage ayant un id null.");
} }
if(!secteurDecoupageRepository.existsById(secteurDecoupage.getId())){ if (!secteurDecoupageRepository.existsById(secteurDecoupage.getId())) {
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié."); throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
} }
return secteurDecoupageRepository.save(secteurDecoupage); return secteurDecoupageRepository.save(secteurDecoupage);
} }
@Override @Override
public void deleteSecteurDecoupage(Long id) throws NotFoundException { public void deleteSecteurDecoupage(Long id) throws NotFoundException {
Optional<SecteurDecoupage> secteurDecoupageOptional = secteurDecoupageRepository.findById(id); Optional<SecteurDecoupage> secteurDecoupageOptional = secteurDecoupageRepository.findById(id);
if(secteurDecoupageOptional.isPresent()){ if (secteurDecoupageOptional.isPresent()) {
secteurDecoupageRepository.deleteById(secteurDecoupageOptional.get().getId()); secteurDecoupageRepository.deleteById(secteurDecoupageOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le secteur découpage spécifié."); throw new NotFoundException("Impossible de trouver le secteur découpage spécifié.");
} }
} }
@@ -60,7 +60,6 @@ public class SecteurDecoupageServiceImpl implements SecteurDecoupageService {
} }
@Override @Override
public Optional<SecteurDecoupage> getSecteurDecoupageById(Long id) { public Optional<SecteurDecoupage> getSecteurDecoupageById(Long id) {
return secteurDecoupageRepository.findById(id); return secteurDecoupageRepository.findById(id);

View File

@@ -41,37 +41,37 @@ public class SecteurServiceImpl implements SecteurService {
@Override @Override
public Secteur createSecteur(SecteurPayload secteurPayload) throws BadRequestException { public Secteur createSecteur(SecteurPayload secteurPayload) throws BadRequestException {
if(secteurPayload.getId() != null ){ if (secteurPayload.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau secteur ayant un id non null.");
} }
if(secteurPayload.getChefSecteurId()!=null && userRepository.existsById(secteurPayload.getChefSecteurId()) ) { if (secteurPayload.getChefSecteurId() != null && userRepository.existsById(secteurPayload.getChefSecteurId())) {
Secteur secteur = getSecteurFromPayload(secteurPayload); Secteur secteur = getSecteurFromPayload(secteurPayload);
return secteurRepository.save(secteur); return secteurRepository.save(secteur);
}else{ } else {
throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur."); throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur.");
} }
} }
private Secteur getSecteurFromPayload(SecteurPayload secteurPayload) { private Secteur getSecteurFromPayload(SecteurPayload secteurPayload) {
Secteur secteur=new Secteur(); Secteur secteur = new Secteur();
Optional<User> optionalUser=userRepository.findById(secteurPayload.getChefSecteurId()); Optional<User> optionalUser = userRepository.findById(secteurPayload.getChefSecteurId());
secteur.setChefSecteur(optionalUser.orElse(null)); secteur.setChefSecteur(optionalUser.orElse(null));
Optional<Structure> optionalStructure=structureRepository.findById(secteurPayload.getStructureId()); Optional<Structure> optionalStructure = structureRepository.findById(secteurPayload.getStructureId());
secteur.setStructure(optionalStructure.orElse(null)); secteur.setStructure(optionalStructure.orElse(null));
List<SecteurDecoupage> secteurDecoupageList=new ArrayList<>(); List<SecteurDecoupage> secteurDecoupageList = new ArrayList<>();
for (SecteurDecoupagePayload sdp: secteurPayload.getSecteurDecoupages()){ for (SecteurDecoupagePayload sdp : secteurPayload.getSecteurDecoupages()) {
SecteurDecoupage sd=new SecteurDecoupage(); SecteurDecoupage sd = new SecteurDecoupage();
if(sdp.getSecteurId()!=null && secteurRepository.existsById(sdp.getSecteurId()) ){ if (sdp.getSecteurId() != null && secteurRepository.existsById(sdp.getSecteurId())) {
sd.setSecteur(secteurRepository.findById(sdp.getSecteurId()).orElse(null)); sd.setSecteur(secteurRepository.findById(sdp.getSecteurId()).orElse(null));
} }
if(sdp.getArrondissementId()!=null && arrondissementRepository.existsById(sdp.getArrondissementId()) ){ if (sdp.getArrondissementId() != null && arrondissementRepository.existsById(sdp.getArrondissementId())) {
sd.setArrondissement(arrondissementRepository.findById(sdp.getArrondissementId()).orElse(null)); sd.setArrondissement(arrondissementRepository.findById(sdp.getArrondissementId()).orElse(null));
} }
if(sdp.getQuartierId()!=null && quartierRepository.existsById(sdp.getQuartierId()) ){ if (sdp.getQuartierId() != null && quartierRepository.existsById(sdp.getQuartierId())) {
sd.setQuartier(quartierRepository.findById(sdp.getQuartierId()).orElse(null)); sd.setQuartier(quartierRepository.findById(sdp.getQuartierId()).orElse(null));
} }
sd.setDateDebut(sdp.getDateDebut()); sd.setDateDebut(sdp.getDateDebut());
@@ -88,17 +88,17 @@ public class SecteurServiceImpl implements SecteurService {
@Override @Override
public Secteur updateSecteur(Long id, SecteurPayload secteurPayload) throws NotFoundException { public Secteur updateSecteur(Long id, SecteurPayload secteurPayload) throws NotFoundException {
if(secteurPayload.getId() == null ){ if (secteurPayload.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau secteur ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau secteur ayant un id null.");
} }
if(!secteurRepository.existsById(secteurPayload.getId())){ if (!secteurRepository.existsById(secteurPayload.getId())) {
throw new NotFoundException("Impossible de trouver le secteur spécifié."); throw new NotFoundException("Impossible de trouver le secteur spécifié.");
} }
if(secteurPayload.getChefSecteurId()!=null && userRepository.existsById(secteurPayload.getChefSecteurId()) ) { if (secteurPayload.getChefSecteurId() != null && userRepository.existsById(secteurPayload.getChefSecteurId())) {
Secteur secteur = getSecteurFromPayload(secteurPayload); Secteur secteur = getSecteurFromPayload(secteurPayload);
return secteurRepository.save(secteur); return secteurRepository.save(secteur);
}else{ } else {
throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur."); throw new BadRequestException("Impossible de créer un nouveau secteur sans le chef le Chef Secteur.");
} }
} }
@@ -106,9 +106,9 @@ public class SecteurServiceImpl implements SecteurService {
@Override @Override
public void deleteSecteur(Long id) throws NotFoundException { public void deleteSecteur(Long id) throws NotFoundException {
Optional<Secteur> secteurOptional = secteurRepository.findById(id); Optional<Secteur> secteurOptional = secteurRepository.findById(id);
if(secteurOptional.isPresent()){ if (secteurOptional.isPresent()) {
secteurRepository.deleteById(secteurOptional.get().getId()); secteurRepository.deleteById(secteurOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le secteur spécifié."); throw new NotFoundException("Impossible de trouver le secteur spécifié.");
} }
} }

View File

@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class ActeurConcerneServiceImpl implements ActeurConcerneService { public class ActeurConcerneServiceImpl implements ActeurConcerneService {

View File

@@ -25,35 +25,35 @@ public class CommentaireServiceImpl implements CommentaireService {
@Override @Override
public Commentaire createCommentaire(Commentaire commentaire) throws BadRequestException { public Commentaire createCommentaire(Commentaire commentaire) throws BadRequestException {
if(commentaire.getId() != null ){ if (commentaire.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau commentaire ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau commentaire ayant un id non null.");
} }
return commentaireRepository.save(commentaire); return commentaireRepository.save(commentaire);
} }
@Override @Override
public Commentaire updateCommentaire(Long id, Commentaire commentaire) throws NotFoundException { public Commentaire updateCommentaire(Long id, Commentaire commentaire) throws NotFoundException {
if(commentaire.getId() == null ){ if (commentaire.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau commentaire ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau commentaire ayant un id null.");
} }
if(!commentaireRepository.existsById(commentaire.getId())){ if (!commentaireRepository.existsById(commentaire.getId())) {
throw new NotFoundException("Impossible de trouver le commentaire spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le commentaire spécifié dans notre base de données.");
} }
return commentaireRepository.save(commentaire); return commentaireRepository.save(commentaire);
} }
@Override @Override
public void deleteCommentaire(Long id) throws NotFoundException { public void deleteCommentaire(Long id) throws NotFoundException {
Optional<Commentaire> commentaireOptional = commentaireRepository.findById(id); Optional<Commentaire> commentaireOptional = commentaireRepository.findById(id);
if(commentaireOptional.isPresent()){ if (commentaireOptional.isPresent()) {
commentaireRepository.deleteById(commentaireOptional.get().getId()); commentaireRepository.deleteById(commentaireOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le commentaire spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le commentaire spécifié dans notre base de données.");
} }
} }
@Override @Override
public List<Commentaire> getCommentairesByEnqueteAndTerminal(Long idEnquete , Long terminalId) { public List<Commentaire> getCommentairesByEnqueteAndTerminal(Long idEnquete, Long terminalId) {
return commentaireRepository.findAllByIdEnqueteAndTerminalId(idEnquete, terminalId); return commentaireRepository.findAllByIdEnqueteAndTerminalId(idEnquete, terminalId);
} }
@@ -90,7 +90,7 @@ public class CommentaireServiceImpl implements CommentaireService {
@Override @Override
public boolean setCommentaireRead(Long id) { public boolean setCommentaireRead(Long id) {
if(commentaireRepository.existsById(id)){ if (commentaireRepository.existsById(id)) {
Commentaire commentaire = commentaireRepository.getById(id); Commentaire commentaire = commentaireRepository.getById(id);
commentaire.setLu(true); commentaire.setLu(true);
updateCommentaire(id, commentaire); updateCommentaire(id, commentaire);
@@ -113,11 +113,11 @@ public class CommentaireServiceImpl implements CommentaireService {
@Override @Override
public List<CommentaireResponse> notifySynchronizedDoneFromMobile(List<SyncCommentaireRequest> syncCommentaireRequests) { public List<CommentaireResponse> notifySynchronizedDoneFromMobile(List<SyncCommentaireRequest> syncCommentaireRequests) {
if(syncCommentaireRequests != null || !syncCommentaireRequests.isEmpty()){ if (syncCommentaireRequests != null || !syncCommentaireRequests.isEmpty()) {
List<CommentaireResponse> commentaireResponses = new ArrayList<>(); List<CommentaireResponse> commentaireResponses = new ArrayList<>();
syncCommentaireRequests.forEach(syncCommentaireRequest -> { syncCommentaireRequests.forEach(syncCommentaireRequest -> {
Optional<Commentaire> commentaireOptional = commentaireRepository.findById(syncCommentaireRequest.getIdBackend()); Optional<Commentaire> commentaireOptional = commentaireRepository.findById(syncCommentaireRequest.getIdBackend());
if(commentaireOptional.isPresent()){ if (commentaireOptional.isPresent()) {
Commentaire commentaire = commentaireOptional.get(); Commentaire commentaire = commentaireOptional.get();
commentaire.setExternalKey(syncCommentaireRequest.getExternalKey()); commentaire.setExternalKey(syncCommentaireRequest.getExternalKey());
commentaire.setSynchronise(true); commentaire.setSynchronise(true);

View File

@@ -68,19 +68,19 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public Enquete createEnquete(EnquetePayLoad enquetePayLoad) throws BadRequestException { public Enquete createEnquete(EnquetePayLoad enquetePayLoad) throws BadRequestException {
Optional<User> optionalUser =userRepository.findById(enquetePayLoad.getUserId()); Optional<User> optionalUser = userRepository.findById(enquetePayLoad.getUserId());
if(!optionalUser.isPresent()){ if (!optionalUser.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec un enquêteur inexistant"); throw new BadRequestException("Impossible d'enregistrer une enquête avec un enquêteur inexistant");
} }
Optional<Bloc> optionalBloc =blocRepository.findById(enquetePayLoad.getBlocId()); Optional<Bloc> optionalBloc = blocRepository.findById(enquetePayLoad.getBlocId());
if(!optionalBloc.isPresent()){ if (!optionalBloc.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec un bloc inexistant"); throw new BadRequestException("Impossible d'enregistrer une enquête avec un bloc inexistant");
} }
Optional<Parcelle> optionalParcelle =parcelleRepository.findById(enquetePayLoad.getParcelleId()); Optional<Parcelle> optionalParcelle = parcelleRepository.findById(enquetePayLoad.getParcelleId());
if(!optionalParcelle.isPresent()){ if (!optionalParcelle.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante"); throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante");
} }
Enquete enquete=new Enquete(); Enquete enquete = new Enquete();
enquete.setDateEnquete(LocalDate.now()); enquete.setDateEnquete(LocalDate.now());
enquete.setBloc(optionalBloc.get()); enquete.setBloc(optionalBloc.get());
enquete.setUser(optionalUser.get()); enquete.setUser(optionalUser.get());
@@ -98,9 +98,9 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public List<EnqueteFiltreResponse> getEnqueteCommuneArrondBlocFiltre(FiltreEnquetePayLoad filtreEnquetePayLoad) { public List<EnqueteFiltreResponse> getEnqueteCommuneArrondBlocFiltre(FiltreEnquetePayLoad filtreEnquetePayLoad) {
String condition=""; String condition = "";
Query query ; Query query;
String sql ="select distinct " + String sql = "select distinct " +
" e.id," + " e.id," +
" e.parcelle_id as parcelleId," + " e.parcelle_id as parcelleId," +
" c.id as communeId, " + " c.id as communeId, " +
@@ -138,80 +138,79 @@ public class EnqueteServiceImpl implements EnqueteService {
" left join type_personne tp on tp.id=per.type_personne_id " + " left join type_personne tp on tp.id=per.type_personne_id " +
" where ac.role_acteur='PROPRIETAIRE' "; " where ac.role_acteur='PROPRIETAIRE' ";
if(filtreEnquetePayLoad.getCommuneId()!=null){ if (filtreEnquetePayLoad.getCommuneId() != null) {
condition+= " AND c.id = "+filtreEnquetePayLoad.getCommuneId(); condition += " AND c.id = " + filtreEnquetePayLoad.getCommuneId();
} }
if(filtreEnquetePayLoad.getArrondissementId()!=null){ if (filtreEnquetePayLoad.getArrondissementId() != null) {
condition+= " AND a.id = "+filtreEnquetePayLoad.getArrondissementId() ; condition += " AND a.id = " + filtreEnquetePayLoad.getArrondissementId();
} }
if(filtreEnquetePayLoad.getStructureId()!=null){ if (filtreEnquetePayLoad.getStructureId() != null) {
condition+= " AND s.id = "+filtreEnquetePayLoad.getStructureId() ; condition += " AND s.id = " + filtreEnquetePayLoad.getStructureId();
} }
if(filtreEnquetePayLoad.getParcelleId()!=null){ if (filtreEnquetePayLoad.getParcelleId() != null) {
condition+= " AND p.id = "+filtreEnquetePayLoad.getParcelleId(); condition += " AND p.id = " + filtreEnquetePayLoad.getParcelleId();
} }
if(filtreEnquetePayLoad.getBlocId()!=null){ if (filtreEnquetePayLoad.getBlocId() != null) {
condition+= " AND b.id = "+filtreEnquetePayLoad.getBlocId() ; condition += " AND b.id = " + filtreEnquetePayLoad.getBlocId();
} }
if(filtreEnquetePayLoad.getNomPersonne()!=null){ if (filtreEnquetePayLoad.getNomPersonne() != null) {
condition+= " AND per.nom_ou_sigle like '%"+filtreEnquetePayLoad.getNomPersonne() +"%'"; condition += " AND per.nom_ou_sigle like '%" + filtreEnquetePayLoad.getNomPersonne() + "%'";
} }
if(filtreEnquetePayLoad.getPrenomPersonne()!=null){ if (filtreEnquetePayLoad.getPrenomPersonne() != null) {
condition+= " AND per.prenom_ou_raison_sociale like '%"+filtreEnquetePayLoad.getPrenomPersonne() +"%'"; condition += " AND per.prenom_ou_raison_sociale like '%" + filtreEnquetePayLoad.getPrenomPersonne() + "%'";
} }
if(filtreEnquetePayLoad.getNatureDomaneId()!=null){ if (filtreEnquetePayLoad.getNatureDomaneId() != null) {
condition+= " AND nd.id = "+filtreEnquetePayLoad.getNatureDomaneId() ; condition += " AND nd.id = " + filtreEnquetePayLoad.getNatureDomaneId();
} }
if(filtreEnquetePayLoad.getTypeDomaineId()!=null){ if (filtreEnquetePayLoad.getTypeDomaineId() != null) {
condition+= " AND td.id = "+filtreEnquetePayLoad.getTypeDomaineId() ; condition += " AND td.id = " + filtreEnquetePayLoad.getTypeDomaineId();
} }
if(filtreEnquetePayLoad.getTypePersonneId()!=null){ if (filtreEnquetePayLoad.getTypePersonneId() != null) {
condition+= " AND tp.id = "+filtreEnquetePayLoad.getTypePersonneId() ; condition += " AND tp.id = " + filtreEnquetePayLoad.getTypePersonneId();
} }
///////////////// /////////////////
if(filtreEnquetePayLoad.getEnqueteurId()!=null){ if (filtreEnquetePayLoad.getEnqueteurId() != null) {
condition+= " AND e.user_id = "+filtreEnquetePayLoad.getEnqueteurId() ; condition += " AND e.user_id = " + filtreEnquetePayLoad.getEnqueteurId();
} }
if(filtreEnquetePayLoad.getStatutEnquete()!=null){ if (filtreEnquetePayLoad.getStatutEnquete() != null) {
condition+= " AND e.status_enquete = "+filtreEnquetePayLoad.getStatutEnquete() ; condition += " AND e.status_enquete = " + filtreEnquetePayLoad.getStatutEnquete();
} }
if(filtreEnquetePayLoad.getLitige()!=null){ if (filtreEnquetePayLoad.getLitige() != null) {
condition+= " AND e.litige is "+filtreEnquetePayLoad.getLitige() ; condition += " AND e.litige is " + filtreEnquetePayLoad.getLitige();
} }
System.out.println(condition); System.out.println(condition);
StringBuilder sb = new StringBuilder(sql).append(condition); StringBuilder sb = new StringBuilder(sql).append(condition);
query = em.createNativeQuery(sb.toString(), EnqueteFiltreResponse.class); query = em.createNativeQuery(sb.toString(), EnqueteFiltreResponse.class);
List<EnqueteFiltreResponse> enqueteFiltreResponses = query.getResultList(); List<EnqueteFiltreResponse> enqueteFiltreResponses = query.getResultList();
return enqueteFiltreResponses ; return enqueteFiltreResponses;
} }
@Override @Override
public Enquete updateEnquete(EnquetePayLoad enquetePayLoad) throws NotFoundException { public Enquete updateEnquete(EnquetePayLoad enquetePayLoad) throws NotFoundException {
if(enquetePayLoad.getIdBackend() == null ){ if (enquetePayLoad.getIdBackend() == null) {
throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une enquête ayant un id null.");
} }
if(!enqueteRepository.existsById(enquetePayLoad.getIdBackend())){ if (!enqueteRepository.existsById(enquetePayLoad.getIdBackend())) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez modifier."); throw new NotFoundException("Impossible de trouver l'enquête que vous désirez modifier.");
} }
Optional<User> optionalUser =userRepository.findById(enquetePayLoad.getUserId()); Optional<User> optionalUser = userRepository.findById(enquetePayLoad.getUserId());
if(!optionalUser.isPresent()){ if (!optionalUser.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec un enquêteur inexistant"); throw new BadRequestException("Impossible d'enregistrer une enquête avec un enquêteur inexistant");
} }
Optional<Bloc> optionalBloc =blocRepository.findById(enquetePayLoad.getBlocId()); Optional<Bloc> optionalBloc = blocRepository.findById(enquetePayLoad.getBlocId());
if(!optionalBloc.isPresent()){ if (!optionalBloc.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec un bloc inexistant"); throw new BadRequestException("Impossible d'enregistrer une enquête avec un bloc inexistant");
} }
Optional<Parcelle> optionalParcelle =parcelleRepository.findById(enquetePayLoad.getParcelleId()); Optional<Parcelle> optionalParcelle = parcelleRepository.findById(enquetePayLoad.getParcelleId());
if(!optionalParcelle.isPresent()){ if (!optionalParcelle.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante"); throw new BadRequestException("Impossible d'enregistrer une enquête avec une parcelle inexistante");
} }
Enquete enquete=enqueteRepository.findById(enquetePayLoad.getParcelleId()).get(); Enquete enquete = enqueteRepository.findById(enquetePayLoad.getParcelleId()).get();
enquete.setBloc(optionalBloc.get()); enquete.setBloc(optionalBloc.get());
enquete.setUser(optionalUser.get()); enquete.setUser(optionalUser.get());
enquete.setParcelle(optionalParcelle.get()); enquete.setParcelle(optionalParcelle.get());
@@ -225,9 +224,9 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public void deleteEnquete(Long id) throws NotFoundException { public void deleteEnquete(Long id) throws NotFoundException {
Optional<Enquete> optionalEnquete = enqueteRepository.findById(id); Optional<Enquete> optionalEnquete = enqueteRepository.findById(id);
if(optionalEnquete.isPresent()){ if (optionalEnquete.isPresent()) {
enqueteRepository.deleteById(optionalEnquete.get().getId()); enqueteRepository.deleteById(optionalEnquete.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez supprimer."); throw new NotFoundException("Impossible de trouver l'enquête que vous désirez supprimer.");
} }
} }
@@ -244,20 +243,20 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public Optional<Enquete> getEnqueteById(Long id) { public Optional<Enquete> getEnqueteById(Long id) {
if(enqueteRepository.existsById(id)){ if (enqueteRepository.existsById(id)) {
return enqueteRepository.findById(id); return enqueteRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver l'enquête."); throw new NotFoundException("Impossible de trouver l'enquête.");
} }
} }
@Override @Override
public Enquete validerEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) { public Enquete validerEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
if(enqueteTraitementPayLoad == null ){ if (enqueteTraitementPayLoad == null) {
throw new BadRequestException("Impossible de valider une enquête ayant un id null."); throw new BadRequestException("Impossible de valider une enquête ayant un id null.");
} }
Optional<Enquete> optionalEnquete=enqueteRepository.findById(enqueteTraitementPayLoad.getIdBackend()); Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteTraitementPayLoad.getIdBackend());
if(!optionalEnquete.isPresent()){ if (!optionalEnquete.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez valider."); throw new NotFoundException("Impossible de trouver l'enquête que vous désirez valider.");
} }
optionalEnquete.get().setDateValidation(LocalDate.now()); optionalEnquete.get().setDateValidation(LocalDate.now());
@@ -268,11 +267,11 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public Enquete rejeterEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) { public Enquete rejeterEnquete(EnqueteTraitementPayLoad enqueteTraitementPayLoad) {
if(enqueteTraitementPayLoad.getIdBackend() == null ){ if (enqueteTraitementPayLoad.getIdBackend() == null) {
throw new BadRequestException("Impossible de rejeter une enquête ayant un id null."); throw new BadRequestException("Impossible de rejeter une enquête ayant un id null.");
} }
Optional<Enquete> optionalEnquete=enqueteRepository.findById(enqueteTraitementPayLoad.getIdBackend()); Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteTraitementPayLoad.getIdBackend());
if(!optionalEnquete.isPresent()){ if (!optionalEnquete.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez rejeter."); throw new NotFoundException("Impossible de trouver l'enquête que vous désirez rejeter.");
} }
optionalEnquete.get().setDateRejet(LocalDate.now()); optionalEnquete.get().setDateRejet(LocalDate.now());
@@ -286,11 +285,11 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public List<Enquete> validerEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) { public List<Enquete> validerEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
List<Enquete> enquetes = new ArrayList<>(); List<Enquete> enquetes = new ArrayList<>();
try{ try {
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) { for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
enquetes.add(validerEnquete(enqueteTraitementPayLoad)); enquetes.add(validerEnquete(enqueteTraitementPayLoad));
} }
}catch (Exception e){ } catch (Exception e) {
enquetes.add(null); enquetes.add(null);
} }
return enquetes; return enquetes;
@@ -299,11 +298,11 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public List<Enquete> rejeterEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) { public List<Enquete> rejeterEnquete(List<EnqueteTraitementPayLoad> enqueteTraitementPayLoads) {
List<Enquete> enquetes = new ArrayList<>(); List<Enquete> enquetes = new ArrayList<>();
try{ try {
for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) { for (EnqueteTraitementPayLoad enqueteTraitementPayLoad : enqueteTraitementPayLoads) {
enquetes.add(rejeterEnquete(enqueteTraitementPayLoad)); enquetes.add(rejeterEnquete(enqueteTraitementPayLoad));
} }
}catch (Exception e){ } catch (Exception e) {
enquetes.add(null); enquetes.add(null);
} }
return enquetes; return enquetes;
@@ -311,11 +310,11 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public Enquete finaliserEnquete(Long enqueteId) { public Enquete finaliserEnquete(Long enqueteId) {
if(enqueteId == null ){ if (enqueteId == null) {
throw new BadRequestException("Impossible de finaliser une enquête ayant un id null."); throw new BadRequestException("Impossible de finaliser une enquête ayant un id null.");
} }
Optional<Enquete> optionalEnquete=enqueteRepository.findById(enqueteId); Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteId);
if(!optionalEnquete.isPresent()){ if (!optionalEnquete.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête que vous désirez finaliser."); throw new NotFoundException("Impossible de trouver l'enquête que vous désirez finaliser.");
} }
optionalEnquete.get().setDateFinalisation(LocalDate.now()); optionalEnquete.get().setDateFinalisation(LocalDate.now());
@@ -325,11 +324,11 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public Enquete reglerLitigeEnquete(Long enqueteId) { public Enquete reglerLitigeEnquete(Long enqueteId) {
if(enqueteId == null ){ if (enqueteId == null) {
throw new BadRequestException("Impossible de régler le litige d'une enquête ayant un id null."); throw new BadRequestException("Impossible de régler le litige d'une enquête ayant un id null.");
} }
Optional<Enquete> optionalEnquete=enqueteRepository.findById(enqueteId); Optional<Enquete> optionalEnquete = enqueteRepository.findById(enqueteId);
if(!optionalEnquete.isPresent()){ if (!optionalEnquete.isPresent()) {
throw new NotFoundException("Impossible de trouver l'enquête dont vous désirez régler le litige."); throw new NotFoundException("Impossible de trouver l'enquête dont vous désirez régler le litige.");
} }
optionalEnquete.get().setDateLitigeResolu(LocalDate.now()); optionalEnquete.get().setDateLitigeResolu(LocalDate.now());
@@ -341,11 +340,11 @@ public class EnqueteServiceImpl implements EnqueteService {
@Override @Override
public UserDecoupageEnqResponses getDecoupageAdminUserConnecterAndStat() { public UserDecoupageEnqResponses getDecoupageAdminUserConnecterAndStat() {
String userName=""; String userName = "";
try { try {
authentication = SecurityContextHolder.getContext().getAuthentication(); authentication = SecurityContextHolder.getContext().getAuthentication();
userName = authentication.getName(); userName = authentication.getName();
}catch (Exception e){ } catch (Exception e) {
return null; return null;
} }
@@ -357,14 +356,14 @@ public class EnqueteServiceImpl implements EnqueteService {
System.out.println(user.isAdmin()); System.out.println(user.isAdmin());
List<CommuneEnqResponse> communeEnqResponses = List<CommuneEnqResponse> communeEnqResponses =
user.isAdmin() ? communeRepository.getAdminCommuneEnqResponse():communeRepository.getCommuneEnqResponse(user.getStructure().getId()); user.isAdmin() ? communeRepository.getAdminCommuneEnqResponse() : communeRepository.getCommuneEnqResponse(user.getStructure().getId());
List<ArrondissementEnqResponse> arrondissementEnqResponses = List<ArrondissementEnqResponse> arrondissementEnqResponses =
user.isAdmin()? arrondissementRepository.getAdminArrondissementEnqResponse() : arrondissementRepository.getArrondissementEnqResponse(user.getStructure().getId()); user.isAdmin() ? arrondissementRepository.getAdminArrondissementEnqResponse() : arrondissementRepository.getArrondissementEnqResponse(user.getStructure().getId());
List<BlocEnqResponse> blocEnqResponses = List<BlocEnqResponse> blocEnqResponses =
user.isAdmin() ? blocRepository.getAdminBlocEnqResponse(): blocRepository.getBlocEnqResponse(user.getStructure().getId()); user.isAdmin() ? blocRepository.getAdminBlocEnqResponse() : blocRepository.getBlocEnqResponse(user.getStructure().getId());
UserDecoupageEnqResponses userDecoupageEnqResponses = new UserDecoupageEnqResponses(); UserDecoupageEnqResponses userDecoupageEnqResponses = new UserDecoupageEnqResponses();
userDecoupageEnqResponses.setCommunes(communeEnqResponses); userDecoupageEnqResponses.setCommunes(communeEnqResponses);
@@ -383,33 +382,33 @@ public class EnqueteServiceImpl implements EnqueteService {
FicheEnquetesResponse ficheEnquetesResponse = new FicheEnquetesResponse(); // classe payload de Enquete FicheEnquetesResponse ficheEnquetesResponse = new FicheEnquetesResponse(); // classe payload de Enquete
if(optionalEnquete.isPresent()){ if (optionalEnquete.isPresent()) {
ficheEnquetesResponse = modelMapper.map(optionalEnquete.get(), FicheEnquetesResponse.class); ficheEnquetesResponse = modelMapper.map(optionalEnquete.get(), FicheEnquetesResponse.class);
} }
List<FicheActeurConcerneResponse> ficheActeurConcerneResponses = new ArrayList<>(); List<FicheActeurConcerneResponse> ficheActeurConcerneResponses = new ArrayList<>();
if(!acteurConcernes.isEmpty()){ if (!acteurConcernes.isEmpty()) {
acteurConcernes.stream().forEach(acteurConcerne -> ficheActeurConcerneResponses.add(modelMapper.map(acteurConcerne, FicheActeurConcerneResponse.class))); acteurConcernes.stream().forEach(acteurConcerne -> ficheActeurConcerneResponses.add(modelMapper.map(acteurConcerne, FicheActeurConcerneResponse.class)));
} }
List<CaracteristiqueParcelle> caracteristiqueParcelles = caracteristiqueParcelleRepository.findAllByEnquete_Id(enqueteId); List<CaracteristiqueParcelle> caracteristiqueParcelles = caracteristiqueParcelleRepository.findAllByEnquete_Id(enqueteId);
List<FicheCaracteristiqueParcelleResponse> caracteristiqueParcelleResponses = new ArrayList<>(); List<FicheCaracteristiqueParcelleResponse> caracteristiqueParcelleResponses = new ArrayList<>();
if(!caracteristiqueParcelles.isEmpty()){ if (!caracteristiqueParcelles.isEmpty()) {
caracteristiqueParcelles.stream().forEach(caracteristiqueParcelle -> caracteristiqueParcelleResponses.add(modelMapper.map(caracteristiqueParcelle, FicheCaracteristiqueParcelleResponse.class))); caracteristiqueParcelles.stream().forEach(caracteristiqueParcelle -> caracteristiqueParcelleResponses.add(modelMapper.map(caracteristiqueParcelle, FicheCaracteristiqueParcelleResponse.class)));
} }
List<FicheEnqueteBatimentResponse> enqueteBatimentResponses = new ArrayList<>(); List<FicheEnqueteBatimentResponse> enqueteBatimentResponses = new ArrayList<>();
List<EnqueteBatiment> enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId); List<EnqueteBatiment> enqueteBatiments = enqueteBatimentRepository.findAllByEnquete_Id(enqueteId);
if(!enqueteBatiments.isEmpty()){ if (!enqueteBatiments.isEmpty()) {
enqueteBatiments.stream().forEach(enqueteBatiment -> enqueteBatimentResponses.add(modelMapper.map(enqueteBatiment, FicheEnqueteBatimentResponse.class))); enqueteBatiments.stream().forEach(enqueteBatiment -> enqueteBatimentResponses.add(modelMapper.map(enqueteBatiment, FicheEnqueteBatimentResponse.class)));
} }
List<FicheEnqueteUniteLogementResponse> enqueteUniteLogementResponses = new ArrayList<>(); List<FicheEnqueteUniteLogementResponse> enqueteUniteLogementResponses = new ArrayList<>();
List<EnqueteUniteLogement> enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId); List<EnqueteUniteLogement> enqueteUniteLogements = enqueteUniteLogementRepository.findAllByEnquete_Id(enqueteId);
if(!enqueteUniteLogements.isEmpty()){ if (!enqueteUniteLogements.isEmpty()) {
enqueteUniteLogements.stream().forEach(enqueteUniteLogement -> enqueteUniteLogementResponses.add(modelMapper.map(enqueteUniteLogement, FicheEnqueteUniteLogementResponse.class))); enqueteUniteLogements.stream().forEach(enqueteUniteLogement -> enqueteUniteLogementResponses.add(modelMapper.map(enqueteUniteLogement, FicheEnqueteUniteLogementResponse.class)));
} }
@@ -420,7 +419,7 @@ public class EnqueteServiceImpl implements EnqueteService {
ficheEnqueteResponse.setEnquete(ficheEnquetesResponse); ficheEnqueteResponse.setEnquete(ficheEnquetesResponse);
ficheEnqueteResponse.setActeurConcernes(ficheActeurConcerneResponses); ficheEnqueteResponse.setActeurConcernes(ficheActeurConcerneResponses);
return ficheEnqueteResponse ; return ficheEnqueteResponse;
} }
@Override @Override

View File

@@ -44,51 +44,51 @@ public class ParcelleServiceImpl implements ParcelleService {
@Override @Override
public Parcelle createParcelle(ParcellePayLoad parcellePayLoad) throws BadRequestException { public Parcelle createParcelle(ParcellePayLoad parcellePayLoad) throws BadRequestException {
Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoad.getNatureDomaineId()); Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoad.getNatureDomaineId());
if(!optionalNatureDomaine.isPresent()){ if (!optionalNatureDomaine.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistant"); throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistant");
} }
Optional<Quartier> optionalQuartier =quartierRepository.findById(parcellePayLoad.getQuartierId()); Optional<Quartier> optionalQuartier = quartierRepository.findById(parcellePayLoad.getQuartierId());
if(!optionalQuartier.isPresent()){ if (!optionalQuartier.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant"); throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant");
} }
Optional<SituationGeographique> optionalSituationGeographique =situationGeographiqueRepository.findById(parcellePayLoad.getSituationGeographiqueId()); Optional<SituationGeographique> optionalSituationGeographique = situationGeographiqueRepository.findById(parcellePayLoad.getSituationGeographiqueId());
if(!optionalSituationGeographique.isPresent()){ if (!optionalSituationGeographique.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une situation géographique inexistant"); throw new BadRequestException("Impossible d'enregistrer une parcelle avec une situation géographique inexistant");
} }
Parcelle parcelle=getParcelle(parcellePayLoad, optionalSituationGeographique, optionalNatureDomaine); Parcelle parcelle = getParcelle(parcellePayLoad, optionalSituationGeographique, optionalNatureDomaine);
return parcelleRepository.save(parcelle); return parcelleRepository.save(parcelle);
} }
@Override @Override
public Parcelle updateParcelle(ParcellePayLoad parcellePayLoad) throws NotFoundException { public Parcelle updateParcelle(ParcellePayLoad parcellePayLoad) throws NotFoundException {
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(parcellePayLoad.getIdBackend()); Optional<Parcelle> optionalParcelle = parcelleRepository.findById(parcellePayLoad.getIdBackend());
if(!optionalParcelle.isPresent()){ if (!optionalParcelle.isPresent()) {
throw new NotFoundException("Impossible de trouver la parcelle que vous désirer modifier"); throw new NotFoundException("Impossible de trouver la parcelle que vous désirer modifier");
} }
Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoad.getNatureDomaineId()); Optional<NatureDomaine> optionalNatureDomaine = natureDomaineRepository.findById(parcellePayLoad.getNatureDomaineId());
if(!optionalNatureDomaine.isPresent()){ if (!optionalNatureDomaine.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistante"); throw new BadRequestException("Impossible d'enregistrer une parcelle avec une nature de domaine inexistante");
} }
Optional<Quartier> optionalQuartier =quartierRepository.findById(parcellePayLoad.getQuartierId()); Optional<Quartier> optionalQuartier = quartierRepository.findById(parcellePayLoad.getQuartierId());
if(!optionalQuartier.isPresent()){ if (!optionalQuartier.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant"); throw new BadRequestException("Impossible d'enregistrer une parcelle avec un quartier/village inexistant");
} }
Optional<SituationGeographique> optionalSituationGeographique =situationGeographiqueRepository.findById(parcellePayLoad.getSituationGeographiqueId()); Optional<SituationGeographique> optionalSituationGeographique = situationGeographiqueRepository.findById(parcellePayLoad.getSituationGeographiqueId());
if(!optionalSituationGeographique.isPresent()){ if (!optionalSituationGeographique.isPresent()) {
throw new BadRequestException("Impossible d'enregistrer une parcelle avec une situation géographique inexistant"); throw new BadRequestException("Impossible d'enregistrer une parcelle avec une situation géographique inexistant");
} }
Parcelle parcelle=getParcelle(optionalParcelle.get(),parcellePayLoad,optionalSituationGeographique, optionalNatureDomaine); Parcelle parcelle = getParcelle(optionalParcelle.get(), parcellePayLoad, optionalSituationGeographique, optionalNatureDomaine);
return parcelleRepository.save(parcelle); return parcelleRepository.save(parcelle);
} }
@Override @Override
public void deleteParcelle(Long id) throws NotFoundException { public void deleteParcelle(Long id) throws NotFoundException {
Optional<Parcelle> optionalParcelle = parcelleRepository.findById(id); Optional<Parcelle> optionalParcelle = parcelleRepository.findById(id);
if(optionalParcelle.isPresent()){ if (optionalParcelle.isPresent()) {
parcelleRepository.deleteById(optionalParcelle.get().getId()); parcelleRepository.deleteById(optionalParcelle.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la parcelle que vous désirez supprimer."); throw new NotFoundException("Impossible de trouver la parcelle que vous désirez supprimer.");
} }
} }
@@ -105,15 +105,16 @@ public class ParcelleServiceImpl implements ParcelleService {
@Override @Override
public Optional<Parcelle> getParcelleById(Long id) { public Optional<Parcelle> getParcelleById(Long id) {
if(parcelleRepository.existsById(id)){ if (parcelleRepository.existsById(id)) {
return parcelleRepository.findById(id); return parcelleRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver l'enquête."); throw new NotFoundException("Impossible de trouver l'enquête.");
} }
} }
private Parcelle getParcelle(ParcellePayLoad parcellePayLoad, Optional<SituationGeographique> optionalSituationGeographique, Optional<NatureDomaine> optionalNatureDomaine) {
StringBuilder coordonnees =new StringBuilder(); private Parcelle getParcelle(ParcellePayLoad parcellePayLoad, Optional<SituationGeographique> optionalSituationGeographique, Optional<NatureDomaine> optionalNatureDomaine) {
Parcelle parcelle=new Parcelle(); StringBuilder coordonnees = new StringBuilder();
Parcelle parcelle = new Parcelle();
parcelle.setP(parcellePayLoad.getP()); parcelle.setP(parcellePayLoad.getP());
parcelle.setI(parcellePayLoad.getI()); parcelle.setI(parcellePayLoad.getI());
parcelle.setQ(parcellePayLoad.getQ()); parcelle.setQ(parcellePayLoad.getQ());
@@ -145,8 +146,9 @@ public class ParcelleServiceImpl implements ParcelleService {
// } // }
return parcelle; return parcelle;
} }
private Parcelle getParcelle(Parcelle parcelle, ParcellePayLoad parcellePayLoad, Optional<SituationGeographique> optionalSituationGeographique, Optional<NatureDomaine> optionalNatureDomaine) {
StringBuilder coordonnees =new StringBuilder(); private Parcelle getParcelle(Parcelle parcelle, ParcellePayLoad parcellePayLoad, Optional<SituationGeographique> optionalSituationGeographique, Optional<NatureDomaine> optionalNatureDomaine) {
StringBuilder coordonnees = new StringBuilder();
parcelle.setP(parcellePayLoad.getP()); parcelle.setP(parcellePayLoad.getP());
parcelle.setI(parcellePayLoad.getI()); parcelle.setI(parcellePayLoad.getI());
parcelle.setQ(parcellePayLoad.getQ()); parcelle.setQ(parcellePayLoad.getQ());
@@ -180,6 +182,4 @@ public class ParcelleServiceImpl implements ParcelleService {
} }
} }

View File

@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class TpeServiceImpl implements TpeService { public class TpeServiceImpl implements TpeService {
@@ -27,40 +28,40 @@ public class TpeServiceImpl implements TpeService {
@Override @Override
public Tpe createTpe(Tpe tpe) throws BadRequestException { public Tpe createTpe(Tpe tpe) throws BadRequestException {
String codeEquipe; String codeEquipe;
do{ do {
codeEquipe = StringService.getCodeEquipe(); codeEquipe = StringService.getCodeEquipe();
}while (tpeRepository.existsDistinctByCodeEquipe(codeEquipe)); } while (tpeRepository.existsDistinctByCodeEquipe(codeEquipe));
tpe.setCodeEquipe(codeEquipe); tpe.setCodeEquipe(codeEquipe);
if(tpe.getId() != null ){ if (tpe.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau tpe ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau tpe ayant un id non null.");
} }
if(tpeRepository.existsDistinctByIdentifier(tpe.getIdentifier())){ if (tpeRepository.existsDistinctByIdentifier(tpe.getIdentifier())) {
return tpeRepository.findDistinctByIdentifier(tpe.getIdentifier()).get(); return tpeRepository.findDistinctByIdentifier(tpe.getIdentifier()).get();
}else{ } else {
return tpeRepository.save(tpe); return tpeRepository.save(tpe);
} }
} }
@Override @Override
public Tpe updateTpe(Long id, Tpe tpe) throws NotFoundException { public Tpe updateTpe(Long id, Tpe tpe) throws NotFoundException {
if(tpe.getId() == null ){ if (tpe.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau tpe ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau tpe ayant un id null.");
} }
if(!tpeRepository.existsById(tpe.getId())){ if (!tpeRepository.existsById(tpe.getId())) {
throw new NotFoundException("Impossible de trouver le tpe spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le tpe spécifié dans notre base de données.");
} }
return tpeRepository.save(tpe); return tpeRepository.save(tpe);
} }
@Override @Override
public void deleteTpe(Long id) throws NotFoundException { public void deleteTpe(Long id) throws NotFoundException {
Optional<Tpe> tpeOptional = tpeRepository.findById(id); Optional<Tpe> tpeOptional = tpeRepository.findById(id);
if(tpeOptional.isPresent()){ if (tpeOptional.isPresent()) {
tpeRepository.deleteById(tpeOptional.get().getId()); tpeRepository.deleteById(tpeOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le tpe spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le tpe spécifié dans notre base de données.");
} }
} }
@@ -77,9 +78,9 @@ public class TpeServiceImpl implements TpeService {
@Override @Override
public Optional<Tpe> getTpeById(Long id) { public Optional<Tpe> getTpeById(Long id) {
if(tpeRepository.existsById(id)){ if (tpeRepository.existsById(id)) {
return tpeRepository.findById(id); return tpeRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver le tpe spécifié dans la base de données."); throw new NotFoundException("Impossible de trouver le tpe spécifié dans la base de données.");
} }
@@ -87,18 +88,18 @@ public class TpeServiceImpl implements TpeService {
@Override @Override
public Optional<Tpe> getTepByIdentifier(String identifier) { public Optional<Tpe> getTepByIdentifier(String identifier) {
if(tpeRepository.existsDistinctByIdentifier(identifier)){ if (tpeRepository.existsDistinctByIdentifier(identifier)) {
return tpeRepository.findDistinctByIdentifier(identifier); return tpeRepository.findDistinctByIdentifier(identifier);
}else{ } else {
throw new NotFoundException("Impossible de trouver le tpe lié à cette clé dans la base de données."); throw new NotFoundException("Impossible de trouver le tpe lié à cette clé dans la base de données.");
} }
} }
@Override @Override
public List<Tpe> getTpeListByModel(String model) { public List<Tpe> getTpeListByModel(String model) {
if(model != null){ if (model != null) {
return tpeRepository.findAllByModel(model); return tpeRepository.findAllByModel(model);
}else{ } else {
throw new BadRequestException("Vous devez spécifier le model du tpe."); throw new BadRequestException("Vous devez spécifier le model du tpe.");
} }
} }

View File

@@ -35,78 +35,78 @@ public class BlocServiceImpl implements BlocService {
@Override @Override
public Bloc createBloc(Bloc bloc) throws BadRequestException { public Bloc createBloc(Bloc bloc) throws BadRequestException {
if(bloc.getId() != null ){ if (bloc.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau bloc ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau bloc ayant un id non null.");
} }
String idBlocParArrondissement = getIdBlocParArrondissementValue(bloc); String idBlocParArrondissement = getIdBlocParArrondissementValue(bloc);
bloc.setIdBlocParArrondissement(idBlocParArrondissement); bloc.setIdBlocParArrondissement(idBlocParArrondissement);
if(bloc.getStructure() == null){ if (bloc.getStructure() == null) {
bloc.setCote(getCoteValue(bloc, idBlocParArrondissement, null)); bloc.setCote(getCoteValue(bloc, idBlocParArrondissement, null));
}else{ } else {
bloc.setCote(getCoteValue(bloc, idBlocParArrondissement, bloc.getStructure().getId())); bloc.setCote(getCoteValue(bloc, idBlocParArrondissement, bloc.getStructure().getId()));
} }
if(bloc.getQuartier() != null){ if (bloc.getQuartier() != null) {
bloc.setCoteq(getCoteQuartierByCoteBloc(bloc.getCote(), bloc.getQuartier())); bloc.setCoteq(getCoteQuartierByCoteBloc(bloc.getCote(), bloc.getQuartier()));
} }
if(bloc.getSecteurDecoupage()!=null) { if (bloc.getSecteurDecoupage() != null) {
bloc.setSecteur(bloc.getSecteurDecoupage().getSecteur()); bloc.setSecteur(bloc.getSecteurDecoupage().getSecteur());
} }
return blocRepository.save(bloc); return blocRepository.save(bloc);
} }
private String getCoteQuartierByCoteBloc(String cote, Quartier quartier) { private String getCoteQuartierByCoteBloc(String cote, Quartier quartier) {
if(cote == null) { if (cote == null) {
throw new BadRequestException("Le bloc spécifié ne dispose pas encore de code."); throw new BadRequestException("Le bloc spécifié ne dispose pas encore de code.");
}else{ } else {
return new StringBuilder().append(cote.substring(0,3)).append(quartier.getCode()).toString(); return new StringBuilder().append(cote.substring(0, 3)).append(quartier.getCode()).toString();
} }
} }
private String getCoteValue(Bloc bloc, String idBlocParArrondissement, Long structure_id) { private String getCoteValue(Bloc bloc, String idBlocParArrondissement, Long structure_id) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
if(structure_id == null){ if (structure_id == null) {
structure_id = blocRepository.getStructureId(bloc.getArrondissement().getId()); structure_id = blocRepository.getStructureId(bloc.getArrondissement().getId());
if(structure_id == null){ if (structure_id == null) {
throw new NotFoundException("Aucune structure n'est associé à ce bloc. Il n'est donc pas possible d'enregistrer ce bloc. Vous devez donc attribué ce bloc à une structure."); throw new NotFoundException("Aucune structure n'est associé à ce bloc. Il n'est donc pas possible d'enregistrer ce bloc. Vous devez donc attribué ce bloc à une structure.");
} }
} }
Optional<Structure> structureOptional = structureService.getStructureById(structure_id); Optional<Structure> structureOptional = structureService.getStructureById(structure_id);
if(structureOptional.isPresent()){ if (structureOptional.isPresent()) {
builder.append(structureOptional.get().getCode()); builder.append(structureOptional.get().getCode());
builder.append(bloc.getArrondissement().getCode()); builder.append(bloc.getArrondissement().getCode());
builder.append(idBlocParArrondissement); builder.append(idBlocParArrondissement);
return builder.toString(); return builder.toString();
}else { } else {
throw new NotFoundException("Impossible de trouver la structure associée à ce bloc"); throw new NotFoundException("Impossible de trouver la structure associée à ce bloc");
} }
} }
private String getIdBlocParArrondissementValue(Bloc bloc) { private String getIdBlocParArrondissementValue(Bloc bloc) {
int a = countAllBlocByArrondissement(bloc.getArrondissement().getId()) + 1; int a = countAllBlocByArrondissement(bloc.getArrondissement().getId()) + 1;
return stringService.generateIntInTwoPositions(a); return stringService.generateIntInTwoPositions(a);
} }
@Override @Override
public Bloc updateBloc(Long id, Bloc bloc) throws NotFoundException { public Bloc updateBloc(Long id, Bloc bloc) throws NotFoundException {
if(bloc.getId() == null ){ if (bloc.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau bloc ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau bloc ayant un id null.");
} }
if(!blocRepository.existsById(bloc.getId())){ if (!blocRepository.existsById(bloc.getId())) {
throw new NotFoundException("Impossible de trouver le bloc spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le bloc spécifié dans notre base de données.");
} }
return blocRepository.save(bloc); return blocRepository.save(bloc);
} }
@Override @Override
public void deleteBloc(Long id) throws NotFoundException { public void deleteBloc(Long id) throws NotFoundException {
Optional<Bloc> blocOptional = blocRepository.findById(id); Optional<Bloc> blocOptional = blocRepository.findById(id);
if(blocOptional.isPresent()){ if (blocOptional.isPresent()) {
blocRepository.deleteById(blocOptional.get().getId()); blocRepository.deleteById(blocOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le bloc spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le bloc spécifié dans notre base de données.");
} }
} }
@@ -126,9 +126,9 @@ public class BlocServiceImpl implements BlocService {
@Override @Override
public List<Bloc> getBlocsByStructure(Long idStructure) { public List<Bloc> getBlocsByStructure(Long idStructure) {
if(structureService.getStructureById(idStructure).isPresent()){ if (structureService.getStructureById(idStructure).isPresent()) {
return blocRepository.getBlocsByStructure(idStructure); return blocRepository.getBlocsByStructure(idStructure);
}else{ } else {
throw new NotFoundException("Impossible de trouver la structure spécifiée."); throw new NotFoundException("Impossible de trouver la structure spécifiée.");
} }
} }
@@ -145,18 +145,18 @@ public class BlocServiceImpl implements BlocService {
@Override @Override
public Optional<Bloc> getBlocById(Long id) { public Optional<Bloc> getBlocById(Long id) {
if(blocRepository.existsById(id)){ if (blocRepository.existsById(id)) {
return blocRepository.findById(id); return blocRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver le bloc spécifié dans la base de données."); throw new NotFoundException("Impossible de trouver le bloc spécifié dans la base de données.");
} }
} }
@Override @Override
public int countAllBlocByArrondissement(Long idArrondissement) { public int countAllBlocByArrondissement(Long idArrondissement) {
if(arrondissementService.getArrondissementById(idArrondissement).isPresent()){ if (arrondissementService.getArrondissementById(idArrondissement).isPresent()) {
return blocRepository.countAllBlocByArrondissement(idArrondissement); return blocRepository.countAllBlocByArrondissement(idArrondissement);
}else{ } else {
throw new NotFoundException("Impossible de trouver l'arrondissement' spécifié dans la base de données."); throw new NotFoundException("Impossible de trouver l'arrondissement' spécifié dans la base de données.");
} }
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class ModeAcquisitionServiceImpl implements ModeAcquisitionService { public class ModeAcquisitionServiceImpl implements ModeAcquisitionService {
@@ -22,29 +23,29 @@ public class ModeAcquisitionServiceImpl implements ModeAcquisitionService {
@Override @Override
public ModeAcquisition createModeAcquisition(ModeAcquisition modeAcquisition) throws BadRequestException { public ModeAcquisition createModeAcquisition(ModeAcquisition modeAcquisition) throws BadRequestException {
if(modeAcquisition.getId() != null ){ if (modeAcquisition.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau mode d'acquisition ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau mode d'acquisition ayant un id non null.");
} }
return modeAcquisitionRepository.save(modeAcquisition); return modeAcquisitionRepository.save(modeAcquisition);
} }
@Override @Override
public ModeAcquisition updateModeAcquisition(Long id, ModeAcquisition modeAcquisition) throws NotFoundException { public ModeAcquisition updateModeAcquisition(Long id, ModeAcquisition modeAcquisition) throws NotFoundException {
if(modeAcquisition.getId() == null ){ if (modeAcquisition.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau mode d'acquisition ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau mode d'acquisition ayant un id null.");
} }
if(!modeAcquisitionRepository.existsById(modeAcquisition.getId())){ if (!modeAcquisitionRepository.existsById(modeAcquisition.getId())) {
throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans notre base de données.");
} }
return modeAcquisitionRepository.save(modeAcquisition); return modeAcquisitionRepository.save(modeAcquisition);
} }
@Override @Override
public void deleteModeAcquisition(Long id) throws NotFoundException { public void deleteModeAcquisition(Long id) throws NotFoundException {
Optional<ModeAcquisition> modeAcquisitionOptional = modeAcquisitionRepository.findById(id); Optional<ModeAcquisition> modeAcquisitionOptional = modeAcquisitionRepository.findById(id);
if(modeAcquisitionOptional.isPresent()){ if (modeAcquisitionOptional.isPresent()) {
modeAcquisitionRepository.deleteById(modeAcquisitionOptional.get().getId()); modeAcquisitionRepository.deleteById(modeAcquisitionOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans notre base de données.");
} }
} }
@@ -61,9 +62,9 @@ public class ModeAcquisitionServiceImpl implements ModeAcquisitionService {
@Override @Override
public Optional<ModeAcquisition> getModeAcquisitionById(Long id) { public Optional<ModeAcquisition> getModeAcquisitionById(Long id) {
if(modeAcquisitionRepository.existsById(id)){ if (modeAcquisitionRepository.existsById(id)) {
return modeAcquisitionRepository.findById(id); return modeAcquisitionRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans la base de données."); throw new NotFoundException("Impossible de trouver le mode d'acquisition spécifié dans la base de données.");
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class NatureDomaineServiceImpl implements NatureDomaineService { public class NatureDomaineServiceImpl implements NatureDomaineService {
@@ -22,29 +23,29 @@ public class NatureDomaineServiceImpl implements NatureDomaineService {
@Override @Override
public NatureDomaine createNatureDomaine(NatureDomaine natureDomaine) throws BadRequestException { public NatureDomaine createNatureDomaine(NatureDomaine natureDomaine) throws BadRequestException {
if(natureDomaine.getId() != null ){ if (natureDomaine.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle nature domaine ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle nature domaine ayant un id non null.");
} }
return natureDomaineRepository.save(natureDomaine); return natureDomaineRepository.save(natureDomaine);
} }
@Override @Override
public NatureDomaine updateNatureDomaine(Long id, NatureDomaine natureDomaine) throws NotFoundException { public NatureDomaine updateNatureDomaine(Long id, NatureDomaine natureDomaine) throws NotFoundException {
if(natureDomaine.getId() == null ){ if (natureDomaine.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle nature domaine ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle nature domaine ayant un id null.");
} }
if(!natureDomaineRepository.existsById(natureDomaine.getId())){ if (!natureDomaineRepository.existsById(natureDomaine.getId())) {
throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans notre base de données.");
} }
return natureDomaineRepository.save(natureDomaine); return natureDomaineRepository.save(natureDomaine);
} }
@Override @Override
public void deleteNatureDomaine(Long id) throws NotFoundException { public void deleteNatureDomaine(Long id) throws NotFoundException {
Optional<NatureDomaine> natureDomaineOptional = natureDomaineRepository.findById(id); Optional<NatureDomaine> natureDomaineOptional = natureDomaineRepository.findById(id);
if(natureDomaineOptional.isPresent()){ if (natureDomaineOptional.isPresent()) {
natureDomaineRepository.deleteById(natureDomaineOptional.get().getId()); natureDomaineRepository.deleteById(natureDomaineOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans notre base de données.");
} }
} }
@@ -61,9 +62,9 @@ public class NatureDomaineServiceImpl implements NatureDomaineService {
@Override @Override
public Optional<NatureDomaine> getNatureDomaineById(Long id) { public Optional<NatureDomaine> getNatureDomaineById(Long id) {
if(natureDomaineRepository.existsById(id)){ if (natureDomaineRepository.existsById(id)) {
return natureDomaineRepository.findById(id); return natureDomaineRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la nature domaine spécifiée dans la base de données.");
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class PositionRepresentationServiceImpl implements PositionRepresentationService { public class PositionRepresentationServiceImpl implements PositionRepresentationService {
@@ -22,29 +23,29 @@ public class PositionRepresentationServiceImpl implements PositionRepresentation
@Override @Override
public PositionRepresentation createPositionRepresentation(PositionRepresentation positionRepresentation) throws BadRequestException { public PositionRepresentation createPositionRepresentation(PositionRepresentation positionRepresentation) throws BadRequestException {
if(positionRepresentation.getId() != null ){ if (positionRepresentation.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle position de représentation ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle position de représentation ayant un id non null.");
} }
return positionRepresentationRepository.save(positionRepresentation); return positionRepresentationRepository.save(positionRepresentation);
} }
@Override @Override
public PositionRepresentation updatePositionRepresentation(Long id, PositionRepresentation positionRepresentation) throws NotFoundException { public PositionRepresentation updatePositionRepresentation(Long id, PositionRepresentation positionRepresentation) throws NotFoundException {
if(positionRepresentation.getId() == null ){ if (positionRepresentation.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle position de représentation ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle position de représentation ayant un id null.");
} }
if(!positionRepresentationRepository.existsById(positionRepresentation.getId())){ if (!positionRepresentationRepository.existsById(positionRepresentation.getId())) {
throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans notre base de données.");
} }
return positionRepresentationRepository.save(positionRepresentation); return positionRepresentationRepository.save(positionRepresentation);
} }
@Override @Override
public void deletePositionRepresentation(Long id) throws NotFoundException { public void deletePositionRepresentation(Long id) throws NotFoundException {
Optional<PositionRepresentation> positionRepresentationOptional = positionRepresentationRepository.findById(id); Optional<PositionRepresentation> positionRepresentationOptional = positionRepresentationRepository.findById(id);
if(positionRepresentationOptional.isPresent()){ if (positionRepresentationOptional.isPresent()) {
positionRepresentationRepository.deleteById(positionRepresentationOptional.get().getId()); positionRepresentationRepository.deleteById(positionRepresentationOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans notre base de données.");
} }
} }
@@ -61,9 +62,9 @@ public class PositionRepresentationServiceImpl implements PositionRepresentation
@Override @Override
public Optional<PositionRepresentation> getPositionRepresentationById(Long id) { public Optional<PositionRepresentation> getPositionRepresentationById(Long id) {
if(positionRepresentationRepository.existsById(id)){ if (positionRepresentationRepository.existsById(id)) {
return positionRepresentationRepository.findById(id); return positionRepresentationRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la position de représentation spécifiée dans la base de données.");
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class ProfessionServiceImpl implements ProfessionService { public class ProfessionServiceImpl implements ProfessionService {
@@ -22,29 +23,29 @@ public class ProfessionServiceImpl implements ProfessionService {
@Override @Override
public Profession createProfession(Profession profession) throws BadRequestException { public Profession createProfession(Profession profession) throws BadRequestException {
if(profession.getId() != null ){ if (profession.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle profession ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle profession ayant un id non null.");
} }
return professionRepository.save(profession); return professionRepository.save(profession);
} }
@Override @Override
public Profession updateProfession(Long id, Profession profession) throws NotFoundException { public Profession updateProfession(Long id, Profession profession) throws NotFoundException {
if(profession.getId() == null ){ if (profession.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle profession ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle profession ayant un id null.");
} }
if(!professionRepository.existsById(profession.getId())){ if (!professionRepository.existsById(profession.getId())) {
throw new NotFoundException("Impossible de trouver la profession spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la profession spécifiée dans notre base de données.");
} }
return professionRepository.save(profession); return professionRepository.save(profession);
} }
@Override @Override
public void deleteProfession(Long id) throws NotFoundException { public void deleteProfession(Long id) throws NotFoundException {
Optional<Profession> professionOptional = professionRepository.findById(id); Optional<Profession> professionOptional = professionRepository.findById(id);
if(professionOptional.isPresent()){ if (professionOptional.isPresent()) {
professionRepository.deleteById(professionOptional.get().getId()); professionRepository.deleteById(professionOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la profession spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la profession spécifiée dans notre base de données.");
} }
} }
@@ -61,9 +62,9 @@ public class ProfessionServiceImpl implements ProfessionService {
@Override @Override
public Optional<Profession> getProfessionById(Long id) { public Optional<Profession> getProfessionById(Long id) {
if(professionRepository.existsById(id)){ if (professionRepository.existsById(id)) {
return professionRepository.findById(id); return professionRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver la profession spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la profession spécifiée dans la base de données.");
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class SituationGeographiqueServiceImpl implements SituationGeographiqueService { public class SituationGeographiqueServiceImpl implements SituationGeographiqueService {
@@ -22,29 +23,29 @@ public class SituationGeographiqueServiceImpl implements SituationGeographiqueSe
@Override @Override
public SituationGeographique createSituationGeographique(SituationGeographique situationGeographique) throws BadRequestException { public SituationGeographique createSituationGeographique(SituationGeographique situationGeographique) throws BadRequestException {
if(situationGeographique.getId() != null ){ if (situationGeographique.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle situation géographique ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle situation géographique ayant un id non null.");
} }
return situationGeographiqueRepository.save(situationGeographique); return situationGeographiqueRepository.save(situationGeographique);
} }
@Override @Override
public SituationGeographique updateSituationGeographique(Long id, SituationGeographique situationGeographique) throws NotFoundException { public SituationGeographique updateSituationGeographique(Long id, SituationGeographique situationGeographique) throws NotFoundException {
if(situationGeographique.getId() == null ){ if (situationGeographique.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle situation géographique ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle situation géographique ayant un id null.");
} }
if(!situationGeographiqueRepository.existsById(situationGeographique.getId())){ if (!situationGeographiqueRepository.existsById(situationGeographique.getId())) {
throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans notre base de données.");
} }
return situationGeographiqueRepository.save(situationGeographique); return situationGeographiqueRepository.save(situationGeographique);
} }
@Override @Override
public void deleteSituationGeographique(Long id) throws NotFoundException { public void deleteSituationGeographique(Long id) throws NotFoundException {
Optional<SituationGeographique> situationGeographiqueOptional = situationGeographiqueRepository.findById(id); Optional<SituationGeographique> situationGeographiqueOptional = situationGeographiqueRepository.findById(id);
if(situationGeographiqueOptional.isPresent()){ if (situationGeographiqueOptional.isPresent()) {
situationGeographiqueRepository.deleteById(situationGeographiqueOptional.get().getId()); situationGeographiqueRepository.deleteById(situationGeographiqueOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans notre base de données.");
} }
} }
@@ -61,9 +62,9 @@ public class SituationGeographiqueServiceImpl implements SituationGeographiqueSe
@Override @Override
public Optional<SituationGeographique> getSituationGeographiqueById(Long id) { public Optional<SituationGeographique> getSituationGeographiqueById(Long id) {
if(situationGeographiqueRepository.existsById(id)){ if (situationGeographiqueRepository.existsById(id)) {
return situationGeographiqueRepository.findById(id); return situationGeographiqueRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la situation géographique spécifiée dans la base de données.");
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeService { public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeService {
@@ -22,29 +23,29 @@ public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeSe
@Override @Override
public SituationMatrimoniale createSituationMatrimoniale(SituationMatrimoniale situationMatrimoniale) throws BadRequestException { public SituationMatrimoniale createSituationMatrimoniale(SituationMatrimoniale situationMatrimoniale) throws BadRequestException {
if(situationMatrimoniale.getId() != null ){ if (situationMatrimoniale.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle situation matrimoniale ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle situation matrimoniale ayant un id non null.");
} }
return situationMatrimonialeRepository.save(situationMatrimoniale); return situationMatrimonialeRepository.save(situationMatrimoniale);
} }
@Override @Override
public SituationMatrimoniale updateSituationMatrimoniale(Long id, SituationMatrimoniale situationMatrimoniale) throws NotFoundException { public SituationMatrimoniale updateSituationMatrimoniale(Long id, SituationMatrimoniale situationMatrimoniale) throws NotFoundException {
if(situationMatrimoniale.getId() == null ){ if (situationMatrimoniale.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle situation matrimoniale ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle situation matrimoniale ayant un id null.");
} }
if(!situationMatrimonialeRepository.existsById(situationMatrimoniale.getId())){ if (!situationMatrimonialeRepository.existsById(situationMatrimoniale.getId())) {
throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans notre base de données.");
} }
return situationMatrimonialeRepository.save(situationMatrimoniale); return situationMatrimonialeRepository.save(situationMatrimoniale);
} }
@Override @Override
public void deleteSituationMatrimoniale(Long id) throws NotFoundException { public void deleteSituationMatrimoniale(Long id) throws NotFoundException {
Optional<SituationMatrimoniale> situationMatrimonialeOptional = situationMatrimonialeRepository.findById(id); Optional<SituationMatrimoniale> situationMatrimonialeOptional = situationMatrimonialeRepository.findById(id);
if(situationMatrimonialeOptional.isPresent()){ if (situationMatrimonialeOptional.isPresent()) {
situationMatrimonialeRepository.deleteById(situationMatrimonialeOptional.get().getId()); situationMatrimonialeRepository.deleteById(situationMatrimonialeOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans notre base de données.");
} }
} }
@@ -61,9 +62,9 @@ public class SituationMatrimonialeServiceImpl implements SituationMatrimonialeSe
@Override @Override
public Optional<SituationMatrimoniale> getSituationMatrimonialeById(Long id) { public Optional<SituationMatrimoniale> getSituationMatrimonialeById(Long id) {
if(situationMatrimonialeRepository.existsById(id)){ if (situationMatrimonialeRepository.existsById(id)) {
return situationMatrimonialeRepository.findById(id); return situationMatrimonialeRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la situation matrimoniale spécifiée dans la base de données.");
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class SourceDroitServiceImpl implements SourceDroitService { public class SourceDroitServiceImpl implements SourceDroitService {
@@ -22,29 +23,29 @@ public class SourceDroitServiceImpl implements SourceDroitService {
@Override @Override
public SourceDroit createSourceDroit(SourceDroit sourceDroit) throws BadRequestException { public SourceDroit createSourceDroit(SourceDroit sourceDroit) throws BadRequestException {
if(sourceDroit.getId() != null ){ if (sourceDroit.getId() != null) {
throw new BadRequestException("Impossible de créer une nouvelle source de droit ayant un id non null."); throw new BadRequestException("Impossible de créer une nouvelle source de droit ayant un id non null.");
} }
return sourceDroitRepository.save(sourceDroit); return sourceDroitRepository.save(sourceDroit);
} }
@Override @Override
public SourceDroit updateSourceDroit(Long id, SourceDroit sourceDroit) throws NotFoundException { public SourceDroit updateSourceDroit(Long id, SourceDroit sourceDroit) throws NotFoundException {
if(sourceDroit.getId() == null ){ if (sourceDroit.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une nouvelle source de droit ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une nouvelle source de droit ayant un id null.");
} }
if(!sourceDroitRepository.existsById(sourceDroit.getId())){ if (!sourceDroitRepository.existsById(sourceDroit.getId())) {
throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans notre base de données.");
} }
return sourceDroitRepository.save(sourceDroit); return sourceDroitRepository.save(sourceDroit);
} }
@Override @Override
public void deleteSourceDroit(Long id) throws NotFoundException { public void deleteSourceDroit(Long id) throws NotFoundException {
Optional<SourceDroit> sourceDroitOptional = sourceDroitRepository.findById(id); Optional<SourceDroit> sourceDroitOptional = sourceDroitRepository.findById(id);
if(sourceDroitOptional.isPresent()){ if (sourceDroitOptional.isPresent()) {
sourceDroitRepository.deleteById(sourceDroitOptional.get().getId()); sourceDroitRepository.deleteById(sourceDroitOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans notre base de données.");
} }
} }
@@ -62,9 +63,9 @@ public class SourceDroitServiceImpl implements SourceDroitService {
@Override @Override
public Optional<SourceDroit> getSourceDroitById(Long id) { public Optional<SourceDroit> getSourceDroitById(Long id) {
if(sourceDroitRepository.existsById(id)){ if (sourceDroitRepository.existsById(id)) {
return sourceDroitRepository.findById(id); return sourceDroitRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la source de droit spécifiée dans la base de données.");
} }

View File

@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class StructureServiceImpl implements StructureService { public class StructureServiceImpl implements StructureService {
@@ -23,12 +24,12 @@ public class StructureServiceImpl implements StructureService {
@Override @Override
public Structure createStructure(Structure structure) throws BadRequestException { public Structure createStructure(Structure structure) throws BadRequestException {
if(structure.getId() != null ){ if (structure.getId() != null) {
throw new BadRequestException("Impossible de créer une structure ayant un id non null."); throw new BadRequestException("Impossible de créer une structure ayant un id non null.");
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("C"); builder.append("C");
builder.append(structureRepository.getLastRecordId()+1); builder.append(structureRepository.getLastRecordId() + 1);
structure.setCode(builder.toString()); structure.setCode(builder.toString());
return structureRepository.save(structure); return structureRepository.save(structure);
} }
@@ -38,10 +39,10 @@ public class StructureServiceImpl implements StructureService {
System.out.println("structure = " + structure); System.out.println("structure = " + structure);
if(structure.getId() == null ){ if (structure.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour une structure ayant un id null."); throw new BadRequestException("Impossible de mettre à jour une structure ayant un id null.");
} }
if(!structureRepository.existsById(structure.getId())){ if (!structureRepository.existsById(structure.getId())) {
throw new NotFoundException("Impossible de trouver la structure spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la structure spécifiée dans notre base de données.");
} }
structureRepository.save(structure); structureRepository.save(structure);
@@ -54,9 +55,9 @@ public class StructureServiceImpl implements StructureService {
@Override @Override
public void deleteStructure(Long id) throws NotFoundException { public void deleteStructure(Long id) throws NotFoundException {
Optional<Structure> structureOptional = structureRepository.findById(id); Optional<Structure> structureOptional = structureRepository.findById(id);
if(structureOptional.isPresent()){ if (structureOptional.isPresent()) {
structureRepository.deleteById(structureOptional.get().getId()); structureRepository.deleteById(structureOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver la structure spécifiée dans notre base de données."); throw new NotFoundException("Impossible de trouver la structure spécifiée dans notre base de données.");
} }
} }
@@ -78,9 +79,9 @@ public class StructureServiceImpl implements StructureService {
@Override @Override
public Optional<Structure> getStructureById(Long id) { public Optional<Structure> getStructureById(Long id) {
if(structureRepository.existsById(id)){ if (structureRepository.existsById(id)) {
return structureRepository.findById(id); return structureRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver la structure spécifiée dans la base de données."); throw new NotFoundException("Impossible de trouver la structure spécifiée dans la base de données.");
} }
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class TypeContestationServiceImpl implements TypeContestationService { public class TypeContestationServiceImpl implements TypeContestationService {
@@ -22,29 +23,29 @@ public class TypeContestationServiceImpl implements TypeContestationService {
@Override @Override
public TypeContestation createTypeContestation(TypeContestation typeContestation) throws BadRequestException { public TypeContestation createTypeContestation(TypeContestation typeContestation) throws BadRequestException {
if(typeContestation.getId() != null ){ if (typeContestation.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau type de contestation ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau type de contestation ayant un id non null.");
} }
return typeContestationRepository.save(typeContestation); return typeContestationRepository.save(typeContestation);
} }
@Override @Override
public TypeContestation updateTypeContestation(Long id, TypeContestation typeContestation) throws NotFoundException { public TypeContestation updateTypeContestation(Long id, TypeContestation typeContestation) throws NotFoundException {
if(typeContestation.getId() == null ){ if (typeContestation.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau type de contestation ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau type de contestation ayant un id null.");
} }
if(!typeContestationRepository.existsById(typeContestation.getId())){ if (!typeContestationRepository.existsById(typeContestation.getId())) {
throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans notre base de données.");
} }
return typeContestationRepository.save(typeContestation); return typeContestationRepository.save(typeContestation);
} }
@Override @Override
public void deleteTypeContestation(Long id) throws NotFoundException { public void deleteTypeContestation(Long id) throws NotFoundException {
Optional<TypeContestation> typeContestationOptional = typeContestationRepository.findById(id); Optional<TypeContestation> typeContestationOptional = typeContestationRepository.findById(id);
if(typeContestationOptional.isPresent()){ if (typeContestationOptional.isPresent()) {
typeContestationRepository.deleteById(typeContestationOptional.get().getId()); typeContestationRepository.deleteById(typeContestationOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans notre base de données.");
} }
} }
@@ -61,9 +62,9 @@ public class TypeContestationServiceImpl implements TypeContestationService {
@Override @Override
public Optional<TypeContestation> getTypeContestationById(Long id) { public Optional<TypeContestation> getTypeContestationById(Long id) {
if(typeContestationRepository.existsById(id)){ if (typeContestationRepository.existsById(id)) {
return typeContestationRepository.findById(id); return typeContestationRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans la base de données."); throw new NotFoundException("Impossible de trouver le type de contestation spécifié dans la base de données.");
} }

View File

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class TypeDomaineServiceImpl implements TypeDomaineService { public class TypeDomaineServiceImpl implements TypeDomaineService {
@@ -22,29 +23,29 @@ public class TypeDomaineServiceImpl implements TypeDomaineService {
@Override @Override
public TypeDomaine createTypeDomaine(TypeDomaine typeDomaine) throws BadRequestException { public TypeDomaine createTypeDomaine(TypeDomaine typeDomaine) throws BadRequestException {
if(typeDomaine.getId() != null ){ if (typeDomaine.getId() != null) {
throw new BadRequestException("Impossible de créer un nouveau type de domaine ayant un id non null."); throw new BadRequestException("Impossible de créer un nouveau type de domaine ayant un id non null.");
} }
return typeDomaineRepository.save(typeDomaine); return typeDomaineRepository.save(typeDomaine);
} }
@Override @Override
public TypeDomaine updateTypeDomaine(Long id, TypeDomaine typeDomaine) throws NotFoundException { public TypeDomaine updateTypeDomaine(Long id, TypeDomaine typeDomaine) throws NotFoundException {
if(typeDomaine.getId() == null ){ if (typeDomaine.getId() == null) {
throw new BadRequestException("Impossible de mettre à jour un nouveau type de domaine ayant un id null."); throw new BadRequestException("Impossible de mettre à jour un nouveau type de domaine ayant un id null.");
} }
if(!typeDomaineRepository.existsById(typeDomaine.getId())){ if (!typeDomaineRepository.existsById(typeDomaine.getId())) {
throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans notre base de données.");
} }
return typeDomaineRepository.save(typeDomaine); return typeDomaineRepository.save(typeDomaine);
} }
@Override @Override
public void deleteTypeDomaine(Long id) throws NotFoundException { public void deleteTypeDomaine(Long id) throws NotFoundException {
Optional<TypeDomaine> typeDomaineOptional = typeDomaineRepository.findById(id); Optional<TypeDomaine> typeDomaineOptional = typeDomaineRepository.findById(id);
if(typeDomaineOptional.isPresent()){ if (typeDomaineOptional.isPresent()) {
typeDomaineRepository.deleteById(typeDomaineOptional.get().getId()); typeDomaineRepository.deleteById(typeDomaineOptional.get().getId());
}else{ } else {
throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans notre base de données."); throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans notre base de données.");
} }
} }
@@ -61,9 +62,9 @@ public class TypeDomaineServiceImpl implements TypeDomaineService {
@Override @Override
public Optional<TypeDomaine> getTypeDomaineById(Long id) { public Optional<TypeDomaine> getTypeDomaineById(Long id) {
if(typeDomaineRepository.existsById(id)){ if (typeDomaineRepository.existsById(id)) {
return typeDomaineRepository.findById(id); return typeDomaineRepository.findById(id);
}else{ } else {
throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans la base de données."); throw new NotFoundException("Impossible de trouver le type de domaine spécifié dans la base de données.");
} }

Some files were not shown because too many files have changed in this diff Show More