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

Commits:

7 changed files:

Changes:

  • dto/src/main/i18n/getters/java.getter
    ... ... @@ -17,8 +17,6 @@ observe.common.gps.activity
    17 17
     observe.common.gps.gpsPoint
    
    18 18
     observe.common.inconnu
    
    19 19
     observe.common.no.unit
    
    20
    -observe.common.nocode
    
    21
    -observe.common.none
    
    22 20
     observe.data.Data.baitHaulingStatus
    
    23 21
     observe.data.Data.captain
    
    24 22
     observe.data.Data.dataQuality
    

  • dto/src/main/java/fr/ird/observe/dto/decoration/decorators/DataReferenceDecorator.java deleted
    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.reference.DataDtoReference;
    
    26
    -import fr.ird.observe.dto.reference.DtoReference;
    
    27
    -import org.apache.commons.jxpath.JXPathContext;
    
    28
    -
    
    29
    -/**
    
    30
    - * @author Kevin Morin (Code Lutin)
    
    31
    - */
    
    32
    -public class DataReferenceDecorator<R extends DataDtoReference> extends ObserveDecorator<R> implements Cloneable {
    
    33
    -
    
    34
    -    private static final long serialVersionUID = 1L;
    
    35
    -
    
    36
    -    public DataReferenceDecorator(Class<R> type, String expression) {
    
    37
    -        super(type, expression);
    
    38
    -    }
    
    39
    -
    
    40
    -    @Override
    
    41
    -    protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
    
    42
    -
    
    43
    -        // assume all values are comparable
    
    44
    -        Comparable<Comparable<?>> value;
    
    45
    -
    
    46
    -        Object contextBean = jxcontext.getContextBean();
    
    47
    -
    
    48
    -        if (contextBean instanceof DtoReference) {
    
    49
    -
    
    50
    -            String[] tokens = token.split("/");
    
    51
    -
    
    52
    -            value = getValueFromReference(tokens, (DtoReference) contextBean, 0);
    
    53
    -
    
    54
    -            if (value == null) {
    
    55
    -                value = (Comparable<Comparable<?>>) getDefaultNullValue(tokens[0]);
    
    56
    -            }
    
    57
    -
    
    58
    -        } else {
    
    59
    -            value = super.getTokenValue(jxcontext, token);
    
    60
    -        }
    
    61
    -
    
    62
    -        return value;
    
    63
    -
    
    64
    -    }
    
    65
    -
    
    66
    -    @Override
    
    67
    -    public String toString(Object bean) {
    
    68
    -        String result = super.toString(bean);
    
    69
    -        return result == null ? null : result.trim();
    
    70
    -    }
    
    71
    -}

  • dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ObserveDecorator.java deleted
    1
    -/*
    
    2
    - * #%L
    
    3
    - * ObServe :: Dto
    
    4
    - * %%
    
    5
    - * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
    
    6
    - * %%
    
    7
    - * This program is free software: you can redistribute it and/or modify
    
    8
    - * it under the terms of the GNU General Public License as
    
    9
    - * published by the Free Software Foundation, either version 3 of the 
    
    10
    - * License, or (at your option) any later version.
    
    11
    - * 
    
    12
    - * This program is distributed in the hope that it will be useful,
    
    13
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    14
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    15
    - * GNU General Public License for more details.
    
    16
    - * 
    
    17
    - * You should have received a copy of the GNU General Public 
    
    18
    - * License along with this program.  If not, see
    
    19
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    20
    - * #L%
    
    21
    - */
    
    22
    -package fr.ird.observe.dto.decoration.decorators;
    
    23
    -
    
    24
    -import fr.ird.observe.dto.reference.DtoReference;
    
    25
    -import org.apache.commons.jxpath.JXPathContext;
    
    26
    -import org.apache.commons.lang3.StringUtils;
    
    27
    -import org.apache.logging.log4j.LogManager;
    
    28
    -import org.apache.logging.log4j.Logger;
    
    29
    -import org.nuiton.decorator.MultiJXPathDecorator;
    
    30
    -
    
    31
    -import java.io.Serializable;
    
    32
    -
    
    33
    -import static io.ultreia.java4all.i18n.I18n.t;
    
    34
    -
    
    35
    -/**
    
    36
    - * Abstract decorator for any complex decorator.
    
    37
    - *
    
    38
    - * @author Tony Chemit - dev@tchemit.fr
    
    39
    - * @since 2.4
    
    40
    - */
    
    41
    -public class ObserveDecorator<E> extends MultiJXPathDecorator<E> implements Cloneable {
    
    42
    -
    
    43
    -    private static final long serialVersionUID = 1L;
    
    44
    -
    
    45
    -    /** Logger. */
    
    46
    -    private static final Logger log = LogManager.getLogger(ObserveDecorator.class);
    
    47
    -
    
    48
    -    public static final String DEFAULT_SEPARATOR = "##";
    
    49
    -
    
    50
    -    public static final String DEFAULT_SEPARATOR_REPLACEMENT = " - ";
    
    51
    -
    
    52
    -    public ObserveDecorator(Class<E> internalClass, String expression) {
    
    53
    -        super(internalClass, expression, DEFAULT_SEPARATOR, DEFAULT_SEPARATOR_REPLACEMENT);
    
    54
    -    }
    
    55
    -
    
    56
    -    public ObserveDecorator(Class<E> internalClass, String expression, String separator) {
    
    57
    -        super(internalClass, expression, DEFAULT_SEPARATOR, separator);
    
    58
    -    }
    
    59
    -
    
    60
    -    @Override
    
    61
    -    public final Object clone() throws CloneNotSupportedException {
    
    62
    -        return super.clone();
    
    63
    -    }
    
    64
    -
    
    65
    -    protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
    
    66
    -        // assume all values are comparable
    
    67
    -        Comparable<Comparable<?>> value;
    
    68
    -
    
    69
    -        try {
    
    70
    -
    
    71
    -            String[] tokens = token.split("/");
    
    72
    -
    
    73
    -            Object value0 = jxcontext.getValue(tokens[0]);
    
    74
    -
    
    75
    -            if (value0 instanceof DtoReference) {
    
    76
    -
    
    77
    -                value = getValueFromReference(tokens, (DtoReference<?, ?>) value0, 1);
    
    78
    -
    
    79
    -            } else {
    
    80
    -
    
    81
    -                value = (Comparable<Comparable<?>>) jxcontext.getValue(token);
    
    82
    -            }
    
    83
    -
    
    84
    -            if (value == null) {
    
    85
    -                value = (Comparable<Comparable<?>>) getDefaultNullValue(token);
    
    86
    -            }
    
    87
    -
    
    88
    -        } catch (Exception e) {
    
    89
    -            value = (Comparable<Comparable<?>>) getDefaultUndefinedValue(token);
    
    90
    -        }
    
    91
    -
    
    92
    -        return value;
    
    93
    -    }
    
    94
    -
    
    95
    -    protected Comparable<Comparable<?>> getValueFromReference(String[] tokens, DtoReference<?, ?> referenceBean, int startIndex) {
    
    96
    -
    
    97
    -        for (int i = startIndex, max = tokens.length - 1; i < max; i++) {
    
    98
    -
    
    99
    -            if (referenceBean.getPropertyNames().contains(tokens[i])) {
    
    100
    -
    
    101
    -                Serializable propertyValue = referenceBean.getPropertyValue(tokens[i]);
    
    102
    -
    
    103
    -                if (!(propertyValue instanceof DtoReference)) {
    
    104
    -
    
    105
    -                    return (Comparable<Comparable<?>>) getDefaultUndefinedValue(StringUtils.join(tokens, "/"));
    
    106
    -
    
    107
    -                }
    
    108
    -
    
    109
    -                referenceBean = (DtoReference<?, ?>) propertyValue;
    
    110
    -            }
    
    111
    -        }
    
    112
    -
    
    113
    -        Comparable<Comparable<?>> value = null;
    
    114
    -
    
    115
    -        String lastToken = tokens[tokens.length - 1];
    
    116
    -        if (referenceBean.getPropertyNames().contains(lastToken)) {
    
    117
    -            value = referenceBean.getPropertyValue(lastToken);
    
    118
    -        } else {
    
    119
    -            value = referenceBean.get(lastToken);
    
    120
    -        }
    
    121
    -
    
    122
    -        return value;
    
    123
    -    }
    
    124
    -
    
    125
    -    protected Comparable<?> getDefaultUndefinedValue(String token) {
    
    126
    -        if (log.isDebugEnabled()) {
    
    127
    -            log.debug("No defined value for token [" + token + "]");
    
    128
    -        }
    
    129
    -        return t("observe.common.none");
    
    130
    -    }
    
    131
    -
    
    132
    -    protected Comparable<?> getDefaultNullValue(String token) {
    
    133
    -        if (log.isDebugEnabled()) {
    
    134
    -            log.debug("Null value for token [" + token + "]");
    
    135
    -        }
    
    136
    -        return t("observe.common.none");
    
    137
    -    }
    
    138
    -
    
    139
    -
    
    140
    -}

  • dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ReferentialReferenceDecorator.java deleted
    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.reference.ReferentialDtoReference;
    
    26
    -import fr.ird.observe.dto.referential.ReferentialDto;
    
    27
    -import org.apache.commons.jxpath.JXPathContext;
    
    28
    -import org.apache.commons.lang3.StringUtils;
    
    29
    -import org.nuiton.decorator.JXPathDecorator;
    
    30
    -
    
    31
    -import java.util.List;
    
    32
    -
    
    33
    -import static io.ultreia.java4all.i18n.I18n.t;
    
    34
    -
    
    35
    -/**
    
    36
    - * @author Kevin Morin (Code Lutin)
    
    37
    - */
    
    38
    -public class ReferentialReferenceDecorator<R extends ReferentialDtoReference> extends ObserveDecorator<R> implements Cloneable {
    
    39
    -
    
    40
    -    private static final long serialVersionUID = 1L;
    
    41
    -
    
    42
    -    public ReferentialReferenceDecorator(Class<R> type, String expression) {
    
    43
    -        super(type, expression);
    
    44
    -        for (int i = 0; i < nbToken; i++) {
    
    45
    -            String property = getProperty(i);
    
    46
    -            if (ReferentialDto.PROPERTY_CODE.equals(property)) {
    
    47
    -
    
    48
    -                // On change le comparateur pour simuler le tri numérique si possible.
    
    49
    -                contexts[i].setComparator(new JXPathComparator<R>(property) {
    
    50
    -
    
    51
    -                    @Override
    
    52
    -                    public void init(JXPathDecorator<R> decorator, List<R> datas) {
    
    53
    -                        clear();
    
    54
    -                        for (R data : datas) {
    
    55
    -                            JXPathContext jxcontext = JXPathContext.newContext(data);
    
    56
    -                            Comparable<Comparable<?>> key = getTokenValue(jxcontext, ReferentialDto.PROPERTY_CODE);
    
    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");
    
    59
    -                            valueCache.put(data, (Comparable) value);
    
    60
    -                        }
    
    61
    -                    }
    
    62
    -                });
    
    63
    -                break;
    
    64
    -            }
    
    65
    -        }
    
    66
    -    }
    
    67
    -
    
    68
    -    @Override
    
    69
    -    protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
    
    70
    -
    
    71
    -
    
    72
    -        // assume all values are comparable
    
    73
    -        Comparable<Comparable<?>> value;
    
    74
    -
    
    75
    -        Object contextBean = jxcontext.getContextBean();
    
    76
    -
    
    77
    -        if (contextBean instanceof ReferentialDtoReference) {
    
    78
    -
    
    79
    -            String[] tokens = token.split("/");
    
    80
    -
    
    81
    -            value = getValueFromReference(tokens, (ReferentialDtoReference) contextBean, 0);
    
    82
    -
    
    83
    -            if (value == null) {
    
    84
    -                value = (Comparable<Comparable<?>>) getDefaultNullValue(tokens[0]);
    
    85
    -            }
    
    86
    -
    
    87
    -        } else {
    
    88
    -            value = super.getTokenValue(jxcontext, token);
    
    89
    -        }
    
    90
    -
    
    91
    -        return value;
    
    92
    -
    
    93
    -    }
    
    94
    -
    
    95
    -    @Override
    
    96
    -    protected Comparable<?> getDefaultNullValue(String token) {
    
    97
    -        if (token.equals("startDate") || token.equals("endDate")) {
    
    98
    -            return null;
    
    99
    -        }
    
    100
    -        return ReferentialDto.PROPERTY_CODE.equals(token) ? t("observe.common.nocode") : super.getDefaultNullValue(token);
    
    101
    -    }
    
    102
    -}

  • observe-i18n/src/main/i18n/translations/observe_en_GB.properties
    ... ... @@ -426,8 +426,6 @@ observe.common.inconnu=Unknown
    426 426
     observe.common.label=Label
    
    427 427
     observe.common.lengthWeightFormula=Length weight formula
    
    428 428
     observe.common.no.unit=No unit
    
    429
    -observe.common.nocode=Nocode
    
    430
    -observe.common.none=None
    
    431 429
     observe.common.operation.resume=Summary of operations
    
    432 430
     observe.common.resume=Summary
    
    433 431
     observe.common.saveFile.overwrite=file alreayd exists, would you like to overwrite it?
    

  • observe-i18n/src/main/i18n/translations/observe_es_ES.properties
    ... ... @@ -426,8 +426,6 @@ observe.common.inconnu=desconocido
    426 426
     observe.common.label=Texto
    
    427 427
     observe.common.lengthWeightFormula=Relación de peso
    
    428 428
     observe.common.no.unit=No unit \#TODO
    
    429
    -observe.common.nocode=codigo ausente
    
    430
    -observe.common.none=Ninguno
    
    431 429
     observe.common.operation.resume=Resumen de operaciones
    
    432 430
     observe.common.resume=Resumen de la configuración
    
    433 431
     observe.common.saveFile.overwrite=El archivo ya existe. Quiere reemplazar lo ?
    

  • observe-i18n/src/main/i18n/translations/observe_fr_FR.properties
    ... ... @@ -426,8 +426,6 @@ observe.common.inconnu=inconnu
    426 426
     observe.common.label=Libellé
    
    427 427
     observe.common.lengthWeightFormula=Relation Poids
    
    428 428
     observe.common.no.unit=Pas d'unité
    
    429
    -observe.common.nocode=code absent
    
    430
    -observe.common.none=Aucun
    
    431 429
     observe.common.operation.resume=Résumé des opérations
    
    432 430
     observe.common.resume=Résumé de la configuration
    
    433 431
     observe.common.saveFile.overwrite=Le fichier existe déjà. Voulez-vous le remplacer ?