Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 747f5194 by Tony Chemit at 2022-12-11T00:56:52+01:00 update pom - - - - - 9bebca7f by Tony Chemit at 2022-12-11T00:57:17+01:00 Report - Fix SumColumn and SumRow total cell condition - - - - - 9d195aef by Tony Chemit at 2022-12-11T00:57:21+01:00 Report - Fix syntax.columnsHeader assert - - - - - e79d8d76 by Tony Chemit at 2022-12-11T00:57:24+01:00 Report - Fix SumColumn and SumRow total cell condition (on psLogbookWellPlanCheck report) - - - - - 9d070c7d by Tony Chemit at 2022-12-11T00:57:28+01:00 Report - Improve how to detect a variable in a request (can have :xxx,) - - - - - 3dbafec5 by Tony Chemit at 2022-12-11T00:57:31+01:00 Report - Add possible Boolean report variable - - - - - 7933cad8 by Tony Chemit at 2022-12-11T00:57:36+01:00 Report - Add report psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation - - - - - afb181a3 by Tony Chemit at 2022-12-11T00:57:40+01:00 Report - Add report psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation - - - - - 424f54de by Tony Chemit at 2022-12-11T00:57:43+01:00 Persistence - be able to add a null parameter in a query - - - - - 8a2e9e77 by Tony Chemit at 2022-12-11T00:57:49+01:00 Merge branch 'feature/issue_2552' into develop Optimisation des rapports Captures de thons selon le type d'association et Rejets de thons selon le type d'association - Closes #2552 - - - - - 15 changed files: - client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportUIHandler.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/PsObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociationReportFixture.java - + core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociationReportFixture.java - core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psLogbookWellPlanCheck.properties - + core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.properties - + core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.properties - pom.xml - toolkit/api/src/main/java/fr/ird/observe/dto/report/Report.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/SumRow.java - toolkit/persistence/src/main/java/fr/ird/observe/spi/report/DefaultReportRequestExecutor.java - toolkit/persistence/src/main/java/org/nuiton/topia/persistence/internal/support/HibernateTopiaJpaSupport.java Changes: ===================================== client/datasource/actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportUIHandler.java ===================================== @@ -41,6 +41,7 @@ import fr.ird.observe.spi.module.BusinessProjectMapping; import fr.ird.observe.spi.module.ObserveBusinessProject; import io.ultreia.java4all.bean.JavaBean; import io.ultreia.java4all.decoration.Decorator; +import io.ultreia.java4all.jaxx.widgets.choice.BooleanEditor; import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox; import io.ultreia.java4all.util.TimeLog; import org.apache.logging.log4j.LogManager; @@ -220,43 +221,79 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa for (ReportVariable variable : report.getVariables()) { String variableName = variable.getName(); Set values = variable.getValues(); - List<JavaBean> universe = new ArrayList<>(values); log.info("Variable type: " + variable.getType()); //FIXME Decorators, let's object deal with it and never ask at this level... Just do a toString()... Decorator decorator; Class type; BusinessProjectMapping mapping = ObserveBusinessProject.get().getMapping(); - if (ReferentialDto.class.isAssignableFrom(variable.getType()) && !universe.isEmpty()) { + if (ReferentialDto.class.isAssignableFrom(variable.getType()) && !values.isEmpty()) { type = mapping.getReferenceType(variable.getType()); decorator = getDecoratorService().getDecoratorByType(type); - } else if (DataDto.class.isAssignableFrom(variable.getType()) && !universe.isEmpty()) { + } else if (DataDto.class.isAssignableFrom(variable.getType()) && !values.isEmpty()) { type = mapping.getReferenceType(variable.getType()); decorator = getDecoratorService().getDecoratorByType(type); + } else if (Boolean.class.isAssignableFrom(variable.getType()) && !values.isEmpty()) { + type = variable.getType(); + decorator = null; } else { type = variable.getType(); decorator = getDecoratorService().getDecoratorByType(type); } log.info(String.format("Variable real type: %s", type)); - FilterableComboBox<?> combo = UIHelper.newFilterableComboBox(type, decorator, universe); - combo.setShowReset(true); - JPanel p = new JPanel(new BorderLayout()); - p.add(new JLabel(t(I18nDecoratorHelper.getType(variable.getType()))), BorderLayout.WEST); - p.add(combo, BorderLayout.CENTER); - variablesPanel.add(p); - JComboBox<?> jComboBox = combo.getCombobox(); - jComboBox.putClientProperty(VARIABLE_NAME, variableName); - jComboBox.addItemListener(e -> { - JComboBox<?> comboBox = (JComboBox<?>) e.getSource(); - if (e.getStateChange() == ItemEvent.DESELECTED) { - // ne rien faire de l'évènement de déselection sauf si le modèle devient vide - if (comboBox.getSelectedItem() == null) { - updateVariable(comboBox, null); - } - return; + if (type.equals(Boolean.class)) { + BooleanEditor.Builder builder = BooleanEditor.newBuilder(); + if (values.contains(false)) { + builder.addFalseEntry("conservé"); + } + if (values.contains(true)) { + builder.addTrueEntry("rejeté"); } - Object o = e.getItem(); - updateVariable(comboBox, o); - }); + if (values.contains(null)) { + builder.addNullEntry("inconnu"); + } + BooleanEditor jComboBox = builder.build(); + JPanel p = new JPanel(new BorderLayout()); + //FIXME Add i18n from the reportName + reportVariableName + p.add(new JLabel("Mode (conservé/rejeté/inconnu)"), BorderLayout.WEST); + p.add(jComboBox, BorderLayout.CENTER); + variablesPanel.add(p); + jComboBox.putClientProperty(VARIABLE_NAME, variableName); + jComboBox.addItemListener(e -> { + JComboBox<?> comboBox = (JComboBox<?>) e.getSource(); + if (e.getStateChange() == ItemEvent.DESELECTED) { + // ne rien faire de l'évènement de déselection sauf si le modèle devient vide + if (comboBox.getSelectedItem() == null) { + updateVariable(comboBox, null); + } + return; + } + Boolean booleanValue = jComboBox.getBooleanValue(); + updateVariable(comboBox, booleanValue); + }); + } else { + List<JavaBean> universe = new ArrayList<>(values); + FilterableComboBox<?> combo = UIHelper.newFilterableComboBox(type, decorator, universe); + combo.setShowReset(true); + JPanel p = new JPanel(new BorderLayout()); + p.add(new JLabel(t(I18nDecoratorHelper.getType(variable.getType()))), BorderLayout.WEST); + p.add(combo, BorderLayout.CENTER); + variablesPanel.add(p); + JComboBox<?> jComboBox = combo.getCombobox(); + jComboBox.putClientProperty(VARIABLE_NAME, variableName); + jComboBox.addItemListener(e -> { + JComboBox<?> comboBox = (JComboBox<?>) e.getSource(); + if (e.getStateChange() == ItemEvent.DESELECTED) { + // ne rien faire de l'évènement de déselection sauf si le modèle devient vide + if (comboBox.getSelectedItem() == null) { + updateVariable(comboBox, null); + } + return; + } + Object o = e.getItem(); + updateVariable(comboBox, o); + }); + } + } } ===================================== core/api/dto/src/main/resources/observe-reports.properties ===================================== @@ -567,6 +567,266 @@ 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) ################################################################################ +## Observations - Poids des captures selon le type d'association, filtrées par groupe et rejet +################################################################################ +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.modelType=PS +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.name=Observations - Poids des captures selon le type d'association, filtrées par groupe et mode (rejeté/conservé) (en t) +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.description=Afficher le poids de rejets par groupe d'espèces et mode (rejeté/conservé) selon le type d'association +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.columns=Espèce,BL sans baleine,BL avec baleine,BO avec requin-baleine,BO sans requin-baleine,Total +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.variable.1.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|\ +Select distinct sg \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set c \ +Join c.catches ca with ca.catchWeight Is Not Null \ +Join ca.species e \ +Join e.speciesGroup sg \ +Where t.id In :tripId \ +Order By sg.code +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.variable.2.discardMode=java.lang.Boolean|\ +Select distinct sf.discard \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set c \ +Join c.catches ca with ca.catchWeight Is Not Null \ +Join ca.speciesFate sf \ +Where t.id In :tripId \ +Order By sf.discard +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.repeatVariable.1.species=fr.ird.observe.entities.referential.common.Species|\ +Select distinct e \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set c \ +Join c.catches ca with ca.catchWeight Is Not Null And ca.speciesFate.discard = :discardMode \ +Join ca.species e with e.speciesGroup.id = :speciesGroup \ +Where t.id In :tripId \ +Order By e.faoCode +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.operations.1=SumRow:0|1 +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.operations.2=SumColumn:0|1 +# Colonne 1 (les espèces) +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.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 = :species +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.1.repeat=species|column +# colonne 2 (BL sans baleine) +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.2=1,0|row|\ + Select Sum(CASE When ca.species = :species Then ca.catchWeight Else 0.0 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 ca with ca.catchWeight Is Not Null \ + Join ca.speciesFate sf with sf.discard = :discardMode, \ + ObservedSystemImpl os, \ + SpeciesImpl e \ + Where \ + m.id In :tripId \ + And e = :species \ + And os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9395222812356602' \ + And os not in elements(a.observedSystem) \ + Group by e +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.2.repeat=species|column +# colonne 3 (BL avec baleine) +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.3=2,0|row|\ + Select Sum(CASE When ca.species = :species Then ca.catchWeight Else 0.0 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 ca with ca.catchWeight Is Not Null \ + Join ca.speciesFate sf with sf.discard = :discardMode, \ + ObservedSystemImpl os, \ + SpeciesImpl e \ + Where \ + m.id In :tripId \ + And e = :species \ + And os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9395222812356602' \ + And os in elements(a.observedSystem) \ + Group by e +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.3.repeat=species|column +# colonne 4 (BO avec requin-baleine) +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.4=3,0|row|\ + Select Sum(CASE When ca.species = :species Then ca.catchWeight Else 0.0 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 ca with ca.catchWeight Is Not Null \ + Join ca.speciesFate sf with sf.discard = :discardMode, \ + ObservedSystemImpl os1, \ + ObservedSystemImpl os2, \ + ObservedSystemImpl os3, \ + SpeciesImpl e \ + Where \ + m.id In :tripId \ + And e = :species \ + And os1.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ + And os2.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#0#1.0' \ + And os3.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#0#1.1' \ + And ( os1 in elements(a.observedSystem) Or os2 in elements(a.observedSystem) Or os3 in elements(a.observedSystem) ) \ + Group by e +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.4.repeat=species|column +# colonne 5 (BO sans requin-baleine) +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.5=4,0|row|\ + Select Sum(CASE When ca.species = :species Then ca.catchWeight Else 0.0 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 ca with ca.catchWeight Is Not Null \ + Join ca.speciesFate sf with sf.discard = :discardMode, \ + ObservedSystemImpl os1, \ + ObservedSystemImpl os2, \ + ObservedSystemImpl os3, \ + SpeciesImpl e \ + Where \ + m.id In :tripId \ + And e = :species \ + And os1.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ + And os2.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#0#1.0' \ + And os3.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#0#1.1' \ + And os1 not in elements(a.observedSystem) And os2 not in elements(a.observedSystem) And os3 not in elements(a.observedSystem) \ + Group by e +report.psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.request.5.repeat=species|column +################################################################################ +## Observations - Dénombrement des captures selon le type d'association, filtrées par groupe et rejet +################################################################################ +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.modelType=PS +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.name=Observations - Dénombrement des captures selon le type d'association, filtrées par groupe et mode (rejeté/conservé) +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.description=Afficher le dénombrement de rejets par groupe d'espèces et mode (rejeté/conservé) selon le type d'association +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.columns=Espèce,BL sans baleine,BL avec baleine,BO avec requin-baleine,BO sans requin-baleine,Total +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.variable.1.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|\ +Select distinct sg \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set c \ +Join c.catches ca with ca.totalCount Is Not Null \ +Join ca.species e \ +Join e.speciesGroup sg \ +Where t.id In :tripId \ +Order By sg.code +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.variable.2.discardMode=java.lang.Boolean|\ +Select distinct sf.discard \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set c \ +Join c.catches ca with ca.totalCount Is Not Null \ +Join ca.speciesFate sf \ +Where t.id In :tripId \ +Order By sf.discard +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.repeatVariable.1.species=fr.ird.observe.entities.referential.common.Species|\ +Select distinct e \ +From TripImpl t \ +Join t.routeObs r \ +Join r.activity a \ +Join a.set c \ +Join c.catches ca with ca.totalCount Is Not Null And ca.speciesFate.discard = :discardMode \ +Join ca.species e with e.speciesGroup.id = :speciesGroup \ +Where t.id In :tripId \ +Order By e.faoCode +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.operations.1=SumIntRow:0|1 +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.operations.2=SumIntColumn:0|1 +# Colonne 1 (les espèces) +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.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 = :species +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.1.repeat=species|column +# colonne 2 (BL sans baleine) +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.2=1,0|row|\ + Select Sum(CASE When ca.species = :species Then ca.totalCount Else 0.0 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 ca with ca.totalCount Is Not Null \ + Join ca.speciesFate sf with sf.discard = :discardMode, \ + ObservedSystemImpl os, \ + SpeciesImpl e \ + Where \ + m.id In :tripId \ + And e = :species \ + And os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9395222812356602' \ + And os not in elements(a.observedSystem) \ + Group by e +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.2.repeat=species|column +# colonne 3 (BL avec baleine) +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.3=2,0|row|\ + Select Sum(CASE When ca.species = :species Then ca.totalCount Else 0.0 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 ca with ca.totalCount Is Not Null \ + Join ca.speciesFate sf with sf.discard = :discardMode, \ + ObservedSystemImpl os, \ + SpeciesImpl e \ + Where \ + m.id In :tripId \ + And e = :species \ + And os.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9395222812356602' \ + And os in elements(a.observedSystem) \ + Group by e +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.3.repeat=species|column +# colonne 4 (BO avec requin-baleine) +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.4=3,0|row|\ + Select Sum(CASE When ca.species = :species Then ca.totalCount Else 0.0 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 ca with ca.totalCount Is Not Null \ + Join ca.speciesFate sf with sf.discard = :discardMode, \ + ObservedSystemImpl os1, \ + ObservedSystemImpl os2, \ + ObservedSystemImpl os3, \ + SpeciesImpl e \ + Where \ + m.id In :tripId \ + And e = :species \ + And os1.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ + And os2.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#0#1.0' \ + And os3.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#0#1.1' \ + And ( os1 in elements(a.observedSystem) Or os2 in elements(a.observedSystem) Or os3 in elements(a.observedSystem) ) \ + Group by e +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.4.repeat=species|column +# colonne 5 (BO sans requin-baleine) +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.5=4,0|row|\ + Select Sum(CASE When ca.species = :species Then ca.totalCount Else 0.0 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 ca with ca.totalCount Is Not Null \ + Join ca.speciesFate sf with sf.discard = :discardMode, \ + ObservedSystemImpl os1, \ + ObservedSystemImpl os2, \ + ObservedSystemImpl os3, \ + SpeciesImpl e \ + Where \ + m.id In :tripId \ + And e = :species \ + And os1.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#1239832686428#0.9217864901728908' \ + And os2.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#0#1.0' \ + And os3.topiaId = 'fr.ird.referential.ps.common.ObservedSystem#0#1.1' \ + And os1 not in elements(a.observedSystem) And os2 not in elements(a.observedSystem) And os3 not in elements(a.observedSystem) \ + Group by e +report.psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.request.5.repeat=species|column +################################################################################ ## Captures thons selon le type d'association ################################################################################ report.psObservationTargetCatchByAssociation.modelType=PS ===================================== core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java ===================================== @@ -59,4 +59,16 @@ public class ReportServiceLocalReadTest extends GeneratedReportServiceLocalReadT ReportService service = getService(); fixtures.executeReport(getServicesProvider(), service, "psObservationCatchTotalCountByGroupPerReasonForDiscard"); } + + @Test + public void executeReportPsObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation() { + ReportService service = getService(); + fixtures.executeReport(getServicesProvider(), service, "psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation"); + } + + @Test + public void executeReportPsObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation() { + ReportService service = getService(); + fixtures.executeReport(getServicesProvider(), service, "psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation"); + } } ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/ReportFixture.java ===================================== @@ -35,6 +35,7 @@ import java.beans.Introspector; import java.util.Arrays; import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.Objects; import java.util.Set; import static fr.ird.observe.test.ObserveFixtures.WITH_ASSERT; @@ -107,6 +108,18 @@ public abstract class ReportFixture { } } + protected void setVariableValue(Report report, String variableName, Boolean id) { + for (ReportVariable variable : report.getVariables()) { + if (variableName.equals(variable.getName())) { + Boolean value = (Boolean) variable.getValues().stream() + .filter(f-> Objects.equals(f, id)) + .findFirst() + .orElse(null); + variable.setSelectedValue(value); + } + } + } + public void assertSyntax(Report actual) { Assert.assertNotNull(actual); assertReportName(actual); @@ -175,7 +188,7 @@ public abstract class ReportFixture { } else { ReportServiceFixtures.addAssert("syntax.rows", report.getRows()); ReportServiceFixtures.addAssert("syntax.columns", report.getColumns()); - if (report.getRowHeaders() == null) { + if (report.getColumnHeaders() == null) { ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader"); } else { ReportServiceFixtures.writeArrayAssert("syntax.columnsHeader", (Object[]) report.getColumnHeaders()); ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociationReportFixture.java ===================================== @@ -0,0 +1,57 @@ +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 09/12/2022. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 9.0.22 + */ +@AutoService(ReportFixture.class) +public class PsObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociationReportFixture extends ReportFixture { + + @Override + public void assertSyntax(Report report) { + super.assertSyntax(report); + Iterator<ReportRequest> requests = getRequestIterator(report); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 1, 0); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 2, 0); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 3, 0); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 4, 0); + } + + @Override + protected void setVariables(Report report) { + setVariableValue(report, "speciesGroup", "fr.ird.referential.common.SpeciesGroup#1239832683689#0.17327457618202002"); + setVariableValue(report, "discardMode", false); + } +} \ No newline at end of file ===================================== core/services/test/src/main/java/fr/ird/observe/services/service/report/ps/PsObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociationReportFixture.java ===================================== @@ -0,0 +1,58 @@ +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 09/12/2022. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 9.0.22 + */ +@AutoService(ReportFixture.class) +public class PsObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociationReportFixture extends ReportFixture { + + @Override + public void assertSyntax(Report report) { + super.assertSyntax(report); + Iterator<ReportRequest> requests = getRequestIterator(report); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 0, 0); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 1, 0); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 2, 0); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 3, 0); + assertReportRequestDimension(requests, ReportRequest.RequestLayout.row, 4, 0); + } + + @Override + protected void setVariables(Report report) { + setVariableValue(report, "speciesGroup", "fr.ird.referential.common.SpeciesGroup#1433499401278#0.203439718578011"); + setVariableValue(report, "discardMode", false); + } +} + ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psLogbookWellPlanCheck.properties ===================================== @@ -20,7 +20,7 @@ # #L% ### result.0=483^CAP BOJADOR^30/3/2019^8/4/2019^30/3/2019^1^15:12^0.0^123.0^43.0^0.0^0.0^0.0^0.0^24.0^0.0^0.0^166.0^24.0^142.0 -result.1=-^-^-^-^-^-^-^0^123^43^0^0^0^0^24^0^0^166^24^142 +result.1=Total^-^-^-^-^-^-^0^123^43^0^0^0^0^24^0^0^166^24^142 result.columns=20 result.rows=2 syntax.columns=20 ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation.properties ===================================== @@ -0,0 +1,31 @@ +### +# #%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 - Dénombrement des captures selon le type d'association, filtrées par groupe et mode (rejeté/conservé) +syntax.description=Afficher le dénombrement de rejets par groupe d'espèces et mode (rejeté/conservé) selon le type d'association +syntax.rows=-1 +syntax.columns=6 +syntax.columnsHeader=Espèce^BL sans baleine^BL avec baleine^BO avec requin-baleine^BO sans requin-baleine^Total +syntax.rowsHeader= +syntax.nbRequests=5 +result.columns=6 +result.rows=1 +result.0=[FAO]SAI [sc]Istiophorus albicans [fr]Voilier de l'Atlantique^null^null^null^4^4 \ No newline at end of file ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchWeightByGroupAndSpeciesFateDiscardPerAssociation.properties ===================================== @@ -0,0 +1,36 @@ +### +# #%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 - Poids des captures selon le type d'association, filtrées par groupe et mode (rejeté/conservé) (en t) +syntax.description=Afficher le poids de rejets par groupe d'espèces et mode (rejeté/conservé) selon le type d'association +syntax.rows=-1 +syntax.columns=6 +syntax.columnsHeader=Espèce^BL sans baleine^BL avec baleine^BO avec requin-baleine^BO sans requin-baleine^Total +syntax.rowsHeader= +syntax.nbRequests=5 +result.columns=6 +result.rows=6 +result.0=[FAO]BET [sc]Thunnus obesus [fr]Patudo, thon obèse, thon gros yeux^7.0^null^null^0.0^7.0 +result.1=[FAO]FRI [sc]Auxis thazard [fr]Auxide^0.0^null^null^1.0^1.0 +result.2=[FAO]FRZ [sc]Auxis spp [fr]Auxis^0.0^null^null^12.0^12.0 +result.3=[FAO]SKJ [sc]Katsuwonus pelamis [fr]Listao, bonite à ventre rayé^0.0^null^null^1.0^1.0 +result.4=[FAO]YFT [sc]Thunnus albacares [fr]Albacore, thon à nageoires jaunes^175.0^null^null^0.0^175.0 +result.5=Total^182.0^0.0^0.0^14.0^196.0 \ No newline at end of file ===================================== pom.xml ===================================== @@ -23,7 +23,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2022.97</version> + <version>2022.98</version> </parent> <groupId>fr.ird.observe</groupId> <artifactId>ird-observe</artifactId> ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/Report.java ===================================== @@ -164,7 +164,10 @@ public class Report implements Serializable, JsonAware { public boolean canExecute() { for (ReportVariable<?> variable : getVariables()) { - + if (variable.getType().equals(Boolean.class)) { + // Boolean type can be null + continue; + } // on verifie qu'on a bien cette variable String name = variable.getName(); if (variable.getSelectedValue() == null) { @@ -180,7 +183,10 @@ public class Report implements Serializable, JsonAware { public boolean canExecute(Map<String, Object> variables) { for (ReportVariable<?> variable : getVariables()) { - + if (variable.getType().equals(Boolean.class)) { + // Boolean type can be null + continue; + } // on verifie qu'on a bien cette variable String name = variable.getName(); if (variables.get(name) == null) { ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumColumn.java ===================================== @@ -66,7 +66,7 @@ public class SumColumn implements ReportOperationConsumer { tmpMatrix.setValue(column, 0, sumColumn); } DataMatrix merge = DataMatrix.merge(incoming, tmpMatrix); - if (report.getColumnHeaders() == null) { + if (report.getRowHeaders() == null) { merge.setValue(0, height, "Total"); } return merge; ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/SumRow.java ===================================== @@ -67,7 +67,7 @@ public class SumRow implements ReportOperationConsumer { tmpMatrix.setValue(0, row, sumRow); } DataMatrix merge = DataMatrix.merge(incoming, tmpMatrix); - if (report.getRowHeaders() == null) { + if (report.getColumnHeaders() == null) { merge.setValue(width, 0, "Total"); } return merge; ===================================== toolkit/persistence/src/main/java/fr/ird/observe/spi/report/DefaultReportRequestExecutor.java ===================================== @@ -131,7 +131,7 @@ public abstract class DefaultReportRequestExecutor implements ReportRequestExecu Map<String, Object> paramsFixes = new HashMap<>(); for (Map.Entry<String, Object> entry : params.entrySet()) { String name = entry.getKey(); - if (request.contains(":" + name + " ") || request.endsWith(":" + name)) { + if (request.contains(":" + name + " ") || request.contains(":" + name + ",") || request.endsWith(":" + name)) { Object value = entry.getValue(); if (value instanceof DtoReference) { DtoReference referenceDto = (DtoReference) value; ===================================== toolkit/persistence/src/main/java/org/nuiton/topia/persistence/internal/support/HibernateTopiaJpaSupport.java ===================================== @@ -85,7 +85,9 @@ public class HibernateTopiaJpaSupport implements TopiaJpaSupport { for (Map.Entry<String, Object> entry : parameters.entrySet()) { String name = entry.getKey(); Object value = entry.getValue(); - if (value.getClass().isArray()) { + if (value == null) { + query.setParameter(name, null); + } else if (value.getClass().isArray()) { query.setParameterList(name, (Object[]) value); } else if (value instanceof Collection<?>) { query.setParameterList(name, (Collection<?>) value); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/4a495572cba92845d382c9864... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/4a495572cba92845d382c9864... You're receiving this email because of your account on gitlab.com.