Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

6 changed files:

Changes:

  • core/persistence/report/src/main/resources/observe-reports.properties
    ... ... @@ -937,7 +937,19 @@ Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8
    937 937
     When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then 0.0 \
    
    938 938
     When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \
    
    939 939
     When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then 0.0 \
    
    940
    -Else ct.weight End),\
    
    940
    +Else ct.weight End) \
    
    941
    +From TripImpl t \
    
    942
    +Join t.routeLogbook r \
    
    943
    +Join r.activity a \
    
    944
    +Join a.catches ct \
    
    945
    +Join t.vessel vessel \
    
    946
    +Left Join a.vesselActivity vesselActivity \
    
    947
    +Where t.id In :tripId and vesselActivity.id = 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \
    
    948
    +Group By vessel.code,vessel.label2,t.startDate,t.endDate,r.date,a.time,a.number \
    
    949
    +Order By vessel.code,t.startDate,r.date,a.time
    
    950
    +report.psLogbookWellPlanCheck.request.2.location=12,0
    
    951
    +report.psLogbookWellPlanCheck.request.2.layout=row
    
    952
    +report.psLogbookWellPlanCheck.request.2.request=Select \
    
    941 953
     Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then was.weight Else 0.0 End), \
    
    942 954
     Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then was.weight Else 0.0 End), \
    
    943 955
     Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then was.weight Else 0.0 End), \
    
    ... ... @@ -946,24 +958,50 @@ Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.
    946 958
     When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then 0.0 \
    
    947 959
     When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \
    
    948 960
     When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then 0.0 \
    
    949
    -Else was.weight End),\
    
    950
    -Sum(ct.weight), \
    
    951
    -Sum(was.weight), \
    
    952
    -Sum(ct.weight) - Sum(was.weight) \
    
    961
    +Else was.weight End) \
    
    953 962
     From TripImpl t \
    
    954 963
     Join t.well w \
    
    955 964
     Join w.wellActivity wa \
    
    956 965
     Join wa.wellActivitySpecies was \
    
    957 966
     Join t.routeLogbook r \
    
    958 967
     Join r.activity a \
    
    968
    +Join t.vessel vessel \
    
    969
    +Left Join a.vesselActivity vesselActivity \
    
    970
    +Where t.id In :tripId and wa.activity = a and vesselActivity.id = 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \
    
    971
    +Group By vessel.code,vessel.label2,t.startDate,t.endDate,r.date,a.time,a.number \
    
    972
    +Order By vessel.code,t.startDate,r.date,a.time
    
    973
    +report.psLogbookWellPlanCheck.request.3.location=17,0
    
    974
    +report.psLogbookWellPlanCheck.request.3.layout=row
    
    975
    +report.psLogbookWellPlanCheck.request.3.request=Select \
    
    976
    +Sum(ct.weight) \
    
    977
    +From TripImpl t \
    
    978
    +Join t.routeLogbook r \
    
    979
    +Join r.activity a \
    
    959 980
     Join a.catches ct \
    
    960 981
     Join t.vessel vessel \
    
    961 982
     Left Join a.vesselActivity vesselActivity \
    
    983
    +Where t.id In :tripId and vesselActivity.id = 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \
    
    984
    +Group By vessel.code,vessel.label2,t.startDate,t.endDate,r.date,a.time,a.number \
    
    985
    +Order By vessel.code,t.startDate,r.date,a.time
    
    986
    +report.psLogbookWellPlanCheck.request.4.location=18,0
    
    987
    +report.psLogbookWellPlanCheck.request.4.layout=row
    
    988
    +report.psLogbookWellPlanCheck.request.4.request=Select \
    
    989
    +Sum(was.weight) \
    
    990
    +From TripImpl t \
    
    991
    +Join t.well w \
    
    992
    +Join w.wellActivity wa \
    
    993
    +Join wa.wellActivitySpecies was \
    
    994
    +Join t.routeLogbook r \
    
    995
    +Join r.activity a \
    
    996
    +Join t.vessel vessel \
    
    997
    +Left Join a.vesselActivity vesselActivity \
    
    962 998
     Where t.id In :tripId and wa.activity = a and vesselActivity.id = 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \
    
    963 999
     Group By vessel.code,vessel.label2,t.startDate,t.endDate,r.date,a.time,a.number \
    
    964 1000
     Order By vessel.code,t.startDate,r.date,a.time
    
    965
    -report.psLogbookWellPlanCheck.operations.1.type=SumColumn
    
    966
    -report.psLogbookWellPlanCheck.operations.1.parameters=0|6
    
    1001
    +report.psLogbookWellPlanCheck.operations.1.type=SubtractColum
    
    1002
    +report.psLogbookWellPlanCheck.operations.1.parameters=17|18|19
    
    1003
    +report.psLogbookWellPlanCheck.operations.2.type=SumColumn
    
    1004
    +report.psLogbookWellPlanCheck.operations.2.parameters=0|6
    
    967 1005
     report.psObservationActivityWithComment.modelType=PS
    
    968 1006
     report.psObservationActivityWithComment.name=Observations - Activités avec comment et leurs positions
    
    969 1007
     report.psObservationActivityWithComment.description=Afficher les activités avec comment et leurs positions géographiques
    

  • core/services/local/src/test/java/fr/ird/observe/services/local/service/ReportServiceLocalReadTest.java
    ... ... @@ -95,4 +95,11 @@ public class ReportServiceLocalReadTest extends GeneratedReportServiceLocalReadT
    95 95
             ReportService service = getService();
    
    96 96
             fixtures.executeReport(service, "psObservationCatchTotalCountByGroupAndSpeciesFateDiscardPerAssociation");
    
    97 97
         }
    
    98
    +
    
    99
    +    @Test
    
    100
    +    @Ignore
    
    101
    +    public void executeReportPsLogbookWellPlanCheck() {
    
    102
    +        ReportService service = getService();
    
    103
    +        fixtures.executeReport(service, "psLogbookWellPlanCheck");
    
    104
    +    }
    
    98 105
     }

  • core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/ReportService-psLogbookWellPlanCheck.properties
    ... ... @@ -19,14 +19,14 @@
    19 19
     # <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    20 20
     # #L%
    
    21 21
     ###
    
    22
    -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
    
    22
    +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^12.0^0.0^0.0^166.0^12.0^154.0
    
    23 23
     result.columns=20
    
    24 24
     result.rows=1
    
    25 25
     syntax.columns=20
    
    26 26
     syntax.columnsHeader=Code bateau^Nom bateau^Date départ^Date arrivée^Date de route^Numéro activité^Heure activité^Logbook YFT^Logbook SKJ^Logbook BET^Logbook ALB^Logbook Autres^Plan de cuves YFT^Plan de cuves SKJ^Plan de cuves BET^Plan de cuves ALB^Plan de cuves Autres^Logbook Total^Plan de cuves Total^Différence
    
    27 27
     syntax.description=Livre de bord - Vérification des plan de cuves
    
    28 28
     syntax.name=Livre de bord - Vérification des plan de cuves
    
    29
    -syntax.nbRequests=1
    
    29
    +syntax.nbRequests=4
    
    30 30
     syntax.rows=-1
    
    31 31
     syntax.rowsHeader=
    
    32 32
     tripIds=${PS_COMMON_TRIP},${PS_COMMON_TRIP_MOVE}

  • model/src/main/resources/observe-reports-legacy.properties
    ... ... @@ -1407,48 +1407,78 @@ Plan de cuves Autres,\
    1407 1407
     Logbook Total,\
    
    1408 1408
     Plan de cuves Total,\
    
    1409 1409
     Différence
    
    1410
    -report.psLogbookWellPlanCheck.operations.1=SumColumn:0|6
    
    1411
    -report.psLogbookWellPlanCheck.request.1=0,0|row|\
    
    1412
    -Select vessel.code,\
    
    1413
    -  vessel.label2,\
    
    1414
    -  concat(day(t.startDate), '/', month(t.startDate), '/', year(t.startDate)), \
    
    1415
    -  concat(day(t.endDate), '/', month(t.endDate), '/', year(t.endDate)), \
    
    1416
    -  concat(day(r.date), '/', month(r.date), '/', year(r.date)), \
    
    1417
    -  a.number, \
    
    1418
    -  concat(hour(a.time), ':', minute(a.time)), \
    
    1419
    -  Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then ct.weight Else 0.0 End), \
    
    1420
    -  Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then ct.weight Else 0.0 End), \
    
    1421
    -  Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.weight Else 0.0 End), \
    
    1422
    -  Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then ct.weight Else 0.0 End), \
    
    1423
    -  Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then 0.0 \
    
    1424
    -                                             When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then 0.0 \
    
    1425
    -                                             When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \
    
    1426
    -                                             When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then 0.0 \
    
    1427
    -                                             Else ct.weight End),\
    
    1428
    -  Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then was.weight Else 0.0 End), \
    
    1429
    -  Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then was.weight Else 0.0 End), \
    
    1430
    -  Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then was.weight Else 0.0 End), \
    
    1431
    -  Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then was.weight Else 0.0 End), \
    
    1432
    -  Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then 0.0 \
    
    1433
    -                                             When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then 0.0 \
    
    1434
    -                                             When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \
    
    1435
    -                                             When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then 0.0 \
    
    1436
    -                                             Else was.weight End),\
    
    1437
    -  Sum(ct.weight), \
    
    1438
    -  Sum(was.weight), \
    
    1439
    -  Sum(ct.weight) - Sum(was.weight) \
    
    1410
    +report.psLogbookWellPlanCheck.request.1=0,0|row|Select vessel.code,\
    
    1411
    +vessel.label2,\
    
    1412
    +concat(day(t.startDate), '/', month(t.startDate), '/', year(t.startDate)), \
    
    1413
    +concat(day(t.endDate), '/', month(t.endDate), '/', year(t.endDate)), \
    
    1414
    +concat(day(r.date), '/', month(r.date), '/', year(r.date)), \
    
    1415
    +a.number, \
    
    1416
    +concat(hour(a.time), ':', minute(a.time)), \
    
    1417
    +Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then ct.weight Else 0.0 End), \
    
    1418
    +Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then ct.weight Else 0.0 End), \
    
    1419
    +Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then ct.weight Else 0.0 End), \
    
    1420
    +Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then ct.weight Else 0.0 End), \
    
    1421
    +Sum(CASE ct.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then 0.0 \
    
    1422
    +When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then 0.0 \
    
    1423
    +When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \
    
    1424
    +When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then 0.0 \
    
    1425
    +Else ct.weight End) \
    
    1426
    +From TripImpl t \
    
    1427
    +Join t.routeLogbook r \
    
    1428
    +Join r.activity a \
    
    1429
    +Join a.catches ct \
    
    1430
    +Join t.vessel vessel \
    
    1431
    +Left Join a.vesselActivity vesselActivity \
    
    1432
    +Where t.id In :tripId and vesselActivity.id = 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \
    
    1433
    +Group By vessel.code,vessel.label2,t.startDate,t.endDate,r.date,a.time,a.number \
    
    1434
    +Order By vessel.code,t.startDate,r.date,a.time
    
    1435
    +report.psLogbookWellPlanCheck.request.2=12,0|row|Select \
    
    1436
    +Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then was.weight Else 0.0 End), \
    
    1437
    +Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then was.weight Else 0.0 End), \
    
    1438
    +Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then was.weight Else 0.0 End), \
    
    1439
    +Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then was.weight Else 0.0 End), \
    
    1440
    +Sum(CASE was.species.id When 'fr.ird.referential.common.Species#1239832685474#0.8943253454598569'  Then 0.0 \
    
    1441
    +When 'fr.ird.referential.common.Species#1239832685474#0.975344121171992'   Then 0.0 \
    
    1442
    +When 'fr.ird.referential.common.Species#1239832685475#0.13349466123905152' Then 0.0 \
    
    1443
    +When 'fr.ird.referential.common.Species#1239832685476#0.5618871286604711'  Then 0.0 \
    
    1444
    +Else was.weight End) \
    
    1440 1445
     From TripImpl t \
    
    1441 1446
     Join t.well w \
    
    1442 1447
     Join w.wellActivity wa \
    
    1443 1448
     Join wa.wellActivitySpecies was \
    
    1444 1449
     Join t.routeLogbook r \
    
    1445 1450
     Join r.activity a \
    
    1451
    +Join t.vessel vessel \
    
    1452
    +Left Join a.vesselActivity vesselActivity \
    
    1453
    +Where t.id In :tripId and wa.activity = a and vesselActivity.id = 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \
    
    1454
    +Group By vessel.code,vessel.label2,t.startDate,t.endDate,r.date,a.time,a.number \
    
    1455
    +Order By vessel.code,t.startDate,r.date,a.time
    
    1456
    +report.psLogbookWellPlanCheck.request.3=17,0|row|Select \
    
    1457
    +Sum(ct.weight) \
    
    1458
    +From TripImpl t \
    
    1459
    +Join t.routeLogbook r \
    
    1460
    +Join r.activity a \
    
    1446 1461
     Join a.catches ct \
    
    1447 1462
     Join t.vessel vessel \
    
    1448 1463
     Left Join a.vesselActivity vesselActivity \
    
    1464
    +Where t.id In :tripId and vesselActivity.id = 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \
    
    1465
    +Group By vessel.code,vessel.label2,t.startDate,t.endDate,r.date,a.time,a.number \
    
    1466
    +Order By vessel.code,t.startDate,r.date,a.time
    
    1467
    +report.psLogbookWellPlanCheck.request.4=18,0|row|Select \
    
    1468
    +Sum(was.weight) \
    
    1469
    +From TripImpl t \
    
    1470
    +Join t.well w \
    
    1471
    +Join w.wellActivity wa \
    
    1472
    +Join wa.wellActivitySpecies was \
    
    1473
    +Join t.routeLogbook r \
    
    1474
    +Join r.activity a \
    
    1475
    +Join t.vessel vessel \
    
    1476
    +Left Join a.vesselActivity vesselActivity \
    
    1449 1477
     Where t.id In :tripId and wa.activity = a and vesselActivity.id = 'fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586' \
    
    1450 1478
     Group By vessel.code,vessel.label2,t.startDate,t.endDate,r.date,a.time,a.number \
    
    1451 1479
     Order By vessel.code,t.startDate,r.date,a.time
    
    1480
    +report.psLogbookWellPlanCheck.operations.1=SubtractColum:17|18|19
    
    1481
    +report.psLogbookWellPlanCheck.operations.2=SumColumn:0|6
    
    1452 1482
     ############################################
    
    1453 1483
     ## Marché local - Lots
    
    1454 1484
     ############################################
    

  • src/site/markdown/report/embedded-operations.md
    ... ... @@ -215,6 +215,28 @@ report.xxx.operations.1.parameters=0|1
    215 215
     
    
    216 216
     Ici on commence la somme à partir de la ligne **0** et la colonne **1**.
    
    217 217
     
    
    218
    +### SubtractColum
    
    219
    +
    
    220
    +Cette opération permet de réaliser la soustraction de deux colonnes, ligne par ligne et de consigner le résultat dans une nouvelle colonne.
    
    221
    +
    
    222
    +Le résultat sera un **entier avec décimales** (on arrondit à 4 décimales).
    
    223
    +
    
    224
    +**À noter que si une ligne contient des valeurs non numériques, la soustraction n'est pas effectuée et la valeur de la
    
    225
    +celulle sera *-***.
    
    226
    +
    
    227
    +L'opéréation doit être paramétrée pour indiquer les deux colonnes à traiter et où inscrire le résultat de la soustraction.
    
    228
    +
    
    229
    +Le paramétrage est donc trois numéros de colonne codifié sous la forme ```column1|column2|targetColumn```.
    
    230
    +
    
    231
    +Exemple d'utilisation
    
    232
    +
    
    233
    +```properties
    
    234
    +report.xxx.operations.1.type=SubtractColum
    
    235
    +report.xxx.operations.1.parameters=0|1|2
    
    236
    +```
    
    237
    +
    
    238
    +Ici on soustrait la colonne 0 à la colonne 1 et on consigne le résultat dans la colonne 2.
    
    239
    +
    
    218 240
     ## Opérations spécifiques à ObServe
    
    219 241
     
    
    220 242
     Ces opérations étant utilisées uniquement dans les rapport embarqués, elles ne possèdent aucun paramétrage.
    

  • toolkit/api-report/src/main/java/fr/ird/observe/report/operations/SubtractColum.java
    1
    +package fr.ird.observe.report.operations;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe Toolkit :: API :: Report
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2023 IRD, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + *
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + *
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import com.google.auto.service.AutoService;
    
    26
    +import fr.ird.observe.report.Report;
    
    27
    +import fr.ird.observe.report.ReportOperationConsumer;
    
    28
    +import fr.ird.observe.report.ReportRequestExecutor;
    
    29
    +import io.ultreia.java4all.lang.Numbers;
    
    30
    +import io.ultreia.java4all.util.matrix.DataMatrix;
    
    31
    +import org.apache.logging.log4j.LogManager;
    
    32
    +import org.apache.logging.log4j.Logger;
    
    33
    +
    
    34
    +import java.io.Serializable;
    
    35
    +import java.util.Set;
    
    36
    +
    
    37
    +/**
    
    38
    + * To subtract two columns values and place it in a new column.
    
    39
    + * <p>
    
    40
    + * Created on 15/07/2023.
    
    41
    + *
    
    42
    + * @author Tony Chemit - dev@tchemit.fr
    
    43
    + * @since 9.1.6
    
    44
    + */
    
    45
    +@AutoService(ReportOperationConsumer.class)
    
    46
    +public class SubtractColum implements ReportOperationConsumer {
    
    47
    +    private static final Logger log = LogManager.getLogger(SubtractColum.class);
    
    48
    +
    
    49
    +    @Override
    
    50
    +    public DataMatrix consume(String parameters, ReportRequestExecutor requestExecutor, Report report, Set<String> tripId, DataMatrix incoming) {
    
    51
    +        if (parameters.isEmpty()) {
    
    52
    +            throw new IllegalStateException(String.format("parameters of operation %s can't not be null (format: column1|column2|targetColumn)", getClass().getName()));
    
    53
    +        }
    
    54
    +        String[] split = parameters.trim().split("\\|");
    
    55
    +        if (split.length != 3) {
    
    56
    +            throw new IllegalStateException(String.format("parameters of operation %s must have three parameters (format: column1|column2|targetColumn), but was: %s", getClass().getName(), parameters.trim()));
    
    57
    +        }
    
    58
    +        int column1 = Integer.parseInt(split[0]);
    
    59
    +        int column2 = Integer.parseInt(split[1]);
    
    60
    +        int targetColumn = Integer.parseInt(split[2]);
    
    61
    +
    
    62
    +        int height = incoming.getHeight();
    
    63
    +
    
    64
    +        DataMatrix tmpMatrix = createTmpMatrix(targetColumn, 0, 1, height);
    
    65
    +        for (int row = 0; row < height; row++) {
    
    66
    +            Object sumRow = getSubtract(row, column1, column2, incoming);
    
    67
    +            tmpMatrix.setValue(0, row, sumRow);
    
    68
    +        }
    
    69
    +        return DataMatrix.merge(incoming, tmpMatrix);
    
    70
    +    }
    
    71
    +
    
    72
    +    protected Object getSubtract(int row, int column1, int column2, DataMatrix incoming) {
    
    73
    +
    
    74
    +        Double v1 = getValue(row, column1, incoming);
    
    75
    +        Double v2 = getValue(row, column2, incoming);
    
    76
    +        if (v1 == null || v2 == null) {
    
    77
    +            return "-";
    
    78
    +        }
    
    79
    +        float result = (float) (v1 - v2);
    
    80
    +        return Numbers.roundFourDigits(result);
    
    81
    +    }
    
    82
    +
    
    83
    +    protected Double getValue(int x, int y, DataMatrix incoming) {
    
    84
    +        Serializable o = incoming.getValue(y, x);
    
    85
    +        if (o == null || "null".equals(o)) {
    
    86
    +            return null;
    
    87
    +        }
    
    88
    +        try {
    
    89
    +            return Double.parseDouble(o.toString());
    
    90
    +        } catch (NumberFormatException e) {
    
    91
    +            // une des données de la colonne n'est pas un count on sort directement
    
    92
    +            log.debug(String.format("Could not convert %s to number", o), e);
    
    93
    +            return null;
    
    94
    +        }
    
    95
    +    }
    
    96
    +}