mailman.cloud.codelutin.com
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

Observe-commits

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2018 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2017 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2016 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2015 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2014 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2013 -----
  • December
  • November
  • October
  • September
observe-commits@list.forge.codelutin.com

  • 7199 discussions
[Git][ultreiaio/ird-observe][develop] 14 commits: Rapport Liste des captures de faune accessoire selon le type de banc, filtrées...
by Tony CHEMIT (@tchemit) 16 Nov '22

16 Nov '22
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 6684283f by Tony Chemit at 2022-11-16T02:11:22+01:00 Rapport Liste des captures de faune accessoire selon le type de banc, filtrées par groupe - Closes #2532 - - - - - 18379b3e by Tony Chemit at 2022-11-16T02:11:22+01:00 GUI - use resetEdit state when reset entry on content table - - - - - 12dfe7b6 by Tony Chemit at 2022-11-16T02:11:22+01:00 GUI - Sur échantillons PS observations saisis par lots, migrés vers 9.0, valeurs étranges sur le champ poids individuel - Closes #2503 - - - - - 46e605b6 by Tony Chemit at 2022-11-16T02:11:22+01:00 Report API - Add TimeLog in DefaultReportRequestExecutor - - - - - 34b3dec6 by Tony Chemit at 2022-11-16T02:11:22+01:00 Report API - Clean ReportRequest code - - - - - 0ac163ca by Tony Chemit at 2022-11-16T02:11:22+01:00 Report API - Improve executeReportRequest method (one for simple request and one for request with repeat) - - - - - 5694c752 by Tony Chemit at 2022-11-16T02:11:22+01:00 Report API - Improve Sum operations (can now set x and y and better round of double) - - - - - 357f447c by Tony Chemit at 2022-11-16T02:11:22+01:00 Report API - add safe guard tests (to be able to copy partial matrix) - - - - - 6295fc29 by Tony Chemit at 2022-11-16T02:11:22+01:00 Report API - Be able to order variables and repeat variables - - - - - bacdc4d1 by Tony Chemit at 2022-11-16T02:11:22+01:00 Tck Report - columnHeaders can be null Tck Report - Improve when to deliver asserts - - - - - be74c546 by Tony Chemit at 2022-11-16T02:11:22+01:00 Report GUI - Manage report with no columns and row headers (everything is coming from the report result to be able to manage dynamic columns) - - - - - 81146b7a by Tony Chemit at 2022-11-16T02:11:22+01:00 Report GUI - Respect report variables order in Report model - - - - - c0fab2d0 by Tony Chemit at 2022-11-16T02:11:22+01:00 Report API - Improve ReportVariable (add isEmpty and computeIndexList methods) - - - - - f0e84c38 by Tony Chemit at 2022-11-16T02:11:22+01:00 Report API - Add new neutral operations - - - - - 24 changed files: - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ResetEntry.java - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUIHandler.java - core/api/dto/src/main/resources/observe-reports.properties - − core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java - core/services/test/src/main/java/fr/ird/observe/services/service/ReportFixture.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchReportFixture.java - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatch.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatch.properties - toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportRequest.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportRequestExecutor.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportVariable.java - + toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ComputeDynamicHeader.java - + toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/CopyRepeatVariableToFirstColumn.java - + toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ExecuteRequestAndReorganizeCountByRepeatVariable.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ExecuteRequests.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumColumn.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumFloatColumn.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumIntColumn.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumIntRow.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumRow.java - toolkit/persistence/src/main/java/fr/ird/observe/spi/report/DefaultReportRequestExecutor.java Changes: ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java ===================================== @@ -43,10 +43,10 @@ import java.net.URL; import java.nio.file.Files; import java.util.Collections; import java.util.Date; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.TreeMap; import java.util.stream.Collectors; /** @@ -81,7 +81,7 @@ public class ReportModel extends AdminActionModel { /** * les variables utilisées pour le report. */ - protected final Map<String, Object> variables; + protected final Map<String, Object> variables = new LinkedHashMap<>(); /** * la fichier contenant la définition des reports. */ @@ -128,7 +128,6 @@ public class ReportModel extends AdminActionModel { public ReportModel() { super(AdminStep.REPORT); - variables = new TreeMap<>(); // quand le type de modèle change, on mets à jour les rapports disponibles addPropertyChangeListener(REPORT_FILE_PROPERTY_NAME, evt -> updateReports()); } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java ===================================== @@ -149,12 +149,11 @@ public class ResultTableModel extends AbstractTableModel { rowNames.addAll(Arrays.asList(report.getRowHeaders())); } - withColumnHeader = !columnNames.isEmpty(); - withRowHeader = !rowNames.isEmpty(); - table.setTableHeader(!withColumnHeader ? null : tableHeader); - table.createDefaultColumnsFromModel(); int nbRows = incomingData.getHeight(); int nbCols = incomingData.getWidth(); + + withColumnHeader = !columnNames.isEmpty(); + withRowHeader = !rowNames.isEmpty(); if (withRowHeader) { // on ajoute une première colonne aux données nbCols += 1; @@ -162,6 +161,22 @@ public class ResultTableModel extends AbstractTableModel { incomingData.setX(1); } + if (!withColumnHeader && !withRowHeader) { + // let's say we always use columns from incomingData + table.setTableHeader(tableHeader); + for (int i = 0; i < nbCols; i++) { + columnNames.add((String) incomingData.getValue(i, 0)); + } + incomingData.setY(-1); + withColumnHeader = true; + nbRows--; + + } else { + table.setTableHeader(!withColumnHeader ? null : tableHeader); + } + table.createDefaultColumnsFromModel(); + + data.setHeight(nbRows); data.setWidth(nbCols); @@ -185,7 +200,9 @@ public class ResultTableModel extends AbstractTableModel { } else if (withColumnHeader) { } - data.copyData(incomingData); + if (nbCols > 0) { + data.copyData(incomingData); + } fireTableStructureChanged(); table.revalidate(); table.repaint(); @@ -220,7 +237,7 @@ public class ResultTableModel extends AbstractTableModel { } public String getClipboardContent(boolean copyRowHeaders, boolean copyColumnHeaders) { - return getDataContent(copyRowHeaders, copyColumnHeaders, true,'\t'); + return getDataContent(copyRowHeaders, copyColumnHeaders, true, '\t'); } public String getCsvContent() { ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ResetEntry.java ===================================== @@ -59,7 +59,12 @@ public final class ResetEntry extends ContentTableUIActionSupport<ContentTableUI } } else { // reset existing entry - tableModel.resetEditBean(); + ui.getStates().setResetEdit(true); + try { + tableModel.resetEditBean(); + } finally { + ui.getStates().setResetEdit(false); + } } } ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUIHandler.java ===================================== @@ -72,12 +72,11 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { private final PropertyChangeListener speciesChanged; public SampleUIHandler() { - weightChanged = evt -> onWeightChanged((Float) evt.getNewValue()); - lengthChanged = evt -> onLengthChanged((Float) evt.getNewValue()); + weightChanged = evt -> onWeightChanged((Float) evt.getNewValue(), !ui.getStates().isResetEdit()); + lengthChanged = evt -> onLengthChanged((Float) evt.getNewValue(), !ui.getStates().isResetEdit()); speciesChanged = evt -> onSpeciesChanged((SpeciesReference) evt.getNewValue()); } - @Override public void onInit(SampleUI ui) { super.onInit(ui); @@ -97,8 +96,8 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { public void onSelectedRowChanged(SampleMeasureDto tableEditBean, SampleMeasureDto previousRowBean, boolean notPersisted, boolean newRow) { - onLengthChanged(tableEditBean.getLength()); - onWeightChanged(tableEditBean.getWeight()); + onLengthChanged(tableEditBean.getLength(), false); + onWeightChanged(tableEditBean.getWeight(), false); SampleUIModel sampleModel = getModel(); @@ -209,6 +208,9 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { } public void startEditTableEditBean(SampleMeasureDto tableEditBean) { + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_WEIGHT, weightChanged); + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_LENGTH, lengthChanged); + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_SPECIES, speciesChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_WEIGHT, weightChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_LENGTH, lengthChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_SPECIES, speciesChanged); @@ -249,9 +251,9 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { acquisitionModeGroup.setSelectedValue(acquisitionMode); } - protected void onWeightChanged(Float newValue) { + protected void onWeightChanged(Float newValue, boolean realChange) { SampleMeasureDto tableEditBean = ui.getModel().getStates().getTableEditBean(); - if (tableEditBean.getAcquisitionMode() == 1) { + if (realChange && tableEditBean.getAcquisitionMode() == 1) { tableEditBean.setIsWeightComputed(false); } if (newValue == null) { @@ -259,9 +261,11 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { } } - protected void onLengthChanged(Float newValue) { + protected void onLengthChanged(Float newValue, boolean realChange) { SampleMeasureDto tableEditBean = ui.getModel().getStates().getTableEditBean(); - tableEditBean.setIsLengthComputed(false); + if (realChange) { + tableEditBean.setIsLengthComputed(false); + } if (newValue == null) { tableEditBean.setLengthMeasureMethod(null); } ===================================== core/api/dto/src/main/resources/observe-reports.properties ===================================== @@ -697,26 +697,26 @@ report.psObservationTargetDiscardedByAssociation.request.19=0,3|row|\ and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) ################################################################################ -## Captures accessoires observées +## Captures observées ################################################################################ -report.psObservationAccessoryCatch.modelType=PS -report.psObservationAccessoryCatch.name=Observations - Liste des captures accessoires selon le type de banc, filtrées par groupe -report.psObservationAccessoryCatch.description=Afficher les captures accessoires par groupe d'espèce\nLes poids sont exprimés en tonnes. -report.psObservationAccessoryCatch.columns=Espèce, Banc libre, Banc objet -report.psObservationAccessoryCatch.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code -report.psObservationAccessoryCatch.repeatVariable.speciesId=java.lang.String|\ +report.psObservationCatch.modelType=PS +report.psObservationCatch.name=Observations - Liste des captures selon le type de banc, filtrées par groupe +report.psObservationCatch.description=Afficher les captures par groupe d'espèce\nLes poids sont exprimés en tonnes. +report.psObservationCatch.columns=Espèce, Banc libre, Banc objet +report.psObservationCatch.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code +report.psObservationCatch.repeatVariable.speciesId=java.lang.String|\ Select e.id From SpeciesImpl e \ Where e.speciesGroup.id = :speciesGroup \ Order By e.homeId -report.psObservationAccessoryCatch.request.1=0,0|row|\ +report.psObservationCatch.request.1=0,0|row|\ Select \ concat('[FAO]', (case when e.faoCode is not null then e.faoCode else '-' end), \ ' [sc]', (case when e.scientificLabel is not null then e.scientificLabel else '-' end), \ ' [fr]', (case when e.label2 is not null then e.label2 else '-' end)) \ From SpeciesImpl e \ Where e.id = :speciesId -report.psObservationAccessoryCatch.request.1.repeat=speciesId|column -report.psObservationAccessoryCatch.request.2=1,0|row|\ +report.psObservationCatch.request.1.repeat=speciesId|column +report.psObservationCatch.request.2=1,0|row|\ Select \ case when Count(ca) > 0 then \ concat('+', \ @@ -731,8 +731,8 @@ report.psObservationAccessoryCatch.request.2=1,0|row|\ Join c.catches ca \ with ca.species.id = :speciesId \ Where m.id In :tripId -report.psObservationAccessoryCatch.request.2.repeat=speciesId|column -report.psObservationAccessoryCatch.request.3=2,0|row|\ +report.psObservationCatch.request.2.repeat=speciesId|column +report.psObservationCatch.request.3=2,0|row|\ Select \ case when Count(ca) > 0 then \ concat('+', \ @@ -747,7 +747,7 @@ report.psObservationAccessoryCatch.request.3=2,0|row|\ Join c.catches ca \ with ca.species.id = :speciesId \ Where m.id In :tripId -report.psObservationAccessoryCatch.request.3.repeat=speciesId|column +report.psObservationCatch.request.3.repeat=speciesId|column ################################################################################ ## Captures accessoires par speciesGroup d'espèces ################################################################################ ===================================== core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java deleted ===================================== @@ -1,38 +0,0 @@ -package fr.ird.observe.services.local.service; - -/*- - * #%L - * ObServe Core :: Services :: Local - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ird.observe.services.service.ReportServiceFixtures; -import org.junit.AfterClass; - -public class ReportServiceLocalReadTest extends GeneratedReportServiceLocalReadTest { - - @AfterClass - public static void afterClass() { - if (!ReportServiceFixtures.WITH_ASSERT) { - System.out.println("New asserts:\n" + String.join("\n", ReportServiceFixtures.getAsserts())); - ReportServiceFixtures.getAsserts().clear(); - } - } - -} ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/ReportFixture.java ===================================== @@ -76,6 +76,7 @@ public abstract class ReportFixture { } public final DataMatrix execute(ReportService service, Report report) { + log.warn("Starting report {}", report.getName()); return service.executeReport(report, getTripIds()); } @@ -127,6 +128,8 @@ public abstract class ReportFixture { for (int i = 0; i < rows; i++) { ReportServiceFixtures.writeArrayAssert(String.format("result.%d", i), actual.getData()[i]); } + System.out.println("New asserts:\n" + String.join("\n", ReportServiceFixtures.getAsserts())); + ReportServiceFixtures.getAsserts().clear(); } } @@ -159,7 +162,11 @@ public abstract class ReportFixture { Assert.assertEquals(rows, report.getRows()); Assert.assertEquals(columns, report.getColumns()); - Assert.assertArrayEquals(columnsHeader, report.getColumnHeaders()); + if (report.getColumnHeaders() == null) { + Assert.assertEquals(0, columnsHeader.length); + } else { + Assert.assertArrayEquals(columnsHeader, report.getColumnHeaders()); + } if (report.getRowHeaders() == null) { Assert.assertEquals(0, rowsHeader.length); } else { @@ -168,7 +175,11 @@ public abstract class ReportFixture { } else { ReportServiceFixtures.addAssert("syntax.rows", report.getRows()); ReportServiceFixtures.addAssert("syntax.columns", report.getColumns()); - ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader", (Object[]) report.getColumnHeaders()); + if (report.getRowHeaders() == null) { + ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader"); + } else { + ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader", (Object[]) report.getColumnHeaders()); + } if (report.getRowHeaders() == null) { ReportServiceFixtures.writeArrayAssert("syntax.rowsHeader"); } else { ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchReportFixture.java ===================================== @@ -36,7 +36,7 @@ import java.util.Iterator; * @since 1.9 */ @AutoService(ReportFixture.class) -public class PsObservationAccessoryCatchReportFixture extends ReportFixture { +public class PsObservationCatchReportFixture extends ReportFixture { @Override public void assertSyntax(Report report) { ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatch.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatch.properties ===================================== @@ -19,8 +19,24 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### +syntax.name=Observations - Liste des captures selon le type de banc, filtrées par groupe +syntax.description=Afficher les captures par groupe d'espèce-Les poids sont exprimés en tonnes. +syntax.columns=3 +syntax.rows=-1 +syntax.columnsHeader=Espèce^Banc libre^Banc objet +syntax.nbRequests=3 +result.columns=3 +result.rows=49 result.0=[FAO]CCB [sc]Carcharhinus brevipinna [fr]Requin tisserand^-^- result.1=[FAO]ALS [sc]Carcharhinus albimarginatus [fr]Requin pointe blanche^-^- +result.2=[FAO]AML [sc]Carcharhinus amblyrhynchos [fr]Grey reef shark^-^- +result.3=[FAO]PTH [sc]Alopias pelagicus [fr]Renard pélagique^-^- +result.4=[FAO]BTH [sc]Alopias superciliosus [fr]Renard à gros yeux^-^- +result.5=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^-^+ Effectif : 3 Poids total (t) : 12.0 +result.6=[FAO]BLR [sc]Carcharhinus melanopterus [fr]Requin pointes noires^-^- +result.7=[FAO]BRO [sc]Carcharhinus brachyurus [fr]Requin cuivre^-^- +result.8=[FAO]WSH [sc]Carcharodon carcharias [fr]Grand requin blanc^-^- +result.9=[FAO]CCE [sc]Carcharhinus leucas [fr]Requin bouledogue^-^- result.10=[FAO]CCL [sc]Carcharhinus limbatus [fr]Requin bordé^-^- result.11=[FAO]CCP [sc]Carcharhinus plumbeus [fr]Requin gris^-^- result.12=[FAO]FAL [sc]Carcharhinus falciformis [fr]Requin soyeux^-^- @@ -28,10 +44,9 @@ result.13=[FAO]OCS [sc]Carcharhinus longimanus [fr]Requin océanique^-^- result.14=[FAO]CWZ [sc]Carcharhinus spp [fr]Requins Carcharhinus nca^-^- result.15=[FAO]DUS [sc]Carcharhinus obscurus [fr]Requin sombre^-^- result.16=[FAO]SHL [sc]Etmopterus spp [fr]Genre Etmopterus^-^- -result.17=[FAO]THR [sc]Alopias spp [fr]Renards de mer nca ^-^- +result.17=[FAO]THR [sc]Alopias spp [fr]Renards de mer nca^-^- result.18=[FAO]RSK [sc]Carcharhinidae spp [fr]Famille Carcharhinidae^-^- result.19=[FAO]MSK [sc]Lamnidae [fr]Famille Lamnidae^-^- -result.2=[FAO]AML [sc]Carcharhinus amblyrhynchos [fr]Grey reef shark^-^- result.20=[FAO]2FOD [sc]Odontaspididae [fr]Odontaspididae^-^- result.21=[FAO]2FRH [sc]Rhincodontidae [fr]Famille Rhincodontidae^-^- result.22=[FAO]SPY [sc]Sphyrnidae [fr]Famille Sphyrnidae^-^- @@ -42,18 +57,16 @@ result.26=[FAO]LMA [sc]Isurus paucus [fr]Petite taupe, Mako^-^- result.27=[FAO]MAK [sc]Isurus spp [fr]Taupes^-^- result.28=[FAO]LMP [sc]Megachasma pelagios [fr]Requin grande gueule^-^- result.29=[FAO]CVX [sc]Carcharhiniformes [fr]Ordre Carcharhiniformes^-^- -result.3=[FAO]PTH [sc]Alopias pelagicus [fr]Renard pélagique^-^- result.30=[FAO]HDQ [sc]Heterodontiformes [fr]Ordre Heterodontiformes^-^- result.31=[FAO]HXW [sc]Hexanchiformes [fr]Ordre Hexanchiformes^-^- result.32=[FAO]LMZ [sc]Lamniformes [fr]Ordre Lamniformes^-^- result.33=[FAO]OCX [sc]Orectolobiformes [fr]Ordre Orectolobiformes^-^- -result.34=[FAO]PWS [sc]Pristiophorus spp [fr]Requins-scies nca ^-^- +result.34=[FAO]PWS [sc]Pristiophorus spp [fr]Requins-scies nca^-^- result.35=[FAO]OSF [sc]Stegostoma fasciatum [fr]Requin zèbre^-^- result.36=[FAO]SHX [sc]Squaliformes [fr]Ordre Squaliformes^-^- -result.37=[FAO]ASK [sc]Squatinidae [fr]Anges de mer nca ^-^- +result.37=[FAO]ASK [sc]Squatinidae [fr]Anges de mer nca^-^- result.38=[FAO]BSH [sc]Prionace glauca [fr]Peau bleue^-^- result.39=[FAO]POR [sc]Lamna nasus [fr]Requin taupe commun^-^- -result.4=[FAO]BTH [sc]Alopias superciliosus [fr]Renard à gros yeux^-^- result.40=[FAO]PSK [sc]Pseudocarcharias kamoharai [fr]Requin crocodile^-^- result.41=[FAO]2REX [sc]Requin non identifié [fr]Requin non identifié^-^- result.42=[FAO]BSK [sc]Cetorhinus maximus [fr]Requin pèlerin^-^- @@ -63,17 +76,3 @@ result.45=[FAO]SPL [sc]Sphyrna lewini [fr]Requin marteau halicorne^-^- result.46=[FAO]SPK [sc]Sphyrna mokarran [fr]Grand requin marteau^-^- result.47=[FAO]SPN [sc]Sphyrna spp [fr]Requins marteau nca^-^- result.48=[FAO]SPZ [sc]Sphyrna zygaena [fr]Requin marteau commun^-^- -result.5=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^-^+ Effectif : 3 Poids total (t) : 12.0 -result.6=[FAO]BLR [sc]Carcharhinus melanopterus [fr]Requin pointes noires^-^- -result.7=[FAO]BRO [sc]Carcharhinus brachyurus [fr]Requin cuivre^-^- -result.8=[FAO]WSH [sc]Carcharodon carcharias [fr]Grand requin blanc^-^- -result.9=[FAO]CCE [sc]Carcharhinus leucas [fr]Requin bouledogue^-^- -result.columns=3 -result.rows=49 -syntax.columns=3 -syntax.columnsHeader=Espèce^Banc libre^Banc objet -syntax.description=Afficher les captures accessoires par groupe d'espèce-Les poids sont exprimés en tonnes. -syntax.name=Observations - Liste des captures accessoires selon le type de banc, filtrées par groupe -syntax.nbRequests=3 -syntax.rows=-1 -syntax.rowsHeader= ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java ===================================== @@ -159,7 +159,13 @@ public class DataMatrix implements JsonAware { log.debug(String.format("copying incoming matrix (dim: %s, location: %s)", incoming.getDimension(), incoming.getLocation())); for (int i = 0; i < width; i++) { + if (x + i < 0) { + continue; + } for (int j = 0; j < height; j++) { + if (y + j < 0) { + continue; + } Serializable value = incoming.getValue(i, j); setValue(x + i, y + j, value); } ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java ===================================== @@ -319,12 +319,14 @@ public class ReportBuilder { Map.Entry<String, String> entry = itr.next(); String key = entry.getKey(); if (!key.startsWith(VARIABLE_PREFIX)) { - continue; } String operations = entry.getValue(); String id = key.substring(VARIABLE_PREFIX.length()); - + int indexOf = id.indexOf("."); + if (indexOf > -1) { + id = id.substring(indexOf + 1); + } // on interdit la surcharge d'une variable déjà trouvée pour le report if (ids.contains(id)) { throw new IllegalArgumentException("La variable " + id + " est déjà définie pour le report " + reportName); @@ -359,12 +361,14 @@ public class ReportBuilder { Map.Entry<String, String> entry = itr.next(); String key = entry.getKey(); if (!key.startsWith(REPEAT_VARIABLE_PREFIX)) { - continue; } String operations = entry.getValue(); String id = key.substring(REPEAT_VARIABLE_PREFIX.length()); - + int indexOf = id.indexOf("."); + if (indexOf > -1) { + id = id.substring(indexOf + 1); + } // on interdit la surcharge d'une variable déjà trouvée pour le report if (ids.contains(id)) { throw new IllegalArgumentException("La variable de répétition " + id + " est déjà définie pour le report " + reportName); ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportRequest.java ===================================== @@ -27,9 +27,9 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import java.awt.Point; import java.io.Serializable; -import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.TreeMap; /** * Pour caractériser une requète à lancer dans un report. @@ -90,46 +90,17 @@ public class ReportRequest implements Serializable, JsonAware { } public static Map<String, Object> extractParams(Report report, Set<String> tripId) { - - Map<String, Object> params = new HashMap<>(); - + Map<String, Object> params = new TreeMap<>(); params.put(TRIP_ID_VARIABLE, tripId); - for (ReportVariable<?> variable : report.getVariables()) { - String name = variable.getName(); - Object value = variable.getSelectedValue(); - params.put(name, value); - } return params; } -// public static Object[] getParams(String request, Map<String, Object> params) { -// -// // on parcourt la liste de tous les paramètres pour savoir si on doit -// // les inclure pour la requête donnée : -// List<String> namesToUsed = new ArrayList<>(); -// for (String paramName : params.keySet()) { -// if (request.contains(":" + paramName)) { -// namesToUsed.add(paramName); -// } -// } -// Object[] datas = new Object[namesToUsed.size() * 2]; -// int index = 0; -// for (String name : namesToUsed) { -// Object value = params.get(name); -// datas[index * 2] = name; -// datas[index * 2 + 1] = value; -// index++; -// } -// namesToUsed.clear(); -// return datas; -// } - public ReportRequest(RequestLayout layout, int x, int y, ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportRequestExecutor.java ===================================== @@ -29,6 +29,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; /** * To execute a request. @@ -49,11 +50,20 @@ public interface ReportRequestExecutor { <V> void populateVariable(ReportVariable<V> variable, Map<String, Object> vars); - default DataMatrix executeReportRequest(ReportRequest request, Report report, Set<String> dataId, ReportVariable<?> repeatValues) { + default DataMatrix executeReportRequest(ReportRequest request, Report report, Set<String> dataId) { Map<String, Object> params = ReportRequest.extractParams(report, dataId); - if (repeatValues == null) { - return executeReportRequest(request, params); + String hql = request.getRequest(); + for (ReportVariable<?> repeatVariable : report.getRepeatVariables()) { + if (hql.contains(":" + repeatVariable.getName() + " ")) { + // add this repeat variable values to parameters + params.put(repeatVariable.getName(), repeatVariable.computeIndexList()); + } } + return executeReportRequest(request, params); + } + + default DataMatrix executeReportRequest(ReportRequest request, Report report, Set<String> dataId, ReportVariable<?> repeatValues) { + Map<String, Object> params = ReportRequest.extractParams(report, dataId); DataMatrix result = new DataMatrix(); for (Object repeatValue : repeatValues.getValues()) { params.put(request.getRepeat().getVariableName(), repeatValue); @@ -97,15 +107,27 @@ public interface ReportRequestExecutor { return result; } - @SuppressWarnings("unchecked") default void doPopulateRepeatVariables(Report report, Set<String> tripId) { Map<String, Object> vars = ReportRequest.extractParams(report, tripId); - for (@SuppressWarnings("rawtypes") ReportVariable variable : report.getRepeatVariables()) { - String hql = variable.getRequest(); - List<Object> universe = executeRequest(hql, vars); - LinkedHashSet<Object> values = new LinkedHashSet<>(universe); - variable.setValues(values); + for (ReportVariable<?> variable : report.getRepeatVariables()) { + doPopulateRepeatVariable(report, tripId, new TreeMap<>(vars), variable); + } + } + + default <R> void doPopulateRepeatVariable(Report report, Set<String> tripId, Map<String, Object> vars, ReportVariable<R> variable) { + String hql = variable.getRequest(); + for (ReportVariable<?> repeatVariable : report.getRepeatVariables()) { + if (variable.equals(repeatVariable)) { + continue; + } + if (hql.contains(":" + repeatVariable.getName() + " ")) { + // add this repeat variable values to parameters + vars.put(repeatVariable.getName(), repeatVariable.computeIndexList()); + } } + List<R> universe = executeRequest(hql, vars); + LinkedHashSet<R> values = new LinkedHashSet<>(universe); + variable.setValues(values); } private DataMatrixDimension computeDimension(ReportRequest request, List<?> list) { ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportVariable.java ===================================== @@ -22,10 +22,15 @@ package fr.ird.observe.dto.report; * #L% */ +import fr.ird.observe.dto.ToolkitId; import io.ultreia.java4all.util.json.JsonAware; import java.io.Serializable; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; import java.util.Set; +import java.util.stream.Collectors; /** * La définition d'une variable utilisable dans un report. @@ -90,4 +95,31 @@ public class ReportVariable<V> implements Serializable, JsonAware { public void setSelectedValue(V selectedValue) { this.selectedValue = selectedValue; } + + public List<String> computeIndexList() { + Set<V> tmp = new LinkedHashSet<>(values); + boolean useNullValue = tmp.remove(null); + List<String> result = tmp.stream().map(s -> s instanceof ToolkitId ? ((ToolkitId) s).getId() : String.valueOf(s)).collect(Collectors.toList()); + if (useNullValue) { + result.add("null"); + } + return result; + } + + public boolean isEmpty() { + return values == null || values.isEmpty(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ReportVariable)) return false; + ReportVariable<?> that = (ReportVariable<?>) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } } ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ComputeDynamicHeader.java ===================================== @@ -0,0 +1,84 @@ +package fr.ird.observe.dto.report.operations; + +/*- + * #%L + * ObServe Toolkit :: API + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.auto.service.AutoService; +import fr.ird.observe.dto.referential.WithI18n; +import fr.ird.observe.dto.report.DataMatrix; +import fr.ird.observe.dto.report.Report; +import fr.ird.observe.dto.report.ReportOperationConsumer; +import fr.ird.observe.dto.report.ReportRequestExecutor; + +import java.util.Set; + +/** + * To compute dynamic headers (for report with no column headers defined). + * <p> + * You can set as parameters an array of fixed column names + a repeat variable to complete the header. + * <p> + * Example: + * <code>Col1,Col2,Col3|repeatVariableName</code> + * <p> + * Created on 15/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +(a)AutoService(ReportOperationConsumer.class) +public class ComputeDynamicHeader implements ReportOperationConsumer { + @Override + public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) { + if (parameters.isEmpty()) { + throw new IllegalStateException(String.format("parameters of operation %s can't not be null (format: col1,col2,...|repeatVariableName)", getClass().getName())); + } + String[] split = parameters.split("\\|"); + if (split.length != 2) { + throw new IllegalStateException(String.format("parameters of operation %s (value %s) has bad format (format: col1,col2,...|repeatVariableName)", getClass().getName(), parameters)); + } + String[] fixedColumnNames = split[0].split("\\s*,\\s*"); + String repeatVariableName = split[1].trim(); + Set<?> repeatVariableValues = report.getRepeatVariable(repeatVariableName).getValues(); + int columnIndex = 0; + DataMatrix tmpMatrix = createTmpMatrix(0, 0, incoming.getWidth(), 1); + boolean useNullRepeatVariableValue = false; + for (String beginHeader : fixedColumnNames) { + tmpMatrix.setValue(columnIndex++, 0, beginHeader); + } + for (Object repeatVariable : repeatVariableValues) { + if (repeatVariable == null) { + useNullRepeatVariableValue = true; + } else { + if (repeatVariable instanceof WithI18n) { + tmpMatrix.setValue(columnIndex++, 0, ((WithI18n) repeatVariable).getLabel2()); + } else { + tmpMatrix.setValue(columnIndex++, 0, repeatVariable.toString()); + } + } + } + if (useNullRepeatVariableValue) { + tmpMatrix.setValue(columnIndex, 0, "Aucun"); + } + incoming.setY(1); + return DataMatrix.merge(incoming, tmpMatrix); + } +} ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/CopyRepeatVariableToFirstColumn.java ===================================== @@ -0,0 +1,66 @@ +package fr.ird.observe.dto.report.operations; + +/*- + * #%L + * ObServe Toolkit :: API + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.auto.service.AutoService; +import fr.ird.observe.dto.referential.WithI18n; +import fr.ird.observe.dto.report.DataMatrix; +import fr.ird.observe.dto.report.Report; +import fr.ird.observe.dto.report.ReportOperationConsumer; +import fr.ird.observe.dto.report.ReportRequestExecutor; + +import java.util.Set; + +/** + * To copy all values of a repeat variable to the first column. + * <p> + * If repeat variables values are {@link WithI18n}, then will use the {@link WithI18n#getLabel2()}. + * <p> + * TODO: Be able to use the correct locale to translate with correct label. + * <p> + * Created on 15/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +(a)AutoService(ReportOperationConsumer.class) +public class CopyRepeatVariableToFirstColumn implements ReportOperationConsumer { + @Override + public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) { + if (parameters.isEmpty()) { + throw new IllegalStateException(String.format("parameters of operation %s can't not be null (format: repeatVariableName)", getClass().getName())); + } + String repeatVariableName = parameters.trim(); + Set<?> repeatVariableValues = report.getRepeatVariable(repeatVariableName).getValues(); + DataMatrix tmpMatrix = createTmpMatrix(0, 0, 1 + incoming.getWidth(), repeatVariableValues.size()); + int index = 0; + for (Object value : repeatVariableValues) { + if (value instanceof WithI18n) { + value = ((WithI18n) value).getLabel2(); + } + tmpMatrix.setValue(0, index++, value); + } + incoming.setX(1); + return DataMatrix.merge(incoming, tmpMatrix); + } +} ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ExecuteRequestAndReorganizeCountByRepeatVariable.java ===================================== @@ -0,0 +1,120 @@ +package fr.ird.observe.dto.report.operations; + +/*- + * #%L + * ObServe Toolkit :: API + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.auto.service.AutoService; +import fr.ird.observe.dto.report.DataMatrix; +import fr.ird.observe.dto.report.Report; +import fr.ird.observe.dto.report.ReportOperationConsumer; +import fr.ird.observe.dto.report.ReportRequest; +import fr.ird.observe.dto.report.ReportRequestExecutor; +import fr.ird.observe.dto.report.ReportVariable; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * To execute a query and then reorganize it using repeat variables position (on x axis and y axis). + * <p> + * Created on 15/11/2022. + * <p> + * Parameters format is + * <code>repeatVariableForRow|repeatVariableFormColum|request</code> + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +(a)AutoService(ReportOperationConsumer.class) +public class ExecuteRequestAndReorganizeCountByRepeatVariable implements ReportOperationConsumer { + + @Override + public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) { + if (parameters.isEmpty()) { + throw new IllegalStateException(String.format("parameters of operation %s can't not be null (format: repeatVariableForRow|repeatVariableFormColum|request)", getClass().getName())); + } + String[] split = parameters.split("\\|"); + if (split.length != 3) { + throw new IllegalStateException(String.format("parameters of operation %s (value %s) has bad format (format: repeatVariableForRow|repeatVariableFormColum|request)", getClass().getName(), parameters)); + } + String repeatVariableForColumName = split[1].trim(); + ReportVariable<?> repeatVariableForColumn = report.getRepeatVariable(repeatVariableForColumName); + if (repeatVariableForColumn.isEmpty()) { + return incoming; + } + String repeatVariableForRowName = split[0].trim(); + ReportVariable<?> repeatVariableForRow = report.getRepeatVariable(repeatVariableForRowName); + if (repeatVariableForRow.isEmpty()) { + return incoming; + } + String request = split[2].trim(); + + List<String> columnIdList = repeatVariableForColumn.computeIndexList(); + List<String> rowIdList = repeatVariableForRow.computeIndexList(); + + Map<String, Object> queryParameters = computeQueryParameters(report, + tripId, + request, + repeatVariableForRowName, + rowIdList, + repeatVariableForColumName, + columnIdList); + + DataMatrix result = createTmpMatrix(incoming.getWidth(), 0, columnIdList.size(), rowIdList.size()); + + List<Object[]> rows = requestExecutor.executeRequest(request, queryParameters); + reorganize(result, rows, rowIdList, columnIdList); + return DataMatrix.merge(incoming, result); + } + + private Map<String, Object> computeQueryParameters(Report report, + Set<String> tripId, + String request, + String repeatVariableForRow, + List<String> rowIdList, + String repeatVariableFormColum, + List<String> columnIdList) { + Map<String, Object> queryParameters = ReportRequest.extractParams(report, tripId); + + if (request.contains(":" + repeatVariableForRow + " ")) { + // add this variable to queryParameters + queryParameters.put(repeatVariableForRow, rowIdList); + } + if (request.contains(":" + repeatVariableFormColum + " ")) { + // add this variable to queryParameters + queryParameters.put(repeatVariableFormColum, columnIdList); + } + return queryParameters; + } + + private void reorganize(DataMatrix result, List<Object[]> rows, List<String> rowIdList, List<String> columnIdList) { + for (Object[] row : rows) { + String rowId = String.valueOf(row[0]); + int rowIndex = rowIdList.indexOf(rowId); + String columnId = String.valueOf(row[1]); + int columnIndex = columnIdList.indexOf(columnId); + Number count = (Number) row[2]; + result.setValue(columnIndex, rowIndex, count); + } + } +} ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ExecuteRequests.java ===================================== @@ -53,7 +53,7 @@ public class ExecuteRequests implements ReportOperationConsumer { DataMatrix result; if (repeatVariable == null) { // requête simple sans repetition - result = requestExecutor.executeReportRequest(request, report, tripId, null); + result = requestExecutor.executeReportRequest(request, report, tripId); } else { // on a une requête avec repetition String repeatVariableName = repeatVariable.getVariableName(); ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumColumn.java ===================================== @@ -27,6 +27,7 @@ import fr.ird.observe.dto.report.DataMatrix; import fr.ird.observe.dto.report.Report; import fr.ird.observe.dto.report.ReportOperationConsumer; import fr.ird.observe.dto.report.ReportRequestExecutor; +import io.ultreia.java4all.lang.Numbers; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -45,19 +46,37 @@ public class SumColumn implements ReportOperationConsumer { @Override public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) { - DataMatrix tmpMatrix = createTmpMatrix(0, incoming.getHeight(), incoming.getWidth(), 1); - for (int column = 0, nbColumns = incoming.getWidth(); column < nbColumns; column++) { - Object sumColumn = getSumColumn(column, incoming); + int x = 0; + int y = 0; + int height = incoming.getHeight(); + int width = incoming.getWidth(); + if (!parameters.isEmpty()) { + String[] split = parameters.split("\\|"); + x = Integer.parseInt(split[0]); + y = Integer.parseInt(split[1]); + if (x + 1 >= height) { + // only one row in column to sum, so skip operation + return incoming; + } + } + + DataMatrix tmpMatrix = createTmpMatrix(0, height, width, 1); + for (int column = y; column < width; column++) { + Object sumColumn = getSumColumn(column, x, incoming); tmpMatrix.setValue(column, 0, sumColumn); } - return DataMatrix.merge(incoming, tmpMatrix); + DataMatrix merge = DataMatrix.merge(incoming, tmpMatrix); + if (report.getColumnHeaders() == null) { + merge.setValue(0, height, "Total"); + } + return merge; } - protected Object getSumColumn(int column, DataMatrix incoming) { - double result = 0d; + protected Object getSumColumn(int column, int x, DataMatrix incoming) { + float result = 0f; int nbRows = incoming.getHeight(); - for (int row = 0; row < nbRows; row++) { + for (int row = x; row < nbRows; row++) { Serializable o = incoming.getValue(column, row); if (o == null || "null".equals(o)) { o = 0; @@ -71,6 +90,6 @@ public class SumColumn implements ReportOperationConsumer { } result += d; } - return result; + return Numbers.roundFourDigits(result); } } ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumFloatColumn.java ===================================== @@ -41,7 +41,7 @@ public class SumFloatColumn extends SumColumn implements ReportOperationConsumer private static final Logger log = LogManager.getLogger(SumFloatColumn.class); @Override - protected Object getSumColumn(int column, DataMatrix incoming) { + protected Object getSumColumn(int column, int x, DataMatrix incoming) { double result = 0d; int nbRows = incoming.getHeight(); for (int row = 0; row < nbRows; row++) { ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumIntColumn.java ===================================== @@ -36,8 +36,8 @@ import fr.ird.observe.dto.report.ReportOperationConsumer; public class SumIntColumn extends SumColumn implements ReportOperationConsumer { @Override - protected Object getSumColumn(int column, DataMatrix incoming) { - Object sumColumn = super.getSumColumn(column, incoming); + protected Object getSumColumn(int column, int x, DataMatrix incoming) { + Object sumColumn = super.getSumColumn(column, x, incoming); return sumColumn instanceof Number ? ((Number) sumColumn).intValue() : sumColumn; } } ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumIntRow.java ===================================== @@ -35,8 +35,8 @@ import fr.ird.observe.dto.report.ReportOperationConsumer; @AutoService(ReportOperationConsumer.class) public class SumIntRow extends SumRow implements ReportOperationConsumer { @Override - protected Object getSumRow(int row, DataMatrix incoming) { - Object sumColumn = super.getSumRow(row, incoming); + protected Object getSumRow(int row, int y, DataMatrix incoming) { + Object sumColumn = super.getSumRow(row, y, incoming); return sumColumn instanceof Number ? ((Number) sumColumn).intValue() : sumColumn; } } ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumRow.java ===================================== @@ -27,6 +27,7 @@ import fr.ird.observe.dto.report.DataMatrix; import fr.ird.observe.dto.report.Report; import fr.ird.observe.dto.report.ReportOperationConsumer; import fr.ird.observe.dto.report.ReportRequestExecutor; +import io.ultreia.java4all.lang.Numbers; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -45,18 +46,37 @@ public class SumRow implements ReportOperationConsumer { @Override public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) { - DataMatrix tmpMatrix = createTmpMatrix(incoming.getWidth(), 0, 1, incoming.getHeight()); - for (int row = 0, nbRows = incoming.getHeight(); row < nbRows; row++) { - Object sumRow = getSumRow(row, incoming); + int x = 0; + int y = 0; + int width = incoming.getWidth(); + int height = incoming.getHeight(); + + + if (!parameters.isEmpty()) { + String[] split = parameters.split("\\|"); + x = Integer.parseInt(split[0]); + y = Integer.parseInt(split[1]); + if (y + 1 >= width) { + // only one column in row to sum, so skip operation + return incoming; + } + } + DataMatrix tmpMatrix = createTmpMatrix(width, 0, 1, height); + for (int row = x; row < height; row++) { + Object sumRow = getSumRow(row, y, incoming); tmpMatrix.setValue(0, row, sumRow); } - return DataMatrix.merge(incoming, tmpMatrix); + DataMatrix merge = DataMatrix.merge(incoming, tmpMatrix); + if (report.getRowHeaders() == null) { + merge.setValue(width, 0, "Total"); + } + return merge; } - protected Object getSumRow(int row, DataMatrix incoming) { - double result = 0d; + protected Object getSumRow(int row, int y, DataMatrix incoming) { + float result = 0f; int nbColumns = incoming.getWidth(); - for (int col = 0; col < nbColumns; col++) { + for (int col = y; col < nbColumns; col++) { Serializable o = incoming.getValue(col, row); if (o == null || "null".equals(o)) { o = 0; @@ -71,6 +91,6 @@ public class SumRow implements ReportOperationConsumer { } result += d; } - return result; + return Numbers.roundFourDigits(result); } } ===================================== toolkit/persistence/src/main/java/fr/ird/observe/spi/report/DefaultReportRequestExecutor.java ===================================== @@ -36,6 +36,7 @@ import fr.ird.observe.dto.report.ReportRequestExecutor; import fr.ird.observe.dto.report.ReportVariable; import fr.ird.observe.dto.report.operations.ExecuteRequests; import fr.ird.observe.spi.PersistenceBusinessProject; +import io.ultreia.java4all.util.TimeLog; import org.nuiton.topia.persistence.TopiaDao; import java.util.Collection; @@ -57,6 +58,7 @@ import java.util.function.Supplier; @SuppressWarnings("SpellCheckingInspection") public abstract class DefaultReportRequestExecutor implements ReportRequestExecutor { + public static final TimeLog TIME_LOG = new TimeLog(DefaultReportRequestExecutor.class, 500, 1000); private final Supplier<? extends TopiaDao<?>> daoSupplier; private final ReferentialLocale referentialLocale; @@ -67,11 +69,15 @@ public abstract class DefaultReportRequestExecutor implements ReportRequestExecu @Override public Report populateVariables(Report report, Set<String> tripIds) { + long t00 = TimeLog.getTime(); Map<String, Object> vars = new TreeMap<>(); vars.put(ReportRequest.TRIP_ID_VARIABLE, tripIds); for (ReportVariable<?> variable : report.getVariables()) { + long t0 = TimeLog.getTime(); populateVariable(variable, vars); + TIME_LOG.log(t0, "populate variable", variable.getName()); } + TIME_LOG.log(t00, "populate variables"); return report; } @@ -103,14 +109,29 @@ public abstract class DefaultReportRequestExecutor implements ReportRequestExecu return result; } + @Override + public void doPopulateRepeatVariables(Report report, Set<String> tripId) { + long t0 = TimeLog.getTime(); + ReportRequestExecutor.super.doPopulateRepeatVariables(report, tripId); + TIME_LOG.log(t0, "populate repeat variables"); + } + + @Override + public <R> void doPopulateRepeatVariable(Report report, Set<String> tripId, Map<String, Object> vars, ReportVariable<R> variable) { + long t0 = TimeLog.getTime(); + ReportRequestExecutor.super.doPopulateRepeatVariable(report, tripId, vars, variable); + TIME_LOG.log(t0, "populate repeat variable", variable.getName()); + } + @Override public <R> List<R> executeRequest(String request, Map<String, Object> params) { + long t0 = TimeLog.getTime(); // si il y a des references de DTO dans les valeurs des paramètres on les remplace par leur id // on copie pour ne pas modifier le paramètre de la méthode Map<String, Object> paramsFixes = new HashMap<>(); for (Map.Entry<String, Object> entry : params.entrySet()) { String name = entry.getKey(); - if (request.contains(":" + name)) { + if (request.contains(":" + name + " ") || request.endsWith(":" + name)) { Object value = entry.getValue(); if (value instanceof DtoReference) { DtoReference referenceDto = (DtoReference) value; @@ -120,7 +141,11 @@ public abstract class DefaultReportRequestExecutor implements ReportRequestExecu } } log.debug(String.format("Request: %s, params: %s", request, paramsFixes)); - return daoSupplier.get().findAll(request, paramsFixes); + try { + return daoSupplier.get().findAll(request, paramsFixes); + } finally { + TIME_LOG.log(t0, "execute request", request); + } } @SuppressWarnings("unchecked") View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/b8a08b6b41646e5e148525dc… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/b8a08b6b41646e5e148525dc… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-9.0.x] 17 commits: Report API - Add TimeLog in DefaultReportRequestExecutor
by Tony CHEMIT (@tchemit) 16 Nov '22

16 Nov '22
Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe Commits: 5e4a6ebb by Tony Chemit at 2022-11-16T00:45:19+01:00 Report API - Add TimeLog in DefaultReportRequestExecutor - - - - - 3bd433b6 by Tony Chemit at 2022-11-16T00:45:28+01:00 Report API - Clean ReportRequest code - - - - - e8829668 by Tony Chemit at 2022-11-16T00:45:37+01:00 Report API - Improve executeReportRequest method (one for simple request and one for request with repeat) - - - - - 9db0b05d by Tony Chemit at 2022-11-16T00:45:43+01:00 Report API - Improve Sum operations (can now set x and y and better round of double) - - - - - 50e5bc76 by Tony Chemit at 2022-11-16T00:47:17+01:00 Report API - add safe guard tests (to be able to copy partial matrix) - - - - - 9eea592f by Tony Chemit at 2022-11-16T00:47:23+01:00 Report API - Be able to order variables and repeat variables - - - - - 35b99acf by Tony Chemit at 2022-11-16T00:47:29+01:00 Tck Report - columnHeaders can be null Tck Report - Improve when to deliver asserts - - - - - 4ca5a8fb by Tony Chemit at 2022-11-16T00:47:34+01:00 Report GUI - Manage report with no columns and row headers (everything is coming from the report result to be able to manage dynamic columns) - - - - - f0e410ce by Tony Chemit at 2022-11-16T00:47:42+01:00 Report GUI - Respect report variables order in Report model - - - - - c3a6a87b by Tony Chemit at 2022-11-16T00:58:54+01:00 Report API - Improve ReportVariable (add isEmpty and computeIndexList methods) - - - - - f68f8bc0 by Tony Chemit at 2022-11-16T01:15:15+01:00 Report API - Add new neutral operations - - - - - 5c72bc35 by Tony Chemit at 2022-11-16T01:18:28+01:00 Report model - Fix psObservationFobUsageMinimal report (one line escape was missing) - - - - - 9304dbbb by Tony Chemit at 2022-11-16T01:18:28+01:00 Rapports Captures/Rejets selon le type d&#39;association - Closes #2530 - - - - - 782d2838 by Tony Chemit at 2022-11-16T01:18:28+01:00 Rapport Dénombrement des captures accessoires et devenir, filtrées par groupe - Closes #2534 - - - - - af7f63c9 by Tony Chemit at 2022-11-16T01:18:28+01:00 Rapports Distributions de tailles - Closes #2533 - - - - - 1b675eeb by Tony Chemit at 2022-11-16T01:18:28+01:00 Report Tck - Add more tests (for complex reports to make debug more easy) - - - - - 03903a9e by Tony Chemit at 2022-11-16T01:18:53+01:00 Merge branch &#39;feature/issue_2531_v9.0.x&#39; into develop-9.0.x Closes #2531 - - - - - 30 changed files: - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java - core/api/dto/src/main/resources/observe-reports.properties - core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java - core/services/test/src/main/java/fr/ird/observe/services/service/ReportFixture.java - core/services/test/src/main/java/fr/ird/observe/services/service/ReportServiceFixtures.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchByGroupReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchByGroupReportFixture.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLFReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationLengthsDistributionReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationNonTargetDistributionLengthsReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLD1ReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLFReportFixture.java - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatchByGroup.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLD1.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchByGroup.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationNonTargetDistributionLengths.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationLengthsDistribution.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetCatchByAssociation.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedByAssociation.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLD1.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLF.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLF.properties - toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportRequest.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportRequestExecutor.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportVariable.java - + toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ComputeDynamicHeader.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLD1ReportFixture.java → toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/CopyRepeatVariableToFirstColumn.java - + toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ExecuteRequestAndReorganizeCountByRepeatVariable.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ExecuteRequests.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumColumn.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumFloatColumn.java The diff was not included because it is too large. View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/0ae68cbfaca820bd5ebd103e… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/0ae68cbfaca820bd5ebd103e… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-9.0.x] Deleted 9 commits: Rapports Captures/Rejets selon le type d'association - Closes #2530
by Tony CHEMIT (@tchemit) 14 Nov '22

14 Nov '22
Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below. Deleted commits: 18be9c7c by Tony Chemit at 2022-11-13T15:28:50+01:00 Rapports Captures/Rejets selon le type d&#39;association - Closes #2530 - - - - - eadf39d0 by Tony Chemit at 2022-11-13T16:05:04+01:00 Rapport Dénombrement des captures accessoires et devenir, filtrées par groupe - Closes #2534 - - - - - 6cc3444c by Tony Chemit at 2022-11-14T07:34:11+01:00 Tck Report - columnHeaders can be null Tck Report - Improve when to deliver asserts - - - - - 5973b503 by Tony Chemit at 2022-11-14T13:38:45+01:00 Rapports Distributions de tailles - Closes #2533 - - - - - 5829f08b by Tony Chemit at 2022-11-14T13:38:45+01:00 Report API - add safe guard tests (to be able to copy partial matrix) - - - - - 21b35310 by Tony Chemit at 2022-11-14T13:38:45+01:00 Report GUI - Manage report with no columns and row headers (everything is coming from the report result to be able to manage dynamic columns) - - - - - 246f57a8 by Tony Chemit at 2022-11-14T13:38:45+01:00 Report model - Fix psObservationFobUsageMinimal report (one line escape was missing) - - - - - 832e14f1 by Tony Chemit at 2022-11-14T13:38:45+01:00 Report API - Be able to order variables and repeat variables - - - - - 78659144 by Tony Chemit at 2022-11-14T13:38:45+01:00 Report GUI - Respect report variables order in Report model - - - - - 22 changed files: - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java - core/api/dto/src/main/resources/observe-reports.properties - + core/persistence/java/src/main/java/fr/ird/observe/spi/report/ComputePsObservationLengthsDistribution.java - − core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java - core/services/test/src/main/java/fr/ird/observe/services/service/ReportFixture.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchByGroupReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchByGroupReportFixture.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLFReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationLengthsDistributionReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationNonTargetDistributionLengthsReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLD1ReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLFReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLD1ReportFixture.java - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatchByGroup.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchByGroup.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationNonTargetDistributionLengths.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationLengthsDistribution.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetCatchByAssociation.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedByAssociation.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLD1.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLF.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLD1.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLF.properties - toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java Changes: ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java ===================================== @@ -43,10 +43,10 @@ import java.net.URL; import java.nio.file.Files; import java.util.Collections; import java.util.Date; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.TreeMap; import java.util.stream.Collectors; /** @@ -81,7 +81,7 @@ public class ReportModel extends AdminActionModel { /** * les variables utilisées pour le report. */ - protected final Map<String, Object> variables; + protected final Map<String, Object> variables = new LinkedHashMap<>(); /** * la fichier contenant la définition des reports. */ @@ -128,7 +128,6 @@ public class ReportModel extends AdminActionModel { public ReportModel() { super(AdminStep.REPORT); - variables = new TreeMap<>(); // quand le type de modèle change, on mets à jour les rapports disponibles addPropertyChangeListener(REPORT_FILE_PROPERTY_NAME, evt -> updateReports()); } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java ===================================== @@ -149,12 +149,11 @@ public class ResultTableModel extends AbstractTableModel { rowNames.addAll(Arrays.asList(report.getRowHeaders())); } - withColumnHeader = !columnNames.isEmpty(); - withRowHeader = !rowNames.isEmpty(); - table.setTableHeader(!withColumnHeader ? null : tableHeader); - table.createDefaultColumnsFromModel(); int nbRows = incomingData.getHeight(); int nbCols = incomingData.getWidth(); + + withColumnHeader = !columnNames.isEmpty(); + withRowHeader = !rowNames.isEmpty(); if (withRowHeader) { // on ajoute une première colonne aux données nbCols += 1; @@ -162,6 +161,22 @@ public class ResultTableModel extends AbstractTableModel { incomingData.setX(1); } + if (!withColumnHeader && !withRowHeader) { + // let's say we always use columns from incomingData + table.setTableHeader(tableHeader); + for (int i = 0; i < nbCols; i++) { + columnNames.add((String) incomingData.getValue(i, 0)); + } + incomingData.setY(-1); + withColumnHeader = true; + nbRows--; + + } else { + table.setTableHeader(!withColumnHeader ? null : tableHeader); + } + table.createDefaultColumnsFromModel(); + + data.setHeight(nbRows); data.setWidth(nbCols); @@ -185,7 +200,9 @@ public class ResultTableModel extends AbstractTableModel { } else if (withColumnHeader) { } - data.copyData(incomingData); + if (nbCols > 0) { + data.copyData(incomingData); + } fireTableStructureChanged(); table.revalidate(); table.repaint(); @@ -220,7 +237,7 @@ public class ResultTableModel extends AbstractTableModel { } public String getClipboardContent(boolean copyRowHeaders, boolean copyColumnHeaders) { - return getDataContent(copyRowHeaders, copyColumnHeaders, true,'\t'); + return getDataContent(copyRowHeaders, copyColumnHeaders, true, '\t'); } public String getCsvContent() { ===================================== core/api/dto/src/main/resources/observe-reports.properties ===================================== @@ -157,8 +157,8 @@ report.psObservationFobUsageMinimal.request.3=2,0|row|\ Where \ m.id In :tripId \ and dcp.computedWhenArrivingSimplifiedObjectType = :typeObjetId \ - and a.vesselActivity.id != 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' -and (dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#2' \ + and a.vesselActivity.id != 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \ + and (dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#2' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#8' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#4' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#5' \ @@ -567,6 +567,140 @@ report.psObservationSetByAssociation.request.8=3,1|column|\ and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) ################################################################################ +## Captures thons selon le type d'association +################################################################################ +report.psObservationTargetCatchByAssociation.modelType=PS +report.psObservationTargetCatchByAssociation.name=Observations - Captures de thons selon le type d’association (en t) +report.psObservationTargetCatchByAssociation.description=Afficher la répartitions des captures de thons selon le type d'association +report.psObservationTargetCatchByAssociation.columns=YFT, SKJ, BET, LTA, FRI, Autres, Total +report.psObservationTargetCatchByAssociation.rows=BL sans baleine, BL avec baleine, BO avec requin-baleine, BO sans requin-baleine, Total +report.psObservationTargetCatchByAssociation.operations.1=SumRow +report.psObservationTargetCatchByAssociation.operations.2=SumColumn +# ligne 1 +report.psObservationTargetCatchByAssociation.request.1=0,0|row|\ + Select \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then 0.0 \ + Else ct.catchWeight End) \ + From TripImpl m \ + Join m.routeObs r \ + Join r.activity a \ + Join a.set c \ + with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#2' \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = FALSE, \ + ObservedSystemImpl os \ + Where \ + m.id In :tripId \ + and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9395222812356602' \ + and os not in elements(a.observedSystem) +# ligne 2 +report.psObservationTargetCatchByAssociation.request.7=0,1|row|\ + Select \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then 0.0 \ + Else ct.catchWeight End) \ + From TripImpl m \ + Join m.routeObs r \ + Join r.activity a \ + Join a.set c \ + with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#2' \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = FALSE, \ + ObservedSystemImpl os \ + Where \ + m.id In :tripId \ + and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9395222812356602' \ + and os in elements(a.observedSystem) +# ligne 3 +report.psObservationTargetCatchByAssociation.request.13=0,2|row|\ + Select \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then 0.0 \ + Else ct.catchWeight End) \ + From TripImpl m \ + Join m.routeObs r \ + Join r.activity a \ + Join a.set c \ + with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#1' \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = FALSE, \ + ObservedSystemImpl os \ + Where \ + m.id In :tripId \ + and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ + and os in elements(a.observedSystem) +# ligne 4 +report.psObservationTargetCatchByAssociation.request.19=0,3|row|\ + Select \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then 0.0 \ + Else ct.catchWeight End) \ + From TripImpl m \ + Join m.routeObs r \ + Join r.activity a \ + Join a.set c \ + with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#1' \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = FALSE, \ + ObservedSystemImpl os \ + Where \ + m.id In :tripId \ + and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ + and os not in elements(a.observedSystem) +################################################################################ ## Rejets thons selon le type d'association ################################################################################ report.psObservationTargetDiscardedByAssociation.modelType=PS @@ -600,7 +734,8 @@ report.psObservationTargetDiscardedByAssociation.request.1=0,0|row|\ Join r.activity a \ Join a.set c \ with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#2' \ - Join c.catches ct, \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = TRUE, \ ObservedSystemImpl os \ Where \ m.id In :tripId \ @@ -630,7 +765,8 @@ report.psObservationTargetDiscardedByAssociation.request.7=0,1|row|\ Join r.activity a \ Join a.set c \ with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#2' \ - Join c.catches ct, \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = TRUE, \ ObservedSystemImpl os \ Where \ m.id In :tripId \ @@ -660,7 +796,8 @@ report.psObservationTargetDiscardedByAssociation.request.13=0,2|row|\ Join r.activity a \ Join a.set c \ with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#1' \ - Join c.catches ct, \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = TRUE, \ ObservedSystemImpl os \ Where \ m.id In :tripId \ @@ -690,7 +827,8 @@ report.psObservationTargetDiscardedByAssociation.request.19=0,3|row|\ Join r.activity a \ Join a.set c \ with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#1' \ - Join c.catches ct, \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = TRUE, \ ObservedSystemImpl os \ Where \ m.id In :tripId \ @@ -749,14 +887,14 @@ report.psObservationCatch.request.3=2,0|row|\ Where m.id In :tripId report.psObservationCatch.request.3.repeat=speciesId|column ################################################################################ -## Captures accessoires par speciesGroup d'espèces +## Captures par groupe d'espèces ################################################################################ -report.psObservationAccessoryCatchByGroup.modelType=PS -report.psObservationAccessoryCatchByGroup.name=Observations - Dénombrement des captures accessoires et devenir, filtrés par groupe -report.psObservationAccessoryCatchByGroup.description=Afficher les nombres de captures accessoires par groupe d'espèce selon le type de banc et le devenir -report.psObservationAccessoryCatchByGroup.columns=Espèce, Total BL, Total BO, Sorti vivant/échappé, Sorti mort, Rejeté vivant, Rejeté mort, Partiellement conservé, Cuve, Cuisine, Autre -report.psObservationAccessoryCatchByGroup.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code -report.psObservationAccessoryCatchByGroup.request.1=0,0|row|\ +report.psObservationCatchByGroup.modelType=PS +report.psObservationCatchByGroup.name=Observations - Dénombrement des captures par devenir, filtrés par groupe +report.psObservationCatchByGroup.description=Afficher les nombres de captures par groupe d'espèce selon le type de banc et le devenir +report.psObservationCatchByGroup.columns=Espèce, Total BL, Total BO, Sorti vivant/échappé, Sorti mort, Rejeté vivant, Rejeté mort, Partiellement conservé, Cuve, Cuisine, Conservé pour le marché local ou poisson séché/salé à bord, Ailerons seulements, Rejeté statut inconnu (seulement pour l'observation électronique), Conservé à des fins scientifiques, Rejeté suffocant, Rejeté blessé, Autre +report.psObservationCatchByGroup.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code +report.psObservationCatchByGroup.request.1=0,0|row|\ Select \ concat(\ '[FAO]', (case when e.faoCode is not null then e.faoCode else '-' end), \ @@ -779,6 +917,12 @@ report.psObservationAccessoryCatchByGroup.request.1=0,0|row|\ else 0.0 end), \ Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1239832683621#0.6728026426066158' then ca.totalCount \ else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1464000000000#15' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1467372855729#0.568287924081734' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1501492537510#0.9210847837998154' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1501492831539#0.9377232562184147' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1544448835551#0.620629930572886' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1544448977865#0.24265421995390768' then ca.totalCount else 0.0 end), \ Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.9931091059863436' then 0.0 \ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683618#0.06155887805368032' then 0.0 \ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.11883784875534997' then 0.0 \ @@ -787,6 +931,12 @@ report.psObservationAccessoryCatchByGroup.request.1=0,0|row|\ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683620#0.46609703818634485' then 0.0 \ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.5722739932065866' then 0.0 \ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683621#0.6728026426066158' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1464000000000#15' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1467372855729#0.568287924081734' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1501492537510#0.9210847837998154' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1501492831539#0.9377232562184147' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1544448835551#0.620629930572886' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1544448977865#0.24265421995390768' then 0.0 \ else ca.totalCount end) \ From TripImpl m \ Join m.routeObs r \ @@ -799,14 +949,13 @@ report.psObservationAccessoryCatchByGroup.request.1=0,0|row|\ Group by e \ Order By e.homeId ########################################################### -## Distribution des tailles par espèces non ciblées +## Distribution des tailles par espèces et type de mesure ########################################################### -report.psObservationNonTargetDistributionLengths.modelType=PS -report.psObservationNonTargetDistributionLengths.name=Observations - Distribution des tailles par espèces non ciblées -report.psObservationNonTargetDistributionLengths.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces non ciblées -report.psObservationNonTargetDistributionLengths.columns=Classe de taille,Effectif -report.psObservationNonTargetDistributionLengths.operations.1=GroupByLength -report.psObservationNonTargetDistributionLengths.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ +report.psObservationLengthsDistribution.modelType=PS +report.psObservationLengthsDistribution.name=Observations - Distribution des tailles par espèces et type de mesure +report.psObservationLengthsDistribution.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces et le type de mesure +report.psObservationLengthsDistribution.operations.1=ComputePsObservationLengthsDistribution +report.psObservationLengthsDistribution.variable.1.species=fr.ird.observe.dto.referential.common.SpeciesDto|\ Select distinct ntl.species \ From TripImpl t \ Join t.routeObs r \ @@ -814,133 +963,32 @@ Join r.activity a \ Join a.set.sample nts \ Join nts.sampleMeasure ntl \ Where t.id In :tripId -report.psObservationNonTargetDistributionLengths.request.1=0,0|row| \ -Select ntl.length, sum(ntl.count) \ +report.psObservationLengthsDistribution.variable.2.sizeMeasureType=fr.ird.observe.dto.referential.common.SizeMeasureTypeDto|\ +Select distinct ntl.sizeMeasureType \ From TripImpl t \ Join t.routeObs r \ Join r.activity a \ Join a.set.sample nts \ Join nts.sampleMeasure ntl \ -Where t.id In :tripId \ -And ntl.species.id = :speciesId \ -Group By ntl.length \ -Order By ntl.length -#################################################################### -## Distribution des tailles des conservés par espèces ciblées (LD1) -#################################################################### -report.psObservationTargetStoredDistributionLengthsLD1.modelType=PS -report.psObservationTargetStoredDistributionLengthsLD1.name=Observations - Distribution des tailles des captures par espèces ciblées (mesure LD1) -report.psObservationTargetStoredDistributionLengthsLD1.description=Afficher le nombre d'individus capturés, mesurés par classe de taille LD1 pour les espèces ciblées -report.psObservationTargetStoredDistributionLengthsLD1.columns=Classe de taille,Effectif -report.psObservationTargetStoredDistributionLengthsLD1.operations.1=GroupByLength -report.psObservationTargetStoredDistributionLengthsLD1.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ -Select distinct tl.species \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ -And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499466774#0.529249255312607' -report.psObservationTargetStoredDistributionLengthsLD1.request.1=0,0|row| \ -Select tl.length , Sum(tl.count) \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ - And tl.species.id = :speciesId \ - And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499466774#0.529249255312607' \ -Group By tl.length \ -Order By tl.length -################################################################ -## Distribution des tailles des rejets par espèces ciblées (LD1) -################################################################ -report.psObservationTargetDiscardedDistributionLengthsLD1.modelType=PS -report.psObservationTargetDiscardedDistributionLengthsLD1.name=Observations - Distribution des tailles des rejets par espèces ciblées (mesure LD1) -report.psObservationTargetDiscardedDistributionLengthsLD1.description=Afficher la nombre d'individus rejetés, mesurés par classe de taille LD1 pour les espèces ciblées -report.psObservationTargetDiscardedDistributionLengthsLD1.columns=Classe de taille,Effectif -report.psObservationTargetDiscardedDistributionLengthsLD1.operations.1=GroupByLength -report.psObservationTargetDiscardedDistributionLengthsLD1.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ -Select distinct tl.species \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ -And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499466774#0.529249255312607' -report.psObservationTargetDiscardedDistributionLengthsLD1.request.1=0,0|row| \ -Select tl.length , Sum(tl.count) \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ - And tl.species.id = :speciesId \ - And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499466774#0.529249255312607'\ -Group By tl.length \ -Order By tl.length -############################################################### -## Distribution des tailles des conservés par espèces ciblées (LF) -############################################################### -report.psObservationTargetStoredDistributionLengthsLF.modelType=PS -report.psObservationTargetStoredDistributionLengthsLF.name=Observations - Distribution des tailles des captures par espèces ciblées (mesure LF) -report.psObservationTargetStoredDistributionLengthsLF.description=Afficher le nombre d'individus capturés, mesurés par classe de taille LF pour les espèces ciblées -report.psObservationTargetStoredDistributionLengthsLF.columns=Classe de taille,Effectif -report.psObservationTargetStoredDistributionLengthsLF.operations.1=GroupByLength -report.psObservationTargetStoredDistributionLengthsLF.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ -Select distinct tl.species \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ -And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336' -report.psObservationTargetStoredDistributionLengthsLF.request.1=0,0|row| \ -Select tl.length , Sum(tl.count) \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ - And tl.species.id = :speciesId \ - And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336' \ -Group By tl.length \ -Order By tl.length -############################################################### -## Distribution des tailles des rejets par espèces ciblées (LF) -############################################################### -report.psObservationTargetDiscardedDistributionLengthsLF.modelType=PS -report.psObservationTargetDiscardedDistributionLengthsLF.name=Observations - Distribution des tailles des rejets par espèces ciblées (mesure LF) -report.psObservationTargetDiscardedDistributionLengthsLF.description=Afficher le nombre d'individus rejetés, mesurés par classe de taille LF pour les espèces ciblées -report.psObservationTargetDiscardedDistributionLengthsLF.columns=Classe de taille,Effectif -report.psObservationTargetDiscardedDistributionLengthsLF.operations.1=GroupByLength -report.psObservationTargetDiscardedDistributionLengthsLF.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ -Select distinct tl.species \ +Where t.id In :tripId +report.psObservationLengthsDistribution.repeatVariable.speciesFate=fr.ird.observe.entities.referential.ps.common.SpeciesFate|\ +Select distinct sf \ From TripImpl t \ Join t.routeObs r \ Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ -And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336' -report.psObservationTargetDiscardedDistributionLengthsLF.request.1=0,0|row| \ -Select tl.length , Sum(tl.count) \ +Join a.set.sample nts \ +Join nts.sampleMeasure ntl with ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \ +Left Join ntl.speciesFate sf \ +Where t.id In :tripId +report.psObservationLengthsDistribution.repeatVariable.length=java.lang.Float|\ +Select distinct ntl.length \ From TripImpl t \ Join t.routeObs r \ Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ +Join a.set.sample nts \ +Join nts.sampleMeasure ntl with ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \ Where t.id In :tripId \ - And tl.species.id = :speciesId \ - And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336' \ -Group By tl.length \ -Order By tl.length +Order By ntl.length ############################################ ## Répartition des calées par cuves ############################################ ===================================== core/persistence/java/src/main/java/fr/ird/observe/spi/report/ComputePsObservationLengthsDistribution.java ===================================== @@ -0,0 +1,161 @@ +package fr.ird.observe.spi.report; + +/*- + * #%L + * ObServe Core :: Persistence :: Java + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.auto.service.AutoService; +import fr.ird.observe.dto.report.DataMatrix; +import fr.ird.observe.dto.report.Report; +import fr.ird.observe.dto.report.ReportOperationConsumer; +import fr.ird.observe.dto.report.ReportRequestExecutor; +import fr.ird.observe.dto.report.ReportVariable; +import fr.ird.observe.entities.referential.ps.common.SpeciesFate; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; + +/** + * Created on 13/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +(a)AutoService(ReportOperationConsumer.class) +public class ComputePsObservationLengthsDistribution implements ReportOperationConsumer { + + /** + * To get total count per length. + */ + public static final String TOTAL_COUNT_REQUEST = "" + + "Select sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + /** + * To get species fate count per length + */ + public static final String SPECIES_FATE_COUNT_REQUEST = "" + + "Select ntl.length, sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType And ntl.speciesFate.id = :speciesFate\n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + /** + * To get null species fate count per length + */ + public static final String NULL_SPECIES_FATE_COUNT_REQUEST = "" + + "Select ntl.length, sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType And ntl.speciesFate Is Null\n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + @Override + public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) { + + Map<String, Object> queryParameters = new TreeMap<>(); + queryParameters.put("tripId", tripId); + for (ReportVariable<?> variable : report.getVariables()) { + queryParameters.put(variable.getName(), variable.getSelectedValue()); + } + + Set<SpeciesFate> speciesFateList = report.<SpeciesFate>getRepeatVariable("speciesFate").getValues(); + List<String> lengthList = report.getRepeatVariable("length").getValues().stream().map(Object::toString).collect(Collectors.toList()); + + DataMatrix result = createTmpMatrix(0, 0, 2 + speciesFateList.size(), 1 + lengthList.size()); + boolean useNullSpeciesFate = speciesFateList.remove(null); + int columnIndex = 0; + fillLengthsColumn(result, columnIndex++, lengthList); + + for (SpeciesFate speciesFate : speciesFateList) { + fillSpeciesFateCountColumn(result, columnIndex++, queryParameters, speciesFate, lengthList, requestExecutor); + } + + if (useNullSpeciesFate) { + fillSpeciesFateCountColumn(result, columnIndex++, queryParameters, null, lengthList, requestExecutor); + } + + fillTotalCountColumn(result, columnIndex, queryParameters, requestExecutor); + + return result; + } + + private void fillLengthsColumn(DataMatrix result, int columnIndex, List<String> lengthList) { + int index = 0; + result.setValue(columnIndex, index++, "Classe de taille (cm)"); + for (String length : lengthList) { + result.setValue(columnIndex, index++, length); + } + } + + private void fillSpeciesFateCountColumn(DataMatrix result, int columnIndex, Map<String, Object> queryParameters, SpeciesFate speciesFate, List<String> lengthList, ReportRequestExecutor requestExecutor) { + String header; + List<Object[]> rows; + if (speciesFate == null) { + header = "Aucun"; + queryParameters.remove("speciesFate"); + rows = requestExecutor.executeRequest(NULL_SPECIES_FATE_COUNT_REQUEST, queryParameters); + } else { + header = speciesFate.getLabel2(); + queryParameters.put("speciesFate", speciesFate.getId()); + rows = requestExecutor.executeRequest(SPECIES_FATE_COUNT_REQUEST, queryParameters); + } + result.setValue(columnIndex, 0, String.format("Effectif ( devenir - %s )", header)); + + for (Object[] row : rows) { + String length = row[0].toString(); + Number count = (Number) row[1]; + int index = lengthList.indexOf(length); + result.setValue(columnIndex, index + 1, count); + } + } + + private void fillTotalCountColumn(DataMatrix result, int columnIndex, Map<String, Object> queryParameters, ReportRequestExecutor requestExecutor) { + result.setValue(columnIndex, 0, "Effectif total"); + List<Object> rows = requestExecutor.executeRequest(TOTAL_COUNT_REQUEST, queryParameters); + int index = 1; + for (Object row : rows) { + Number count = (Number) row; + result.setValue(columnIndex, index++, count); + } + } + +} + ===================================== core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java deleted ===================================== @@ -1,38 +0,0 @@ -package fr.ird.observe.services.local.service; - -/*- - * #%L - * ObServe Core :: Services :: Local - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ird.observe.services.service.ReportServiceFixtures; -import org.junit.AfterClass; - -public class ReportServiceLocalReadTest extends GeneratedReportServiceLocalReadTest { - - @AfterClass - public static void afterClass() { - if (!ReportServiceFixtures.WITH_ASSERT) { - System.out.println("New asserts:\n" + String.join("\n", ReportServiceFixtures.getAsserts())); - ReportServiceFixtures.getAsserts().clear(); - } - } - -} ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/ReportFixture.java ===================================== @@ -76,6 +76,7 @@ public abstract class ReportFixture { } public final DataMatrix execute(ReportService service, Report report) { + log.warn("Starting report {}", report.getName()); return service.executeReport(report, getTripIds()); } @@ -127,6 +128,8 @@ public abstract class ReportFixture { for (int i = 0; i < rows; i++) { ReportServiceFixtures.writeArrayAssert(String.format("result.%d", i), actual.getData()[i]); } + System.out.println("New asserts:\n" + String.join("\n", ReportServiceFixtures.getAsserts())); + ReportServiceFixtures.getAsserts().clear(); } } @@ -159,7 +162,11 @@ public abstract class ReportFixture { Assert.assertEquals(rows, report.getRows()); Assert.assertEquals(columns, report.getColumns()); - Assert.assertArrayEquals(columnsHeader, report.getColumnHeaders()); + if (report.getColumnHeaders() == null) { + Assert.assertEquals(0, columnsHeader.length); + } else { + Assert.assertArrayEquals(columnsHeader, report.getColumnHeaders()); + } if (report.getRowHeaders() == null) { Assert.assertEquals(0, rowsHeader.length); } else { @@ -168,7 +175,11 @@ public abstract class ReportFixture { } else { ReportServiceFixtures.addAssert("syntax.rows", report.getRows()); ReportServiceFixtures.addAssert("syntax.columns", report.getColumns()); - ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader", (Object[]) report.getColumnHeaders()); + if (report.getRowHeaders() == null) { + ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader"); + } else { + ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader", (Object[]) report.getColumnHeaders()); + } if (report.getRowHeaders() == null) { ReportServiceFixtures.writeArrayAssert("syntax.rowsHeader"); } else { ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchByGroupReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchByGroupReportFixture.java ===================================== @@ -35,7 +35,7 @@ import java.util.Iterator; * @since 1.9 */ @AutoService(ReportFixture.class) -public class PsObservationAccessoryCatchByGroupReportFixture extends ReportFixture { +public class PsObservationCatchByGroupReportFixture extends ReportFixture { @Override public void assertSyntax(Report report) { ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLFReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationLengthsDistributionReportFixture.java ===================================== @@ -24,24 +24,21 @@ package fr.ird.observe.services.service.report.ps; import com.google.auto.service.AutoService; import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; import fr.ird.observe.services.service.ReportFixture; -import java.util.Iterator; - /** - * Created on 17/02/2021. + * Created on 13/11/2022. * * @author Tony Chemit - dev(a)tchemit.fr - * @since 8.0.6 + * @since 9.0.17 */ @AutoService(ReportFixture.class) -public class PsObservationTargetStoredDistributionLengthsLFReportFixture extends ReportFixture { +public class PsObservationLengthsDistributionReportFixture extends ReportFixture { @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); + protected void setVariables(Report report) { + setVariableValue(report, "species", "fr.ird.referential.common.Species#1239832684537#0.2397229787936519"); + setVariableValue(report, "sizeMeasureType", "fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336"); } } + ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationNonTargetDistributionLengthsReportFixture.java deleted ===================================== @@ -1,47 +0,0 @@ -/* - * #%L - * ObServe Core :: Services :: Test - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.services.service.report.ps; - - -import com.google.auto.service.AutoService; -import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; -import fr.ird.observe.services.service.ReportFixture; - -import java.util.Iterator; - -/** - * Test du report {@code accessoryCatch}. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 1.9 - */ -(a)AutoService(ReportFixture.class) -public class PsObservationNonTargetDistributionLengthsReportFixture extends ReportFixture { - - @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); - } -} ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLD1ReportFixture.java deleted ===================================== @@ -1,47 +0,0 @@ -package fr.ird.observe.services.service.report.ps; - -/*- - * #%L - * ObServe Core :: Services :: Test - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.auto.service.AutoService; -import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; -import fr.ird.observe.services.service.ReportFixture; - -import java.util.Iterator; - -/** - * Created on 17/02/2021. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 8.0.6 - */ -(a)AutoService(ReportFixture.class) -public class PsObservationTargetDiscardedDistributionLengthsLD1ReportFixture extends ReportFixture { - - @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); - } -} ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLFReportFixture.java deleted ===================================== @@ -1,47 +0,0 @@ -package fr.ird.observe.services.service.report.ps; - -/*- - * #%L - * ObServe Core :: Services :: Test - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.auto.service.AutoService; -import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; -import fr.ird.observe.services.service.ReportFixture; - -import java.util.Iterator; - -/** - * Created on 17/02/2021. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 8.0.6 - */ -(a)AutoService(ReportFixture.class) -public class PsObservationTargetDiscardedDistributionLengthsLFReportFixture extends ReportFixture { - - @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); - } -} ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLD1ReportFixture.java deleted ===================================== @@ -1,47 +0,0 @@ -package fr.ird.observe.services.service.report.ps; - -/*- - * #%L - * ObServe Core :: Services :: Test - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.auto.service.AutoService; -import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; -import fr.ird.observe.services.service.ReportFixture; - -import java.util.Iterator; - -/** - * Created on 17/02/2021. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 8.0.6 - */ -(a)AutoService(ReportFixture.class) -public class PsObservationTargetStoredDistributionLengthsLD1ReportFixture extends ReportFixture { - - @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); - } -} ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatchByGroup.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchByGroup.properties ===================================== @@ -19,13 +19,13 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -result.0=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^0^3^3^0^0^0^0^0^0^0.0 -result.columns=11 +result.0=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^0^3^3^0^0^0^0^0^0^0^0^0^0^0^0^0.0 +result.columns=17 result.rows=1 -syntax.columns=11 -syntax.columnsHeader=Espèce^Total BL^Total BO^Sorti vivant/échappé^Sorti mort^Rejeté vivant^Rejeté mort^Partiellement conservé^Cuve^Cuisine^Autre -syntax.description=Afficher les nombres de captures accessoires par groupe d'espèce selon le type de banc et le devenir -syntax.name=Observations - Dénombrement des captures accessoires et devenir, filtrés par groupe +syntax.columns=17 +syntax.columnsHeader=Espèce^Total BL^Total BO^Sorti vivant/échappé^Sorti mort^Rejeté vivant^Rejeté mort^Partiellement conservé^Cuve^Cuisine^Conservé pour le marché local ou poisson séché/salé à bord^Ailerons seulements^Rejeté statut inconnu (seulement pour l'observation électronique)^Conservé à des fins scientifiques^Rejeté suffocant^Rejeté blessé^Autre +syntax.description=Afficher les nombres de captures par groupe d'espèce selon le type de banc et le devenir +syntax.name=Observations - Dénombrement des captures par devenir, filtrés par groupe syntax.nbRequests=1 syntax.rows=-1 syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationNonTargetDistributionLengths.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationLengthsDistribution.properties ===================================== @@ -19,11 +19,17 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces non ciblées -syntax.name=Observations - Distribution des tailles par espèces non ciblées -syntax.nbRequests=1 +syntax.name=Observations - Distribution des tailles par espèces et type de mesure +syntax.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces et le type de mesure syntax.rows=-1 +syntax.columns=-1 +syntax.columnsHeader= syntax.rowsHeader= -tripIds=${PS_COMMON_TRIP},${PS_COMMON_TRIP_MOVE} +syntax.nbRequests=0 +result.columns=3 +result.rows=5 +result.0=Classe de taille (cm)^Effectif ( devenir - Aucun )^Effectif total +result.1=50.0^2^2 +result.2=54.0^1^1 +result.3=68.0^1^1 +result.4=70.0^1^1 ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetCatchByAssociation.properties ===================================== @@ -19,3 +19,17 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### +syntax.name=Observations - Captures de thons selon le type d’association (en t) +syntax.description=Afficher la répartitions des captures de thons selon le type d'association +syntax.rows=5 +syntax.columns=7 +syntax.columnsHeader=YFT^SKJ^BET^LTA^FRI^Autres^Total +syntax.rowsHeader=BL sans baleine^BL avec baleine^BO avec requin-baleine^BO sans requin-baleine^Total +syntax.nbRequests=4 +result.columns=7 +result.rows=5 +result.0=175.0^0.0^7.0^0.0^0.0^0.0^182.0 +result.1=null^null^null^null^null^null^0.0 +result.2=null^null^null^null^null^null^0.0 +result.3=0.0^1.0^0.0^0.0^1.0^12.1406^14.1406 +result.4=175.0^1.0^7.0^0.0^1.0^12.1406^196.1406 \ No newline at end of file ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedByAssociation.properties ===================================== @@ -19,11 +19,11 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -result.0=175.0^0.0^7.0^0.0^0.0^0.2882^182.2882 +result.0=0.0^0.0^0.0^0.0^0.0^0.2882^0.2882 result.1=null^null^null^null^null^null^0.0 result.2=null^null^null^null^null^null^0.0 -result.3=0.0^1.0^5.0^0.0^1.0^160.4436^167.4436 -result.4=175.0^1.0^12.0^0.0^1.0^160.7318^349.7318 +result.3=0.0^0.0^5.0^0.0^0.0^148.303^153.303 +result.4=0.0^0.0^5.0^0.0^0.0^148.5912^153.5912 result.columns=7 result.rows=5 syntax.columns=7 ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLD1.properties deleted ===================================== @@ -1,28 +0,0 @@ -### -# #%L -# ObServe Core :: Services :: Test -# %% -# Copyright (C) 2008 - 2022 IRD, Ultreia.io -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher la nombre d'individus rejetés, mesurés par classe de taille LD1 pour les espèces ciblées -syntax.name=Observations - Distribution des tailles des rejets par espèces ciblées (mesure LD1) -syntax.nbRequests=1 -syntax.rows=-1 -syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLF.properties deleted ===================================== @@ -1,28 +0,0 @@ -### -# #%L -# ObServe Core :: Services :: Test -# %% -# Copyright (C) 2008 - 2022 IRD, Ultreia.io -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher le nombre d'individus rejetés, mesurés par classe de taille LF pour les espèces ciblées -syntax.name=Observations - Distribution des tailles des rejets par espèces ciblées (mesure LF) -syntax.nbRequests=1 -syntax.rows=-1 -syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLD1.properties deleted ===================================== @@ -1,28 +0,0 @@ -### -# #%L -# ObServe Core :: Services :: Test -# %% -# Copyright (C) 2008 - 2022 IRD, Ultreia.io -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher le nombre d'individus capturés, mesurés par classe de taille LD1 pour les espèces ciblées -syntax.name=Observations - Distribution des tailles des captures par espèces ciblées (mesure LD1) -syntax.nbRequests=1 -syntax.rows=-1 -syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLF.properties deleted ===================================== @@ -1,28 +0,0 @@ -### -# #%L -# ObServe Core :: Services :: Test -# %% -# Copyright (C) 2008 - 2022 IRD, Ultreia.io -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher le nombre d'individus capturés, mesurés par classe de taille LF pour les espèces ciblées -syntax.name=Observations - Distribution des tailles des captures par espèces ciblées (mesure LF) -syntax.nbRequests=1 -syntax.rows=-1 -syntax.rowsHeader= ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java ===================================== @@ -159,7 +159,13 @@ public class DataMatrix implements JsonAware { log.debug(String.format("copying incoming matrix (dim: %s, location: %s)", incoming.getDimension(), incoming.getLocation())); for (int i = 0; i < width; i++) { + if (x + i < 0) { + continue; + } for (int j = 0; j < height; j++) { + if (y + j < 0) { + continue; + } Serializable value = incoming.getValue(i, j); setValue(x + i, y + j, value); } ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java ===================================== @@ -319,12 +319,14 @@ public class ReportBuilder { Map.Entry<String, String> entry = itr.next(); String key = entry.getKey(); if (!key.startsWith(VARIABLE_PREFIX)) { - continue; } String operations = entry.getValue(); String id = key.substring(VARIABLE_PREFIX.length()); - + int indexOf = id.indexOf("."); + if (indexOf > -1) { + id = id.substring(indexOf + 1); + } // on interdit la surcharge d'une variable déjà trouvée pour le report if (ids.contains(id)) { throw new IllegalArgumentException("La variable " + id + " est déjà définie pour le report " + reportName); @@ -359,12 +361,14 @@ public class ReportBuilder { Map.Entry<String, String> entry = itr.next(); String key = entry.getKey(); if (!key.startsWith(REPEAT_VARIABLE_PREFIX)) { - continue; } String operations = entry.getValue(); String id = key.substring(REPEAT_VARIABLE_PREFIX.length()); - + int indexOf = id.indexOf("."); + if (indexOf > -1) { + id = id.substring(indexOf + 1); + } // on interdit la surcharge d'une variable déjà trouvée pour le report if (ids.contains(id)) { throw new IllegalArgumentException("La variable de répétition " + id + " est déjà définie pour le report " + reportName); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/0ae68cbfaca820bd5ebd103e… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/0ae68cbfaca820bd5ebd103e… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-9.0.x] 6 commits: Rapports Distributions de tailles - Closes #2533
by Tony CHEMIT (@tchemit) 14 Nov '22

14 Nov '22
Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe Commits: 5973b503 by Tony Chemit at 2022-11-14T13:38:45+01:00 Rapports Distributions de tailles - Closes #2533 - - - - - 5829f08b by Tony Chemit at 2022-11-14T13:38:45+01:00 Report API - add safe guard tests (to be able to copy partial matrix) - - - - - 21b35310 by Tony Chemit at 2022-11-14T13:38:45+01:00 Report GUI - Manage report with no columns and row headers (everything is coming from the report result to be able to manage dynamic columns) - - - - - 246f57a8 by Tony Chemit at 2022-11-14T13:38:45+01:00 Report model - Fix psObservationFobUsageMinimal report (one line escape was missing) - - - - - 832e14f1 by Tony Chemit at 2022-11-14T13:38:45+01:00 Report API - Be able to order variables and repeat variables - - - - - 78659144 by Tony Chemit at 2022-11-14T13:38:45+01:00 Report GUI - Respect report variables order in Report model - - - - - 16 changed files: - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java - core/api/dto/src/main/resources/observe-reports.properties - + core/persistence/java/src/main/java/fr/ird/observe/spi/report/ComputePsObservationLengthsDistribution.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLFReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationLengthsDistributionReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationNonTargetDistributionLengthsReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLD1ReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLFReportFixture.java - − core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLD1ReportFixture.java - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationNonTargetDistributionLengths.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationLengthsDistribution.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLD1.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLF.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLD1.properties - − core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLF.properties - toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java Changes: ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java ===================================== @@ -43,10 +43,10 @@ import java.net.URL; import java.nio.file.Files; import java.util.Collections; import java.util.Date; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.TreeMap; import java.util.stream.Collectors; /** @@ -81,7 +81,7 @@ public class ReportModel extends AdminActionModel { /** * les variables utilisées pour le report. */ - protected final Map<String, Object> variables; + protected final Map<String, Object> variables = new LinkedHashMap<>(); /** * la fichier contenant la définition des reports. */ @@ -128,7 +128,6 @@ public class ReportModel extends AdminActionModel { public ReportModel() { super(AdminStep.REPORT); - variables = new TreeMap<>(); // quand le type de modèle change, on mets à jour les rapports disponibles addPropertyChangeListener(REPORT_FILE_PROPERTY_NAME, evt -> updateReports()); } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java ===================================== @@ -149,12 +149,11 @@ public class ResultTableModel extends AbstractTableModel { rowNames.addAll(Arrays.asList(report.getRowHeaders())); } - withColumnHeader = !columnNames.isEmpty(); - withRowHeader = !rowNames.isEmpty(); - table.setTableHeader(!withColumnHeader ? null : tableHeader); - table.createDefaultColumnsFromModel(); int nbRows = incomingData.getHeight(); int nbCols = incomingData.getWidth(); + + withColumnHeader = !columnNames.isEmpty(); + withRowHeader = !rowNames.isEmpty(); if (withRowHeader) { // on ajoute une première colonne aux données nbCols += 1; @@ -162,6 +161,22 @@ public class ResultTableModel extends AbstractTableModel { incomingData.setX(1); } + if (!withColumnHeader && !withRowHeader) { + // let's say we always use columns from incomingData + table.setTableHeader(tableHeader); + for (int i = 0; i < nbCols; i++) { + columnNames.add((String) incomingData.getValue(i, 0)); + } + incomingData.setY(-1); + withColumnHeader = true; + nbRows--; + + } else { + table.setTableHeader(!withColumnHeader ? null : tableHeader); + } + table.createDefaultColumnsFromModel(); + + data.setHeight(nbRows); data.setWidth(nbCols); @@ -185,7 +200,9 @@ public class ResultTableModel extends AbstractTableModel { } else if (withColumnHeader) { } - data.copyData(incomingData); + if (nbCols > 0) { + data.copyData(incomingData); + } fireTableStructureChanged(); table.revalidate(); table.repaint(); @@ -220,7 +237,7 @@ public class ResultTableModel extends AbstractTableModel { } public String getClipboardContent(boolean copyRowHeaders, boolean copyColumnHeaders) { - return getDataContent(copyRowHeaders, copyColumnHeaders, true,'\t'); + return getDataContent(copyRowHeaders, copyColumnHeaders, true, '\t'); } public String getCsvContent() { ===================================== core/api/dto/src/main/resources/observe-reports.properties ===================================== @@ -157,8 +157,8 @@ report.psObservationFobUsageMinimal.request.3=2,0|row|\ Where \ m.id In :tripId \ and dcp.computedWhenArrivingSimplifiedObjectType = :typeObjetId \ - and a.vesselActivity.id != 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' -and (dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#2' \ + and a.vesselActivity.id != 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \ + and (dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#2' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#8' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#4' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#5' \ @@ -949,14 +949,13 @@ report.psObservationCatchByGroup.request.1=0,0|row|\ Group by e \ Order By e.homeId ########################################################### -## Distribution des tailles par espèces non ciblées +## Distribution des tailles par espèces et type de mesure ########################################################### -report.psObservationNonTargetDistributionLengths.modelType=PS -report.psObservationNonTargetDistributionLengths.name=Observations - Distribution des tailles par espèces non ciblées -report.psObservationNonTargetDistributionLengths.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces non ciblées -report.psObservationNonTargetDistributionLengths.columns=Classe de taille,Effectif -report.psObservationNonTargetDistributionLengths.operations.1=GroupByLength -report.psObservationNonTargetDistributionLengths.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ +report.psObservationLengthsDistribution.modelType=PS +report.psObservationLengthsDistribution.name=Observations - Distribution des tailles par espèces et type de mesure +report.psObservationLengthsDistribution.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces et le type de mesure +report.psObservationLengthsDistribution.operations.1=ComputePsObservationLengthsDistribution +report.psObservationLengthsDistribution.variable.1.species=fr.ird.observe.dto.referential.common.SpeciesDto|\ Select distinct ntl.species \ From TripImpl t \ Join t.routeObs r \ @@ -964,133 +963,32 @@ Join r.activity a \ Join a.set.sample nts \ Join nts.sampleMeasure ntl \ Where t.id In :tripId -report.psObservationNonTargetDistributionLengths.request.1=0,0|row| \ -Select ntl.length, sum(ntl.count) \ +report.psObservationLengthsDistribution.variable.2.sizeMeasureType=fr.ird.observe.dto.referential.common.SizeMeasureTypeDto|\ +Select distinct ntl.sizeMeasureType \ From TripImpl t \ Join t.routeObs r \ Join r.activity a \ Join a.set.sample nts \ Join nts.sampleMeasure ntl \ -Where t.id In :tripId \ -And ntl.species.id = :speciesId \ -Group By ntl.length \ -Order By ntl.length -#################################################################### -## Distribution des tailles des conservés par espèces ciblées (LD1) -#################################################################### -report.psObservationTargetStoredDistributionLengthsLD1.modelType=PS -report.psObservationTargetStoredDistributionLengthsLD1.name=Observations - Distribution des tailles des captures par espèces ciblées (mesure LD1) -report.psObservationTargetStoredDistributionLengthsLD1.description=Afficher le nombre d'individus capturés, mesurés par classe de taille LD1 pour les espèces ciblées -report.psObservationTargetStoredDistributionLengthsLD1.columns=Classe de taille,Effectif -report.psObservationTargetStoredDistributionLengthsLD1.operations.1=GroupByLength -report.psObservationTargetStoredDistributionLengthsLD1.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ -Select distinct tl.species \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ -And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499466774#0.529249255312607' -report.psObservationTargetStoredDistributionLengthsLD1.request.1=0,0|row| \ -Select tl.length , Sum(tl.count) \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ - And tl.species.id = :speciesId \ - And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499466774#0.529249255312607' \ -Group By tl.length \ -Order By tl.length -################################################################ -## Distribution des tailles des rejets par espèces ciblées (LD1) -################################################################ -report.psObservationTargetDiscardedDistributionLengthsLD1.modelType=PS -report.psObservationTargetDiscardedDistributionLengthsLD1.name=Observations - Distribution des tailles des rejets par espèces ciblées (mesure LD1) -report.psObservationTargetDiscardedDistributionLengthsLD1.description=Afficher la nombre d'individus rejetés, mesurés par classe de taille LD1 pour les espèces ciblées -report.psObservationTargetDiscardedDistributionLengthsLD1.columns=Classe de taille,Effectif -report.psObservationTargetDiscardedDistributionLengthsLD1.operations.1=GroupByLength -report.psObservationTargetDiscardedDistributionLengthsLD1.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ -Select distinct tl.species \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ -And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499466774#0.529249255312607' -report.psObservationTargetDiscardedDistributionLengthsLD1.request.1=0,0|row| \ -Select tl.length , Sum(tl.count) \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ - And tl.species.id = :speciesId \ - And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499466774#0.529249255312607'\ -Group By tl.length \ -Order By tl.length -############################################################### -## Distribution des tailles des conservés par espèces ciblées (LF) -############################################################### -report.psObservationTargetStoredDistributionLengthsLF.modelType=PS -report.psObservationTargetStoredDistributionLengthsLF.name=Observations - Distribution des tailles des captures par espèces ciblées (mesure LF) -report.psObservationTargetStoredDistributionLengthsLF.description=Afficher le nombre d'individus capturés, mesurés par classe de taille LF pour les espèces ciblées -report.psObservationTargetStoredDistributionLengthsLF.columns=Classe de taille,Effectif -report.psObservationTargetStoredDistributionLengthsLF.operations.1=GroupByLength -report.psObservationTargetStoredDistributionLengthsLF.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ -Select distinct tl.species \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ -And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336' -report.psObservationTargetStoredDistributionLengthsLF.request.1=0,0|row| \ -Select tl.length , Sum(tl.count) \ -From TripImpl t \ -Join t.routeObs r \ -Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ - And tl.species.id = :speciesId \ - And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336' \ -Group By tl.length \ -Order By tl.length -############################################################### -## Distribution des tailles des rejets par espèces ciblées (LF) -############################################################### -report.psObservationTargetDiscardedDistributionLengthsLF.modelType=PS -report.psObservationTargetDiscardedDistributionLengthsLF.name=Observations - Distribution des tailles des rejets par espèces ciblées (mesure LF) -report.psObservationTargetDiscardedDistributionLengthsLF.description=Afficher le nombre d'individus rejetés, mesurés par classe de taille LF pour les espèces ciblées -report.psObservationTargetDiscardedDistributionLengthsLF.columns=Classe de taille,Effectif -report.psObservationTargetDiscardedDistributionLengthsLF.operations.1=GroupByLength -report.psObservationTargetDiscardedDistributionLengthsLF.variable.speciesId=fr.ird.observe.dto.referential.common.SpeciesDto|\ -Select distinct tl.species \ +Where t.id In :tripId +report.psObservationLengthsDistribution.repeatVariable.speciesFate=fr.ird.observe.entities.referential.ps.common.SpeciesFate|\ +Select distinct sf \ From TripImpl t \ Join t.routeObs r \ Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ -Where t.id In :tripId \ -And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336' -report.psObservationTargetDiscardedDistributionLengthsLF.request.1=0,0|row| \ -Select tl.length , Sum(tl.count) \ +Join a.set.sample nts \ +Join nts.sampleMeasure ntl with ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \ +Left Join ntl.speciesFate sf \ +Where t.id In :tripId +report.psObservationLengthsDistribution.repeatVariable.length=java.lang.Float|\ +Select distinct ntl.length \ From TripImpl t \ Join t.routeObs r \ Join r.activity a \ -Join a.set.sample ts \ -Join ts.sampleMeasure tl \ +Join a.set.sample nts \ +Join nts.sampleMeasure ntl with ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \ Where t.id In :tripId \ - And tl.species.id = :speciesId \ - And tl.sizeMeasureType = 'fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336' \ -Group By tl.length \ -Order By tl.length +Order By ntl.length ############################################ ## Répartition des calées par cuves ############################################ ===================================== core/persistence/java/src/main/java/fr/ird/observe/spi/report/ComputePsObservationLengthsDistribution.java ===================================== @@ -0,0 +1,161 @@ +package fr.ird.observe.spi.report; + +/*- + * #%L + * ObServe Core :: Persistence :: Java + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.auto.service.AutoService; +import fr.ird.observe.dto.report.DataMatrix; +import fr.ird.observe.dto.report.Report; +import fr.ird.observe.dto.report.ReportOperationConsumer; +import fr.ird.observe.dto.report.ReportRequestExecutor; +import fr.ird.observe.dto.report.ReportVariable; +import fr.ird.observe.entities.referential.ps.common.SpeciesFate; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; + +/** + * Created on 13/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +(a)AutoService(ReportOperationConsumer.class) +public class ComputePsObservationLengthsDistribution implements ReportOperationConsumer { + + /** + * To get total count per length. + */ + public static final String TOTAL_COUNT_REQUEST = "" + + "Select sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + /** + * To get species fate count per length + */ + public static final String SPECIES_FATE_COUNT_REQUEST = "" + + "Select ntl.length, sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType And ntl.speciesFate.id = :speciesFate\n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + /** + * To get null species fate count per length + */ + public static final String NULL_SPECIES_FATE_COUNT_REQUEST = "" + + "Select ntl.length, sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType And ntl.speciesFate Is Null\n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + @Override + public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) { + + Map<String, Object> queryParameters = new TreeMap<>(); + queryParameters.put("tripId", tripId); + for (ReportVariable<?> variable : report.getVariables()) { + queryParameters.put(variable.getName(), variable.getSelectedValue()); + } + + Set<SpeciesFate> speciesFateList = report.<SpeciesFate>getRepeatVariable("speciesFate").getValues(); + List<String> lengthList = report.getRepeatVariable("length").getValues().stream().map(Object::toString).collect(Collectors.toList()); + + DataMatrix result = createTmpMatrix(0, 0, 2 + speciesFateList.size(), 1 + lengthList.size()); + boolean useNullSpeciesFate = speciesFateList.remove(null); + int columnIndex = 0; + fillLengthsColumn(result, columnIndex++, lengthList); + + for (SpeciesFate speciesFate : speciesFateList) { + fillSpeciesFateCountColumn(result, columnIndex++, queryParameters, speciesFate, lengthList, requestExecutor); + } + + if (useNullSpeciesFate) { + fillSpeciesFateCountColumn(result, columnIndex++, queryParameters, null, lengthList, requestExecutor); + } + + fillTotalCountColumn(result, columnIndex, queryParameters, requestExecutor); + + return result; + } + + private void fillLengthsColumn(DataMatrix result, int columnIndex, List<String> lengthList) { + int index = 0; + result.setValue(columnIndex, index++, "Classe de taille (cm)"); + for (String length : lengthList) { + result.setValue(columnIndex, index++, length); + } + } + + private void fillSpeciesFateCountColumn(DataMatrix result, int columnIndex, Map<String, Object> queryParameters, SpeciesFate speciesFate, List<String> lengthList, ReportRequestExecutor requestExecutor) { + String header; + List<Object[]> rows; + if (speciesFate == null) { + header = "Aucun"; + queryParameters.remove("speciesFate"); + rows = requestExecutor.executeRequest(NULL_SPECIES_FATE_COUNT_REQUEST, queryParameters); + } else { + header = speciesFate.getLabel2(); + queryParameters.put("speciesFate", speciesFate.getId()); + rows = requestExecutor.executeRequest(SPECIES_FATE_COUNT_REQUEST, queryParameters); + } + result.setValue(columnIndex, 0, String.format("Effectif ( devenir - %s )", header)); + + for (Object[] row : rows) { + String length = row[0].toString(); + Number count = (Number) row[1]; + int index = lengthList.indexOf(length); + result.setValue(columnIndex, index + 1, count); + } + } + + private void fillTotalCountColumn(DataMatrix result, int columnIndex, Map<String, Object> queryParameters, ReportRequestExecutor requestExecutor) { + result.setValue(columnIndex, 0, "Effectif total"); + List<Object> rows = requestExecutor.executeRequest(TOTAL_COUNT_REQUEST, queryParameters); + int index = 1; + for (Object row : rows) { + Number count = (Number) row; + result.setValue(columnIndex, index++, count); + } + } + +} + ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLFReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationLengthsDistributionReportFixture.java ===================================== @@ -24,24 +24,21 @@ package fr.ird.observe.services.service.report.ps; import com.google.auto.service.AutoService; import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; import fr.ird.observe.services.service.ReportFixture; -import java.util.Iterator; - /** - * Created on 17/02/2021. + * Created on 13/11/2022. * * @author Tony Chemit - dev(a)tchemit.fr - * @since 8.0.6 + * @since 9.0.17 */ @AutoService(ReportFixture.class) -public class PsObservationTargetStoredDistributionLengthsLFReportFixture extends ReportFixture { +public class PsObservationLengthsDistributionReportFixture extends ReportFixture { @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); + protected void setVariables(Report report) { + setVariableValue(report, "species", "fr.ird.referential.common.Species#1239832684537#0.2397229787936519"); + setVariableValue(report, "sizeMeasureType", "fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336"); } } + ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationNonTargetDistributionLengthsReportFixture.java deleted ===================================== @@ -1,47 +0,0 @@ -/* - * #%L - * ObServe Core :: Services :: Test - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.services.service.report.ps; - - -import com.google.auto.service.AutoService; -import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; -import fr.ird.observe.services.service.ReportFixture; - -import java.util.Iterator; - -/** - * Test du report {@code accessoryCatch}. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 1.9 - */ -(a)AutoService(ReportFixture.class) -public class PsObservationNonTargetDistributionLengthsReportFixture extends ReportFixture { - - @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); - } -} ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLD1ReportFixture.java deleted ===================================== @@ -1,47 +0,0 @@ -package fr.ird.observe.services.service.report.ps; - -/*- - * #%L - * ObServe Core :: Services :: Test - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.auto.service.AutoService; -import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; -import fr.ird.observe.services.service.ReportFixture; - -import java.util.Iterator; - -/** - * Created on 17/02/2021. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 8.0.6 - */ -(a)AutoService(ReportFixture.class) -public class PsObservationTargetDiscardedDistributionLengthsLD1ReportFixture extends ReportFixture { - - @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); - } -} ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetDiscardedDistributionLengthsLFReportFixture.java deleted ===================================== @@ -1,47 +0,0 @@ -package fr.ird.observe.services.service.report.ps; - -/*- - * #%L - * ObServe Core :: Services :: Test - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.auto.service.AutoService; -import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; -import fr.ird.observe.services.service.ReportFixture; - -import java.util.Iterator; - -/** - * Created on 17/02/2021. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 8.0.6 - */ -(a)AutoService(ReportFixture.class) -public class PsObservationTargetDiscardedDistributionLengthsLFReportFixture extends ReportFixture { - - @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); - } -} ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationTargetStoredDistributionLengthsLD1ReportFixture.java deleted ===================================== @@ -1,47 +0,0 @@ -package fr.ird.observe.services.service.report.ps; - -/*- - * #%L - * ObServe Core :: Services :: Test - * %% - * Copyright (C) 2008 - 2022 IRD, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.auto.service.AutoService; -import fr.ird.observe.dto.report.Report; -import fr.ird.observe.dto.report.ReportRequest; -import fr.ird.observe.services.service.ReportFixture; - -import java.util.Iterator; - -/** - * Created on 17/02/2021. - * - * @author Tony Chemit - dev(a)tchemit.fr - * @since 8.0.6 - */ -(a)AutoService(ReportFixture.class) -public class PsObservationTargetStoredDistributionLengthsLD1ReportFixture extends ReportFixture { - - @Override - public void assertSyntax(Report report) { - super.assertSyntax(report); - Iterator<ReportRequest> requests = getRequestIterator(report); - assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); - } -} ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationNonTargetDistributionLengths.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationLengthsDistribution.properties ===================================== @@ -19,11 +19,17 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces non ciblées -syntax.name=Observations - Distribution des tailles par espèces non ciblées -syntax.nbRequests=1 +syntax.name=Observations - Distribution des tailles par espèces et type de mesure +syntax.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces et le type de mesure syntax.rows=-1 +syntax.columns=-1 +syntax.columnsHeader= syntax.rowsHeader= -tripIds=${PS_COMMON_TRIP},${PS_COMMON_TRIP_MOVE} +syntax.nbRequests=0 +result.columns=3 +result.rows=5 +result.0=Classe de taille (cm)^Effectif ( devenir - Aucun )^Effectif total +result.1=50.0^2^2 +result.2=54.0^1^1 +result.3=68.0^1^1 +result.4=70.0^1^1 ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLD1.properties deleted ===================================== @@ -1,28 +0,0 @@ -### -# #%L -# ObServe Core :: Services :: Test -# %% -# Copyright (C) 2008 - 2022 IRD, Ultreia.io -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher la nombre d'individus rejetés, mesurés par classe de taille LD1 pour les espèces ciblées -syntax.name=Observations - Distribution des tailles des rejets par espèces ciblées (mesure LD1) -syntax.nbRequests=1 -syntax.rows=-1 -syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedDistributionLengthsLF.properties deleted ===================================== @@ -1,28 +0,0 @@ -### -# #%L -# ObServe Core :: Services :: Test -# %% -# Copyright (C) 2008 - 2022 IRD, Ultreia.io -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher le nombre d'individus rejetés, mesurés par classe de taille LF pour les espèces ciblées -syntax.name=Observations - Distribution des tailles des rejets par espèces ciblées (mesure LF) -syntax.nbRequests=1 -syntax.rows=-1 -syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLD1.properties deleted ===================================== @@ -1,28 +0,0 @@ -### -# #%L -# ObServe Core :: Services :: Test -# %% -# Copyright (C) 2008 - 2022 IRD, Ultreia.io -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher le nombre d'individus capturés, mesurés par classe de taille LD1 pour les espèces ciblées -syntax.name=Observations - Distribution des tailles des captures par espèces ciblées (mesure LD1) -syntax.nbRequests=1 -syntax.rows=-1 -syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetStoredDistributionLengthsLF.properties deleted ===================================== @@ -1,28 +0,0 @@ -### -# #%L -# ObServe Core :: Services :: Test -# %% -# Copyright (C) 2008 - 2022 IRD, Ultreia.io -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -syntax.columns=2 -syntax.columnsHeader=Classe de taille^Effectif -syntax.description=Afficher le nombre d'individus capturés, mesurés par classe de taille LF pour les espèces ciblées -syntax.name=Observations - Distribution des tailles des captures par espèces ciblées (mesure LF) -syntax.nbRequests=1 -syntax.rows=-1 -syntax.rowsHeader= ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java ===================================== @@ -159,7 +159,13 @@ public class DataMatrix implements JsonAware { log.debug(String.format("copying incoming matrix (dim: %s, location: %s)", incoming.getDimension(), incoming.getLocation())); for (int i = 0; i < width; i++) { + if (x + i < 0) { + continue; + } for (int j = 0; j < height; j++) { + if (y + j < 0) { + continue; + } Serializable value = incoming.getValue(i, j); setValue(x + i, y + j, value); } ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java ===================================== @@ -319,12 +319,14 @@ public class ReportBuilder { Map.Entry<String, String> entry = itr.next(); String key = entry.getKey(); if (!key.startsWith(VARIABLE_PREFIX)) { - continue; } String operations = entry.getValue(); String id = key.substring(VARIABLE_PREFIX.length()); - + int indexOf = id.indexOf("."); + if (indexOf > -1) { + id = id.substring(indexOf + 1); + } // on interdit la surcharge d'une variable déjà trouvée pour le report if (ids.contains(id)) { throw new IllegalArgumentException("La variable " + id + " est déjà définie pour le report " + reportName); @@ -359,12 +361,14 @@ public class ReportBuilder { Map.Entry<String, String> entry = itr.next(); String key = entry.getKey(); if (!key.startsWith(REPEAT_VARIABLE_PREFIX)) { - continue; } String operations = entry.getValue(); String id = key.substring(REPEAT_VARIABLE_PREFIX.length()); - + int indexOf = id.indexOf("."); + if (indexOf > -1) { + id = id.substring(indexOf + 1); + } // on interdit la surcharge d'une variable déjà trouvée pour le report if (ids.contains(id)) { throw new IllegalArgumentException("La variable de répétition " + id + " est déjà définie pour le report " + reportName); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/29db74f10ccd6fa8fa2cf010… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/29db74f10ccd6fa8fa2cf010… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-9.0.x] 12 commits: Rapport Liste des captures de faune accessoire selon le type de banc, filtrées...
by Tony CHEMIT (@tchemit) 14 Nov '22

14 Nov '22
Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe Commits: 4fcb9612 by Tony Chemit at 2022-11-13T15:28:50+01:00 Rapport Liste des captures de faune accessoire selon le type de banc, filtrées par groupe - Closes #2532 - - - - - ec5fe21b by Tony Chemit at 2022-11-13T15:28:50+01:00 GUI - use resetEdit state when reset entry on content table - - - - - 0ae68cbf by Tony Chemit at 2022-11-13T15:28:50+01:00 GUI - Sur échantillons PS observations saisis par lots, migrés vers 9.0, valeurs étranges sur le champ poids individuel - Closes #2503 - - - - - 18be9c7c by Tony Chemit at 2022-11-13T15:28:50+01:00 Rapports Captures/Rejets selon le type d&#39;association - Closes #2530 - - - - - eadf39d0 by Tony Chemit at 2022-11-13T16:05:04+01:00 Rapport Dénombrement des captures accessoires et devenir, filtrées par groupe - Closes #2534 - - - - - 6cc3444c by Tony Chemit at 2022-11-14T07:34:11+01:00 Tck Report - columnHeaders can be null Tck Report - Improve when to deliver asserts - - - - - 6a3376f9 by Tony Chemit at 2022-11-14T13:21:55+01:00 Rapports Distributions de tailles - Closes #2533 - - - - - 6534f2a5 by Tony Chemit at 2022-11-14T13:22:16+01:00 Report API - add safe guard tests (to be able to copy partial matrix) - - - - - c81cfbc3 by Tony Chemit at 2022-11-14T13:22:16+01:00 Report GUI - Manage report with no columns and row headers (everything is coming from the report result to be able to manage dynamic columns) - - - - - 63946e03 by Tony Chemit at 2022-11-14T13:22:16+01:00 Report model - Fix psObservationFobUsageMinimal report (one line escape was missing) - - - - - 4ae9268b by Tony Chemit at 2022-11-14T13:22:16+01:00 Report API - Be able to order variables and repeat variables - - - - - 29db74f1 by Tony Chemit at 2022-11-14T13:22:16+01:00 Report GUI - Respect report variables order in Report model - - - - - 17 changed files: - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ResetEntry.java - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUIHandler.java - core/api/dto/src/main/resources/observe-reports.properties - + core/persistence/java/src/main/java/fr/ird/observe/spi/report/ComputePsObservationLengthsDistribution.java - core/services/test/src/main/java/fr/ird/observe/services/service/ReportFixture.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchByGroupReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchByGroupReportFixture.java - core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchReportFixture.java - core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationLengthsDistributionReportFixture.java - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatch.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatch.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatchByGroup.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchByGroup.properties - + core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationLengthsDistribution.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetCatchByAssociation.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedByAssociation.properties - toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java Changes: ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java ===================================== @@ -43,10 +43,10 @@ import java.net.URL; import java.nio.file.Files; import java.util.Collections; import java.util.Date; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.TreeMap; import java.util.stream.Collectors; /** @@ -81,7 +81,7 @@ public class ReportModel extends AdminActionModel { /** * les variables utilisées pour le report. */ - protected final Map<String, Object> variables; + protected final Map<String, Object> variables = new LinkedHashMap<>(); /** * la fichier contenant la définition des reports. */ @@ -128,7 +128,6 @@ public class ReportModel extends AdminActionModel { public ReportModel() { super(AdminStep.REPORT); - variables = new TreeMap<>(); // quand le type de modèle change, on mets à jour les rapports disponibles addPropertyChangeListener(REPORT_FILE_PROPERTY_NAME, evt -> updateReports()); } ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ResultTableModel.java ===================================== @@ -149,12 +149,11 @@ public class ResultTableModel extends AbstractTableModel { rowNames.addAll(Arrays.asList(report.getRowHeaders())); } - withColumnHeader = !columnNames.isEmpty(); - withRowHeader = !rowNames.isEmpty(); - table.setTableHeader(!withColumnHeader ? null : tableHeader); - table.createDefaultColumnsFromModel(); int nbRows = incomingData.getHeight(); int nbCols = incomingData.getWidth(); + + withColumnHeader = !columnNames.isEmpty(); + withRowHeader = !rowNames.isEmpty(); if (withRowHeader) { // on ajoute une première colonne aux données nbCols += 1; @@ -162,6 +161,22 @@ public class ResultTableModel extends AbstractTableModel { incomingData.setX(1); } + if (!withColumnHeader && !withRowHeader) { + // let's say we always use columns from incomingData + table.setTableHeader(tableHeader); + for (int i = 0; i < nbCols; i++) { + columnNames.add((String) incomingData.getValue(i, 0)); + } + incomingData.setY(-1); + withColumnHeader = true; + nbRows--; + + } else { + table.setTableHeader(!withColumnHeader ? null : tableHeader); + } + table.createDefaultColumnsFromModel(); + + data.setHeight(nbRows); data.setWidth(nbCols); @@ -185,7 +200,9 @@ public class ResultTableModel extends AbstractTableModel { } else if (withColumnHeader) { } - data.copyData(incomingData); + if (nbCols > 0) { + data.copyData(incomingData); + } fireTableStructureChanged(); table.revalidate(); table.repaint(); @@ -220,7 +237,7 @@ public class ResultTableModel extends AbstractTableModel { } public String getClipboardContent(boolean copyRowHeaders, boolean copyColumnHeaders) { - return getDataContent(copyRowHeaders, copyColumnHeaders, true,'\t'); + return getDataContent(copyRowHeaders, copyColumnHeaders, true, '\t'); } public String getCsvContent() { ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ResetEntry.java ===================================== @@ -59,7 +59,12 @@ public final class ResetEntry extends ContentTableUIActionSupport<ContentTableUI } } else { // reset existing entry - tableModel.resetEditBean(); + ui.getStates().setResetEdit(true); + try { + tableModel.resetEditBean(); + } finally { + ui.getStates().setResetEdit(false); + } } } ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUIHandler.java ===================================== @@ -72,12 +72,11 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { private final PropertyChangeListener speciesChanged; public SampleUIHandler() { - weightChanged = evt -> onWeightChanged((Float) evt.getNewValue()); - lengthChanged = evt -> onLengthChanged((Float) evt.getNewValue()); + weightChanged = evt -> onWeightChanged((Float) evt.getNewValue(), !ui.getStates().isResetEdit()); + lengthChanged = evt -> onLengthChanged((Float) evt.getNewValue(), !ui.getStates().isResetEdit()); speciesChanged = evt -> onSpeciesChanged((SpeciesReference) evt.getNewValue()); } - @Override public void onInit(SampleUI ui) { super.onInit(ui); @@ -97,8 +96,8 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { public void onSelectedRowChanged(SampleMeasureDto tableEditBean, SampleMeasureDto previousRowBean, boolean notPersisted, boolean newRow) { - onLengthChanged(tableEditBean.getLength()); - onWeightChanged(tableEditBean.getWeight()); + onLengthChanged(tableEditBean.getLength(), false); + onWeightChanged(tableEditBean.getWeight(), false); SampleUIModel sampleModel = getModel(); @@ -209,6 +208,9 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { } public void startEditTableEditBean(SampleMeasureDto tableEditBean) { + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_WEIGHT, weightChanged); + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_LENGTH, lengthChanged); + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_SPECIES, speciesChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_WEIGHT, weightChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_LENGTH, lengthChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_SPECIES, speciesChanged); @@ -249,9 +251,9 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { acquisitionModeGroup.setSelectedValue(acquisitionMode); } - protected void onWeightChanged(Float newValue) { + protected void onWeightChanged(Float newValue, boolean realChange) { SampleMeasureDto tableEditBean = ui.getModel().getStates().getTableEditBean(); - if (tableEditBean.getAcquisitionMode() == 1) { + if (realChange && tableEditBean.getAcquisitionMode() == 1) { tableEditBean.setIsWeightComputed(false); } if (newValue == null) { @@ -259,9 +261,11 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { } } - protected void onLengthChanged(Float newValue) { + protected void onLengthChanged(Float newValue, boolean realChange) { SampleMeasureDto tableEditBean = ui.getModel().getStates().getTableEditBean(); - tableEditBean.setIsLengthComputed(false); + if (realChange) { + tableEditBean.setIsLengthComputed(false); + } if (newValue == null) { tableEditBean.setLengthMeasureMethod(null); } ===================================== core/api/dto/src/main/resources/observe-reports.properties ===================================== @@ -157,8 +157,8 @@ report.psObservationFobUsageMinimal.request.3=2,0|row|\ Where \ m.id In :tripId \ and dcp.computedWhenArrivingSimplifiedObjectType = :typeObjetId \ - and a.vesselActivity.id != 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' -and (dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#2' \ + and a.vesselActivity.id != 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \ + and (dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#2' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#8' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#4' \ or dcp.objectOperation.id = 'fr.ird.referential.ps.common.ObjectOperation#0#5' \ @@ -567,6 +567,140 @@ report.psObservationSetByAssociation.request.8=3,1|column|\ and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) ################################################################################ +## Captures thons selon le type d'association +################################################################################ +report.psObservationTargetCatchByAssociation.modelType=PS +report.psObservationTargetCatchByAssociation.name=Observations - Captures de thons selon le type d’association (en t) +report.psObservationTargetCatchByAssociation.description=Afficher la répartitions des captures de thons selon le type d'association +report.psObservationTargetCatchByAssociation.columns=YFT, SKJ, BET, LTA, FRI, Autres, Total +report.psObservationTargetCatchByAssociation.rows=BL sans baleine, BL avec baleine, BO avec requin-baleine, BO sans requin-baleine, Total +report.psObservationTargetCatchByAssociation.operations.1=SumRow +report.psObservationTargetCatchByAssociation.operations.2=SumColumn +# ligne 1 +report.psObservationTargetCatchByAssociation.request.1=0,0|row|\ + Select \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then 0.0 \ + Else ct.catchWeight End) \ + From TripImpl m \ + Join m.routeObs r \ + Join r.activity a \ + Join a.set c \ + with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#2' \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = FALSE, \ + ObservedSystemImpl os \ + Where \ + m.id In :tripId \ + and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9395222812356602' \ + and os not in elements(a.observedSystem) +# ligne 2 +report.psObservationTargetCatchByAssociation.request.7=0,1|row|\ + Select \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then 0.0 \ + Else ct.catchWeight End) \ + From TripImpl m \ + Join m.routeObs r \ + Join r.activity a \ + Join a.set c \ + with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#2' \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = FALSE, \ + ObservedSystemImpl os \ + Where \ + m.id In :tripId \ + and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9395222812356602' \ + and os in elements(a.observedSystem) +# ligne 3 +report.psObservationTargetCatchByAssociation.request.13=0,2|row|\ + Select \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then 0.0 \ + Else ct.catchWeight End) \ + From TripImpl m \ + Join m.routeObs r \ + Join r.activity a \ + Join a.set c \ + with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#1' \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = FALSE, \ + ObservedSystemImpl os \ + Where \ + m.id In :tripId \ + and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ + and os in elements(a.observedSystem) +# ligne 4 +report.psObservationTargetCatchByAssociation.request.19=0,3|row|\ + Select \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then ct.catchWeight \ + Else 0.0 End), \ + Sum(CASE ct.species.topiaId When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.8024257002747615' Then 0.0 \ + When 'fr.ird.referential.common.Species#1239832685477#0.3846921632590058' Then 0.0 \ + Else ct.catchWeight End) \ + From TripImpl m \ + Join m.routeObs r \ + Join r.activity a \ + Join a.set c \ + with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#1' \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = FALSE, \ + ObservedSystemImpl os \ + Where \ + m.id In :tripId \ + and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ + and os not in elements(a.observedSystem) +################################################################################ ## Rejets thons selon le type d'association ################################################################################ report.psObservationTargetDiscardedByAssociation.modelType=PS @@ -600,7 +734,8 @@ report.psObservationTargetDiscardedByAssociation.request.1=0,0|row|\ Join r.activity a \ Join a.set c \ with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#2' \ - Join c.catches ct, \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = TRUE, \ ObservedSystemImpl os \ Where \ m.id In :tripId \ @@ -630,7 +765,8 @@ report.psObservationTargetDiscardedByAssociation.request.7=0,1|row|\ Join r.activity a \ Join a.set c \ with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#2' \ - Join c.catches ct, \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = TRUE, \ ObservedSystemImpl os \ Where \ m.id In :tripId \ @@ -660,7 +796,8 @@ report.psObservationTargetDiscardedByAssociation.request.13=0,2|row|\ Join r.activity a \ Join a.set c \ with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#1' \ - Join c.catches ct, \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = TRUE, \ ObservedSystemImpl os \ Where \ m.id In :tripId \ @@ -690,33 +827,34 @@ report.psObservationTargetDiscardedByAssociation.request.19=0,3|row|\ Join r.activity a \ Join a.set c \ with c.schoolType.id = 'fr.ird.referential.ps.common.SchoolType#0#1' \ - Join c.catches ct, \ + Join c.catches ct \ + Join ct.speciesFate sf with sf.discard = TRUE, \ ObservedSystemImpl os \ Where \ m.id In :tripId \ and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) ################################################################################ -## Captures accessoires observées +## Captures observées ################################################################################ -report.psObservationAccessoryCatch.modelType=PS -report.psObservationAccessoryCatch.name=Observations - Liste des captures accessoires selon le type de banc, filtrées par groupe -report.psObservationAccessoryCatch.description=Afficher les captures accessoires par groupe d'espèce\nLes poids sont exprimés en tonnes. -report.psObservationAccessoryCatch.columns=Espèce, Banc libre, Banc objet -report.psObservationAccessoryCatch.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code -report.psObservationAccessoryCatch.repeatVariable.speciesId=java.lang.String|\ +report.psObservationCatch.modelType=PS +report.psObservationCatch.name=Observations - Liste des captures selon le type de banc, filtrées par groupe +report.psObservationCatch.description=Afficher les captures par groupe d'espèce\nLes poids sont exprimés en tonnes. +report.psObservationCatch.columns=Espèce, Banc libre, Banc objet +report.psObservationCatch.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code +report.psObservationCatch.repeatVariable.speciesId=java.lang.String|\ Select e.id From SpeciesImpl e \ Where e.speciesGroup.id = :speciesGroup \ Order By e.homeId -report.psObservationAccessoryCatch.request.1=0,0|row|\ +report.psObservationCatch.request.1=0,0|row|\ Select \ concat('[FAO]', (case when e.faoCode is not null then e.faoCode else '-' end), \ ' [sc]', (case when e.scientificLabel is not null then e.scientificLabel else '-' end), \ ' [fr]', (case when e.label2 is not null then e.label2 else '-' end)) \ From SpeciesImpl e \ Where e.id = :speciesId -report.psObservationAccessoryCatch.request.1.repeat=speciesId|column -report.psObservationAccessoryCatch.request.2=1,0|row|\ +report.psObservationCatch.request.1.repeat=speciesId|column +report.psObservationCatch.request.2=1,0|row|\ Select \ case when Count(ca) > 0 then \ concat('+', \ @@ -731,8 +869,8 @@ report.psObservationAccessoryCatch.request.2=1,0|row|\ Join c.catches ca \ with ca.species.id = :speciesId \ Where m.id In :tripId -report.psObservationAccessoryCatch.request.2.repeat=speciesId|column -report.psObservationAccessoryCatch.request.3=2,0|row|\ +report.psObservationCatch.request.2.repeat=speciesId|column +report.psObservationCatch.request.3=2,0|row|\ Select \ case when Count(ca) > 0 then \ concat('+', \ @@ -747,16 +885,16 @@ report.psObservationAccessoryCatch.request.3=2,0|row|\ Join c.catches ca \ with ca.species.id = :speciesId \ Where m.id In :tripId -report.psObservationAccessoryCatch.request.3.repeat=speciesId|column +report.psObservationCatch.request.3.repeat=speciesId|column ################################################################################ -## Captures accessoires par speciesGroup d'espèces +## Captures par groupe d'espèces ################################################################################ -report.psObservationAccessoryCatchByGroup.modelType=PS -report.psObservationAccessoryCatchByGroup.name=Observations - Dénombrement des captures accessoires et devenir, filtrés par groupe -report.psObservationAccessoryCatchByGroup.description=Afficher les nombres de captures accessoires par groupe d'espèce selon le type de banc et le devenir -report.psObservationAccessoryCatchByGroup.columns=Espèce, Total BL, Total BO, Sorti vivant/échappé, Sorti mort, Rejeté vivant, Rejeté mort, Partiellement conservé, Cuve, Cuisine, Autre -report.psObservationAccessoryCatchByGroup.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code -report.psObservationAccessoryCatchByGroup.request.1=0,0|row|\ +report.psObservationCatchByGroup.modelType=PS +report.psObservationCatchByGroup.name=Observations - Dénombrement des captures par devenir, filtrés par groupe +report.psObservationCatchByGroup.description=Afficher les nombres de captures par groupe d'espèce selon le type de banc et le devenir +report.psObservationCatchByGroup.columns=Espèce, Total BL, Total BO, Sorti vivant/échappé, Sorti mort, Rejeté vivant, Rejeté mort, Partiellement conservé, Cuve, Cuisine, Conservé pour le marché local ou poisson séché/salé à bord, Ailerons seulements, Rejeté statut inconnu (seulement pour l'observation électronique), Conservé à des fins scientifiques, Rejeté suffocant, Rejeté blessé, Autre +report.psObservationCatchByGroup.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code +report.psObservationCatchByGroup.request.1=0,0|row|\ Select \ concat(\ '[FAO]', (case when e.faoCode is not null then e.faoCode else '-' end), \ @@ -779,6 +917,12 @@ report.psObservationAccessoryCatchByGroup.request.1=0,0|row|\ else 0.0 end), \ Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1239832683621#0.6728026426066158' then ca.totalCount \ else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1464000000000#15' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1467372855729#0.568287924081734' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1501492537510#0.9210847837998154' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1501492831539#0.9377232562184147' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1544448835551#0.620629930572886' then ca.totalCount else 0.0 end), \ + Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1544448977865#0.24265421995390768' then ca.totalCount else 0.0 end), \ Sum(case ca.speciesFate.id when 'fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.9931091059863436' then 0.0 \ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683618#0.06155887805368032' then 0.0 \ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.11883784875534997' then 0.0 \ @@ -787,6 +931,12 @@ report.psObservationAccessoryCatchByGroup.request.1=0,0|row|\ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683620#0.46609703818634485' then 0.0 \ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.5722739932065866' then 0.0 \ when 'fr.ird.referential.ps.common.SpeciesFate#1239832683621#0.6728026426066158' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1464000000000#15' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1467372855729#0.568287924081734' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1501492537510#0.9210847837998154' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1501492831539#0.9377232562184147' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1544448835551#0.620629930572886' then 0.0 \ + when 'fr.ird.referential.ps.common.SpeciesFate#1544448977865#0.24265421995390768' then 0.0 \ else ca.totalCount end) \ From TripImpl m \ Join m.routeObs r \ @@ -799,6 +949,47 @@ report.psObservationAccessoryCatchByGroup.request.1=0,0|row|\ Group by e \ Order By e.homeId ########################################################### +## Distribution des tailles par espèces et type de mesure +########################################################### +report.psObservationLengthsDistribution.modelType=PS +report.psObservationLengthsDistribution.name=Observations - Distribution des tailles par espèces et type de mesure +report.psObservationLengthsDistribution.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces et le type de mesure +report.psObservationLengthsDistribution.operations.1=ComputePsObservationLengthsDistribution +report.psObservationLengthsDistribution.variable.1.species=fr.ird.observe.dto.referential.common.SpeciesDto|\ +Select distinct ntl.species \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set.sample nts \ +Join nts.sampleMeasure ntl \ +Where t.id In :tripId +report.psObservationLengthsDistribution.variable.2.sizeMeasureType=fr.ird.observe.dto.referential.common.SizeMeasureTypeDto|\ +Select distinct ntl.sizeMeasureType \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set.sample nts \ +Join nts.sampleMeasure ntl \ +Where t.id In :tripId +report.psObservationLengthsDistribution.repeatVariable.speciesFate=fr.ird.observe.entities.referential.ps.common.SpeciesFate|\ +Select distinct sf \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set.sample nts \ +Join nts.sampleMeasure ntl with ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \ +Left Join ntl.speciesFate sf \ +Where t.id In :tripId +report.psObservationLengthsDistribution.repeatVariable.length=java.lang.Float|\ +Select distinct ntl.length \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set.sample nts \ +Join nts.sampleMeasure ntl with ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \ +Where t.id In :tripId \ +Order By ntl.length +########################################################### ## Distribution des tailles par espèces non ciblées ########################################################### report.psObservationNonTargetDistributionLengths.modelType=PS ===================================== core/persistence/java/src/main/java/fr/ird/observe/spi/report/ComputePsObservationLengthsDistribution.java ===================================== @@ -0,0 +1,161 @@ +package fr.ird.observe.spi.report; + +/*- + * #%L + * ObServe Core :: Persistence :: Java + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.auto.service.AutoService; +import fr.ird.observe.dto.report.DataMatrix; +import fr.ird.observe.dto.report.Report; +import fr.ird.observe.dto.report.ReportOperationConsumer; +import fr.ird.observe.dto.report.ReportRequestExecutor; +import fr.ird.observe.dto.report.ReportVariable; +import fr.ird.observe.entities.referential.ps.common.SpeciesFate; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; + +/** + * Created on 13/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +(a)AutoService(ReportOperationConsumer.class) +public class ComputePsObservationLengthsDistribution implements ReportOperationConsumer { + + /** + * To get total count per length. + */ + public static final String TOTAL_COUNT_REQUEST = "" + + "Select sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType \n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + /** + * To get species fate count per length + */ + public static final String SPECIES_FATE_COUNT_REQUEST = "" + + "Select ntl.length, sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType And ntl.speciesFate.id = :speciesFate\n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + /** + * To get null species fate count per length + */ + public static final String NULL_SPECIES_FATE_COUNT_REQUEST = "" + + "Select ntl.length, sum(ntl.count) \n" + + "From TripImpl t \n" + + "Join t.routeObs r \n" + + "Join r.activity a \n" + + "Join a.set.sample nts \n" + + "Join nts.sampleMeasure ntl With ntl.species.id = :species And ntl.sizeMeasureType.id = :sizeMeasureType And ntl.speciesFate Is Null\n" + + "Where t.id In :tripId \n" + + "Group By ntl.length \n" + + "Order By ntl.length"; + + @Override + public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) { + + Map<String, Object> queryParameters = new TreeMap<>(); + queryParameters.put("tripId", tripId); + for (ReportVariable<?> variable : report.getVariables()) { + queryParameters.put(variable.getName(), variable.getSelectedValue()); + } + + Set<SpeciesFate> speciesFateList = report.<SpeciesFate>getRepeatVariable("speciesFate").getValues(); + List<String> lengthList = report.getRepeatVariable("length").getValues().stream().map(Object::toString).collect(Collectors.toList()); + + DataMatrix result = createTmpMatrix(0, 0, 2 + speciesFateList.size(), 1 + lengthList.size()); + boolean useNullSpeciesFate = speciesFateList.remove(null); + int columnIndex = 0; + fillLengthsColumn(result, columnIndex++, lengthList); + + for (SpeciesFate speciesFate : speciesFateList) { + fillSpeciesFateCountColumn(result, columnIndex++, queryParameters, speciesFate, lengthList, requestExecutor); + } + + if (useNullSpeciesFate) { + fillSpeciesFateCountColumn(result, columnIndex++, queryParameters, null, lengthList, requestExecutor); + } + + fillTotalCountColumn(result, columnIndex, queryParameters, requestExecutor); + + return result; + } + + private void fillLengthsColumn(DataMatrix result, int columnIndex, List<String> lengthList) { + int index = 0; + result.setValue(columnIndex, index++, "Classe de taille (cm)"); + for (String length : lengthList) { + result.setValue(columnIndex, index++, length); + } + } + + private void fillSpeciesFateCountColumn(DataMatrix result, int columnIndex, Map<String, Object> queryParameters, SpeciesFate speciesFate, List<String> lengthList, ReportRequestExecutor requestExecutor) { + String header; + List<Object[]> rows; + if (speciesFate == null) { + header = "Aucun"; + queryParameters.remove("speciesFate"); + rows = requestExecutor.executeRequest(NULL_SPECIES_FATE_COUNT_REQUEST, queryParameters); + } else { + header = speciesFate.getLabel2(); + queryParameters.put("speciesFate", speciesFate.getId()); + rows = requestExecutor.executeRequest(SPECIES_FATE_COUNT_REQUEST, queryParameters); + } + result.setValue(columnIndex, 0, String.format("Effectif ( devenir - %s )", header)); + + for (Object[] row : rows) { + String length = row[0].toString(); + Number count = (Number) row[1]; + int index = lengthList.indexOf(length); + result.setValue(columnIndex, index + 1, count); + } + } + + private void fillTotalCountColumn(DataMatrix result, int columnIndex, Map<String, Object> queryParameters, ReportRequestExecutor requestExecutor) { + result.setValue(columnIndex, 0, "Effectif total"); + List<Object> rows = requestExecutor.executeRequest(TOTAL_COUNT_REQUEST, queryParameters); + int index = 1; + for (Object row : rows) { + Number count = (Number) row; + result.setValue(columnIndex, index++, count); + } + } + +} + ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/ReportFixture.java ===================================== @@ -76,6 +76,7 @@ public abstract class ReportFixture { } public final DataMatrix execute(ReportService service, Report report) { + log.warn("Starting report {}", report.getName()); return service.executeReport(report, getTripIds()); } @@ -127,6 +128,8 @@ public abstract class ReportFixture { for (int i = 0; i < rows; i++) { ReportServiceFixtures.writeArrayAssert(String.format("result.%d", i), actual.getData()[i]); } + System.out.println("New asserts:\n" + String.join("\n", ReportServiceFixtures.getAsserts())); + ReportServiceFixtures.getAsserts().clear(); } } @@ -159,7 +162,11 @@ public abstract class ReportFixture { Assert.assertEquals(rows, report.getRows()); Assert.assertEquals(columns, report.getColumns()); - Assert.assertArrayEquals(columnsHeader, report.getColumnHeaders()); + if (report.getColumnHeaders() == null) { + Assert.assertEquals(0, columnsHeader.length); + } else { + Assert.assertArrayEquals(columnsHeader, report.getColumnHeaders()); + } if (report.getRowHeaders() == null) { Assert.assertEquals(0, rowsHeader.length); } else { @@ -168,7 +175,11 @@ public abstract class ReportFixture { } else { ReportServiceFixtures.addAssert("syntax.rows", report.getRows()); ReportServiceFixtures.addAssert("syntax.columns", report.getColumns()); - ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader", (Object[]) report.getColumnHeaders()); + if (report.getRowHeaders() == null) { + ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader"); + } else { + ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader", (Object[]) report.getColumnHeaders()); + } if (report.getRowHeaders() == null) { ReportServiceFixtures.writeArrayAssert("syntax.rowsHeader"); } else { ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchByGroupReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchByGroupReportFixture.java ===================================== @@ -35,7 +35,7 @@ import java.util.Iterator; * @since 1.9 */ @AutoService(ReportFixture.class) -public class PsObservationAccessoryCatchByGroupReportFixture extends ReportFixture { +public class PsObservationCatchByGroupReportFixture extends ReportFixture { @Override public void assertSyntax(Report report) { ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationAccessoryCatchReportFixture.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchReportFixture.java ===================================== @@ -36,7 +36,7 @@ import java.util.Iterator; * @since 1.9 */ @AutoService(ReportFixture.class) -public class PsObservationAccessoryCatchReportFixture extends ReportFixture { +public class PsObservationCatchReportFixture extends ReportFixture { @Override public void assertSyntax(Report report) { ===================================== core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java → core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationLengthsDistributionReportFixture.java ===================================== @@ -1,8 +1,8 @@ -package fr.ird.observe.services.local.service; +package fr.ird.observe.services.service.report.ps; /*- * #%L - * ObServe Core :: Services :: Local + * ObServe Core :: Services :: Test * %% * Copyright (C) 2008 - 2022 IRD, Ultreia.io * %% @@ -22,17 +22,23 @@ package fr.ird.observe.services.local.service; * #L% */ -import fr.ird.observe.services.service.ReportServiceFixtures; -import org.junit.AfterClass; +import com.google.auto.service.AutoService; +import fr.ird.observe.dto.report.Report; +import fr.ird.observe.services.service.ReportFixture; -public class ReportServiceLocalReadTest extends GeneratedReportServiceLocalReadTest { +/** + * Created on 13/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +(a)AutoService(ReportFixture.class) +public class PsObservationLengthsDistributionReportFixture extends ReportFixture { - @AfterClass - public static void afterClass() { - if (!ReportServiceFixtures.WITH_ASSERT) { - System.out.println("New asserts:\n" + String.join("\n", ReportServiceFixtures.getAsserts())); - ReportServiceFixtures.getAsserts().clear(); - } + @Override + protected void setVariables(Report report) { + setVariableValue(report, "species", "fr.ird.referential.common.Species#1239832684537#0.2397229787936519"); + setVariableValue(report, "sizeMeasureType", "fr.ird.referential.common.SizeMeasureType#1433499465700#0.0902433863375336"); } - } + ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatch.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatch.properties ===================================== @@ -19,8 +19,24 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### +syntax.name=Observations - Liste des captures selon le type de banc, filtrées par groupe +syntax.description=Afficher les captures par groupe d'espèce-Les poids sont exprimés en tonnes. +syntax.columns=3 +syntax.rows=-1 +syntax.columnsHeader=Espèce^Banc libre^Banc objet +syntax.nbRequests=3 +result.columns=3 +result.rows=49 result.0=[FAO]CCB [sc]Carcharhinus brevipinna [fr]Requin tisserand^-^- result.1=[FAO]ALS [sc]Carcharhinus albimarginatus [fr]Requin pointe blanche^-^- +result.2=[FAO]AML [sc]Carcharhinus amblyrhynchos [fr]Grey reef shark^-^- +result.3=[FAO]PTH [sc]Alopias pelagicus [fr]Renard pélagique^-^- +result.4=[FAO]BTH [sc]Alopias superciliosus [fr]Renard à gros yeux^-^- +result.5=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^-^+ Effectif : 3 Poids total (t) : 12.0 +result.6=[FAO]BLR [sc]Carcharhinus melanopterus [fr]Requin pointes noires^-^- +result.7=[FAO]BRO [sc]Carcharhinus brachyurus [fr]Requin cuivre^-^- +result.8=[FAO]WSH [sc]Carcharodon carcharias [fr]Grand requin blanc^-^- +result.9=[FAO]CCE [sc]Carcharhinus leucas [fr]Requin bouledogue^-^- result.10=[FAO]CCL [sc]Carcharhinus limbatus [fr]Requin bordé^-^- result.11=[FAO]CCP [sc]Carcharhinus plumbeus [fr]Requin gris^-^- result.12=[FAO]FAL [sc]Carcharhinus falciformis [fr]Requin soyeux^-^- @@ -28,10 +44,9 @@ result.13=[FAO]OCS [sc]Carcharhinus longimanus [fr]Requin océanique^-^- result.14=[FAO]CWZ [sc]Carcharhinus spp [fr]Requins Carcharhinus nca^-^- result.15=[FAO]DUS [sc]Carcharhinus obscurus [fr]Requin sombre^-^- result.16=[FAO]SHL [sc]Etmopterus spp [fr]Genre Etmopterus^-^- -result.17=[FAO]THR [sc]Alopias spp [fr]Renards de mer nca ^-^- +result.17=[FAO]THR [sc]Alopias spp [fr]Renards de mer nca^-^- result.18=[FAO]RSK [sc]Carcharhinidae spp [fr]Famille Carcharhinidae^-^- result.19=[FAO]MSK [sc]Lamnidae [fr]Famille Lamnidae^-^- -result.2=[FAO]AML [sc]Carcharhinus amblyrhynchos [fr]Grey reef shark^-^- result.20=[FAO]2FOD [sc]Odontaspididae [fr]Odontaspididae^-^- result.21=[FAO]2FRH [sc]Rhincodontidae [fr]Famille Rhincodontidae^-^- result.22=[FAO]SPY [sc]Sphyrnidae [fr]Famille Sphyrnidae^-^- @@ -42,18 +57,16 @@ result.26=[FAO]LMA [sc]Isurus paucus [fr]Petite taupe, Mako^-^- result.27=[FAO]MAK [sc]Isurus spp [fr]Taupes^-^- result.28=[FAO]LMP [sc]Megachasma pelagios [fr]Requin grande gueule^-^- result.29=[FAO]CVX [sc]Carcharhiniformes [fr]Ordre Carcharhiniformes^-^- -result.3=[FAO]PTH [sc]Alopias pelagicus [fr]Renard pélagique^-^- result.30=[FAO]HDQ [sc]Heterodontiformes [fr]Ordre Heterodontiformes^-^- result.31=[FAO]HXW [sc]Hexanchiformes [fr]Ordre Hexanchiformes^-^- result.32=[FAO]LMZ [sc]Lamniformes [fr]Ordre Lamniformes^-^- result.33=[FAO]OCX [sc]Orectolobiformes [fr]Ordre Orectolobiformes^-^- -result.34=[FAO]PWS [sc]Pristiophorus spp [fr]Requins-scies nca ^-^- +result.34=[FAO]PWS [sc]Pristiophorus spp [fr]Requins-scies nca^-^- result.35=[FAO]OSF [sc]Stegostoma fasciatum [fr]Requin zèbre^-^- result.36=[FAO]SHX [sc]Squaliformes [fr]Ordre Squaliformes^-^- -result.37=[FAO]ASK [sc]Squatinidae [fr]Anges de mer nca ^-^- +result.37=[FAO]ASK [sc]Squatinidae [fr]Anges de mer nca^-^- result.38=[FAO]BSH [sc]Prionace glauca [fr]Peau bleue^-^- result.39=[FAO]POR [sc]Lamna nasus [fr]Requin taupe commun^-^- -result.4=[FAO]BTH [sc]Alopias superciliosus [fr]Renard à gros yeux^-^- result.40=[FAO]PSK [sc]Pseudocarcharias kamoharai [fr]Requin crocodile^-^- result.41=[FAO]2REX [sc]Requin non identifié [fr]Requin non identifié^-^- result.42=[FAO]BSK [sc]Cetorhinus maximus [fr]Requin pèlerin^-^- @@ -63,17 +76,3 @@ result.45=[FAO]SPL [sc]Sphyrna lewini [fr]Requin marteau halicorne^-^- result.46=[FAO]SPK [sc]Sphyrna mokarran [fr]Grand requin marteau^-^- result.47=[FAO]SPN [sc]Sphyrna spp [fr]Requins marteau nca^-^- result.48=[FAO]SPZ [sc]Sphyrna zygaena [fr]Requin marteau commun^-^- -result.5=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^-^+ Effectif : 3 Poids total (t) : 12.0 -result.6=[FAO]BLR [sc]Carcharhinus melanopterus [fr]Requin pointes noires^-^- -result.7=[FAO]BRO [sc]Carcharhinus brachyurus [fr]Requin cuivre^-^- -result.8=[FAO]WSH [sc]Carcharodon carcharias [fr]Grand requin blanc^-^- -result.9=[FAO]CCE [sc]Carcharhinus leucas [fr]Requin bouledogue^-^- -result.columns=3 -result.rows=49 -syntax.columns=3 -syntax.columnsHeader=Espèce^Banc libre^Banc objet -syntax.description=Afficher les captures accessoires par groupe d'espèce-Les poids sont exprimés en tonnes. -syntax.name=Observations - Liste des captures accessoires selon le type de banc, filtrées par groupe -syntax.nbRequests=3 -syntax.rows=-1 -syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationAccessoryCatchByGroup.properties → core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchByGroup.properties ===================================== @@ -19,13 +19,13 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -result.0=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^0^3^3^0^0^0^0^0^0^0.0 -result.columns=11 +result.0=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^0^3^3^0^0^0^0^0^0^0^0^0^0^0^0^0.0 +result.columns=17 result.rows=1 -syntax.columns=11 -syntax.columnsHeader=Espèce^Total BL^Total BO^Sorti vivant/échappé^Sorti mort^Rejeté vivant^Rejeté mort^Partiellement conservé^Cuve^Cuisine^Autre -syntax.description=Afficher les nombres de captures accessoires par groupe d'espèce selon le type de banc et le devenir -syntax.name=Observations - Dénombrement des captures accessoires et devenir, filtrés par groupe +syntax.columns=17 +syntax.columnsHeader=Espèce^Total BL^Total BO^Sorti vivant/échappé^Sorti mort^Rejeté vivant^Rejeté mort^Partiellement conservé^Cuve^Cuisine^Conservé pour le marché local ou poisson séché/salé à bord^Ailerons seulements^Rejeté statut inconnu (seulement pour l'observation électronique)^Conservé à des fins scientifiques^Rejeté suffocant^Rejeté blessé^Autre +syntax.description=Afficher les nombres de captures par groupe d'espèce selon le type de banc et le devenir +syntax.name=Observations - Dénombrement des captures par devenir, filtrés par groupe syntax.nbRequests=1 syntax.rows=-1 syntax.rowsHeader= ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationLengthsDistribution.properties ===================================== @@ -0,0 +1,35 @@ +### +# #%L +# ObServe Core :: Services :: Test +# %% +# Copyright (C) 2008 - 2022 IRD, Ultreia.io +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### +syntax.name=Observations - Distribution des tailles par espèces et type de mesure +syntax.description=Afficher la nombre d'individus mesurés par classe de taille pour les espèces et le type de mesure +syntax.rows=-1 +syntax.columns=-1 +syntax.columnsHeader= +syntax.rowsHeader= +syntax.nbRequests=0 +result.columns=3 +result.rows=5 +result.0=Classe de taille (cm)^Effectif ( devenir - Aucun )^Effectif total +result.1=50.0^2^2 +result.2=54.0^1^1 +result.3=68.0^1^1 +result.4=70.0^1^1 ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetCatchByAssociation.properties ===================================== @@ -19,3 +19,17 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### +syntax.name=Observations - Captures de thons selon le type d’association (en t) +syntax.description=Afficher la répartitions des captures de thons selon le type d'association +syntax.rows=5 +syntax.columns=7 +syntax.columnsHeader=YFT^SKJ^BET^LTA^FRI^Autres^Total +syntax.rowsHeader=BL sans baleine^BL avec baleine^BO avec requin-baleine^BO sans requin-baleine^Total +syntax.nbRequests=4 +result.columns=7 +result.rows=5 +result.0=175.0^0.0^7.0^0.0^0.0^0.0^182.0 +result.1=null^null^null^null^null^null^0.0 +result.2=null^null^null^null^null^null^0.0 +result.3=0.0^1.0^0.0^0.0^1.0^12.1406^14.1406 +result.4=175.0^1.0^7.0^0.0^1.0^12.1406^196.1406 \ No newline at end of file ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationTargetDiscardedByAssociation.properties ===================================== @@ -19,11 +19,11 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -result.0=175.0^0.0^7.0^0.0^0.0^0.2882^182.2882 +result.0=0.0^0.0^0.0^0.0^0.0^0.2882^0.2882 result.1=null^null^null^null^null^null^0.0 result.2=null^null^null^null^null^null^0.0 -result.3=0.0^1.0^5.0^0.0^1.0^160.4436^167.4436 -result.4=175.0^1.0^12.0^0.0^1.0^160.7318^349.7318 +result.3=0.0^0.0^5.0^0.0^0.0^148.303^153.303 +result.4=0.0^0.0^5.0^0.0^0.0^148.5912^153.5912 result.columns=7 result.rows=5 syntax.columns=7 ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/DataMatrix.java ===================================== @@ -159,7 +159,13 @@ public class DataMatrix implements JsonAware { log.debug(String.format("copying incoming matrix (dim: %s, location: %s)", incoming.getDimension(), incoming.getLocation())); for (int i = 0; i < width; i++) { + if (x + i < 0) { + continue; + } for (int j = 0; j < height; j++) { + if (y + j < 0) { + continue; + } Serializable value = incoming.getValue(i, j); setValue(x + i, y + j, value); } ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java ===================================== @@ -319,12 +319,14 @@ public class ReportBuilder { Map.Entry<String, String> entry = itr.next(); String key = entry.getKey(); if (!key.startsWith(VARIABLE_PREFIX)) { - continue; } String operations = entry.getValue(); String id = key.substring(VARIABLE_PREFIX.length()); - + int indexOf = id.indexOf("."); + if (indexOf > -1) { + id = id.substring(indexOf + 1); + } // on interdit la surcharge d'une variable déjà trouvée pour le report if (ids.contains(id)) { throw new IllegalArgumentException("La variable " + id + " est déjà définie pour le report " + reportName); @@ -359,12 +361,14 @@ public class ReportBuilder { Map.Entry<String, String> entry = itr.next(); String key = entry.getKey(); if (!key.startsWith(REPEAT_VARIABLE_PREFIX)) { - continue; } String operations = entry.getValue(); String id = key.substring(REPEAT_VARIABLE_PREFIX.length()); - + int indexOf = id.indexOf("."); + if (indexOf > -1) { + id = id.substring(indexOf + 1); + } // on interdit la surcharge d'une variable déjà trouvée pour le report if (ids.contains(id)) { throw new IllegalArgumentException("La variable de répétition " + id + " est déjà définie pour le report " + reportName); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/210adc7fd460ad0565ebe6ea… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/210adc7fd460ad0565ebe6ea… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop] 3 commits: Rapport Liste des captures de faune accessoire selon le type de banc, filtrées...
by Tony CHEMIT (@tchemit) 13 Nov '22

13 Nov '22
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 7d63077a by Tony Chemit at 2022-11-13T12:25:33+01:00 Rapport Liste des captures de faune accessoire selon le type de banc, filtrées par groupe - Closes #2532 - - - - - a0b62552 by Tony Chemit at 2022-11-13T12:25:37+01:00 GUI - use resetEdit state when reset entry on content table - - - - - b8a08b6b by Tony Chemit at 2022-11-13T12:25:42+01:00 GUI - Sur échantillons PS observations saisis par lots, migrés vers 9.0, valeurs étranges sur le champ poids individuel - Closes #2503 - - - - - 3 changed files: - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ResetEntry.java - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUIHandler.java - core/api/dto/src/main/resources/observe-reports.properties Changes: ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ResetEntry.java ===================================== @@ -59,7 +59,12 @@ public final class ResetEntry extends ContentTableUIActionSupport<ContentTableUI } } else { // reset existing entry - tableModel.resetEditBean(); + ui.getStates().setResetEdit(true); + try { + tableModel.resetEditBean(); + } finally { + ui.getStates().setResetEdit(false); + } } } ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUIHandler.java ===================================== @@ -51,7 +51,7 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { * * @since 3.0 */ - private final PropertyChangeListener weightChanged; + private final PropertyChangeListener weightChanged = evt -> onWeightChanged((Float) evt.getNewValue(), !ui.getStates().isResetEdit()); /** * Ecoute les modifications de la propriété {@link SampleMeasureDto#getLength()}, @@ -60,7 +60,7 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { * * @since 3.0 */ - private final PropertyChangeListener lengthChanged; + private final PropertyChangeListener lengthChanged = evt -> onLengthChanged((Float) evt.getNewValue(), !ui.getStates().isResetEdit()); /** * Ecoute les modifications de la propriété {@link SampleMeasureDto#getLength()}, @@ -69,14 +69,7 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { * * @since 3.0 */ - private final PropertyChangeListener speciesChanged; - - public SampleUIHandler() { - weightChanged = evt -> onWeightChanged((Float) evt.getNewValue()); - lengthChanged = evt -> onLengthChanged((Float) evt.getNewValue()); - speciesChanged = evt -> onSpeciesChanged((SpeciesReference) evt.getNewValue()); - } - + private final PropertyChangeListener speciesChanged = evt -> onSpeciesChanged((SpeciesReference) evt.getNewValue()); @Override public void onInit(SampleUI ui) { @@ -97,8 +90,8 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { public void onSelectedRowChanged(SampleMeasureDto tableEditBean, SampleMeasureDto previousRowBean, boolean notPersisted, boolean newRow) { - onLengthChanged(tableEditBean.getLength()); - onWeightChanged(tableEditBean.getWeight()); + onLengthChanged(tableEditBean.getLength(), false); + onWeightChanged(tableEditBean.getWeight(), false); SampleUIModel sampleModel = getModel(); @@ -209,6 +202,9 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { } public void startEditTableEditBean(SampleMeasureDto tableEditBean) { + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_WEIGHT, weightChanged); + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_LENGTH, lengthChanged); + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_SPECIES, speciesChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_WEIGHT, weightChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_LENGTH, lengthChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_SPECIES, speciesChanged); @@ -249,9 +245,9 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { acquisitionModeGroup.setSelectedValue(acquisitionMode); } - protected void onWeightChanged(Float newValue) { + protected void onWeightChanged(Float newValue, boolean realChange) { SampleMeasureDto tableEditBean = ui.getModel().getStates().getTableEditBean(); - if (tableEditBean.getAcquisitionMode() == 1) { + if (realChange && tableEditBean.getAcquisitionMode() == 1) { tableEditBean.setIsWeightComputed(false); } if (newValue == null) { @@ -259,9 +255,11 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { } } - protected void onLengthChanged(Float newValue) { + protected void onLengthChanged(Float newValue, boolean realChange) { SampleMeasureDto tableEditBean = ui.getModel().getStates().getTableEditBean(); - tableEditBean.setIsLengthComputed(false); + if (realChange) { + tableEditBean.setIsLengthComputed(false); + } if (newValue == null) { tableEditBean.setLengthMeasureMethod(null); } ===================================== core/api/dto/src/main/resources/observe-reports.properties ===================================== @@ -697,26 +697,26 @@ report.psObservationTargetDiscardedByAssociation.request.19=0,3|row|\ and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) ################################################################################ -## Captures accessoires observées +## Captures observées ################################################################################ -report.psObservationAccessoryCatch.modelType=PS -report.psObservationAccessoryCatch.name=Observations - Liste des captures accessoires selon le type de banc, filtrées par groupe -report.psObservationAccessoryCatch.description=Afficher les captures accessoires par groupe d'espèce\nLes poids sont exprimés en tonnes. -report.psObservationAccessoryCatch.columns=Espèce, Banc libre, Banc objet -report.psObservationAccessoryCatch.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code -report.psObservationAccessoryCatch.repeatVariable.speciesId=java.lang.String|\ +report.psObservationCatch.modelType=PS +report.psObservationCatch.name=Observations - Liste des captures selon le type de banc, filtrées par groupe +report.psObservationCatch.description=Afficher les captures par groupe d'espèce\nLes poids sont exprimés en tonnes. +report.psObservationCatch.columns=Espèce, Banc libre, Banc objet +report.psObservationCatch.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code +report.psObservationCatch.repeatVariable.speciesId=java.lang.String|\ Select e.id From SpeciesImpl e \ Where e.speciesGroup.id = :speciesGroup \ Order By e.homeId -report.psObservationAccessoryCatch.request.1=0,0|row|\ +report.psObservationCatch.request.1=0,0|row|\ Select \ concat('[FAO]', (case when e.faoCode is not null then e.faoCode else '-' end), \ ' [sc]', (case when e.scientificLabel is not null then e.scientificLabel else '-' end), \ ' [fr]', (case when e.label2 is not null then e.label2 else '-' end)) \ From SpeciesImpl e \ Where e.id = :speciesId -report.psObservationAccessoryCatch.request.1.repeat=speciesId|column -report.psObservationAccessoryCatch.request.2=1,0|row|\ +report.psObservationCatch.request.1.repeat=speciesId|column +report.psObservationCatch.request.2=1,0|row|\ Select \ case when Count(ca) > 0 then \ concat('+', \ @@ -731,8 +731,8 @@ report.psObservationAccessoryCatch.request.2=1,0|row|\ Join c.catches ca \ with ca.species.id = :speciesId \ Where m.id In :tripId -report.psObservationAccessoryCatch.request.2.repeat=speciesId|column -report.psObservationAccessoryCatch.request.3=2,0|row|\ +report.psObservationCatch.request.2.repeat=speciesId|column +report.psObservationCatch.request.3=2,0|row|\ Select \ case when Count(ca) > 0 then \ concat('+', \ @@ -747,7 +747,7 @@ report.psObservationAccessoryCatch.request.3=2,0|row|\ Join c.catches ca \ with ca.species.id = :speciesId \ Where m.id In :tripId -report.psObservationAccessoryCatch.request.3.repeat=speciesId|column +report.psObservationCatch.request.3.repeat=speciesId|column ################################################################################ ## Captures accessoires par speciesGroup d'espèces ################################################################################ View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/43773fea3548323dff3a5ea8… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/43773fea3548323dff3a5ea8… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-9.0.x] 3 commits: Rapport Liste des captures de faune accessoire selon le type de banc, filtrées...
by Tony CHEMIT (@tchemit) 13 Nov '22

13 Nov '22
Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe Commits: eba86672 by Tony Chemit at 2022-11-13T11:30:30+01:00 Rapport Liste des captures de faune accessoire selon le type de banc, filtrées par groupe - Closes #2532 - - - - - 61679ca9 by Tony Chemit at 2022-11-13T12:24:03+01:00 GUI - use resetEdit state when reset entry on content table - - - - - 210adc7f by Tony Chemit at 2022-11-13T12:24:40+01:00 GUI - Sur échantillons PS observations saisis par lots, migrés vers 9.0, valeurs étranges sur le champ poids individuel - Closes #2503 - - - - - 3 changed files: - client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ResetEntry.java - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUIHandler.java - core/api/dto/src/main/resources/observe-reports.properties Changes: ===================================== client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/ResetEntry.java ===================================== @@ -59,7 +59,12 @@ public final class ResetEntry extends ContentTableUIActionSupport<ContentTableUI } } else { // reset existing entry - tableModel.resetEditBean(); + ui.getStates().setResetEdit(true); + try { + tableModel.resetEditBean(); + } finally { + ui.getStates().setResetEdit(false); + } } } ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUIHandler.java ===================================== @@ -51,7 +51,7 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { * * @since 3.0 */ - private final PropertyChangeListener weightChanged; + private final PropertyChangeListener weightChanged = evt -> onWeightChanged((Float) evt.getNewValue(), !ui.getStates().isResetEdit()); /** * Ecoute les modifications de la propriété {@link SampleMeasureDto#getLength()}, @@ -60,7 +60,7 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { * * @since 3.0 */ - private final PropertyChangeListener lengthChanged; + private final PropertyChangeListener lengthChanged = evt -> onLengthChanged((Float) evt.getNewValue(), !ui.getStates().isResetEdit()); /** * Ecoute les modifications de la propriété {@link SampleMeasureDto#getLength()}, @@ -69,14 +69,7 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { * * @since 3.0 */ - private final PropertyChangeListener speciesChanged; - - public SampleUIHandler() { - weightChanged = evt -> onWeightChanged((Float) evt.getNewValue()); - lengthChanged = evt -> onLengthChanged((Float) evt.getNewValue()); - speciesChanged = evt -> onSpeciesChanged((SpeciesReference) evt.getNewValue()); - } - + private final PropertyChangeListener speciesChanged = evt -> onSpeciesChanged((SpeciesReference) evt.getNewValue()); @Override public void onInit(SampleUI ui) { @@ -97,8 +90,8 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { public void onSelectedRowChanged(SampleMeasureDto tableEditBean, SampleMeasureDto previousRowBean, boolean notPersisted, boolean newRow) { - onLengthChanged(tableEditBean.getLength()); - onWeightChanged(tableEditBean.getWeight()); + onLengthChanged(tableEditBean.getLength(), false); + onWeightChanged(tableEditBean.getWeight(), false); SampleUIModel sampleModel = getModel(); @@ -209,6 +202,9 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { } public void startEditTableEditBean(SampleMeasureDto tableEditBean) { + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_WEIGHT, weightChanged); + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_LENGTH, lengthChanged); + tableEditBean.removePropertyChangeListener(SampleMeasureDto.PROPERTY_SPECIES, speciesChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_WEIGHT, weightChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_LENGTH, lengthChanged); tableEditBean.addPropertyChangeListener(SampleMeasureDto.PROPERTY_SPECIES, speciesChanged); @@ -249,9 +245,9 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { acquisitionModeGroup.setSelectedValue(acquisitionMode); } - protected void onWeightChanged(Float newValue) { + protected void onWeightChanged(Float newValue, boolean realChange) { SampleMeasureDto tableEditBean = ui.getModel().getStates().getTableEditBean(); - if (tableEditBean.getAcquisitionMode() == 1) { + if (realChange && tableEditBean.getAcquisitionMode() == 1) { tableEditBean.setIsWeightComputed(false); } if (newValue == null) { @@ -259,9 +255,11 @@ public class SampleUIHandler extends GeneratedSampleUIHandler { } } - protected void onLengthChanged(Float newValue) { + protected void onLengthChanged(Float newValue, boolean realChange) { SampleMeasureDto tableEditBean = ui.getModel().getStates().getTableEditBean(); - tableEditBean.setIsLengthComputed(false); + if (realChange) { + tableEditBean.setIsLengthComputed(false); + } if (newValue == null) { tableEditBean.setLengthMeasureMethod(null); } ===================================== core/api/dto/src/main/resources/observe-reports.properties ===================================== @@ -697,26 +697,26 @@ report.psObservationTargetDiscardedByAssociation.request.19=0,3|row|\ and os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) ################################################################################ -## Captures accessoires observées +## Captures observées ################################################################################ -report.psObservationAccessoryCatch.modelType=PS -report.psObservationAccessoryCatch.name=Observations - Liste des captures accessoires selon le type de banc, filtrées par groupe -report.psObservationAccessoryCatch.description=Afficher les captures accessoires par groupe d'espèce\nLes poids sont exprimés en tonnes. -report.psObservationAccessoryCatch.columns=Espèce, Banc libre, Banc objet -report.psObservationAccessoryCatch.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code -report.psObservationAccessoryCatch.repeatVariable.speciesId=java.lang.String|\ +report.psObservationCatch.modelType=PS +report.psObservationCatch.name=Observations - Liste des captures selon le type de banc, filtrées par groupe +report.psObservationCatch.description=Afficher les captures par groupe d'espèce\nLes poids sont exprimés en tonnes. +report.psObservationCatch.columns=Espèce, Banc libre, Banc objet +report.psObservationCatch.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code +report.psObservationCatch.repeatVariable.speciesId=java.lang.String|\ Select e.id From SpeciesImpl e \ Where e.speciesGroup.id = :speciesGroup \ Order By e.homeId -report.psObservationAccessoryCatch.request.1=0,0|row|\ +report.psObservationCatch.request.1=0,0|row|\ Select \ concat('[FAO]', (case when e.faoCode is not null then e.faoCode else '-' end), \ ' [sc]', (case when e.scientificLabel is not null then e.scientificLabel else '-' end), \ ' [fr]', (case when e.label2 is not null then e.label2 else '-' end)) \ From SpeciesImpl e \ Where e.id = :speciesId -report.psObservationAccessoryCatch.request.1.repeat=speciesId|column -report.psObservationAccessoryCatch.request.2=1,0|row|\ +report.psObservationCatch.request.1.repeat=speciesId|column +report.psObservationCatch.request.2=1,0|row|\ Select \ case when Count(ca) > 0 then \ concat('+', \ @@ -731,8 +731,8 @@ report.psObservationAccessoryCatch.request.2=1,0|row|\ Join c.catches ca \ with ca.species.id = :speciesId \ Where m.id In :tripId -report.psObservationAccessoryCatch.request.2.repeat=speciesId|column -report.psObservationAccessoryCatch.request.3=2,0|row|\ +report.psObservationCatch.request.2.repeat=speciesId|column +report.psObservationCatch.request.3=2,0|row|\ Select \ case when Count(ca) > 0 then \ concat('+', \ @@ -747,7 +747,7 @@ report.psObservationAccessoryCatch.request.3=2,0|row|\ Join c.catches ca \ with ca.species.id = :speciesId \ Where m.id In :tripId -report.psObservationAccessoryCatch.request.3.repeat=speciesId|column +report.psObservationCatch.request.3.repeat=speciesId|column ################################################################################ ## Captures accessoires par speciesGroup d'espèces ################################################################################ View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/7c8b227dfe67f5582e808ca9… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/7c8b227dfe67f5582e808ca9… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop] Adaptation de la validation et du formulaire Captures suite à la nouvelle...
by Tony CHEMIT (@tchemit) 13 Nov '22

13 Nov '22
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 43773fea by Tony Chemit at 2022-11-13T10:58:17+01:00 Adaptation de la validation et du formulaire Captures suite à la nouvelle migration v9 - Closes #2526 - - - - - 8 changed files: - client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetCatchUI.jaxx - core/api/services/src/main/i18n/getters/labels.getter - core/services/i18n/src/main/i18n/translations/services_en_GB.properties - core/services/i18n/src/main/i18n/translations/services_es_ES.properties - core/services/i18n/src/main/i18n/translations/services_fr_FR.properties - model/src/main/models/Observe/dto/class/i18nLabels.properties - model/src/main/models/Observe/dto/class/i18nOverrideLabels.properties Changes: ===================================== client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter ===================================== @@ -187,9 +187,12 @@ observe.data.ps.observation.Activity.previousFpaZone observe.data.ps.observation.Activity.surroundingActivity observe.data.ps.observation.Activity.time observe.data.ps.observation.Catch.catchWeight +observe.data.ps.observation.Catch.catchWeightTotalCount observe.data.ps.observation.Catch.maxWeight observe.data.ps.observation.Catch.meanLength observe.data.ps.observation.Catch.meanWeight +observe.data.ps.observation.Catch.meanWeightMeanLength +observe.data.ps.observation.Catch.minMaxWeight observe.data.ps.observation.Catch.minWeight observe.data.ps.observation.Catch.reasonForDiscard observe.data.ps.observation.Catch.totalCount ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetCatchUI.jaxx ===================================== @@ -62,8 +62,6 @@ errorTableModel='{getErrorTableModel()}' context='update'/> <Table id='editorPanel' fill='both' insets='1' beanScope="tableEditBean"> - - <!-- species --> <row> <cell> <JLabel id='speciesLabel'/> @@ -72,8 +70,6 @@ <FilterableComboBox id='species' genericType='SpeciesReference'/> </cell> </row> - - <!-- speciesFate --> <row> <cell> <JLabel id='speciesFateLabel'/> @@ -82,8 +78,6 @@ <FilterableComboBox id='speciesFate' genericType='SpeciesFateReference'/> </cell> </row> - - <!-- raison rejet --> <row> <cell> <JLabel id='reasonForDiscardLabel'/> @@ -92,18 +86,17 @@ <FilterableComboBox id='reasonForDiscard' genericType='ReasonForDiscardReference'/> </cell> </row> - - <!-- weight estime --> <row> <cell> - <JLabel id='catchWeightLabel'/> + <JLabel id='catchWeightTotalCountLabel'/> </cell> <cell weightx='1' anchor='east'> - <NumberEditor id='catchWeight' styleClass="float3"/> + <JPanel layout="{new GridLayout()}"> + <NumberEditor id='catchWeight' styleClass="float3"/> + <NumberEditor id='totalCount' styleClass="int6"/> + </JPanel> </cell> </row> - - <!-- weightMeasureMethod --> <row> <cell> <JLabel id='weightMeasureMethodLabel'/> @@ -112,53 +105,28 @@ <FilterableComboBox id='weightMeasureMethod' genericType='WeightMeasureMethodReference'/> </cell> </row> - - <!-- count estime --> <row> <cell> - <JLabel id='totalCountLabel'/> + <JLabel id='minMaxWeightLabel'/> </cell> <cell weightx='1'> - <NumberEditor id='totalCount' styleClass="int6"/> - + <JPanel layout="{new GridLayout()}"> + <NumberEditor id='minWeight' styleClass="float2"/> + <NumberEditor id='maxWeight' styleClass="float2"/> + </JPanel> </cell> </row> <row> <cell> - <JLabel id='minWeightLabel'/> + <JLabel id='meanWeightMeanLengthLabel'/> </cell> <cell weightx='1'> - <NumberEditor id='minWeight' styleClass="float2"/> + <JPanel layout="{new GridLayout()}"> + <NumberEditor id='meanWeight' styleClass="float2"/> + <NumberEditor id='meanLength' styleClass="float2"/> + </JPanel> </cell> </row> - <row> - <cell> - <JLabel id='meanWeightLabel'/> - </cell> - <cell weightx='1'> - <NumberEditor id='meanWeight' styleClass="float2"/> - </cell> - </row> - <row> - <cell> - <JLabel id='maxWeightLabel'/> - </cell> - <cell weightx='1'> - <NumberEditor id='maxWeight' styleClass="float2"/> - </cell> - </row> - - <!-- taille moyenne --> - <row> - <cell> - <JLabel id='meanLengthLabel'/> - </cell> - <cell weightx='1'> - <NumberEditor id='meanLength' styleClass="float2"/> - </cell> - </row> - - <!-- well --> <row> <cell> <JLabel id='wellLabel'/> @@ -167,8 +135,6 @@ <NormalTextEditor id='well'/> </cell> </row> - - <!-- informationSource --> <row> <cell> <JLabel id='informationSourceLabel'/> @@ -177,8 +143,6 @@ <FilterableComboBox id='informationSource' genericType='InformationSourceReference'/> </cell> </row> - - <!-- comment --> <row> <cell columns='3' weighty='1'> <BigTextEditor id="comment"/> ===================================== core/api/services/src/main/i18n/getters/labels.getter ===================================== @@ -1065,6 +1065,7 @@ observe.data.ps.observation.Catch.catchWeight observe.data.ps.observation.Catch.catchWeight.short observe.data.ps.observation.Catch.catchWeightComputed.computed.tip observe.data.ps.observation.Catch.catchWeightComputed.observed.tip +observe.data.ps.observation.Catch.catchWeightTotalCount observe.data.ps.observation.Catch.maxWeight observe.data.ps.observation.Catch.maxWeight.short observe.data.ps.observation.Catch.meanLength @@ -1075,6 +1076,8 @@ observe.data.ps.observation.Catch.meanWeight observe.data.ps.observation.Catch.meanWeight.short observe.data.ps.observation.Catch.meanWeightComputed.computed.tip observe.data.ps.observation.Catch.meanWeightComputed.observed.tip +observe.data.ps.observation.Catch.meanWeightMeanLength +observe.data.ps.observation.Catch.minMaxWeight observe.data.ps.observation.Catch.minWeight observe.data.ps.observation.Catch.minWeight.short observe.data.ps.observation.Catch.reasonForDiscard ===================================== core/services/i18n/src/main/i18n/translations/services_en_GB.properties ===================================== @@ -1275,6 +1275,7 @@ observe.data.ps.observation.Catch.catchWeight.short=Weight observe.data.ps.observation.Catch.catchWeight.validation.required=Weight or estimated count must be filled observe.data.ps.observation.Catch.catchWeightComputed.computed.tip=Catch weight was computed (%s) observe.data.ps.observation.Catch.catchWeightComputed.observed.tip=Catch weight was observed +observe.data.ps.observation.Catch.catchWeightTotalCount=Total weight estimated (in t) / Estimated count observe.data.ps.observation.Catch.maxWeight=Upper weight limit (in kg) observe.data.ps.observation.Catch.maxWeight.short=Max weight (in kg) observe.data.ps.observation.Catch.meanLength=Mean length (in cm) @@ -1287,6 +1288,8 @@ observe.data.ps.observation.Catch.meanWeight.short=Mean weight observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Weight or mean size must be filled. observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=Mean weight was computed (%s) observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=Mean weight was observed +observe.data.ps.observation.Catch.meanWeightMeanLength=Mean weight (in kg) / Mean length (in cm) +observe.data.ps.observation.Catch.minMaxWeight=Lower / upper weight limit (in kg) observe.data.ps.observation.Catch.minWeight=Lower weight limit (in kg) observe.data.ps.observation.Catch.minWeight.short=Min weight (in kg) observe.data.ps.observation.Catch.reasonForDiscard=Reason for discard ===================================== core/services/i18n/src/main/i18n/translations/services_es_ES.properties ===================================== @@ -1275,6 +1275,7 @@ observe.data.ps.observation.Catch.catchWeight.short=Peso observe.data.ps.observation.Catch.catchWeight.validation.required=Debe seleccionar uno de los dos valores (peso o count) observe.data.ps.observation.Catch.catchWeightComputed.computed.tip=Peso estimado calculado observe.data.ps.observation.Catch.catchWeightComputed.observed.tip=Peso estimado observado +observe.data.ps.observation.Catch.catchWeightTotalCount=Pesos total estimados (en t) / Número estimado observe.data.ps.observation.Catch.maxWeight=Upper weight limit (in kg) TODO observe.data.ps.observation.Catch.maxWeight.short=Max weight (in kg) observe.data.ps.observation.Catch.meanLength=Talla media (en cm) @@ -1287,6 +1288,8 @@ observe.data.ps.observation.Catch.meanWeight.short=Peso medio observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Debe seleccionar uno de los dos valores (peso medio o talla media). observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=El peso medio se calculó observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=El peso medio se observó +observe.data.ps.observation.Catch.meanWeightMeanLength=Peso medio (en kg) / Talla media (en cm) +observe.data.ps.observation.Catch.minMaxWeight=Lower / upper weight limit (in kg) TODO observe.data.ps.observation.Catch.minWeight=Lower weight limit (in kg) TODO observe.data.ps.observation.Catch.minWeight.short=Max weight (in kg) observe.data.ps.observation.Catch.reasonForDiscard=Razón del descarte ===================================== core/services/i18n/src/main/i18n/translations/services_fr_FR.properties ===================================== @@ -1275,6 +1275,7 @@ observe.data.ps.observation.Catch.catchWeight.short=Poids observe.data.ps.observation.Catch.catchWeight.validation.required=Une des deux valeurs (poids ou taille moyenne) devrait être renseignée. observe.data.ps.observation.Catch.catchWeightComputed.computed.tip=Le poids estimé a été calculé (%s) observe.data.ps.observation.Catch.catchWeightComputed.observed.tip=Le poids estimé a été observé +observe.data.ps.observation.Catch.catchWeightTotalCount=Poids total estimé (en t) / Nombre estimé observe.data.ps.observation.Catch.maxWeight=Borne de poids supérieure (en kg) observe.data.ps.observation.Catch.maxWeight.short=Poids max (en kg) observe.data.ps.observation.Catch.meanLength=Taille moyenne (en cm) @@ -1287,6 +1288,8 @@ observe.data.ps.observation.Catch.meanWeight.short=Poids moy observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Une des deux valeurs (poids moyen ou taille moyenne) devrait être renseignée. observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=Le poids moyen a été calculé (%s) observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=Le poids moyen a été observé +observe.data.ps.observation.Catch.meanWeightMeanLength=Poids moyen (en kg) / Taille moyenne (en cm) +observe.data.ps.observation.Catch.minMaxWeight=Borne de poids inférieure / supérieure (en kg) observe.data.ps.observation.Catch.minWeight=Borne de poids inférieure (en kg) observe.data.ps.observation.Catch.minWeight.short=Poids min (en kg) observe.data.ps.observation.Catch.reasonForDiscard=Raison rejet ===================================== model/src/main/models/Observe/dto/class/i18nLabels.properties ===================================== @@ -84,7 +84,7 @@ data.ps.logbook.Well=well,wellVessel,wellFactory,wellSamplingConformity,wellSamp data.ps.logbook.WellActivity=activity,wellActivitySpecies data.ps.logbook.WellActivitySpecies=species,weight,weightCategory,count,setSpeciesNumber data.ps.observation.Activity=date,coordinate,observedSystem.available,observedSystem.selected,comment,comment2,currentFpaZone,dataQuality,detectionMode,ersId,floatingObjectEmpty,latitude,longitude,nextFpaZone,nonTargetCatchSpecies,observedSystem,observedSystemDistance,previousFpaZone,quadrant,reasonForNoFishing,seaSurfaceTemperature,surroundingActivity,time,vesselActivity,vesselSpeed,wind,generalTab,error.no.activity.6,measurementsTab,observedSystemTab -data.ps.observation.Catch=catchWeight,comment,informationSource,lengthMeasureMethod,meanLength,minWeight,maxWeight,meanWeight,reasonForDiscard,species,speciesFate,totalCount,weightMeasureMethod,well,catchWeightComputed.computed.tip,catchWeightComputed.observed.tip,meanLengthComputed.computed.tip,meanLengthComputed.observed.tip,meanWeightComputed.computed.tip,meanWeightComputed.observed.tip,totalCountComputed.computed.tip,totalCountComputed.observed.tip +data.ps.observation.Catch=catchWeight,catchWeightTotalCount,meanWeightMeanLength,comment,informationSource,lengthMeasureMethod,meanLength,minWeight,maxWeight,meanWeight,minMaxWeight,reasonForDiscard,species,speciesFate,totalCount,weightMeasureMethod,well,catchWeightComputed.computed.tip,catchWeightComputed.observed.tip,meanLengthComputed.computed.tip,meanLengthComputed.observed.tip,meanWeightComputed.computed.tip,meanWeightComputed.observed.tip,totalCountComputed.computed.tip,totalCountComputed.observed.tip data.ps.observation.FloatingObject=materialsValid,objectOperation,supportVesselName,country,vessel,computedBiodegradable,computedNonEntangling,computedSimplifiedObjectType,computedValues,generalTab,buoysTab,materialsTab,notComputed,type.short data.ps.observation.NonTargetCatchRelease=comment,conformity,count,length,lengthMeasureMethod,releasingTime,sex,status,species,speciesGroupReleaseMode,message.cantAdd data.ps.observation.ObjectObservedSpecies=count,species,speciesStatus ===================================== model/src/main/models/Observe/dto/class/i18nOverrideLabels.properties ===================================== @@ -23,7 +23,7 @@ data.ll.common.Trip=species data.ll.landing.Landing=vessel data.ps.localmarket.Sample=well data.ps.logbook.Catch=weightMeasureMethod.validation.required -data.ps.observation.Catch=minWeight,maxWeight,weightMeasureMethod +data.ps.observation.Catch=minWeight,maxWeight,minMaxWeight,weightMeasureMethod data.ps.observation.SchoolEstimate=species data.ps.observation.Set=startTime,haulingStartTimeStamp,haulingEndTimeStamp,endTimeStamp referential.common.Species=codeAndHomeId View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/43773fea3548323dff3a5ea8e… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/43773fea3548323dff3a5ea8e… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop-9.0.x] 2 commits: Adaptation de la validation et du formulaire Captures suite à la nouvelle...
by Tony CHEMIT (@tchemit) 13 Nov '22

13 Nov '22
Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe Commits: ffe04d3e by Tony Chemit at 2022-11-13T10:53:48+01:00 Adaptation de la validation et du formulaire Captures suite à la nouvelle migration v9 - Closes #2526 - - - - - 7c8b227d by Tony Chemit at 2022-11-13T10:53:48+01:00 Revert &quot;FIXME - Do not drop table until release time&quot; This reverts commit 73c88a1f12625a827361ececc852b783e4a0941d. - - - - - 10 changed files: - client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetCatchUI.jaxx - core/api/services/src/main/i18n/getters/labels.getter - core/persistence/resources/src/main/resources/db/migration/v9/9.0/99_2_drop_tables-H2.sql - core/persistence/resources/src/main/resources/db/migration/v9/9.0/99_2_drop_tables-PG.sql - core/services/i18n/src/main/i18n/translations/services_en_GB.properties - core/services/i18n/src/main/i18n/translations/services_es_ES.properties - core/services/i18n/src/main/i18n/translations/services_fr_FR.properties - model/src/main/models/Observe/dto/class/i18nLabels.properties - model/src/main/models/Observe/dto/class/i18nOverrideLabels.properties Changes: ===================================== client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter ===================================== @@ -183,9 +183,12 @@ observe.data.ps.observation.Activity.previousFpaZone observe.data.ps.observation.Activity.surroundingActivity observe.data.ps.observation.Activity.time observe.data.ps.observation.Catch.catchWeight +observe.data.ps.observation.Catch.catchWeightTotalCount observe.data.ps.observation.Catch.maxWeight observe.data.ps.observation.Catch.meanLength observe.data.ps.observation.Catch.meanWeight +observe.data.ps.observation.Catch.meanWeightMeanLength +observe.data.ps.observation.Catch.minMaxWeight observe.data.ps.observation.Catch.minWeight observe.data.ps.observation.Catch.reasonForDiscard observe.data.ps.observation.Catch.totalCount ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetCatchUI.jaxx ===================================== @@ -62,8 +62,6 @@ errorTableModel='{getErrorTableModel()}' context='update'/> <Table id='editorPanel' fill='both' insets='1' beanScope="tableEditBean"> - - <!-- species --> <row> <cell> <JLabel id='speciesLabel'/> @@ -72,8 +70,6 @@ <FilterableComboBox id='species' genericType='SpeciesReference'/> </cell> </row> - - <!-- speciesFate --> <row> <cell> <JLabel id='speciesFateLabel'/> @@ -82,8 +78,6 @@ <FilterableComboBox id='speciesFate' genericType='SpeciesFateReference'/> </cell> </row> - - <!-- raison rejet --> <row> <cell> <JLabel id='reasonForDiscardLabel'/> @@ -92,18 +86,17 @@ <FilterableComboBox id='reasonForDiscard' genericType='ReasonForDiscardReference'/> </cell> </row> - - <!-- weight estime --> <row> <cell> - <JLabel id='catchWeightLabel'/> + <JLabel id='catchWeightTotalCountLabel'/> </cell> <cell weightx='1' anchor='east'> - <NumberEditor id='catchWeight' styleClass="float3"/> + <JPanel layout="{new GridLayout()}"> + <NumberEditor id='catchWeight' styleClass="float3"/> + <NumberEditor id='totalCount' styleClass="int6"/> + </JPanel> </cell> </row> - - <!-- weightMeasureMethod --> <row> <cell> <JLabel id='weightMeasureMethodLabel'/> @@ -112,53 +105,28 @@ <FilterableComboBox id='weightMeasureMethod' genericType='WeightMeasureMethodReference'/> </cell> </row> - - <!-- count estime --> <row> <cell> - <JLabel id='totalCountLabel'/> + <JLabel id='minMaxWeightLabel'/> </cell> <cell weightx='1'> - <NumberEditor id='totalCount' styleClass="int6"/> - + <JPanel layout="{new GridLayout()}"> + <NumberEditor id='minWeight' styleClass="float2"/> + <NumberEditor id='maxWeight' styleClass="float2"/> + </JPanel> </cell> </row> <row> <cell> - <JLabel id='minWeightLabel'/> + <JLabel id='meanWeightMeanLengthLabel'/> </cell> <cell weightx='1'> - <NumberEditor id='minWeight' styleClass="float2"/> + <JPanel layout="{new GridLayout()}"> + <NumberEditor id='meanWeight' styleClass="float2"/> + <NumberEditor id='meanLength' styleClass="float2"/> + </JPanel> </cell> </row> - <row> - <cell> - <JLabel id='meanWeightLabel'/> - </cell> - <cell weightx='1'> - <NumberEditor id='meanWeight' styleClass="float2"/> - </cell> - </row> - <row> - <cell> - <JLabel id='maxWeightLabel'/> - </cell> - <cell weightx='1'> - <NumberEditor id='maxWeight' styleClass="float2"/> - </cell> - </row> - - <!-- taille moyenne --> - <row> - <cell> - <JLabel id='meanLengthLabel'/> - </cell> - <cell weightx='1'> - <NumberEditor id='meanLength' styleClass="float2"/> - </cell> - </row> - - <!-- well --> <row> <cell> <JLabel id='wellLabel'/> @@ -167,8 +135,6 @@ <NormalTextEditor id='well'/> </cell> </row> - - <!-- informationSource --> <row> <cell> <JLabel id='informationSourceLabel'/> @@ -177,8 +143,6 @@ <FilterableComboBox id='informationSource' genericType='InformationSourceReference'/> </cell> </row> - - <!-- comment --> <row> <cell columns='3' weighty='1'> <BigTextEditor id="comment"/> ===================================== core/api/services/src/main/i18n/getters/labels.getter ===================================== @@ -1028,6 +1028,7 @@ observe.data.ps.observation.Catch.catchWeight observe.data.ps.observation.Catch.catchWeight.short observe.data.ps.observation.Catch.catchWeightComputed.computed.tip observe.data.ps.observation.Catch.catchWeightComputed.observed.tip +observe.data.ps.observation.Catch.catchWeightTotalCount observe.data.ps.observation.Catch.maxWeight observe.data.ps.observation.Catch.maxWeight.short observe.data.ps.observation.Catch.meanLength @@ -1038,6 +1039,8 @@ observe.data.ps.observation.Catch.meanWeight observe.data.ps.observation.Catch.meanWeight.short observe.data.ps.observation.Catch.meanWeightComputed.computed.tip observe.data.ps.observation.Catch.meanWeightComputed.observed.tip +observe.data.ps.observation.Catch.meanWeightMeanLength +observe.data.ps.observation.Catch.minMaxWeight observe.data.ps.observation.Catch.minWeight observe.data.ps.observation.Catch.minWeight.short observe.data.ps.observation.Catch.reasonForDiscard ===================================== core/persistence/resources/src/main/resources/db/migration/v9/9.0/99_2_drop_tables-H2.sql ===================================== @@ -25,12 +25,12 @@ ALTER TABLE ps_observation.Set DROP COLUMN targetdiscardcatchcompositionestimate ALTER TABLE ll_common.Trip DROP COLUMN program; ALTER TABLE ps_common.Trip DROP COLUMN program; --- DROP TABLE ps_observation.NonTargetLength; --- DROP TABLE ps_observation.NonTargetSample; --- DROP TABLE ps_observation.NonTargetCatch; --- DROP TABLE ps_observation.TargetCatch; --- DROP TABLE ps_observation.TargetSample; --- DROP TABLE ps_observation.TargetLength; +DROP TABLE ps_observation.NonTargetLength; +DROP TABLE ps_observation.NonTargetSample; +DROP TABLE ps_observation.NonTargetCatch; +DROP TABLE ps_observation.TargetCatch; +DROP TABLE ps_observation.TargetSample; +DROP TABLE ps_observation.TargetLength; DROP TABLE ps_observation.ReasonForNullSet; DROP TABLE ps_observation.ReasonForNoFishing; DROP TABLE ps_observation.WeightCategory; ===================================== core/persistence/resources/src/main/resources/db/migration/v9/9.0/99_2_drop_tables-PG.sql ===================================== @@ -25,12 +25,12 @@ ALTER TABLE ps_observation.Set DROP COLUMN targetdiscardcatchcompositionestimate ALTER TABLE ll_common.Trip DROP COLUMN program CASCADE; ALTER TABLE ps_common.Trip DROP COLUMN program CASCADE; --- DROP TABLE ps_observation.NonTargetLength CASCADE; --- DROP TABLE ps_observation.NonTargetSample CASCADE; --- DROP TABLE ps_observation.NonTargetCatch CASCADE; --- DROP TABLE ps_observation.TargetLength CASCADE; --- DROP TABLE ps_observation.TargetSample CASCADE; --- DROP TABLE ps_observation.TargetCatch CASCADE; +DROP TABLE ps_observation.NonTargetLength CASCADE; +DROP TABLE ps_observation.NonTargetSample CASCADE; +DROP TABLE ps_observation.NonTargetCatch CASCADE; +DROP TABLE ps_observation.TargetLength CASCADE; +DROP TABLE ps_observation.TargetSample CASCADE; +DROP TABLE ps_observation.TargetCatch CASCADE; DROP TABLE ps_observation.ReasonForNullSet CASCADE; DROP TABLE ps_observation.ReasonForNoFishing CASCADE; DROP TABLE ps_observation.WeightCategory CASCADE; ===================================== core/services/i18n/src/main/i18n/translations/services_en_GB.properties ===================================== @@ -1232,6 +1232,7 @@ observe.data.ps.observation.Catch.catchWeight.short=Weight observe.data.ps.observation.Catch.catchWeight.validation.required=Weight or estimated count must be filled observe.data.ps.observation.Catch.catchWeightComputed.computed.tip=Catch weight was computed (%s) observe.data.ps.observation.Catch.catchWeightComputed.observed.tip=Catch weight was observed +observe.data.ps.observation.Catch.catchWeightTotalCount=Total weight estimated (in t) / Estimated count observe.data.ps.observation.Catch.maxWeight=Upper weight limit (in kg) observe.data.ps.observation.Catch.maxWeight.short=Max weight (in kg) observe.data.ps.observation.Catch.meanLength=Mean length (in cm) @@ -1244,6 +1245,8 @@ observe.data.ps.observation.Catch.meanWeight.short=Mean weight observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Weight or mean size must be filled. observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=Mean weight was computed (%s) observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=Mean weight was observed +observe.data.ps.observation.Catch.meanWeightMeanLength=Mean weight (in kg) / Mean length (in cm) +observe.data.ps.observation.Catch.minMaxWeight=Lower / upper weight limit (in kg) observe.data.ps.observation.Catch.minWeight=Lower weight limit (in kg) observe.data.ps.observation.Catch.minWeight.short=Min weight (in kg) observe.data.ps.observation.Catch.reasonForDiscard=Reason for discard ===================================== core/services/i18n/src/main/i18n/translations/services_es_ES.properties ===================================== @@ -1232,6 +1232,7 @@ observe.data.ps.observation.Catch.catchWeight.short=Peso observe.data.ps.observation.Catch.catchWeight.validation.required=Debe seleccionar uno de los dos valores (peso o count) observe.data.ps.observation.Catch.catchWeightComputed.computed.tip=Peso estimado calculado observe.data.ps.observation.Catch.catchWeightComputed.observed.tip=Peso estimado observado +observe.data.ps.observation.Catch.catchWeightTotalCount=Pesos total estimados (en t) / Número estimado observe.data.ps.observation.Catch.maxWeight=Upper weight limit (in kg) TODO observe.data.ps.observation.Catch.maxWeight.short=Max weight (in kg) observe.data.ps.observation.Catch.meanLength=Talla media (en cm) @@ -1244,6 +1245,8 @@ observe.data.ps.observation.Catch.meanWeight.short=Peso medio observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Debe seleccionar uno de los dos valores (peso medio o talla media). observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=El peso medio se calculó observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=El peso medio se observó +observe.data.ps.observation.Catch.meanWeightMeanLength=Peso medio (en kg) / Talla media (en cm) +observe.data.ps.observation.Catch.minMaxWeight=Lower / upper weight limit (in kg) TODO observe.data.ps.observation.Catch.minWeight=Lower weight limit (in kg) TODO observe.data.ps.observation.Catch.minWeight.short=Max weight (in kg) observe.data.ps.observation.Catch.reasonForDiscard=Razón del descarte ===================================== core/services/i18n/src/main/i18n/translations/services_fr_FR.properties ===================================== @@ -1232,6 +1232,7 @@ observe.data.ps.observation.Catch.catchWeight.short=Poids observe.data.ps.observation.Catch.catchWeight.validation.required=Une des deux valeurs (poids ou taille moyenne) devrait être renseignée. observe.data.ps.observation.Catch.catchWeightComputed.computed.tip=Le poids estimé a été calculé (%s) observe.data.ps.observation.Catch.catchWeightComputed.observed.tip=Le poids estimé a été observé +observe.data.ps.observation.Catch.catchWeightTotalCount=Poids total estimé (en t) / Nombre estimé observe.data.ps.observation.Catch.maxWeight=Borne de poids supérieure (en kg) observe.data.ps.observation.Catch.maxWeight.short=Poids max (en kg) observe.data.ps.observation.Catch.meanLength=Taille moyenne (en cm) @@ -1244,6 +1245,8 @@ observe.data.ps.observation.Catch.meanWeight.short=Poids moy observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Une des deux valeurs (poids moyen ou taille moyenne) devrait être renseignée. observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=Le poids moyen a été calculé (%s) observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=Le poids moyen a été observé +observe.data.ps.observation.Catch.meanWeightMeanLength=Poids moyen (en kg) / Taille moyenne (en cm) +observe.data.ps.observation.Catch.minMaxWeight=Borne de poids inférieure / supérieure (en kg) observe.data.ps.observation.Catch.minWeight=Borne de poids inférieure (en kg) observe.data.ps.observation.Catch.minWeight.short=Poids min (en kg) observe.data.ps.observation.Catch.reasonForDiscard=Raison rejet ===================================== model/src/main/models/Observe/dto/class/i18nLabels.properties ===================================== @@ -82,7 +82,7 @@ data.ps.logbook.SampleSpeciesMeasure=count,sizeClass data.ps.logbook.TransmittingBuoy=comment,code,transmittingBuoyOwnership,transmittingBuoyType,transmittingBuoyOperation,country,vessel,latitude,longitude,quadrant data.ps.logbook.WellPlan=activity,species,weight,weightCategory,well,wellSamplingConformity,wellSamplingStatus data.ps.observation.Activity=date,coordinate,observedSystem.available,observedSystem.selected,comment,comment2,currentFpaZone,dataQuality,detectionMode,ersId,floatingObjectEmpty,latitude,longitude,nextFpaZone,nonTargetCatchSpecies,observedSystem,observedSystemDistance,previousFpaZone,quadrant,reasonForNoFishing,seaSurfaceTemperature,surroundingActivity,time,vesselActivity,vesselSpeed,wind,generalTab,error.no.activity.6,measurementsTab,observedSystemTab -data.ps.observation.Catch=catchWeight,comment,informationSource,lengthMeasureMethod,meanLength,minWeight,maxWeight,meanWeight,reasonForDiscard,species,speciesFate,totalCount,weightMeasureMethod,well,catchWeightComputed.computed.tip,catchWeightComputed.observed.tip,meanLengthComputed.computed.tip,meanLengthComputed.observed.tip,meanWeightComputed.computed.tip,meanWeightComputed.observed.tip,totalCountComputed.computed.tip,totalCountComputed.observed.tip +data.ps.observation.Catch=catchWeight,catchWeightTotalCount,meanWeightMeanLength,comment,informationSource,lengthMeasureMethod,meanLength,minWeight,maxWeight,meanWeight,minMaxWeight,reasonForDiscard,species,speciesFate,totalCount,weightMeasureMethod,well,catchWeightComputed.computed.tip,catchWeightComputed.observed.tip,meanLengthComputed.computed.tip,meanLengthComputed.observed.tip,meanWeightComputed.computed.tip,meanWeightComputed.observed.tip,totalCountComputed.computed.tip,totalCountComputed.observed.tip data.ps.observation.FloatingObject=materialsValid,objectOperation,supportVesselName,country,vessel,computedBiodegradable,computedNonEntangling,computedSimplifiedObjectType,computedValues,generalTab,buoysTab,materialsTab,notComputed,type.short data.ps.observation.NonTargetCatchRelease=comment,conformity,count,length,lengthMeasureMethod,releasingTime,sex,status,species,speciesGroupReleaseMode,message.cantAdd data.ps.observation.ObjectObservedSpecies=count,species,speciesStatus ===================================== model/src/main/models/Observe/dto/class/i18nOverrideLabels.properties ===================================== @@ -23,7 +23,7 @@ data.ll.common.Trip=species data.ll.landing.Landing=vessel data.ps.localmarket.Sample=well data.ps.logbook.Catch=weightMeasureMethod.validation.required -data.ps.observation.Catch=minWeight,maxWeight,weightMeasureMethod +data.ps.observation.Catch=minWeight,maxWeight,minMaxWeight,weightMeasureMethod data.ps.observation.SchoolEstimate=species data.ps.observation.Set=startTime,haulingStartTimeStamp,haulingEndTimeStamp,endTimeStamp referential.common.Species=codeAndHomeId View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/df3efb6fa50e0a5cd7c82df9… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/df3efb6fa50e0a5cd7c82df9… You're receiving this email because of your account on gitlab.com.
1 0
0 0
[Git][ultreiaio/ird-observe][develop] 4 commits: [UI REFERENTIELS] Envisager un auto-trim droite et gauche sur les champs...
by Tony CHEMIT (@tchemit) 12 Nov '22

12 Nov '22
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 7ea06d73 by Tony Chemit at 2022-11-12T14:43:10+01:00 [UI REFERENTIELS] Envisager un auto-trim droite et gauche sur les champs alphanumériques - See #1544 Nettoyage par migration de tous les champs texte - Closes #2529 - - - - - 8f5e68fb by Tony Chemit at 2022-11-12T16:10:50+01:00 Test fixtures - [UI REFERENTIELS] Envisager un auto-trim droite et gauche sur les champs alphanumériques - See #1544 - - - - - c7278943 by Tony Chemit at 2022-11-12T16:10:50+01:00 Test fixtures - Renommage speciesFate - - - - - 247c8c3d by Tony Chemit at 2022-11-12T16:10:50+01:00 SetCatch - MEttre minWeight et maxWeight sur la meme ligne du formulaire - - - - - 20 changed files: - client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetCatchUI.jaxx - core/api/services/src/main/i18n/getters/labels.getter - core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripSpi.java - core/persistence/resources/src/main/java/fr/ird/observe/persistence/avdth/data/DataWriter.java - core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/DataSourceMigrationForVersion_9_0.java - core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/DiscardedTargetCatchRecord.java - + core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/FixCommentHelper.java - + core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/FixStringHelper.java - core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/NotDiscardedTargetCatchRecord.java - core/services/i18n/src/main/i18n/translations/services_en_GB.properties - core/services/i18n/src/main/i18n/translations/services_es_ES.properties - core/services/i18n/src/main/i18n/translations/services_fr_FR.properties - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ValidateService-dataResult.json - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ValidateService-referentialResult.json - model/src/main/models/Observe/dto/class/i18nLabels.properties - model/src/main/models/Observe/dto/class/i18nOverrideLabels.properties - + toolkit/api/src/main/java/fr/ird/observe/dto/StringCleaner.java - toolkit/api/src/main/java/fr/ird/observe/persistence/SqlHelper.java - toolkit/persistence/src/main/java/fr/ird/observe/spi/context/DataDtoEntityContext.java Changes: ===================================== client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter ===================================== @@ -190,6 +190,7 @@ observe.data.ps.observation.Catch.catchWeight observe.data.ps.observation.Catch.maxWeight observe.data.ps.observation.Catch.meanLength observe.data.ps.observation.Catch.meanWeight +observe.data.ps.observation.Catch.minMaxWeight observe.data.ps.observation.Catch.minWeight observe.data.ps.observation.Catch.reasonForDiscard observe.data.ps.observation.Catch.totalCount ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetCatchUI.jaxx ===================================== @@ -125,10 +125,13 @@ </row> <row> <cell> - <JLabel id='minWeightLabel'/> + <JLabel id='minMaxWeightLabel'/> </cell> <cell weightx='1'> - <NumberEditor id='minWeight' styleClass="float2"/> + <JPanel layout="{new GridLayout()}"> + <NumberEditor id='minWeight' styleClass="float2"/> + <NumberEditor id='maxWeight' styleClass="float2"/> + </JPanel> </cell> </row> <row> @@ -139,15 +142,6 @@ <NumberEditor id='meanWeight' styleClass="float2"/> </cell> </row> - <row> - <cell> - <JLabel id='maxWeightLabel'/> - </cell> - <cell weightx='1'> - <NumberEditor id='maxWeight' styleClass="float2"/> - </cell> - </row> - <!-- taille moyenne --> <row> <cell> ===================================== core/api/services/src/main/i18n/getters/labels.getter ===================================== @@ -1075,6 +1075,7 @@ observe.data.ps.observation.Catch.meanWeight observe.data.ps.observation.Catch.meanWeight.short observe.data.ps.observation.Catch.meanWeightComputed.computed.tip observe.data.ps.observation.Catch.meanWeightComputed.observed.tip +observe.data.ps.observation.Catch.minMaxWeight observe.data.ps.observation.Catch.minWeight observe.data.ps.observation.Catch.minWeight.short observe.data.ps.observation.Catch.reasonForDiscard ===================================== core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripSpi.java ===================================== @@ -45,6 +45,7 @@ import fr.ird.observe.entities.referential.ps.common.AcquisitionStatus; import fr.ird.observe.entities.referential.ps.common.ObservedSystem; import fr.ird.observe.entities.referential.ps.common.Program; import fr.ird.observe.entities.referential.ps.logbook.WellContentStatus; +import fr.ird.observe.persistence.SqlHelper; import fr.ird.observe.spi.service.ServiceContext; import io.ultreia.java4all.util.Dates; import io.ultreia.java4all.util.sql.SqlScriptWriter; @@ -330,8 +331,8 @@ public class TripSpi extends GeneratedTripSpi { toId(observationsDataQuality), toId(observer), commentFormat.apply(observationsComment), - escapeString(formsUrl), - escapeString(reportsUrl), + SqlHelper.escapeString(formsUrl), + SqlHelper.escapeString(reportsUrl), newId); } ===================================== core/persistence/resources/src/main/java/fr/ird/observe/persistence/avdth/data/DataWriter.java ===================================== @@ -77,7 +77,7 @@ public abstract class DataWriter<E extends DataEntity, R extends DataReader<E>> } public static String escapeString(String comment) { - return DataDtoEntityContext.escapeString(comment); + return SqlHelper.escapeString(comment); } public static String roundFloat2(Float comment) { ===================================== core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/DataSourceMigrationForVersion_9_0.java ===================================== @@ -23,7 +23,8 @@ package fr.ird.observe.spi.migration.v9; */ import com.google.auto.service.AutoService; -import fr.ird.observe.spi.context.DataDtoEntityContext; +import fr.ird.observe.dto.StringCleaner; +import fr.ird.observe.persistence.SqlHelper; import fr.ird.observe.spi.migration.ByMajorMigrationVersionResource; import io.ultreia.java4all.util.Version; import io.ultreia.java4all.util.sql.SqlQuery; @@ -254,6 +255,7 @@ public class DataSourceMigrationForVersion_9_0 extends ByMajorMigrationVersionRe executor.addScript("96", "add_referential_ps_common_ObservedSystem_finalize"); } } + private void migrateCatches(MigrationVersionResourceExecutor executor) { Function<String, String> commentFormat = executor.commentFormat(); @@ -395,7 +397,7 @@ public class DataSourceMigrationForVersion_9_0 extends ByMajorMigrationVersionRe sample.topiaId, sample.topiaVersion, sample.topiaCreateDate, - DataDtoEntityContext.escapeString(sample.homeId), + SqlHelper.escapeString(StringCleaner.ALL.apply(sample.homeId)), stringFormat.apply(sample.comment), sample.set, sample.lastUpdateDate @@ -564,31 +566,39 @@ public class DataSourceMigrationForVersion_9_0 extends ByMajorMigrationVersionRe sampleMeasure.topiaId, sampleMeasure.topiaVersion, sampleMeasure.topiaCreateDate, - DataDtoEntityContext.escapeString(sampleMeasure.homeId == null ? null : sampleMeasure.homeId.replaceAll("'", "")), + SqlHelper.escapeString(sampleMeasure.homeId == null ? null : sampleMeasure.homeId.replaceAll("'", "")), sampleMeasure.length, sampleMeasure.isLengthComputed, - DataDtoEntityContext.escapeString(sampleMeasure.picturesReferences == null ? null : sampleMeasure.picturesReferences.replaceAll("'", "")), + SqlHelper.escapeString(sampleMeasure.picturesReferences == null ? null : sampleMeasure.picturesReferences.replaceAll("'", "")), sampleMeasure.weight, sampleMeasure.isWeightComputed, sampleMeasure.count, sampleMeasure.acquisitionMode, - DataDtoEntityContext.escapeString(sampleMeasure.species), + SqlHelper.escapeString(sampleMeasure.species), sampleId, - DataDtoEntityContext.escapeString(sampleMeasure.sex), + SqlHelper.escapeString(sampleMeasure.sex), sampleMeasure.lastUpdateDate, - DataDtoEntityContext.escapeString(sampleMeasure.sizeMeasureType), - DataDtoEntityContext.escapeString(sampleMeasure.weightMeasureType), - DataDtoEntityContext.escapeString(sampleMeasure.tagNumber), - DataDtoEntityContext.escapeString(sampleMeasure.speciesFate), + SqlHelper.escapeString(sampleMeasure.sizeMeasureType), + SqlHelper.escapeString(sampleMeasure.weightMeasureType), + SqlHelper.escapeString(sampleMeasure.tagNumber), + SqlHelper.escapeString(sampleMeasure.speciesFate), sampleMeasure.sample_idx, - DataDtoEntityContext.escapeString(sampleMeasure.lengthMeasureMethod), - DataDtoEntityContext.escapeString(sampleMeasure.weightMeasureMethod) + SqlHelper.escapeString(sampleMeasure.lengthMeasureMethod), + SqlHelper.escapeString(sampleMeasure.weightMeasureMethod) )); } } @Override public void generateFinalizeSqlScript(MigrationVersionResourceExecutor executor) { + long stringFixedCount = new FixStringHelper(executor).execute(); + if (stringFixedCount > 0) { + log.warn(String.format("Fix %s string rows(s).", stringFixedCount)); + } + long commentFixedCount = new FixCommentHelper(executor).execute(); + if (commentFixedCount > 0) { + log.warn(String.format("Fix %s comment rows(s).", commentFixedCount)); + } migrateIdx(executor, "ps_observation", "catch", "set"); migrateIdx(executor, "ps_observation", "SampleMeasure", "sample"); } ===================================== core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/DiscardedTargetCatchRecord.java ===================================== @@ -22,6 +22,8 @@ package fr.ird.observe.spi.migration.v9; * #L% */ +import fr.ird.observe.dto.StringCleaner; +import fr.ird.observe.persistence.SqlHelper; import fr.ird.observe.spi.context.DataDtoEntityContext; import java.sql.Connection; @@ -56,19 +58,19 @@ public class DiscardedTargetCatchRecord { public static PreparedStatement prepareStatement(Connection connection) throws SQLException { return connection.prepareStatement("SELECT" + - /* 01 */ " REPLACE(tc.topiaId, '.TargetCatch', '.Catch')," + - /* 02 */ " tc.topiaVersion + 1," + - /* 03 */ " tc.topiaCreateDate," + - /* 04 */ " tc.homeId," + - /* 05 */ " tc.catchWeight," + - /* 06 */ " tc.weightCategory," + - /* 07 */ " tc.comment," + - /* 08 */ " tc.reasonForDiscard," + - /* 09 */ " tc.set," + - /* 10 */ " tc.lastUpdateDate," + - /* 11 */ " tc.well," + - /* 12 */ " -tc.set_idx," + - /* 13 */ " tc.weightMeasureMethod" + + /* 01 */ " REPLACE(tc.topiaId, '.TargetCatch', '.Catch')," + + /* 02 */ " tc.topiaVersion + 1," + + /* 03 */ " tc.topiaCreateDate," + + /* 04 */ " tc.homeId," + + /* 05 */ " tc.catchWeight," + + /* 06 */ " tc.weightCategory," + + /* 07 */ " tc.comment," + + /* 08 */ " tc.reasonForDiscard," + + /* 09 */ " tc.set," + + /* 10 */ " tc.lastUpdateDate," + + /* 11 */ " tc.well," + + /* 12 */ " -tc.set_idx," + + /* 13 */ " tc.weightMeasureMethod" + " FROM ps_observation.TargetCatch tc" + " WHERE tc.discarded"); } @@ -132,24 +134,24 @@ public class DiscardedTargetCatchRecord { "%17$s, " + "%18$s" + ");", - /*1*/ DataDtoEntityContext.escapeString(id), + /*1*/ SqlHelper.escapeString(id), /*2*/ topiaVersion, /*3*/ DataDtoEntityContext.timestamp(topiaCreateDate), - /*4*/ DataDtoEntityContext.escapeString(homeId), + /*4*/ SqlHelper.escapeString(StringCleaner.ALL.apply(homeId)), /*5*/ catchWeight, /*6*/ weightCategoryRecord.getMinWeight(), /*7*/ weightCategoryRecord.getMaxWeight(), /*8*/ null, /*9*/ getComment(weightCategoryRecord, commentFormat), - /*10*/ DataDtoEntityContext.escapeString(reasonForDiscardId), - /*11*/ DataDtoEntityContext.escapeString(weightCategoryRecord.getSpeciesId()), - /*12*/ DataDtoEntityContext.escapeString(DataSourceMigrationForVersion_9_0.SPECIES_FATE_5), - /*13*/ DataDtoEntityContext.escapeString(setId), + /*10*/ SqlHelper.escapeString(reasonForDiscardId), + /*11*/ SqlHelper.escapeString(weightCategoryRecord.getSpeciesId()), + /*12*/ SqlHelper.escapeString(DataSourceMigrationForVersion_9_0.SPECIES_FATE_5), + /*13*/ SqlHelper.escapeString(setId), /*14*/ DataDtoEntityContext.timestamp(lastUpdateDate), - /*15*/ DataDtoEntityContext.escapeString(getWell()), + /*15*/ SqlHelper.escapeString(StringCleaner.ALL.apply(well)), /*16*/ setIdx, - /*17*/ DataDtoEntityContext.escapeString(weightMeasureMethodId == null ? "fr.ird.referential.common.WeightMeasureMethod#666#03" : weightCategoryId), - /*18*/ DataDtoEntityContext.escapeString(DataSourceMigrationForVersion_9_0.INFORMATION_SOURCE_O) + /*17*/ SqlHelper.escapeString(weightMeasureMethodId == null ? "fr.ird.referential.common.WeightMeasureMethod#666#03" : weightCategoryId), + /*18*/ SqlHelper.escapeString(DataSourceMigrationForVersion_9_0.INFORMATION_SOURCE_O) ); } @@ -160,14 +162,4 @@ public class DiscardedTargetCatchRecord { return stringFormat.apply(comment + "\n" + weightCategoryRecord.toComment()); } - public String getWell() { - String result = well; - if (result!=null) { - result = well.trim(); - if (well.startsWith("'")) { - result = result.substring(1); - } - } - return result; - } } ===================================== core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/FixCommentHelper.java ===================================== @@ -0,0 +1,133 @@ +package fr.ird.observe.spi.migration.v9; + +/*- + * #%L + * ObServe Core :: Persistence :: Resources + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.nuiton.topia.service.migration.resources.MigrationVersionResourceExecutor; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Function; + +/** + * To auto-trim string comment fields. + * <p> + * <strong>Note:</strong> If fixed value is empty or blank then set {@code null} value. + * <p> + * Created on 11/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +public class FixCommentHelper { + + private static final Logger log = LogManager.getLogger(FixCommentHelper.class); + + private final MigrationVersionResourceExecutor executor; + private final AtomicLong count = new AtomicLong(); + private final Function<String, String> commentFormat; + + public FixCommentHelper(MigrationVersionResourceExecutor executor) { + this.executor = Objects.requireNonNull(executor); + commentFormat = executor.commentFormat(); + } + + public long execute() { + + fixField("common.Vessel", "comment"); + + fixField("ll_common.GearUseFeatures", "comment"); + fixField("ll_common.Program", "comment"); + fixField("ll_common.Trip", "generalComment"); + fixField("ll_common.Trip", "logbookComment"); + fixField("ll_common.Trip", "observationsComment"); + + fixField("ll_landing.Landing", "comment"); + + fixField("ll_logbook.Activity", "comment"); + fixField("ll_logbook.Catch", "comment"); + fixField("ll_logbook.Set", "comment"); + fixField("ll_logbook.Sample", "comment"); + + fixField("ll_observation.Activity", "comment"); + fixField("ll_observation.Branchline", "comment"); + fixField("ll_observation.Catch", "comment"); + fixField("ll_observation.Set", "comment"); + + fixField("ps_common.GearUseFeatures", "comment"); + fixField("ps_common.Program", "comment"); + fixField("ps_common.Trip", "generalComment"); + fixField("ps_common.Trip", "logbookComment"); + fixField("ps_common.Trip", "observationsComment"); + + fixField("ps_localmarket.Batch", "origin"); + fixField("ps_localmarket.Sample", "comment"); + fixField("ps_localmarket.SampleSpecies", "comment"); + fixField("ps_localmarket.Survey", "comment"); + + fixField("ps_logbook.Activity", "comment"); + fixField("ps_logbook.Catch", "comment"); + fixField("ps_logbook.FloatingObject", "comment"); + fixField("ps_logbook.Route", "comment"); + fixField("ps_logbook.Sample", "comment"); + fixField("ps_logbook.SampleSpecies", "comment"); + fixField("ps_logbook.TransmittingBuoy", "comment"); + + fixField("ps_observation.Activity", "comment"); + fixField("ps_observation.Catch", "comment"); + fixField("ps_observation.FloatingObject", "comment"); + fixField("ps_observation.NonTargetCatchRelease", "comment"); + fixField("ps_observation.Route", "comment"); + fixField("ps_observation.Set", "comment"); + fixField("ps_observation.TransmittingBuoy", "comment"); + return count.get(); + } + + public void fixField(String gav, String field) { + + executor.doSqlWork(connection -> { + try (PreparedStatement statement = connection.prepareStatement(String.format("SELECT topiaId, %2$s FROM %1$s WHERE %2$s IS NOT NULL", gav, field))) { + try (ResultSet resultSet = statement.executeQuery()) { + while (resultSet.next()) { + String fieldValue = resultSet.getString(2); + String fixFieldValue = fieldValue.trim(); + if (!fieldValue.equals(fixFieldValue)) { + if (fixFieldValue.isEmpty()) { + fixFieldValue = null; + } + String id = resultSet.getString(1); + String finalFieldValue = commentFormat.apply(fixFieldValue); + log.info(String.format("Fix comment field %s.%s[%s] from\n[%s]\nto\n[%s]", gav, field, id, fieldValue, fixFieldValue)); + executor.writeSql(String.format("UPDATE %s SET %s = %s WHERE topiaId = '%s';", gav, field, finalFieldValue, id)); + count.incrementAndGet(); + } + } + } + } + }); + + } +} ===================================== core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/FixStringHelper.java ===================================== @@ -0,0 +1,264 @@ +package fr.ird.observe.spi.migration.v9; + +/*- + * #%L + * ObServe Core :: Persistence :: Resources + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ird.observe.dto.StringCleaner; +import fr.ird.observe.persistence.SqlHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.nuiton.topia.service.migration.resources.MigrationVersionResourceExecutor; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collections; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.concurrent.atomic.AtomicLong; + +/** + * To auto-trim string fields and remove any {@code '} characters inside it. + * <p> + * <strong>Note:</strong> If fixed value is empty or blank then set {@code null} value. + * <p> + * Created on 11/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.0.17 + */ +public class FixStringHelper { + + private static final Logger log = LogManager.getLogger(FixStringHelper.class); + + private final MigrationVersionResourceExecutor executor; + private final AtomicLong count = new AtomicLong(); + + public FixStringHelper(MigrationVersionResourceExecutor executor) { + this.executor = Objects.requireNonNull(executor); + } + + static class FixStringEntityModel { + + private final String gav; + private final Map<String, StringCleaner> fieldsActions; + private final Set<String> fieldsDeleteIfNull; + + static FixStringEntityModel on(String gav, StringCleaner cleaner, String firstField, String... fields) { + return new FixStringEntityModel(gav).add(cleaner, firstField, fields); + } + + static FixStringEntityModel onI18n(String gav, StringCleaner cleaner, String firstField, String... fields) { + return on(gav, StringCleaner.TRIM, "label1", "label2", "label3").add(cleaner, firstField, fields); + } + + private FixStringEntityModel(String gav) { + this.gav = gav; + this.fieldsActions = new TreeMap<>(); + this.fieldsDeleteIfNull = new TreeSet<>(); + } + + FixStringEntityModel add(StringCleaner cleaner, String firstField, String... fields) { + fieldsActions.put(firstField, cleaner); + for (String field : fields) { + fieldsActions.put(field, cleaner); + } + return this; + } + + FixStringEntityModel deleteIfNull(String firstField, String... fields) { + fieldsDeleteIfNull.add(firstField); + Collections.addAll(fieldsDeleteIfNull, fields); + return this; + } + + } + + public long execute() { + executor.doSqlWork(connection -> { + execute(connection, FixStringEntityModel.onI18n("common.Country", StringCleaner.ALL, "code", "iso2Code", "iso3Code")); + execute(connection, FixStringEntityModel.onI18n("common.DataQuality", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.FpaZone", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.Gear", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.GearCharacteristic", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.GearCharacteristicType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.Harbour", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.on("common.LengthLengthParameter", StringCleaner.ALL, "coefficients", "inputOutputFormula", "outputInputFormula")); + execute(connection, FixStringEntityModel.onI18n("common.LengthMeasureMethod", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.on("common.LengthWeightParameter", StringCleaner.ALL, "coefficients", "lengthWeightFormula", "weightLengthFormula")); + execute(connection, FixStringEntityModel.onI18n("common.Ocean", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.Organism", StringCleaner.ALL, "code")); + // not removing single quotes + execute(connection, FixStringEntityModel.on("common.Person", StringCleaner.TRIM, "firstName", "lastName")); + execute(connection, FixStringEntityModel.onI18n("common.Sex", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.on("common.ShipOwner", StringCleaner.ALL, "code", "label")); + execute(connection, FixStringEntityModel.onI18n("common.SizeMeasureType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.Species", StringCleaner.ALL, "scientificLabel")); + execute(connection, FixStringEntityModel.onI18n("common.SpeciesGroup", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.SpeciesGroupReleaseMode", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.SpeciesList", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.Vessel", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.VesselType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.on("common.VesselSizeCategory", StringCleaner.ALL, "code", "capacityLabel", "gaugeLabel")); + execute(connection, FixStringEntityModel.onI18n("common.WeightMeasureMethod", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.WeightMeasureType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("common.Wind", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.onI18n("ll_common.BaitSettingStatus", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.BaitType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.CatchFate", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.HealthStatus", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.HookSize", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.HookType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.LightsticksColor", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.LightsticksType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.LineType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.MitigationType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.ObservationMethod", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.OnBoardProcessing", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.Program", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.SettingShape", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.TripType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.VesselActivity", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_common.WeightDeterminationMethod", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.onI18n("ll_landing.Company", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_landing.Conservation", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_landing.DataSource", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.onI18n("ll_observation.BaitHaulingStatus", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_observation.EncounterType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_observation.HookPosition", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_observation.ItemHorizontalPosition", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_observation.ItemVerticalPosition", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_observation.MaturityStatus", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.on("ll_observation.SensorBrand", StringCleaner.ALL, "brandName", "code")); + execute(connection, FixStringEntityModel.onI18n("ll_observation.SensorDataFormat", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_observation.SensorType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ll_observation.StomachFullness", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.onI18n("ps_common.AcquisitionStatus", StringCleaner.ALL, "code")); + // not set to null if empty (special value FOB has an empty code) + execute(connection, FixStringEntityModel.onI18n("ps_common.ObjectMaterial", StringCleaner.REMOVE_SINGLE_QUOTE_AND_TRIM, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.ObjectMaterialType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.ObjectOperation", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.ObservedSystem", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.Program", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.ReasonForNoFishing", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.ReasonForNullSet", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.SampleType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.SchoolType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.SpeciesFate", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.TransmittingBuoyOperation", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.TransmittingBuoyOwnership", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.TransmittingBuoyType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.VesselActivity", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_common.WeightCategory", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.onI18n("ps_landing.Destination", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_landing.Fate", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.onI18n("ps_localmarket.BatchComposition", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_localmarket.BatchWeightType", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_localmarket.Packaging", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.onI18n("ps_logbook.InformationSource", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_logbook.SampleQuality", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_logbook.SetSuccessStatus", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_logbook.WellContentStatus", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_logbook.WellSamplingConformity", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_logbook.WellSamplingStatus", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.onI18n("ps_observation.DetectionMode", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_observation.InformationSource", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_observation.NonTargetCatchReleaseConformity", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_observation.NonTargetCatchReleaseStatus", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_observation.NonTargetCatchReleasingTime", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_observation.ReasonForDiscard", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_observation.SpeciesStatus", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.onI18n("ps_observation.SurroundingActivity", StringCleaner.ALL, "code")); + + execute(connection, FixStringEntityModel.on("ll_common.GearUseFeaturesMeasurement", StringCleaner.ALL, "measurementValue").deleteIfNull("measurementValue")); + execute(connection, FixStringEntityModel.on("ll_common.Trip", StringCleaner.ALL, "ersId", "homeId")); + + execute(connection, FixStringEntityModel.on("ll_logbook.Catch", StringCleaner.ALL, "photoReferences", "tagNumber")); + execute(connection, FixStringEntityModel.on("ll_logbook.SamplePart", StringCleaner.ALL, "tagNumber")); + execute(connection, FixStringEntityModel.on("ll_logbook.Set", StringCleaner.ALL, "homeId")); + + execute(connection, FixStringEntityModel.on("ll_observation.Catch", StringCleaner.ALL, "photoReferences", "tagNumber")); + execute(connection, FixStringEntityModel.on("ll_observation.SensorUsed", StringCleaner.ALL, "sensorSerialNo")); + execute(connection, FixStringEntityModel.on("ll_observation.Set", StringCleaner.ALL, "homeId")); + execute(connection, FixStringEntityModel.on("ll_observation.Tdr", StringCleaner.ALL, "serialNo")); + + execute(connection, FixStringEntityModel.on("ps_common.GearUseFeaturesMeasurement", StringCleaner.ALL, "measurementValue").deleteIfNull("measurementValue")); + execute(connection, FixStringEntityModel.on("ps_common.Trip", StringCleaner.ALL, "ersId", "formsUrl", "homeId", "reportsUrl")); + + execute(connection, FixStringEntityModel.on("ps_localmarket.Sample", StringCleaner.ALL, "number")); + + execute(connection, FixStringEntityModel.on("ps_logbook.Catch", StringCleaner.ALL, "well")); + execute(connection, FixStringEntityModel.on("ps_logbook.FloatingObject", StringCleaner.ALL, "supportVesselName")); + execute(connection, FixStringEntityModel.on("ps_logbook.Sample", StringCleaner.ALL, "well")); + execute(connection, FixStringEntityModel.on("ps_logbook.TransmittingBuoy", StringCleaner.ALL, "code")); + execute(connection, FixStringEntityModel.on("ps_logbook.WellPlan", StringCleaner.ALL, "well")); + + execute(connection, FixStringEntityModel.on("ps_observation.Activity", StringCleaner.ALL, "ersId")); + execute(connection, FixStringEntityModel.on("ps_observation.FloatingObject", StringCleaner.ALL, "supportVesselName")); + execute(connection, FixStringEntityModel.on("ps_observation.SampleMeasure", StringCleaner.ALL, "picturesReferences", "tagNumber")); + execute(connection, FixStringEntityModel.on("ps_observation.Set", StringCleaner.ALL, "supportVesselName")); + execute(connection, FixStringEntityModel.on("ps_observation.TransmittingBuoy", StringCleaner.ALL, "code")); + }); + return count.get(); + } + + void execute(Connection connection, FixStringEntityModel model) throws SQLException { + for (Map.Entry<String, StringCleaner> entry : model.fieldsActions.entrySet()) { + execute(connection, model.gav, entry.getKey(), entry.getValue(), model.fieldsDeleteIfNull.contains(entry.getKey())); + } + } + + void execute(Connection connection, String gav, String field, StringCleaner cleaner, boolean deleteIfNull) throws SQLException { + try (PreparedStatement statement = connection.prepareStatement(String.format("SELECT topiaId, %2$s FROM %1$s WHERE %2$s IS NOT NULL", gav, field))) { + try (ResultSet resultSet = statement.executeQuery()) { + while (resultSet.next()) { + String fieldValue = resultSet.getString(2); + String fixFieldValue = cleaner.apply(fieldValue); + if (!fieldValue.equals(fixFieldValue)) { + String id = resultSet.getString(1); + if (deleteIfNull && fixFieldValue == null) { + log.warn(String.format("Delete row since field is empty %s.%s[%s] (was '%s')", gav, field, id, fieldValue)); + executor.writeSql(String.format("DELETE FROM %1$s WHERE topiaId = '%2$s';", gav, id)); + } else { + log.info(String.format("Fix string field %s.%s[%s] from\n[%s]\n to\n[%s]", gav, field, id, fieldValue, fixFieldValue)); + String finalFieldValue = SqlHelper.escapeString(fixFieldValue); + executor.writeSql(String.format("UPDATE %1$s SET %2$s = %3$s WHERE topiaId = '%4$s';", gav, field, finalFieldValue, id)); + } + count.incrementAndGet(); + } + } + } + } + } +} ===================================== core/persistence/resources/src/main/java/fr/ird/observe/spi/migration/v9/NotDiscardedTargetCatchRecord.java ===================================== @@ -22,6 +22,8 @@ package fr.ird.observe.spi.migration.v9; * #L% */ +import fr.ird.observe.dto.StringCleaner; +import fr.ird.observe.persistence.SqlHelper; import fr.ird.observe.spi.context.DataDtoEntityContext; import java.sql.Connection; @@ -42,19 +44,19 @@ class NotDiscardedTargetCatchRecord { public static PreparedStatement prepareStatement(Connection connection) throws SQLException { return connection.prepareStatement("SELECT" + - /* 01 */ " REPLACE(tc.topiaId, '.TargetCatch', '.Catch')," + - /* 02 */ " tc.topiaVersion + 1," + - /* 03 */ " tc.topiaCreateDate," + - /* 04 */ " tc.homeId," + - /* 05 */ " tc.catchWeight," + - /* 06 */ " tc.weightCategory," + - /* 07 */ " tc.comment," + - /* 08 */ " tc.set," + - /* 09 */ " tc.lastUpdateDate," + - /* 10 */ " tc.well," + - /* 11 */ " -tc.set_idx," + - /* 12 */ " tc.weightMeasureMethod," + - /* 13 */ " s.targetcatchcompositionestimatedbyobserver " + + /* 01 */ " REPLACE(tc.topiaId, '.TargetCatch', '.Catch')," + + /* 02 */ " tc.topiaVersion + 1," + + /* 03 */ " tc.topiaCreateDate," + + /* 04 */ " tc.homeId," + + /* 05 */ " tc.catchWeight," + + /* 06 */ " tc.weightCategory," + + /* 07 */ " tc.comment," + + /* 08 */ " tc.set," + + /* 09 */ " tc.lastUpdateDate," + + /* 10 */ " tc.well," + + /* 11 */ " -tc.set_idx," + + /* 12 */ " tc.weightMeasureMethod," + + /* 13 */ " s.targetcatchcompositionestimatedbyobserver " + " FROM ps_observation.TargetCatch tc INNER JOIN ps_observation.set s on s.topiaId = tc.set" + " WHERE NOT tc.discarded AND NOT ( weightCategory IS NULL AND catchweight IS NULL AND well IS NULL AND broughtondeck IS NULL AND reasonfordiscard IS NULL )"); } @@ -131,24 +133,24 @@ class NotDiscardedTargetCatchRecord { "%16$s, " + "%17$s, " + "%18$s);", - /*1*/ DataDtoEntityContext.escapeString(id), + /*1*/ SqlHelper.escapeString(id), /*2*/ topiaVersion, /*3*/ DataDtoEntityContext.timestamp(topiaCreateDate), - /*4*/ DataDtoEntityContext.escapeString(homeId), + /*4*/ SqlHelper.escapeString(StringCleaner.ALL.apply(homeId)), /*5*/ catchWeight, /*6*/ weightCategoryRecord.getMinWeight(), /*7*/ weightCategoryRecord.getMaxWeight(), /*8*/ null, /*9*/ getComment(weightCategoryRecord, commentFormat), /*10*/ null, - /*11*/ DataDtoEntityContext.escapeString(weightCategoryRecord.getSpeciesId()), - /*12*/ DataDtoEntityContext.escapeString("10".equals(weightCategoryRecord.getCode()) ? DataSourceMigrationForVersion_9_0.SPECIES_FATE_15 : DataSourceMigrationForVersion_9_0.SPECIES_FATE_6), - /*13*/ DataDtoEntityContext.escapeString(setId), + /*11*/ SqlHelper.escapeString(weightCategoryRecord.getSpeciesId()), + /*12*/ SqlHelper.escapeString("10".equals(weightCategoryRecord.getCode()) ? DataSourceMigrationForVersion_9_0.SPECIES_FATE_15 : DataSourceMigrationForVersion_9_0.SPECIES_FATE_6), + /*13*/ SqlHelper.escapeString(setId), /*14*/ DataDtoEntityContext.timestamp(lastUpdateDate), - /*15*/ DataDtoEntityContext.escapeString(getWell()), + /*15*/ SqlHelper.escapeString(StringCleaner.ALL.apply(well)), /*16*/ setIdx, - /*17*/ DataDtoEntityContext.escapeString(weightMeasureMethodId == null ? "fr.ird.referential.common.WeightMeasureMethod#666#03" : weightCategoryId), - /*18*/ DataDtoEntityContext.escapeString(targetCatchCompositionEstimatedByObserver ? DataSourceMigrationForVersion_9_0.INFORMATION_SOURCE_P : DataSourceMigrationForVersion_9_0.INFORMATION_SOURCE_U) + /*17*/ SqlHelper.escapeString(weightMeasureMethodId == null ? "fr.ird.referential.common.WeightMeasureMethod#666#03" : weightCategoryId), + /*18*/ SqlHelper.escapeString(targetCatchCompositionEstimatedByObserver ? DataSourceMigrationForVersion_9_0.INFORMATION_SOURCE_P : DataSourceMigrationForVersion_9_0.INFORMATION_SOURCE_U) ); } @@ -158,16 +160,4 @@ class NotDiscardedTargetCatchRecord { } return stringFormat.apply(comment + "\n" + weightCategoryRecord.toComment()); } - - - public String getWell() { - String result = well; - if (result!=null) { - result = well.trim(); - if (well.startsWith("'")) { - result = result.substring(1); - } - } - return result; - } } ===================================== core/services/i18n/src/main/i18n/translations/services_en_GB.properties ===================================== @@ -1287,6 +1287,7 @@ observe.data.ps.observation.Catch.meanWeight.short=Mean weight observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Weight or mean size must be filled. observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=Mean weight was computed (%s) observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=Mean weight was observed +observe.data.ps.observation.Catch.minMaxWeight=Lower / upper weight limit (in kg) observe.data.ps.observation.Catch.minWeight=Lower weight limit (in kg) observe.data.ps.observation.Catch.minWeight.short=Min weight (in kg) observe.data.ps.observation.Catch.reasonForDiscard=Reason for discard ===================================== core/services/i18n/src/main/i18n/translations/services_es_ES.properties ===================================== @@ -1287,6 +1287,7 @@ observe.data.ps.observation.Catch.meanWeight.short=Peso medio observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Debe seleccionar uno de los dos valores (peso medio o talla media). observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=El peso medio se calculó observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=El peso medio se observó +observe.data.ps.observation.Catch.minMaxWeight=Lower / upper weight limit (in kg) TODO observe.data.ps.observation.Catch.minWeight=Lower weight limit (in kg) TODO observe.data.ps.observation.Catch.minWeight.short=Max weight (in kg) observe.data.ps.observation.Catch.reasonForDiscard=Razón del descarte ===================================== core/services/i18n/src/main/i18n/translations/services_fr_FR.properties ===================================== @@ -1287,6 +1287,7 @@ observe.data.ps.observation.Catch.meanWeight.short=Poids moy observe.data.ps.observation.Catch.meanWeight.validation.notFilled=Une des deux valeurs (poids moyen ou taille moyenne) devrait être renseignée. observe.data.ps.observation.Catch.meanWeightComputed.computed.tip=Le poids moyen a été calculé (%s) observe.data.ps.observation.Catch.meanWeightComputed.observed.tip=Le poids moyen a été observé +observe.data.ps.observation.Catch.minMaxWeight=Borne de poids inférieure / supérieure (en kg) observe.data.ps.observation.Catch.minWeight=Borne de poids inférieure (en kg) observe.data.ps.observation.Catch.minWeight.short=Poids min (en kg) observe.data.ps.observation.Catch.reasonForDiscard=Raison rejet ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ValidateService-dataResult.json ===================================== @@ -43828,7 +43828,7 @@ "topiaVersion": 16, "topiaCreateDate": "2009-04-15T00:00:00.009Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 1.0, "well": "2", "id": "fr.ird.data.ps.observation.Catch#1554060786914#0.3899957341641852", @@ -43874,7 +43874,7 @@ "topiaVersion": 16, "topiaCreateDate": "2009-04-15T00:00:00.004Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 1.0, "well": "2", "id": "fr.ird.data.ps.observation.Catch#1554060786914#0.455212337619455", @@ -43920,7 +43920,7 @@ "topiaVersion": 16, "topiaCreateDate": "2009-04-15T00:00:00.010Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 16.0, "well": "1", "id": "fr.ird.data.ps.observation.Catch#1554228692388#0.40195828823649804", @@ -43966,7 +43966,7 @@ "topiaVersion": 15, "topiaCreateDate": "2009-04-15T00:00:00.001Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 1.0, "well": "1", "id": "fr.ird.data.ps.observation.Catch#1554228692388#0.5827043409961202", @@ -44012,7 +44012,7 @@ "topiaVersion": 15, "topiaCreateDate": "2009-04-15T00:00:00.001Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 4.0, "well": "1", "id": "fr.ird.data.ps.observation.Catch#1554228964667#0.3873882731438876", @@ -44058,7 +44058,7 @@ "topiaVersion": 16, "topiaCreateDate": "2009-04-15T00:00:00.010Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 27.0, "well": "1", "id": "fr.ird.data.ps.observation.Catch#1554228964667#0.6898347092973715", @@ -44104,7 +44104,7 @@ "topiaVersion": 15, "topiaCreateDate": "2009-04-15T00:00:00.001Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 1.0, "well": "4", "id": "fr.ird.data.ps.observation.Catch#1554228964683#0.5525193499129678", @@ -44150,7 +44150,7 @@ "topiaVersion": 16, "topiaCreateDate": "2009-04-15T00:00:00.010Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 39.0, "well": "4", "id": "fr.ird.data.ps.observation.Catch#1554228964683#0.6111969202426193", @@ -44196,7 +44196,7 @@ "topiaVersion": 16, "topiaCreateDate": "2009-04-15T00:00:00.010Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 15.0, "well": "4", "id": "fr.ird.data.ps.observation.Catch#1554229020077#0.06929838028483837", @@ -44242,7 +44242,7 @@ "topiaVersion": 16, "topiaCreateDate": "2009-04-15T00:00:00.010Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 25.0, "well": "2", "id": "fr.ird.data.ps.observation.Catch#1554229020077#0.764944972601716", @@ -44288,7 +44288,7 @@ "topiaVersion": 15, "topiaCreateDate": "2009-04-15T00:00:00.001Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 1.0, "well": "3", "id": "fr.ird.data.ps.observation.Catch#1554659569269#0.5089206009917716", @@ -44334,7 +44334,7 @@ "topiaVersion": 16, "topiaCreateDate": "2009-04-15T00:00:00.010Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 53.0, "well": "3", "id": "fr.ird.data.ps.observation.Catch#1554659569269#0.9595940690443661", @@ -44470,7 +44470,7 @@ "topiaVersion": 19, "topiaCreateDate": "2009-04-15T00:00:00.005Z" }, - "speciesFateLabel": "Conservé (en cuve, poisson séché ou salé)", + "speciesFateLabel": "Conservé à destination de la conserverie", "catchWeight": 12.0, "well": "3T", "id": "fr.ird.data.ps.observation.Catch#1612860304046#0.051529228859696796", ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ValidateService-referentialResult.json ===================================== @@ -56940,13 +56940,13 @@ }, { "fieldName": "uri", - "scope": "WARNING", - "message": "Le champ n\u0027est pas renseigné." + "scope": "ERROR", + "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." }, { "fieldName": "uri", - "scope": "ERROR", - "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." + "scope": "WARNING", + "message": "Le champ n\u0027est pas renseigné." }, { "fieldName": "wormsId", @@ -62791,13 +62791,13 @@ }, { "fieldName": "uri", - "scope": "WARNING", - "message": "Le champ n\u0027est pas renseigné." + "scope": "ERROR", + "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." }, { "fieldName": "uri", - "scope": "ERROR", - "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." + "scope": "WARNING", + "message": "Le champ n\u0027est pas renseigné." }, { "fieldName": "wormsId", @@ -63241,13 +63241,13 @@ "messages": [ { "fieldName": "uri", - "scope": "WARNING", - "message": "Le champ n\u0027est pas renseigné." + "scope": "ERROR", + "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." }, { "fieldName": "uri", - "scope": "ERROR", - "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." + "scope": "WARNING", + "message": "Le champ n\u0027est pas renseigné." }, { "fieldName": "wormsId", @@ -68238,12 +68238,12 @@ { "fieldName": "species", "scope": "ERROR", - "message": "Le référentiel sélectionné «SPY - Sphyrnidae - Famille Sphyrnidae» (à la position 24) est désactivé." + "message": "Le référentiel sélectionné «LKY - Lepidochelys kempii - Tortue de Kemp» (à la position 120) est désactivé." }, { "fieldName": "species", "scope": "ERROR", - "message": "Le référentiel sélectionné «LKY - Lepidochelys kempii - Tortue de Kemp» (à la position 120) est désactivé." + "message": "Le référentiel sélectionné «SPY - Sphyrnidae - Famille Sphyrnidae» (à la position 24) est désactivé." }, { "fieldName": "species", @@ -68504,7 +68504,7 @@ { "fieldName": "species", "scope": "ERROR", - "message": "Le référentiel sélectionné «SPY - Sphyrnidae - Famille Sphyrnidae» (à la position 24) est désactivé." + "message": "Le référentiel sélectionné «LKY - Lepidochelys kempii - Tortue de Kemp» (à la position 120) est désactivé." }, { "fieldName": "species", @@ -68514,7 +68514,7 @@ { "fieldName": "species", "scope": "ERROR", - "message": "Le référentiel sélectionné «LKY - Lepidochelys kempii - Tortue de Kemp» (à la position 120) est désactivé." + "message": "Le référentiel sélectionné «SPY - Sphyrnidae - Famille Sphyrnidae» (à la position 24) est désactivé." }, { "fieldName": "species", @@ -142383,13 +142383,13 @@ }, { "fieldName": "uri", - "scope": "WARNING", - "message": "Le champ n\u0027est pas renseigné." + "scope": "ERROR", + "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." }, { "fieldName": "uri", - "scope": "ERROR", - "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." + "scope": "WARNING", + "message": "Le champ n\u0027est pas renseigné." }, { "fieldName": "wellRegex", @@ -157800,13 +157800,13 @@ }, { "fieldName": "uri", - "scope": "WARNING", - "message": "Le champ n\u0027est pas renseigné." + "scope": "ERROR", + "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." }, { "fieldName": "uri", - "scope": "ERROR", - "message": "Le champ (s\u0027il est renseigné) ne doit pas être consituté que d\u0027espaces." + "scope": "WARNING", + "message": "Le champ n\u0027est pas renseigné." }, { "fieldName": "vesselSizeCategory", @@ -196593,6 +196593,7 @@ "code": "1", "label": "Echappe du filet (pour requin-baleine et cétacés)", "discard": true, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683618#0.06155887805368032", @@ -196626,6 +196627,7 @@ "code": "3", "label": "Sortie mort du filet (pour requin-baleine et cétacés)", "discard": true, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.11883784875534997", @@ -196659,6 +196661,7 @@ "code": "4", "label": "Rejeté vivant", "discard": true, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.5308862132841506", @@ -196682,6 +196685,7 @@ "code": "6", "label": "Conservé à destination de la conserverie", "discard": false, + "weightRangeAllowed": true, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.5722739932065866", @@ -196710,6 +196714,7 @@ "code": "5", "label": "Rejeté mort", "discard": true, + "weightRangeAllowed": true, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.6250731662108877", @@ -196733,6 +196738,7 @@ "code": "2", "label": "Sortie vivant du filet (pour requin-baleine et cétacés)", "discard": true, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683619#0.9931091059863436", @@ -196765,6 +196771,7 @@ "content": { "code": "7", "label": "Partiellement conservé (ex: ailerons de requin, poisson séché)", + "weightRangeAllowed": false, "needComment": false, "enabled": false, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683620#0.46609703818634485", @@ -196803,6 +196810,7 @@ "code": "8", "label": "Utilisé en cuisine du bord", "discard": false, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683621#0.6728026426066158", @@ -196835,6 +196843,7 @@ "content": { "code": "9", "label": "Autres (à préciser dans les notes)", + "weightRangeAllowed": false, "needComment": true, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1239832683621#0.9099804284263154", @@ -196868,6 +196877,7 @@ "code": "15", "label": "Conservé pour le marché local ou poisson séché/salé à bord", "discard": false, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1464000000000#15", @@ -196895,6 +196905,7 @@ "content": { "code": "10", "label": "Ailerons seulements", + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1467372855729#0.568287924081734", @@ -196918,6 +196929,7 @@ "code": "11", "label": "Rejeté, statut non observé", "discard": true, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1501492537510#0.9210847837998154", @@ -196941,6 +196953,7 @@ "code": "12", "label": "Conservé pour raisons scientifiques", "discard": false, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1501492831539#0.9377232562184147", @@ -196964,6 +196977,7 @@ "code": "13", "label": "Rejeté suffocant", "discard": true, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1544448835551#0.620629930572886", @@ -196987,6 +197001,7 @@ "code": "14", "label": "Rejeté suffocant blessé", "discard": true, + "weightRangeAllowed": false, "needComment": false, "enabled": true, "id": "fr.ird.referential.ps.common.SpeciesFate#1544448977865#0.24265421995390768", ===================================== model/src/main/models/Observe/dto/class/i18nLabels.properties ===================================== @@ -84,7 +84,7 @@ data.ps.logbook.Well=well,wellVessel,wellFactory,wellSamplingConformity,wellSamp data.ps.logbook.WellActivity=activity,wellActivitySpecies data.ps.logbook.WellActivitySpecies=species,weight,weightCategory,count,setSpeciesNumber data.ps.observation.Activity=date,coordinate,observedSystem.available,observedSystem.selected,comment,comment2,currentFpaZone,dataQuality,detectionMode,ersId,floatingObjectEmpty,latitude,longitude,nextFpaZone,nonTargetCatchSpecies,observedSystem,observedSystemDistance,previousFpaZone,quadrant,reasonForNoFishing,seaSurfaceTemperature,surroundingActivity,time,vesselActivity,vesselSpeed,wind,generalTab,error.no.activity.6,measurementsTab,observedSystemTab -data.ps.observation.Catch=catchWeight,comment,informationSource,lengthMeasureMethod,meanLength,minWeight,maxWeight,meanWeight,reasonForDiscard,species,speciesFate,totalCount,weightMeasureMethod,well,catchWeightComputed.computed.tip,catchWeightComputed.observed.tip,meanLengthComputed.computed.tip,meanLengthComputed.observed.tip,meanWeightComputed.computed.tip,meanWeightComputed.observed.tip,totalCountComputed.computed.tip,totalCountComputed.observed.tip +data.ps.observation.Catch=catchWeight,comment,informationSource,lengthMeasureMethod,meanLength,minWeight,maxWeight,meanWeight,minMaxWeight,reasonForDiscard,species,speciesFate,totalCount,weightMeasureMethod,well,catchWeightComputed.computed.tip,catchWeightComputed.observed.tip,meanLengthComputed.computed.tip,meanLengthComputed.observed.tip,meanWeightComputed.computed.tip,meanWeightComputed.observed.tip,totalCountComputed.computed.tip,totalCountComputed.observed.tip data.ps.observation.FloatingObject=materialsValid,objectOperation,supportVesselName,country,vessel,computedBiodegradable,computedNonEntangling,computedSimplifiedObjectType,computedValues,generalTab,buoysTab,materialsTab,notComputed,type.short data.ps.observation.NonTargetCatchRelease=comment,conformity,count,length,lengthMeasureMethod,releasingTime,sex,status,species,speciesGroupReleaseMode,message.cantAdd data.ps.observation.ObjectObservedSpecies=count,species,speciesStatus ===================================== model/src/main/models/Observe/dto/class/i18nOverrideLabels.properties ===================================== @@ -23,7 +23,7 @@ data.ll.common.Trip=species data.ll.landing.Landing=vessel data.ps.localmarket.Sample=well data.ps.logbook.Catch=weightMeasureMethod.validation.required -data.ps.observation.Catch=minWeight,maxWeight,weightMeasureMethod +data.ps.observation.Catch=minWeight,maxWeight,minMaxWeight,weightMeasureMethod data.ps.observation.SchoolEstimate=species data.ps.observation.Set=startTime,haulingStartTimeStamp,haulingEndTimeStamp,endTimeStamp referential.common.Species=codeAndHomeId ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/StringCleaner.java ===================================== @@ -0,0 +1,82 @@ +package fr.ird.observe.dto; + +/*- + * #%L + * ObServe Toolkit :: API + * %% + * Copyright (C) 2008 - 2022 IRD, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import java.util.function.Function; + +/** + * Object to clean a string related to a database field. + * <p> + * Created on 12/11/2022. + * + * @author Tony Chemit - dev(a)tchemit.fr + * @since 9.017 + */ +public class StringCleaner implements Function<String, String> { + + public static final StringCleaner ALL = new StringCleaner(true, true, true); + public static final StringCleaner REMOVE_SINGLE_QUOTE_AND_TRIM = new StringCleaner(true, true, false); + public static final StringCleaner TRIM_AND_REPLACE_EMPTY_BY_NULL = new StringCleaner(false, true, true); + public static final StringCleaner TRIM = new StringCleaner(false, true, false); + + /** + * To remove any single quote in given string. + */ + private final boolean removeSingleQuote; + /** + * To perform a trim on given string. + */ + private final boolean trim; + /** + * To replace the given string value by null if it is empty. + */ + private final boolean replaceEmptyByNull; + + public StringCleaner(boolean removeSingleQuote, boolean trim, boolean replaceEmptyByNull) { + this.removeSingleQuote = removeSingleQuote; + this.trim = trim; + this.replaceEmptyByNull = replaceEmptyByNull; + } + + public static String removeSingleQuote(String string) { + return string.replaceAll("'", ""); + } + + @Override + public String apply(String string) { + if (string == null) { + return null; + } + String result = string; + if (removeSingleQuote) { + result = removeSingleQuote(result); + } + if (trim) { + result = result.trim(); + } + if (replaceEmptyByNull && result.isEmpty()) { + result = null; + } + return result; + } +} ===================================== toolkit/api/src/main/java/fr/ird/observe/persistence/SqlHelper.java ===================================== @@ -64,7 +64,21 @@ public class SqlHelper { if (trim.length() > maxLength) { trim = trim.substring(0, maxLength - 1); } - return "'" + trim.replaceAll("'", "''") + "'"; + return "'" + escapeSingleQuote(trim) + "'"; } + public static String escapeSingleQuote(String string) { + return string.replaceAll("'", "''"); + } + + public static String escapeString(String string) { + if (string == null) { + return "NULL"; + } + String trim = string.trim(); + if (trim.isEmpty()) { + return "NULL"; + } + return "'" + escapeSingleQuote(trim) + "'"; + } } ===================================== toolkit/persistence/src/main/java/fr/ird/observe/spi/context/DataDtoEntityContext.java ===================================== @@ -35,6 +35,7 @@ import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.entities.Entity; import fr.ird.observe.entities.data.DataEntity; import fr.ird.observe.entities.data.DataFileAware; +import fr.ird.observe.persistence.SqlHelper; import fr.ird.observe.persistence.request.DeleteRequest; import fr.ird.observe.spi.service.ServiceContext; import fr.ird.observe.spi.usage.UsageHelper; @@ -78,14 +79,7 @@ public abstract class DataDtoEntityContext< } public static String toId(Entity entity) { - return entity == null ? "NULL" : escapeString(entity.getTopiaId()); - } - - public static String escapeString(String string) { - if (string == null) { - return "NULL"; - } - return "'" + string.trim() + "'"; + return entity == null ? "NULL" : SqlHelper.escapeString(entity.getTopiaId()); } public static Blob byteArrayToBlob(byte[] bytes) { View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/ad0dd0ec7e1a4b1c31e84a56… -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/ad0dd0ec7e1a4b1c31e84a56… You're receiving this email because of your account on gitlab.com.
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • ...
  • 720
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.