Commit 3234e669 authored by LAVENIER's avatar LAVENIER
Browse files

[enh] Add cache on VesselSnapshot

[enh] Landing: allow to filter on many locations
[enh] Extraction: finish FREE2 implementation
parent 5b549d65
......@@ -97,6 +97,14 @@ public class Daos extends net.sumaris.core.dao.technical.Daos {
.collect(Collectors.joining(","));
}
public static String getSqlInNumbers(Number... numbers) {
if (numbers == null) return "";
return Stream.of(numbers)
.filter(Objects::nonNull)
.map(String::valueOf)
.collect(Collectors.joining(","));
}
public static String getSqlToDate(Date date) {
if (date == null) return null;
return String.format(SQL_TO_DATE,
......
......@@ -23,6 +23,7 @@
package net.sumaris.core.extraction.dao.trip.free;
import com.google.common.base.Preconditions;
import net.sumaris.core.extraction.dao.technical.Daos;
import net.sumaris.core.extraction.dao.technical.XMLQuery;
import net.sumaris.core.extraction.dao.trip.rdb.ExtractionRdbTripDaoImpl;
import net.sumaris.core.extraction.format.LiveFormatEnum;
......@@ -86,9 +87,10 @@ public class ExtractionFree1TripDaoImpl<C extends ExtractionRdbTripContextVO, F
xmlQuery.injectQuery(getXMLQueryURL(context, "injectionStationTable"));
// Bind some PMFM ids
xmlQuery.bind("headlineCumulativeLengthPmfmId", String.valueOf(PmfmEnum.HEADLINE_CUMULATIVE_LENGTH.getId()));
xmlQuery.bind("beamCumulativeLengthPmfmId", String.valueOf(PmfmEnum.BEAM_CUMULATIVE_LENGTH.getId()));
xmlQuery.bind("netLengthPmfmId", String.valueOf(PmfmEnum.NET_LENGTH.getId()));
xmlQuery.bind("effortPmfmIds", Daos.getSqlInNumbers(
PmfmEnum.HEADLINE_CUMULATIVE_LENGTH.getId(),
PmfmEnum.BEAM_CUMULATIVE_LENGTH.getId(),
PmfmEnum.NET_LENGTH.getId()));
// TODO: add SIH Ifremer missing parameters (see FREE1 format specification) ?
// TOTAL_LENGTH_HAULED Longueur levée, = NET_LENGTH ?
// TOTAL_NB_HOOKS Nombre total d'hameçons, missing in SUMARIS
......
......@@ -78,31 +78,54 @@ public class ExtractionFree2TripDaoImpl<C extends ExtractionFree2ContextVO, F ex
@Override
public <R extends C> R execute(F filter) {
String sheetName = filter != null ? filter.getSheetName() : null;
boolean isPreview = filter.isPreview();
String sheetName = filter != null && filter.isPreview() ? filter.getSheetName() : null;
// Trip
filter.setSheetName(Free2Specification.TRIP_SHEET_NAME); // Force to execute only Trip
filter.setPreview(true);
R context = super.execute(filter);
// Override some context properties
// Restore original values (before was forced to Trip)
filter.setPreview(isPreview);
filter.setSheetName(sheetName);
context.setFormat(LiveFormatEnum.FREE2);
// Stop here, if sheet already filled
if (sheetName != null && context.hasSheet(sheetName)) return context;
// Gear table
long rowCount = createGearTable(context);
// Station
long rowCount = createStationTable(context);
if (rowCount == 0) return context;
if (sheetName != null && context.hasSheet(sheetName)) return context;
// Gear table
rowCount = createGearTable(context);
if (sheetName != null && context.hasSheet(sheetName)) return context;
// Species Raw table
rowCount = createRawSpeciesListTable(context, true /*exclude invalid station*/);
if (rowCount == 0) return context;
// Strategy table
rowCount = createStrategyTable(context);
if (rowCount == 0) return context;
if (sheetName != null && context.hasSheet(sheetName)) return context;
// Strategy table
// Detail table
rowCount = createDetailTable(context);
if (sheetName != null && context.hasSheet(sheetName)) return context;
// Captures table
rowCount = createSpeciesListTable(context);
if (rowCount == 0) return context;
if (sheetName != null && context.hasSheet(sheetName)) return context;
// Mesures
rowCount = createSpeciesLengthTable(context);
if (rowCount == 0) return context;
if (sheetName != null && context.hasSheet(sheetName)) return context;
return context;
}
......@@ -145,7 +168,10 @@ public class ExtractionFree2TripDaoImpl<C extends ExtractionFree2ContextVO, F ex
xmlQuery.bind("tripTableName", context.getTripTableName());
// Bind some referential ids
xmlQuery.bind("contractCodePmfmId", String.valueOf(PmfmEnum.CONTRACT_CODE.getId()));
xmlQuery.bind("contractCodePmfmIds", Daos.getSqlInNumbers(
PmfmEnum.CONTRACT_CODE.getId(),
PmfmEnum.SELF_SAMPLING_PROGRAM.getId()
));
// Date filters
xmlQuery.setGroup("startDateFilter", context.getStartDate() != null);
......@@ -186,24 +212,15 @@ public class ExtractionFree2TripDaoImpl<C extends ExtractionFree2ContextVO, F ex
xmlQuery.bind("meshSizePmfmId", String.valueOf(PmfmEnum.SMALLER_MESH_GAUGE_MM.getId()));
xmlQuery.bind("headlineCumulativeLengthPmfmId", String.valueOf(PmfmEnum.HEADLINE_CUMULATIVE_LENGTH.getId()));
xmlQuery.bind("beamCumulativeLengthPmfmId", String.valueOf(PmfmEnum.BEAM_CUMULATIVE_LENGTH.getId()));
xmlQuery.bind("netLengthPmfmId", String.valueOf(PmfmEnum.NET_LENGTH.getId()));
xmlQuery.bind("gearSpeedPmfmId", String.valueOf(PmfmEnum.GEAR_SPEED.getId()));
xmlQuery.bind("effortPmfmIds", Daos.getSqlInNumbers(
PmfmEnum.HEADLINE_CUMULATIVE_LENGTH.getId(),
PmfmEnum.BEAM_CUMULATIVE_LENGTH.getId(),
PmfmEnum.NET_LENGTH.getId()));
xmlQuery.bind("gearSpeedPmfmIds", String.valueOf(PmfmEnum.GEAR_SPEED.getId()));
xmlQuery.bind("selectionDevicePmfmId", String.valueOf(PmfmEnum.SELECTIVITY_DEVICE.getId()));
// TODO: add SIH Ifremer missing parameters (see FREE1 format specification) ?
// TOTAL_LENGTH_HAULED Longueur levée, = NET_LENGTH ?
// TOTAL_NB_HOOKS Nombre total d'hameçons, missing in SUMARIS
// NB_FISH_POT Nombre de casiers nasses ou poches, missing in SUMARIS
// HEADLINE_LENGTH Longueur de la corde de dos (cumulée si jumeaux), = HEADLINE_CUMULATIVE_LENGTH ?
// WIDTH_GEAR Largeur cumulée (drague), missing in SUMARIS
// SEINE_LENGTH Longueur de la bolinche ou senne missing in SUMARIS
xmlQuery.bind("acousticDeterrentDevicePmfmId", String.valueOf(PmfmEnum.ACOUSTIC_DETERRENT_DEVICE.getId()));
return xmlQuery;
}
......@@ -361,9 +378,7 @@ public class ExtractionFree2TripDaoImpl<C extends ExtractionFree2ContextVO, F ex
}
protected long createSpeciesLengthTable(C context) {
// TODO
return 0;
return super.createSpeciesLengthTable(context);
}
protected String getQueryFullName(C context, String queryName) {
......@@ -371,17 +386,6 @@ public class ExtractionFree2TripDaoImpl<C extends ExtractionFree2ContextVO, F ex
Preconditions.checkNotNull(context.getVersion());
String versionStr = VERSION_1_9.replaceAll("[.]", "_");
switch (queryName) {
case "createTripTable":
case "createStationTable":
case "createRawSpeciesListTable":
case "createSpeciesListTable":
case "createStrategyTable":
case "createDetailTable":
case "createGearTable":
return String.format(XML_QUERY_FREE_PATH, versionStr, queryName);
default:
return super.getQueryFullName(context, queryName);
}
return String.format(XML_QUERY_FREE_PATH, versionStr, queryName);
}
}
......@@ -157,6 +157,10 @@ public class ExtractionContextVO implements IExtractionFormat {
return tableNames.containsValue(sheetName);
}
public boolean hasRawTable(String rawTableName) {
Preconditions.checkNotNull(rawTableName);
return rawTableNames.contains(rawTableName);
}
/**
* Return the hidden columns of the given table
* @param tableName
......
......@@ -39,7 +39,7 @@
<select alias="EFFECTIVE_EFFORT" type="number"><![CDATA[
(SELECT PGM.NUMERICAL_VALUE FROM PHYSICAL_GEAR_MEASUREMENT PGM
WHERE
PGM.PHYSICAL_GEAR_FK=PG.ID and PGM.PMFM_FK in (&headlineCumulativeLengthPmfmId, &beamCumulativeLengthPmfmId, &netLengthPmfmId)
PGM.PHYSICAL_GEAR_FK=PG.ID and PGM.PMFM_FK in (&effortPmfmIds)
)]]></select>
</query>
......@@ -3,23 +3,6 @@
<queries name="extractionCreateGearTable">
<query type="create" temp="false" table="&amp;gearTableName" option="DISTINCT">
<with alias="STATION">
<subquery>
<subselect alias="ID_MAREE" type="number">S.ID_MAREE</subselect>
<subselect alias="ID_OP" type="number">S.ID_OP</subselect>
<subselect alias="NUM_OP" type="number">CAST(COUNT(O.ID)+1 AS INTEGER)</subselect>
<from alias="S">&amp;stationTableName</from>
<from join="true"><![CDATA[
LEFT OUTER JOIN OPERATION O
ON O.TRIP_FK = S.ID_MAREE
AND O.ID <> S.STATION_NUMBER
AND COALESCE(O.FISHING_START_DATE_TIME, O.START_DATE_TIME) <= S.DATE
]]></from>
<groupby>S.ID_MAREE, S.ID_OP</groupby>
</subquery>
</with>
<!-- PK -->
<select alias="TYPE" type="text">'Engins'</select>
......@@ -40,7 +23,7 @@
END)
]]></select>
<select alias="NAME" type="text">P.NAME</select>
<select alias="NUMERICAL_VALUE" type="number">DECODE(P.IS_BOOLEAN, 1, null, PGM.NUMERICAL_VALUE)</select>
<select alias="NUMERICAL_VALUE" type="number">DECODE(P.IS_BOOLEAN, TRUE, null, PGM.NUMERICAL_VALUE)</select>
<select alias="QUALITATIVE_VALUE_NAME" type="number"><![CDATA[
CASE
WHEN (P.IS_BOOLEAN AND PGM.NUMERICAL_VALUE = 1) THEN 'Oui'
......@@ -57,7 +40,7 @@
<select alias="FRACTION" type="text">COALESCE(FRACTION.name, 'totale')</select>
<select alias="METHODE" type="text">COALESCE(METHOD.name, 'Déclaration d''un professionnel')</select>
<from alias="S">STATION</from>
<from alias="S">&amp;stationTableName</from>
<from join="true">INNER JOIN OPERATION O ON O.ID = S.ID_OP</from>
<from join="true">INNER JOIN PHYSICAL_GEAR PG ON PG.ID = O.PHYSICAL_GEAR_FK</from>
<from join="true">LEFT OUTER JOIN PHYSICAL_GEAR_MEASUREMENT PGM ON PGM.PHYSICAL_GEAR_FK = PG.ID</from>
......@@ -104,7 +87,7 @@
<subselect alias="FRACTION" type="text">COALESCE(FRACTION.name, 'totale')</subselect>
<subselect alias="METHODE" type="text">COALESCE(METHOD.name, 'Déclaration d''un professionnel')</subselect>
<from alias="S">STATION</from>
<from alias="S">&amp;stationTableName</from>
<from join="true">INNER JOIN GEAR_USE_MEASUREMENT PGM ON PGM.OPERATION_FK = S.ID_OP</from>
<from join="true">LEFT OUTER JOIN PMFM ON PMFM.ID = PGM.PMFM_FK</from>
<from join="true">LEFT OUTER JOIN PARAMETER P ON P.ID = PMFM.PARAMETER_FK</from>
......
<?xml version="1.0" encoding="UTF-8"?>
<queries name="extractionCreateSpeciesLengthTable">
<query type="create" temp="false" table="&amp;speciesLengthTableName">
<with alias="BATCH_LENGTH">
<subquery>
<subselect alias="SAMPLE_ID" type="number">SL.SAMPLE_ID</subselect>
<subselect alias="ID" type="number">B.ID</subselect>
<subselect alias="SEX" type="text">(SELECT QV.LABEL FROM SORTING_MEASUREMENT_B SM INNER JOIN QUALITATIVE_VALUE QV ON QV.ID=SM.QUALITATIVE_VALUE_FK WHERE SM.BATCH_FK = B.ID and SM.PMFM_FK=&amp;sexPmfmId)</subselect>
<subselect alias="LENGTH" type="number">SM_LENGTH.NUMERICAL_VALUE</subselect>
<subselect alias="UNIT_NAME" type="number">U_LENGTH.NAME</subselect>
<subselect alias="UNIT_SYMBOL" type="number">U_LENGTH.LABEL</subselect>
<subselect alias="INDIVIDUAL_COUNT" type="number">COALESCE(B.INDIVIDUAL_COUNT,1)</subselect>
<subselect alias="COMMENTS" type="text">B.COMMENTS</subselect>
<subselect alias="PARAMETER_LABEL" type="text">P_LENGTH.LABEL</subselect>
<subselect alias="PARAMETER_NAME" type="text">P_LENGTH.NAME</subselect>
<subselect alias="METHOD_NAME" type="text">REGEXP_REPLACE(M_LENGTH.NAME, '(Mesure|Estimation) par ', '$1 au ' || U_LENGTH.LABEL || ' par ')</subselect>
<from alias="SL">&amp;rawSpeciesListTableName</from>
<from join="true">INNER JOIN BATCH B ON B.PARENT_BATCH_FK=SL.SAMPLE_ID AND B.LABEL LIKE 'SORTING_BATCH_INDIVIDUAL#%'</from>
<from join="true">INNER JOIN SORTING_MEASUREMENT_B SM_LENGTH ON SM_LENGTH.BATCH_FK = B.ID and SM_LENGTH.PMFM_FK in (&amp;lengthTotalCmPmfmId, &amp;lengthCarapaceCmPmfmId)</from>
<from join="true">INNER JOIN PMFM PMFM_LENGTH ON PMFM_LENGTH.ID = SM_LENGTH.PMFM_FK</from>
<from join="true">INNER JOIN PARAMETER P_LENGTH ON P_LENGTH.ID = PMFM_LENGTH.PARAMETER_FK</from>
<from join="true">INNER JOIN METHOD M_LENGTH ON M_LENGTH.ID = PMFM_LENGTH.METHOD_FK</from>
<from join="true">INNER JOIN UNIT U_LENGTH ON U_LENGTH.ID = PMFM_LENGTH.UNIT_FK</from>
</subquery>
</with>
<!-- PK -->
<select alias="TYPE" type="text">'Mesures'</select>
<select alias="ID_CAPTURE" type="text">SL.SAMPLE_ID</select>
<select alias="CRITERE" type="text">B.PARAMETER_NAME</select>
<select alias="VALEUR" type="number">B.LENGTH</select>
<select alias="UNITE" type="text">B.UNIT_NAME</select>
<select alias="POIDS_REF" type="number">null</select>
<select alias="METHOD_WEIGHT" type="text">B.METHOD_NAME</select><!-- -->
<select alias="NOMBRE" type="number">B.INDIVIDUAL_COUNT</select>
<select alias="TAUX_ECH" type="number">null</select>
<select alias="WEIGHT_RTP" type="number">null</select>
<select alias="VALEUR_ALPHANUMERIQUE" type="text">null</select>
<!-- other fields -->
<from alias="SL">&amp;rawSpeciesListTableName</from>
<from join="true">INNER JOIN BATCH_LENGTH B ON B.SAMPLE_ID=SL.SAMPLE_ID</from>
<where>1=1</where>
<!--<groupby>
SAMPLING_TYPE, LANDING_COUNTRY, VESSEL_FLAG_COUNTRY, YEAR, PROJECT, TRIP_CODE, STATION_NUMBER, SPECIES,
CATCH_CATEGORY, LANDING_CATEGORY, COMMERCIAL_SIZE_CATEGORY_SCALE, COMMERCIAL_SIZE_CATEGORY, SUBSAMPLING_CATEGORY, SAMPLE_ID
</groupby>-->
</query>
</queries>
\ No newline at end of file
......@@ -14,11 +14,11 @@
ET afficher les nom vernaculaires dans les UI (nécessaire pour ADAP) -->
<subselect alias="ESPECE" type="text">TN.COMMENTS</subselect>
<subselect alias="ESPECE_COM" type="text">TG.NAME</subselect>
<subselect alias="PRESENTATION" type="text">DECODE(SL.CATCH_CATEGORY, 'DIS', 'GUT - Eviscéré', 'LAN', 'WHL - Entier', null)</subselect>
<subselect alias="PRESENTATION" type="text">DECODE(SL.CATCH_CATEGORY, 'LAN', 'GUT - Eviscéré', null)</subselect>
<subselect alias="TAUX_ECH" type="number">
CASE
WHEN SL.SAMPLING_RATIO is not null THEN SL.SAMPLING_RATIO
WHEN SL.WEIGHT is not null AND SL.WEIGHT != 0 AND SL.SUBSAMPLE_WEIGHT is not null THEN SL.SUBSAMPLE_WEIGHT/SL.WEIGHT
WHEN SL.SAMPLING_RATIO is not null THEN ROUND(SL.SAMPLING_RATIO, 7)
WHEN SL.WEIGHT is not null AND SL.WEIGHT != 0 AND SL.SUBSAMPLE_WEIGHT is not null THEN ROUND(SL.SUBSAMPLE_WEIGHT/SL.WEIGHT, 7)
ELSE 1
END CASE
</subselect>
......@@ -57,7 +57,7 @@
<select alias="PRODUCT_DESTINATION" type="text">null</select>
<select alias="CONVERSION_COEFFICIENT" type="number">null</select> <!-- TODO manage RTP -->
<select alias="ALL_TAUX_ECH" type="text">'1#1#' ||  T.TAUX_ECH</select>
<select alias="ALL_TAUX_ECH" type="text">REPLACE(REGEXP_REPLACE('1#1#' || T.TAUX_ECH, '(\.0)?E0', ''), '.', ',')</select>
<!--
<select alias="" type="text">''</select>
......
......@@ -8,6 +8,12 @@
<select alias="TYPE" type="text">'HH'</select>
<select alias="ID_MAREE" type="number">T.TRIP_CODE</select>
<select alias="ID_OP" type="number">O.ID</select>
<select alias="NUM_OP" type="number"><![CDATA[(
SELECT COUNT(O2.ID) + 1 FROM OPERATION O2
WHERE O2.TRIP_FK = O.TRIP_FK
AND O2.ID <> O.ID
AND COALESCE(O2.FISHING_START_DATE_TIME, O2.START_DATE_TIME) < COALESCE(O.FISHING_START_DATE_TIME, O.START_DATE_TIME)
)]]></select>
<!-- Hidden columns used by linked tables -->
<select alias="STATION_NUMBER" type="hidden">O.ID</select>
......@@ -53,14 +59,15 @@
<select alias="METIER2" type="text">G.LABEL || '_' || TG.NAME</select>
<select alias="METIER3" type="text">null</select>
<select alias="METIER_DCF6" type="text">null</select>
<select alias="MAILL" type="number">(SELECT CAST(ROUND(PGM.NUMERICAL_VALUE) AS INTEGER) FROM PHYSICAL_GEAR_MEASUREMENT PGM WHERE PGM.PHYSICAL_GEAR_FK=PG.ID and PGM.PMFM_FK=&amp;meshSizePmfmId)</select>
<select alias="MAILL" type="number">(SELECT PGM.NUMERICAL_VALUE FROM PHYSICAL_GEAR_MEASUREMENT PGM WHERE PGM.PHYSICAL_GEAR_FK=PG.ID and PGM.PMFM_FK=&amp;meshSizePmfmId)</select>
<select alias="EFFORT" type="number"><![CDATA[
(SELECT ROUND(PGM.NUMERICAL_VALUE) as INTEGER
(SELECT CAST(ROUND(PGM.NUMERICAL_VALUE) as INTEGER)
FROM PHYSICAL_GEAR_MEASUREMENT PGM
WHERE
PGM.PHYSICAL_GEAR_FK=PG.ID and PGM.PMFM_FK in (&headlineCumulativeLengthPmfmId, &beamCumulativeLengthPmfmId, &netLengthPmfmId)
PGM.PHYSICAL_GEAR_FK=PG.ID and PGM.PMFM_FK in (&effortPmfmIds)
)]]></select>
<select alias="DISPO_SELECT" type="text"><![CDATA[
......@@ -76,9 +83,17 @@
<!-- TODO: ajouter un PSFM pour le 2eme dispositif selectif -->
<select alias="DISPO_SELECT2" type="text">null</select>
<!-- TODO: ajouter un PSFM pour le 2eme dispositif repusif ? -->
<select alias="DISPO_REPULS" type="text">null</select>
<select alias="DISPO_REPULS1" type="text">null</select>
<select alias="DISPO_REPULS" type="text"><![CDATA[(
SELECT DECODE(count(*), 1, 'Oui', 'Non')
FROM PHYSICAL_GEAR_MEASUREMENT PGM
WHERE PGM.PHYSICAL_GEAR_FK=PG.ID and PGM.PMFM_FK=&acousticDeterrentDevicePmfmId
)]]></select>
<select alias="DISPO_REPULS1" type="text"><![CDATA[
(SELECT QV.NAME FROM PHYSICAL_GEAR_MEASUREMENT PGM
INNER JOIN QUALITATIVE_VALUE QV ON QV.ID=PGM.QUALITATIVE_VALUE_FK
WHERE
PGM.PHYSICAL_GEAR_FK=PG.ID and PGM.PMFM_FK=&acousticDeterrentDevicePmfmId)]]></select>
<select alias="CAPTURE" type="text"><![CDATA[
CASE WHEN B.ID IS NOT NULL THEN 'Oui'
......@@ -86,7 +101,6 @@
END
]]></select>
<select alias="POIDS_REF_CAPT" type="text">null</select> <!-- Not fill (ADAP) -->
<select alias="NBR_VRAC" type="number">2</select><!-- PR/PNR (ADAP) -->
......@@ -95,7 +109,7 @@
<select alias="GEAR_SPEED" type="number"><![CDATA[
(SELECT VUM.NUMERICAL_VALUE FROM VESSEL_USE_MEASUREMENT VUM
WHERE
VUM.OPERATION_FK=O.ID and VUM.PMFM_FK in (&gearSpeedPmfmId)
VUM.OPERATION_FK=O.ID and VUM.PMFM_FK in (&gearSpeedPmfmIds)
)]]></select>
<select alias="VESSEL_ASSOCIATION" type="number">null</select><!-- TODO: à ajouter au modèle -->
<select alias="IS_CATCH_ON_OPERATION_VESSEL" type="number">null</select><!-- TODO: à ajouter au modèle -->
......
......@@ -11,8 +11,8 @@
<select alias="NUM_VRAC" type="number">SL.NUM_VRAC</select>
<select alias="VRAC_HV" type="text">'Vrac'</select>
<select alias="PR_PNR" type="text">DECODE(SL.CATCH_CATEGORY, 'DIS', 'PNR', 'LAN', 'PR', null)</select>
<select alias="EXHAUSTIF" type="text">'Oui'</select>
<select alias="TAUX_ECH" type="number">null</select>
<select alias="EXHAUSTIF" type="text">'Oui'</select><!-- Non saisissable dans SUMARiS -->
<select alias="TAUX_ECH" type="number">1.0</select><!-- Toujours à 1 dans ADAP -->
<select alias="POIDS_REF_VRAC" type="number">null</select>
<from alias="SL">&amp;rawSpeciesListTableName</from>
......
......@@ -20,20 +20,28 @@
<select alias="PUISSANCE" type="number">VF.ADMINISTRATIVE_POWER</select>
<select alias="DATE_DEBUT" type="date">TO_CHAR(T.DEPARTURE_DATE_TIME, 'DD-MM-YYYY HH24:MI:SS')</select>
<select alias="DATE_FIN" type="date">TO_CHAR(T.RETURN_DATE_TIME, 'DD-MM-YYYY HH24:MI:SS')</select>
<select alias="PORT_DEBARQUEMENT" type="text">L.LABEL</select>
<select alias="PORT_DEBARQUEMENT" type="text">L.NAME</select>
<select alias="DATE_VENTE" type="date">TO_CHAR(SALE.START_DATE_TIME, 'DD-MM-YYYY')</select>
<select alias="OBSERVATEUR1" type="text">(CASE WHEN (OBS1.ID IS NOT NULL) THEN
upper(OBS1.LAST_NAME) || ' ' || OBS1.FIRST_NAME
<select alias="OBSERVATEUR1" type="text">(CASE
WHEN (OBS1.ID IS NOT NULL) THEN upper(OBS1.LAST_NAME) || ' ' || OBS1.FIRST_NAME
ELSE null
END)</select>
<select alias="OBSERVATEUR2" type="text">(CASE WHEN (OBS2.ID IS NOT NULL) THEN
upper(OBS2.LAST_NAME) || ' ' || OBS2.FIRST_NAME
<select alias="OBSERVATEUR2" type="text">(CASE
WHEN (OBS2.ID IS NOT NULL) THEN upper(OBS2.LAST_NAME) || ' ' || OBS2.FIRST_NAME
ELSE null
END)</select>
<select alias="SERVICE" type="text">COALESCE(OBS1_DEP.NAME, D.NAME)</select>
<select alias="VALID_PROGRAMME" type="text">(case when (T.QUALIFICATION_DATE is NOT NULL) then 'Données valides' end)</select>
<select alias="VALID_STE" type="text">(case when (T.VALIDATION_DATE is NOT NULL) then 'Données valides' else 'Non' end)</select>
<select alias="VALID_PROGRAMME" type="text">(CASE
WHEN (T.QUALIFICATION_DATE is NOT NULL) THEN 'Données valides'
ELSE null
END)</select>
<select alias="VALID_STE" type="text">CAST(CASE
WHEN (T.VALIDATION_DATE is NOT NULL) THEN 'Données valides'
ELSE 'Non'
END as VARCHAR(15))</select>
<select alias="COMMENTAIRE" type="text">T.COMMENTS</select>
......@@ -42,7 +50,7 @@
(SELECT QV.LABEL FROM VESSEL_USE_MEASUREMENT VUM
INNER JOIN QUALITATIVE_VALUE QV ON QV.ID=VUM.QUALITATIVE_VALUE_FK
WHERE
VUM.TRIP_FK=T.ID and VUM.PMFM_FK=&contractCodePmfmId)]]></select>
VUM.TRIP_FK=T.ID and VUM.PMFM_FK IN (&contractCodePmfmIds))]]></select>
<!-- TODO Ajouter cette colonne dans l'entité Trip -->
<select alias="SAMPLING_STRATA" type="text">null</select>
......
......@@ -3,6 +3,7 @@ sumaris.name=SUMARiS
sumaris.persistence.liquibase.changelog.path=classpath:net/sumaris/core/db/changelog/db-changelog-master.xml
sumaris.test.data.common=data-hsqldb-01-common.xml
sumaris.test.data.additional=data-hsqldb-02-program.xml,data-hsqldb-03-data.xml,data-hsqldb-04-pendings.xml,data-hsqldb-05-extracts.xml,data-hsqldb-06-configs.xml,data-hsqldb-07-backgrounds.xml
sumaris.cache.enabled=false
# Spring: Common properties
# see https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
......@@ -12,7 +13,7 @@ spring.main.banner-mode=off
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.username=sa
spring.datasource.password=
#spring.datasource.url=jdbc:hsqldb:hsql://localhost/sumaris
spring.datasource.url=jdbc:hsqldb:hsql://localhost/sumaris
spring.datasource.platform=hsqldb
spring.datasource.initialization-mode=always
......
......@@ -32,6 +32,7 @@ import net.sumaris.core.vo.administration.programStrategy.ProgramVO;
import net.sumaris.core.vo.administration.programStrategy.StrategyVO;
import net.sumaris.core.vo.administration.user.DepartmentVO;
import net.sumaris.core.vo.administration.user.PersonVO;
import net.sumaris.core.vo.data.VesselSnapshotVO;
import net.sumaris.core.vo.referential.PmfmVO;
import net.sumaris.core.vo.referential.ReferentialTypeVO;
import net.sumaris.core.vo.referential.ReferentialVO;
......@@ -66,6 +67,8 @@ public class CacheConfiguration extends CachingConfigurerSupport {
String REFERENTIAL_TYPES = "net.sumaris.core.dao.referential.allTypes";
String LOCATION_LEVEL_BY_LABEL = "net.sumaris.core.dao.referential.findByUniqueLabel";
String VESSEL_SNAPSHOT_BY_ID_AND_DATE = "net.sumaris.core.service.data.vesselSnapshotById";
String PROGRAM_BY_ID = "net.sumaris.core.dao.administration.programStrategy.programById";
String PROGRAM_BY_LABEL = "net.sumaris.core.dao.administration.programStrategy.programByLabel";
......@@ -112,6 +115,7 @@ public class CacheConfiguration extends CachingConfigurerSupport {
Caches.createHeapCache(cacheManager, Names.DEPARTMENT_BY_LABEL, String.class, DepartmentVO.class, CacheDurations.DEFAULT, 600);
Caches.createHeapCache(cacheManager, Names.PERSON_BY_ID, Integer.class, PersonVO.class, CacheDurations.DEFAULT, 600);
Caches.createHeapCache(cacheManager, Names.PERSON_BY_PUBKEY, String.class, PersonVO.class, CacheDurations.DEFAULT, 600);
Caches.createHeapCache(cacheManager, Names.VESSEL_SNAPSHOT_BY_ID_AND_DATE, VesselSnapshotVO.class, CacheDurations.DEFAULT, 600);
Caches.createCollectionHeapCache(cacheManager, Names.STRATEGIES_BY_FILTER, StrategyVO.class, CacheDurations.DEFAULT, 100);
Caches.createHeapCache(cacheManager, Names.STRATEGY_BY_ID, Integer.class, StrategyVO.class, CacheDurations.LONG, 500);
Caches.createHeapCache(cacheManager, Names.STRATEGY_BY_LABEL, String.class, StrategyVO.class, CacheDurations.LONG, 500);
......
......@@ -69,6 +69,7 @@ public class LandingRepositoryImpl
.and(hasTripId(filter.getTripId()))
.and(betweenDate(filter.getStartDate(), filter.getEndDate()))
.and(hasLocationId(filter.getLocationId()))
.and(inLocationIds(filter.getLocationIds()))
.and(hasVesselId(filter.getVesselId()))
.and(hasExcludeVesselIds(filter.getExcludeVesselIds()));
}
......
......@@ -28,9 +28,11 @@ import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.data.Landing;
import net.sumaris.core.vo.data.LandingVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.data.jpa.domain.Specification;
import javax.persistence.criteria.ParameterExpression;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
......@@ -42,6 +44,7 @@ public interface LandingSpecifications extends RootDataSpecifications<Landing> {
String TRIP_IDS_PARAM = "tripIds";
String TRIP_IDS_SET_PARAM = "tripIdsSet";
String LOCATION_ID_PARAM = "locationId";
String LOCATION_IDS_PARAM = "locationIds";
String VESSEL_ID_PARAM = "vesselId";
String EXCLUDE_VESSEL_IDS_PARAM = "excludeVesselIds";
String EXCLUDE_VESSEL_IDS_SET_PARAM = "excludeVesselIdsSet";
......@@ -96,6 +99,16 @@ public interface LandingSpecifications extends RootDataSpecifications<Landing> {
return specification;
}
default Specification<Landing> inLocationIds(Integer... locationIds) {
if (ArrayUtils.isEmpty(locationIds)) return null;
BindableSpecification<Landing> specification = BindableSpecification.where((root, query, criteriaBuilder) -> {
ParameterExpression<Collection> param = criteriaBuilder.parameter(Collection.class, LOCATION_IDS_PARAM);
return criteriaBuilder.in(root.get(Landing.Fields.LOCATION).get(IEntity.Fields.ID)).value(param);
});
specification.addBind(LOCATION_IDS_PARAM, Arrays.asList(locationIds));
return specification;
}
default Specification<Landing> hasVesselId(Integer vesselId) {
BindableSpecification<Landing> specification = BindableSpecification.where((root, query, criteriaBuilder) -> {
ParameterExpression<Integer> param = criteriaBuilder.parameter(Integer.class, VESSEL_ID_PARAM);
......
......@@ -48,6 +48,7 @@ public enum PmfmEnum implements Serializable {
RANDOM_SAMPLING_OPERATION(26, "RANDOM_SAMPLING_OPERATION"),
SELECTIVITY_DEVICE(4, "SELECTIVITY_DEVICE"),
ACOUSTIC_DETERRENT_DEVICE(5, "ACOUSTIC_DETERRENT_DEVICE"),
SUBSTRATE_TYPE(31, "SUBSTRATE_TYPE"),
SEA_STATE(33, "SEA_STATE"),
TRIP_PROGRESS(34,"TRIP_PROGRESS"),
......@@ -73,6 +74,12 @@ public enum PmfmEnum implements Serializable {
IS_DEAD(94, "IS_DEAD"),
DISCARD_REASON(95, "DISCARD_REASON"),
@Deprecated
/**
* @deprecated Use CONTRACT_CODE instead
*/
SELF_SAMPLING_PROGRAM(28, "SELF_SAMPLING_PROGRAM"),
CONTROL_TYPE(130, "CONTROL_TYPE"),
PRESERVATION(150, "PRESERVATION"),
......
......@@ -23,12 +23,15 @@ package net.sumaris.core.service.data;
*/