Tony CHEMIT pushed to branch develop-9.0.x at ultreiaio / ird-observe Commits: 6afd1b3b by Tony Chemit at 2022-12-05T15:06:26+01:00 Report - Ajouter la valeur nulle possible sur la méthode computeIndexList (utilisé pour l'opération ComputeDynamicHeader et ExecuteRequestAndReorganizeCountByRepeatVariable) - - - - - 4fb73312 by Tony Chemit at 2022-12-05T15:06:42+01:00 Report - Adaptation du report Dénombrement des captures par devenir, filtrés par groupe pour y inclure tous les devenirs existants dans le référentiel - - - - - 1ef23720 by Tony Chemit at 2022-12-05T15:06:53+01:00 Report - Adaptation du report Distribution des tailles par espèces et type de mesure pour y inclure tous les devenirs existants dans le référentiel - - - - - be2abbc1 by Tony Chemit at 2022-12-05T15:45:30+01:00 Merge branch 'feature/issue_2553' into develop-9.0.x Rapport Observations - Dénombrement des captures par devenir, filtrés par groupe - Closes #2553 - - - - - 7 changed files: - core/api/dto/src/main/resources/observe-reports.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 - toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.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/spi/json/toolkit/ReportVariableAdapter.java Changes: ===================================== core/api/dto/src/main/resources/observe-reports.properties ===================================== @@ -890,7 +890,7 @@ report.psObservationCatch.request.3.repeat=speciesId|column ## Captures par groupe d'espèces ################################################################################ report.psObservationCatchByGroup.modelType=PS -report.psObservationCatchByGroup.name=Observations - Dénombrement des captures par devenir, filtrés par groupe +report.psObservationCatchByGroup.name=Observations - Dénombrement des captures par type de banc et 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.variable.speciesGroup=fr.ird.observe.dto.referential.common.SpeciesGroupDto|\ Select distinct sg \ @@ -914,16 +914,9 @@ Join ca.species e with e.speciesGroup.id = :speciesGroup \ Where t.id In :tripId \ Order By e.homeId report.psObservationCatchByGroup.repeatVariable.2.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 c \ -Join c.catches ca with ca.totalCount Is Not Null \ -Join ca.species e with e.id In :species \ -Join ca.speciesFate sf \ -Where t.id In :tripId \ -Order by sf.code +Select sf \ +From SpeciesFateImpl sf \ +Order by sf.discard, sf.code report.psObservationCatchByGroup.request.1=0,0|row|\ Select \ concat(\ @@ -953,7 +946,7 @@ Join ca.species s with s.id In :species \ Join ca.speciesFate sf with sf.id In :speciesFate \ Where m.id In :tripId \ Group by s, sf \ -Order By s.homeId, sf.code +Order By s.homeId report.psObservationCatchByGroup.operations.2=ComputeDynamicHeader:Espèce,Total BL,Total BO|speciesFate report.psObservationCatchByGroup.operations.3=SumIntRow:1|3 report.psObservationCatchByGroup.operations.4=SumIntColumn:1|1 @@ -979,16 +972,10 @@ 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 \ -Order By sf.code +report.psObservationLengthsDistribution.repeatVariable.speciesFate=fr.ird.observe.entities.referential.ps.common.SpeciesFate|true|\ +Select sf \ +From SpeciesFateImpl sf \ +Order by sf.discard, sf.code report.psObservationLengthsDistribution.repeatVariable.length=java.lang.Float|\ Select distinct ntl.length \ From TripImpl t \ @@ -1006,7 +993,7 @@ 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 with sf.id In :speciesFate \ +Left Join ntl.speciesFate sf \ Where t.id In :tripId \ Group By ntl.length, sf \ Order By ntl.length ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationCatchByGroup.properties ===================================== @@ -19,14 +19,14 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### -syntax.name=Observations - Dénombrement des captures par devenir, filtrés par groupe +syntax.name=Observations - Dénombrement des captures par type de banc et devenir, filtrés par groupe syntax.description=Afficher les nombres de captures par groupe d'espèce selon le type de banc et le devenir syntax.rows=-1 syntax.columns=-1 syntax.columnsHeader= syntax.rowsHeader= syntax.nbRequests=1 -result.columns=4 +result.columns=19 result.rows=2 -result.0=Espèce^Total BL^Total BO^Echappe du filet (pour requin-baleine et cétacés) -result.1=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^0^3^3 +result.0=Espèce^Total BL^Total BO^Ailerons seulements^Partiellement conservé (ex: ailerons de requin, poisson séché)^Autres (à préciser dans les notes)^Conservé pour raisons scientifiques^Conservé pour le marché local ou poisson séché/salé à bord^Conservé à destination de la conserverie^Utilisé en cuisine du bord^Echappe du filet (pour requin-baleine et cétacés)^Rejeté, statut non observé^Rejeté suffocant^Rejeté suffocant blessé^Sortie vivant du filet (pour requin-baleine et cétacés)^Sortie mort du filet (pour requin-baleine et cétacés)^Rejeté vivant^Rejeté mort^Total +result.1=[FAO]ALV [sc]Alopias vulpinus [fr]Renard^0^3^null^null^null^null^null^null^null^3^null^null^null^null^null^null^null^3 ===================================== core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psObservationLengthsDistribution.properties ===================================== @@ -26,10 +26,10 @@ syntax.columns=-1 syntax.columnsHeader= syntax.rowsHeader= syntax.nbRequests=0 -result.columns=2 +result.columns=18 result.rows=5 -result.0=Classe de taille (cm)^Aucun -result.1=50.0^2 -result.2=54.0^1 -result.3=68.0^1 -result.4=70.0^1 +result.0=Classe de taille (cm)^Ailerons seulements^Partiellement conservé (ex: ailerons de requin, poisson séché)^Autres (à préciser dans les notes)^Conservé pour raisons scientifiques^Conservé pour le marché local ou poisson séché/salé à bord^Conservé à destination de la conserverie^Utilisé en cuisine du bord^Echappe du filet (pour requin-baleine et cétacés)^Rejeté, statut non observé^Rejeté suffocant^Rejeté suffocant blessé^Sortie vivant du filet (pour requin-baleine et cétacés)^Sortie mort du filet (pour requin-baleine et cétacés)^Rejeté vivant^Rejeté mort^Aucun^Total +result.1=50.0^null^null^null^null^null^null^null^null^null^null^null^null^null^null^null^2^2 +result.2=54.0^null^null^null^null^null^null^null^null^null^null^null^null^null^null^null^1^1 +result.3=68.0^null^null^null^null^null^null^null^null^null^null^null^null^null^null^null^1^1 +result.4=70.0^null^null^null^null^null^null^null^null^null^null^null^null^null^null^null^1^1 ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportBuilder.java ===================================== @@ -345,7 +345,7 @@ public class ReportBuilder { String typeStr = parts[0].trim(); String request = parts[1].trim(); Class<?> type = Objects2.forName(typeStr); - ReportVariable<?> variable = new ReportVariable<>(id, type, request); + ReportVariable<?> variable = new ReportVariable<>(id, type, request, false); log.debug(String.format("Detects a variable : [%s:%s] = %s (type = %s)", reportName, variable.getName(), variable.getRequest(), variable.getType().getName())); result.add(variable); itr.remove(); @@ -381,13 +381,21 @@ public class ReportBuilder { ids.add(id); String[] parts = operations.split("\\|"); - if (parts.length != 2) { - throw new IllegalArgumentException("La définition d'une variable de répétition doit etre de la forme 'type|hql' mais est : " + operations); + if (parts.length != 2 && parts.length != 3) { + throw new IllegalArgumentException("La définition d'une variable de répétition doit etre de la forme 'type|hql' ou 'type|true|hql' mais est : " + operations); } String typeStr = parts[0].trim(); - String request = parts[1].trim(); + boolean addNullValue; + String request; + if (parts.length == 3) { + addNullValue = Boolean.parseBoolean(parts[1]); + request = parts[2].trim(); + } else { + addNullValue = false; + request = parts[1].trim(); + } Class<?> type = Objects2.forName(typeStr); - ReportVariable<?> variable = new ReportVariable<>(id, type, request); + ReportVariable<?> variable = new ReportVariable<>(id, type, request, addNullValue); log.debug(String.format("Detects a variable : [%s:%s] = %s (type = %s)", reportName, variable.getName(), variable.getRequest(), variable.getType().getName())); result.add(variable); itr.remove(); ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/ReportVariable.java ===================================== @@ -49,6 +49,7 @@ public class ReportVariable<V> implements Serializable, JsonAware { public final static String PROPERTY_VALUES = "values"; public final static String PROPERTY_SELECTED_VALUE = "selectedValue"; + public final static String PROPERTY_ADD_NULL_VALUE = "addNullValue"; private static final long serialVersionUID = 1L; @@ -58,14 +59,17 @@ public class ReportVariable<V> implements Serializable, JsonAware { protected final String request; + protected final boolean addNullValue; + protected Set<V> values; protected V selectedValue; - public ReportVariable(String name, Class<V> type, String request) { + public ReportVariable(String name, Class<V> type, String request, boolean addNullValue) { this.name = name; this.type = type; this.request = request; + this.addNullValue = addNullValue; } public String getName() { @@ -96,11 +100,15 @@ public class ReportVariable<V> implements Serializable, JsonAware { this.selectedValue = selectedValue; } + public boolean isAddNullValue() { + return addNullValue; + } + 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) { + if (useNullValue || addNullValue) { result.add("null"); } return result; ===================================== toolkit/api/src/main/java/fr/ird/observe/dto/report/operations/ComputeDynamicHeader.java ===================================== @@ -28,6 +28,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 fr.ird.observe.dto.report.ReportVariable; import java.util.Set; @@ -36,6 +37,8 @@ import java.util.Set; * <p> * You can set as parameters an array of fixed column names + a repeat variable to complete the header. * <p> + * <b>Note:</b> The {@code null} value will be added at the last column (TODO maybe should we be able to customize this in the operation parameters...) + * <p> * Example: * <code>Col1,Col2,Col3|repeatVariableName</code> * <p> @@ -57,7 +60,8 @@ public class ComputeDynamicHeader implements ReportOperationConsumer { } String[] fixedColumnNames = split[0].split("\\s*,\\s*"); String repeatVariableName = split[1].trim(); - Set<?> repeatVariableValues = report.getRepeatVariable(repeatVariableName).getValues(); + ReportVariable<Object> repeatVariable1 = report.getRepeatVariable(repeatVariableName); + Set<?> repeatVariableValues = repeatVariable1.getValues(); int columnIndex = 0; DataMatrix tmpMatrix = createTmpMatrix(0, 0, incoming.getWidth(), 1); boolean useNullRepeatVariableValue = false; @@ -75,7 +79,7 @@ public class ComputeDynamicHeader implements ReportOperationConsumer { } } } - if (useNullRepeatVariableValue) { + if (useNullRepeatVariableValue || repeatVariable1.isAddNullValue()) { tmpMatrix.setValue(columnIndex, 0, "Aucun"); } incoming.setY(1); ===================================== toolkit/api/src/main/java/fr/ird/observe/spi/json/toolkit/ReportVariableAdapter.java ===================================== @@ -59,8 +59,9 @@ public class ReportVariableAdapter implements JsonDeserializer<ReportVariable<?> String name = context.deserialize(reportVariableJson.get(ReportVariable.PROPERTY_NAME), String.class); Class<?> type = context.deserialize(reportVariableJson.get(ReportVariable.PROPERTY_TYPE), Class.class); String request = context.deserialize(reportVariableJson.get(ReportVariable.PROPERTY_REQUEST), String.class); + boolean addNullValue = context.deserialize(reportVariableJson.get(ReportVariable.PROPERTY_ADD_NULL_VALUE), boolean.class); - ReportVariable reportVariable = new ReportVariable<>(name, type, request); + ReportVariable reportVariable = new ReportVariable<>(name, type, request, addNullValue); Class<?> valueType = type; View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/63e0cfb5c2506990b1f18c1be... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/63e0cfb5c2506990b1f18c1be... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT (@tchemit)