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

Commits:

3 changed files:

Changes:

  • dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU General Public License as
    
    9 9
      * published by the Free Software Foundation, either version 3 of the
    
    10 10
      * License, or (at your option) any later version.
    
    11
    - * 
    
    11
    + *
    
    12 12
      * This program is distributed in the hope that it will be useful,
    
    13 13
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    14 14
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    15 15
      * GNU General Public License for more details.
    
    16
    - * 
    
    16
    + *
    
    17 17
      * You should have received a copy of the GNU General Public
    
    18 18
      * License along with this program.  If not, see
    
    19 19
      * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    ... ... @@ -97,6 +97,7 @@ import fr.ird.observe.dto.decoration.decorators.LengthWeightParameterDecorator;
    97 97
     import fr.ird.observe.dto.decoration.decorators.NonTargetCatchDecorator;
    
    98 98
     import fr.ird.observe.dto.decoration.decorators.NonTargetCatchReleaseDecorator;
    
    99 99
     import fr.ird.observe.dto.decoration.decorators.NonTargetLengthDecorator;
    
    100
    +import fr.ird.observe.dto.decoration.decorators.ObjectMaterialReferenceDecorator;
    
    100 101
     import fr.ird.observe.dto.decoration.decorators.ObjectObservedSpeciesDecorator;
    
    101 102
     import fr.ird.observe.dto.decoration.decorators.ObserveDecorator;
    
    102 103
     import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator;
    
    ... ... @@ -209,7 +210,6 @@ import fr.ird.observe.dto.referential.seine.NonTargetCatchReleaseStatusReference
    209 210
     import fr.ird.observe.dto.referential.seine.NonTargetCatchReleasingTimeDto;
    
    210 211
     import fr.ird.observe.dto.referential.seine.NonTargetCatchReleasingTimeReference;
    
    211 212
     import fr.ird.observe.dto.referential.seine.ObjectMaterialDto;
    
    212
    -import fr.ird.observe.dto.referential.seine.ObjectMaterialReference;
    
    213 213
     import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeDto;
    
    214 214
     import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeReference;
    
    215 215
     import fr.ird.observe.dto.referential.seine.ObjectOperationDto;
    
    ... ... @@ -791,7 +791,9 @@ public class DecoratorService extends DecoratorProvider {
    791 791
     
    
    792 792
             @Override
    
    793 793
             public void initObjectMaterialDto() {
    
    794
    -            registerDefaultReferentialAndReferentialReferenceDecorator(ObjectMaterialDto.class, ObjectMaterialReference.class, libelle);
    
    794
    +            registerDecorator(new ObjectMaterialReferenceDecorator());
    
    795
    +            registerObserveDecorator(ObjectMaterialDto.class, "${code}$s##${" + libelle + "}$s", " ");
    
    796
    +//            registerDefaultReferentialAndReferentialReferenceDecorator(ObjectMaterialDto.class, ObjectMaterialReference.class, libelle);
    
    795 797
             }
    
    796 798
     
    
    797 799
             @Override
    

  • dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ObjectMaterialReferenceDecorator.java
    1
    +package fr.ird.observe.dto.decoration.decorators;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe :: Dto
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2019 IRD, Code Lutin, 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 fr.ird.observe.dto.referential.ReferentialDto;
    
    26
    +import fr.ird.observe.dto.referential.seine.ObjectMaterialReference;
    
    27
    +import org.apache.commons.jxpath.JXPathContext;
    
    28
    +
    
    29
    +import static io.ultreia.java4all.i18n.I18n.t;
    
    30
    +
    
    31
    +public class ObjectMaterialReferenceDecorator extends ReferentialReferenceDecorator<ObjectMaterialReference> {
    
    32
    +
    
    33
    +    public ObjectMaterialReferenceDecorator() {
    
    34
    +        super(ObjectMaterialReference.class, "${code}$s##${label}$s");
    
    35
    +    }
    
    36
    +
    
    37
    +    @Override
    
    38
    +    protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
    
    39
    +        Comparable<Comparable<?>> result = super.getTokenValue(jxcontext, token);
    
    40
    +        if (ReferentialDto.PROPERTY_CODE.equals(token) && (result == null || (result + "").isEmpty())) {
    
    41
    +            result = (Comparable) t("observe.common.nocode");
    
    42
    +        }
    
    43
    +        return result;
    
    44
    +    }
    
    45
    +}

  • dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ReferentialReferenceDecorator.java
    ... ... @@ -55,7 +55,7 @@ public class ReferentialReferenceDecorator<R extends ReferentialDtoReference> ex
    55 55
                                 JXPathContext jxcontext = JXPathContext.newContext(data);
    
    56 56
                                 Comparable<Comparable<?>> key = getTokenValue(jxcontext, ReferentialDto.PROPERTY_CODE);
    
    57 57
                                 // on passe en 000000x comme ça si on a des nombres, ils seront bien triés
    
    58
    -                            String value = key == null ? "" : StringUtils.leftPad(key.toString(), 6, "0");
    
    58
    +                            String value = key == null || key.equals(t("observe.common.nocode")) ? "" : StringUtils.leftPad(key.toString(), 6, "0");
    
    59 59
                                 valueCache.put(data, (Comparable) value);
    
    60 60
                             }
    
    61 61
                         }