Tony CHEMIT pushed to branch feature/116 at ultreiaio / ird-t3

Commits:

25 changed files:

Changes:

  • t3-actions/src/main/resources/ftl/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction.ftl
    ... ... @@ -20,7 +20,7 @@
    20 20
     -->
    
    21 21
     <#include "/ftl/header.ftl"/>
    
    22 22
     
    
    23
    -Pilote d'acquisition de données : ${configuration.inputProvider.libelle}
    
    23
    +Pilote d'acquisition de données : ${configuration.inputProvider.label}
    
    24 24
     Source de données               : ${configuration.inputFile.name}
    
    25 25
     Utilisation des plans de cuves  : ${configuration.useWells?string}
    
    26 26
     Type de marées                  : ${configuration.tripType.label}
    

  • t3-actions/src/main/resources/ftl/fr/ird/t3/actions/io/input/AnalyzeInputSourceAction_en.ftl
    ... ... @@ -20,7 +20,7 @@
    20 20
     -->
    
    21 21
     <#include "/ftl/header_en.ftl"/>
    
    22 22
     
    
    23
    -Input Pilot:                 ${configuration.inputProvider.libelle}
    
    23
    +Input Pilot:                 ${configuration.inputProvider.label}
    
    24 24
     Input file:                  ${configuration.inputFile.name}
    
    25 25
     Use wells:                   ${configuration.useWells?string}
    
    26 26
     Trip type:                   ${configuration.tripType.label}
    

  • t3-actions/src/main/resources/ftl/fr/ird/t3/actions/io/input/ImportInputSourceAction.ftl
    ... ... @@ -20,7 +20,7 @@
    20 20
     -->
    
    21 21
     <#include "/ftl/header.ftl"/>
    
    22 22
     
    
    23
    -Pilote d'acquisition de données : ${configuration.inputProvider.libelle}
    
    23
    +Pilote d'acquisition de données : ${configuration.inputProvider.label}
    
    24 24
     Source de données               : ${configuration.inputFile.name}
    
    25 25
     Utilisation des plans de cuves  : ${configuration.useWells?string}
    
    26 26
     Type de marées                  : ${configuration.tripType.label}
    

  • t3-actions/src/main/resources/ftl/fr/ird/t3/actions/io/input/ImportInputSourceAction_en.ftl
    ... ... @@ -20,7 +20,7 @@
    20 20
     -->
    
    21 21
     <#include "/ftl/header_en.ftl"/>
    
    22 22
     
    
    23
    -Input Pilot:                 ${configuration.inputProvider.libelle}
    
    23
    +Input Pilot:                 ${configuration.inputProvider.label}
    
    24 24
     Input file:                  ${configuration.inputFile.name}
    
    25 25
     Use wells:                   ${configuration.useWells?string}
    
    26 26
     Trip type:                   ${configuration.tripType.label}
    

  • t3-actions/src/test/java/fr/ird/t3/io/input/fake/v0/T3InputProviderFake0.java
    ... ... @@ -63,7 +63,7 @@ public class T3InputProviderFake0 implements T3InputProvider {
    63 63
         }
    
    64 64
     
    
    65 65
         @Override
    
    66
    -    public String getLibelle() {
    
    66
    +    public String getLabel() {
    
    67 67
             return getName() + " - v." + getVersion() + " (" + getInputType() + ")";
    
    68 68
         }
    
    69 69
     
    

  • t3-domain/src/main/java/fr/ird/t3/entities/data/TripType.java
    1 1
     package fr.ird.t3.entities.data;
    
    2 2
     
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * T3 :: Domain
    
    6
    + * %%
    
    7
    + * Copyright (C) 2010 - 2018 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 Affero General Public License as published by
    
    11
    + * the Free Software Foundation, either version 3 of the License, or
    
    12
    + * (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 Affero General Public License
    
    20
    + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    21
    + * #L%
    
    22
    + */
    
    23
    +
    
    3 24
     import fr.ird.t3.t3.domain.I18nEnumHelper;
    
    4 25
     
    
    5 26
     import static org.nuiton.i18n.I18n.t;
    

  • t3-domain/src/main/java/fr/ird/t3/io/input/T3InputProvider.java
    ... ... @@ -71,7 +71,7 @@ public interface T3InputProvider extends Serializable {
    71 71
          *
    
    72 72
          * @return the description of the provider
    
    73 73
          */
    
    74
    -    String getLibelle();
    
    74
    +    String getLabel();
    
    75 75
     
    
    76 76
         /**
    
    77 77
          * To instanciate a new {@link T3Input} for a given {@code inputFile} to
    

  • t3-domain/src/main/java/fr/ird/t3/io/input/access/T3AvdthDataEntityVisitor.java
    1
    +package fr.ird.t3.io.input.access;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * T3 :: Domain
    
    6
    + * %%
    
    7
    + * Copyright (C) 2010 - 2018 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 Affero General Public License as published by
    
    11
    + * the Free Software Foundation, either version 3 of the License, or
    
    12
    + * (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 Affero General Public License
    
    20
    + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    21
    + * #L%
    
    22
    + */
    
    23
    +
    
    24
    +import fr.ird.t3.entities.ReferenceEntityMap;
    
    25
    +import fr.ird.t3.entities.T3EntityEnum;
    
    26
    +import fr.ird.t3.entities.data.Activity;
    
    27
    +import fr.ird.t3.entities.data.ElementaryCatch;
    
    28
    +import fr.ird.t3.entities.data.ElementaryLanding;
    
    29
    +import fr.ird.t3.entities.data.Sample;
    
    30
    +import fr.ird.t3.entities.data.SampleSet;
    
    31
    +import fr.ird.t3.entities.data.Trip;
    
    32
    +import fr.ird.t3.entities.data.Well;
    
    33
    +import fr.ird.t3.entities.data.WellPlan;
    
    34
    +import fr.ird.t3.entities.reference.WeightCategoryLanding;
    
    35
    +import fr.ird.t3.entities.reference.WeightCategoryLogBook;
    
    36
    +import fr.ird.t3.io.input.MissingForeignKeyInT3;
    
    37
    +import fr.ird.type.CoordinateHelper;
    
    38
    +import org.apache.commons.logging.Log;
    
    39
    +import org.apache.commons.logging.LogFactory;
    
    40
    +import org.nuiton.topia.persistence.TopiaEntity;
    
    41
    +
    
    42
    +import java.io.Serializable;
    
    43
    +
    
    44
    +/**
    
    45
    + * Created by tchemit on 04/03/2018.
    
    46
    + *
    
    47
    + * @author Tony Chemit - dev@tchemit.fr
    
    48
    + */
    
    49
    +public abstract class T3AvdthDataEntityVisitor extends T3DataEntityVisitor {
    
    50
    +
    
    51
    +    private static final Log log = LogFactory.getLog(T3AvdthDataEntityVisitor.class);
    
    52
    +
    
    53
    +
    
    54
    +    private final ReverseAssociationGetter<Trip, WellPlan, Activity> wellPlanReverse;
    
    55
    +    private final ReverseAssociationGetter<Trip, Sample, Well> sampleReverse;
    
    56
    +    private final ReverseAssociationGetter<Trip, SampleSet, Activity> sampleSetReverse;
    
    57
    +
    
    58
    +    protected T3AvdthDataEntityVisitor(T3AccessDataSource dataSource, ReferenceEntityMap referentiel) {
    
    59
    +        super(dataSource, referentiel);
    
    60
    +        wellPlanReverse = newReverseAssociationGetter(
    
    61
    +                Trip.class,
    
    62
    +                WellPlan.class,
    
    63
    +                Activity.class,
    
    64
    +                Trip.PROPERTY_ACTIVITY,
    
    65
    +                WellPlan.PROPERTY_ACTIVITY);
    
    66
    +        sampleReverse = newReverseAssociationGetter(
    
    67
    +                Trip.class,
    
    68
    +                Sample.class,
    
    69
    +                Well.class,
    
    70
    +                Trip.PROPERTY_WELL,
    
    71
    +                Sample.PROPERTY_WELL);
    
    72
    +        sampleSetReverse = newReverseAssociationGetter(
    
    73
    +                Trip.class,
    
    74
    +                SampleSet.class,
    
    75
    +                Activity.class,
    
    76
    +                Trip.PROPERTY_ACTIVITY,
    
    77
    +                SampleSet.PROPERTY_ACTIVITY);
    
    78
    +    }
    
    79
    +
    
    80
    +
    
    81
    +    @Override
    
    82
    +    public void onEnd(T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    83
    +        super.onEnd(entity, meta);
    
    84
    +        if (!deepVisit) {
    
    85
    +            return;
    
    86
    +        }
    
    87
    +        endActivity(entity, meta);
    
    88
    +    }
    
    89
    +
    
    90
    +    @Override
    
    91
    +    public void onVisitReverseAssociation(String propertyName, T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    92
    +        if (!deepVisit) {
    
    93
    +            return;
    
    94
    +        }
    
    95
    +        if (SampleSet.PROPERTY_ACTIVITY.equals(propertyName) && entity instanceof SampleSet) {
    
    96
    +            // special case, must obtain the activity from the trip
    
    97
    +            sampleSetReverse.attachReverseAssociation(entity);
    
    98
    +            return;
    
    99
    +        }
    
    100
    +        if (WellPlan.PROPERTY_ACTIVITY.equals(propertyName) && entity instanceof WellPlan) {
    
    101
    +            // special case, must obtain the activity from the trip
    
    102
    +            wellPlanReverse.attachReverseAssociation(entity);
    
    103
    +            return;
    
    104
    +        }
    
    105
    +        if (Sample.PROPERTY_WELL.equals(propertyName) && entity instanceof Sample) {
    
    106
    +            // special case, must obtain the well from the trip
    
    107
    +            sampleReverse.attachReverseAssociation(entity);
    
    108
    +            return;
    
    109
    +        }
    
    110
    +        super.onVisitReverseAssociation(propertyName, entity, meta);
    
    111
    +    }
    
    112
    +
    
    113
    +    @Override
    
    114
    +    public void onVisitComposition(String propertyName, Class<?> type, T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    115
    +        if (onVisitElementaryLanding(propertyName, entity)) {
    
    116
    +            return;
    
    117
    +        }
    
    118
    +        if (onVisitElementaryCatch(propertyName, entity)) {
    
    119
    +            return;
    
    120
    +        }
    
    121
    +        super.onVisitComposition(propertyName, type, entity, meta);
    
    122
    +    }
    
    123
    +
    
    124
    +    private void endActivity(T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    125
    +        T3EntityEnum type = meta.getType();
    
    126
    +        if (type == T3EntityEnum.Activity) {
    
    127
    +            Activity a = (Activity) entity;
    
    128
    +            Integer quadrant = a.getQuadrant();
    
    129
    +            Float latitude = CoordinateHelper.getSignedLatitude(quadrant, a.getLatitude());
    
    130
    +            Float longitude = CoordinateHelper.getSignedLongitude(quadrant, a.getLongitude());
    
    131
    +            a.setLatitude(latitude);
    
    132
    +            a.setLongitude(longitude);
    
    133
    +            log.debug(String.format("Will use for activity %s coordinates <%s,%s>", entity, a.getLongitude(), a.getLatitude()));
    
    134
    +        }
    
    135
    +    }
    
    136
    +
    
    137
    +    protected boolean onVisitElementaryLanding(String propertyName, T3AccessEntity entity) {
    
    138
    +        if (!(ElementaryLanding.PROPERTY_WEIGHT_CATEGORY_LANDING.equals(propertyName) && entity instanceof ElementaryLanding)) {
    
    139
    +            return false;
    
    140
    +        }
    
    141
    +        Serializable codeEspece = getProperty("C_ESP", row);
    
    142
    +        Serializable codeCate = getProperty("C_CAT_C", row);
    
    143
    +
    
    144
    +        // must found the species
    
    145
    +        T3AccessEntityMeta specieMeta = dataSource.getMeta(T3EntityEnum.Species);
    
    146
    +        TopiaEntity specie = getReferenceEntity(specieMeta, codeEspece);
    
    147
    +        T3AccessEntityMeta categoryMeta = dataSource.getMeta(T3EntityEnum.WeightCategoryLanding);
    
    148
    +
    
    149
    +        // special case : need to find a reference with two primary keys...
    
    150
    +        TopiaEntity ref = getReferenceEntity(
    
    151
    +                categoryMeta,
    
    152
    +                new String[]{WeightCategoryLanding.PROPERTY_CODE, WeightCategoryLanding.PROPERTY_SPECIES},
    
    153
    +                codeCate, specie);
    
    154
    +        if (ref == null) {
    
    155
    +            log.warn(String.format("Can't find WeightCategoryLanding for speciesCode / categoryCode: %s/%s", codeEspece, codeCate));
    
    156
    +            getMissingForeignKeys().add(new MissingForeignKeyInT3(
    
    157
    +                    T3EntityEnum.ElementaryLanding,
    
    158
    +                    T3EntityEnum.WeightCategoryLanding,
    
    159
    +                    getPKey(T3EntityEnum.ElementaryLanding),
    
    160
    +                    new Object[]{codeEspece, codeCate}));
    
    161
    +        } else {
    
    162
    +            log.debug(String.format("Detected landing catch weight category : %s", ref));
    
    163
    +            entity.setProperty(ElementaryLanding.PROPERTY_WEIGHT_CATEGORY_LANDING, ref);
    
    164
    +        }
    
    165
    +        return true;
    
    166
    +    }
    
    167
    +
    
    168
    +    protected boolean onVisitElementaryCatch(String propertyName, T3AccessEntity entity) {
    
    169
    +        if (!(ElementaryCatch.PROPERTY_WEIGHT_CATEGORY_LOG_BOOK.equals(propertyName) && entity instanceof ElementaryCatch)) {
    
    170
    +            return false;
    
    171
    +        }
    
    172
    +
    
    173
    +        // special case : need to find a reference with two primary keys...
    
    174
    +        Serializable codeEspece = getProperty("C_ESP", row);
    
    175
    +        Serializable codeCate = getProperty("C_CAT_T", row);
    
    176
    +
    
    177
    +        // must found the species
    
    178
    +        T3AccessEntityMeta specieMeta = dataSource.getMeta(T3EntityEnum.Species);
    
    179
    +        TopiaEntity specie = getReferenceEntity(specieMeta, codeEspece);
    
    180
    +        T3AccessEntityMeta categoryMeta = dataSource.getMeta(T3EntityEnum.WeightCategoryLogBook);
    
    181
    +
    
    182
    +        // special case : need to find a reference with two primary keys...
    
    183
    +        TopiaEntity ref = getReferenceEntity(
    
    184
    +                categoryMeta,
    
    185
    +                new String[]{WeightCategoryLogBook.PROPERTY_CODE, WeightCategoryLogBook.PROPERTY_SPECIES},
    
    186
    +                codeCate, specie);
    
    187
    +
    
    188
    +        if (ref == null) {
    
    189
    +            log.warn(String.format("Can't find weightCategoryLogBook for speciesCode / categoryCode: %s/%s", codeEspece, codeCate));
    
    190
    +            getMissingForeignKeys().add(new MissingForeignKeyInT3(
    
    191
    +                    T3EntityEnum.ElementaryCatch,
    
    192
    +                    T3EntityEnum.WeightCategoryLogBook,
    
    193
    +                    getPKey(T3EntityEnum.ElementaryCatch),
    
    194
    +                    new Object[]{codeCate, codeEspece}));
    
    195
    +        } else {
    
    196
    +            log.debug(String.format("Detected logBook catch weight category : %s", ref));
    
    197
    +            entity.setProperty(propertyName, ref);
    
    198
    +        }
    
    199
    +        return true;
    
    200
    +    }
    
    201
    +
    
    202
    +}

  • t3-domain/src/main/java/fr/ird/t3/io/input/access/T3DataEntityVisitor.java
    ... ... @@ -8,41 +8,42 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    20 20
      */
    
    21 21
     package fr.ird.t3.io.input.access;
    
    22 22
     
    
    23
    -import com.google.common.collect.Lists;
    
    24 23
     import fr.ird.msaccess.importer.AbstractAccessEntityMeta;
    
    25 24
     import fr.ird.t3.entities.ReferenceEntityMap;
    
    26 25
     import fr.ird.t3.entities.T3EntityEnum;
    
    27 26
     import fr.ird.t3.entities.T3EntityMap;
    
    28 27
     import fr.ird.t3.entities.reference.T3ReferenceEntity;
    
    29 28
     import fr.ird.t3.io.input.MissingForeignKey;
    
    29
    +import org.apache.commons.logging.Log;
    
    30
    +import org.apache.commons.logging.LogFactory;
    
    31
    +import org.nuiton.topia.persistence.TopiaEntity;
    
    32
    +import org.nuiton.topia.persistence.util.EntityOperator;
    
    33
    +
    
    30 34
     import java.io.Serializable;
    
    35
    +import java.util.ArrayList;
    
    31 36
     import java.util.Arrays;
    
    32 37
     import java.util.Collection;
    
    33 38
     import java.util.List;
    
    34 39
     import java.util.Map;
    
    35 40
     import java.util.Stack;
    
    36
    -import org.apache.commons.logging.Log;
    
    37
    -import org.apache.commons.logging.LogFactory;
    
    38
    -import org.nuiton.topia.persistence.TopiaEntity;
    
    39
    -import org.nuiton.topia.persistence.util.EntityOperator;
    
    40 41
     
    
    41 42
     /**
    
    42 43
      * To visit and fill properly an data entity.
    
    43 44
      * <p/>
    
    44 45
      * If visitor has the flag {@link #deepVisit} is set to {@code false}, then
    
    45
    - * only the pkey will be filled, otherwise all fields, compositions or
    
    46
    + * only the pKey will be filled, otherwise all fields, compositions or
    
    46 47
      * associations are filled.
    
    47 48
      *
    
    48 49
      * @author Tony Chemit - dev@tchemit.fr
    
    ... ... @@ -50,7 +51,6 @@ import org.nuiton.topia.persistence.util.EntityOperator;
    50 51
      */
    
    51 52
     public class T3DataEntityVisitor extends AbstractT3EntityVisitor {
    
    52 53
     
    
    53
    -    /** Logger. */
    
    54 54
         private static final Log log = LogFactory.getLog(T3DataEntityVisitor.class);
    
    55 55
     
    
    56 56
         /** la pile des objets en cours de construction. */
    
    ... ... @@ -60,14 +60,14 @@ public class T3DataEntityVisitor extends AbstractT3EntityVisitor {
    60 60
         private final Stack<Map<String, Object>> rows;
    
    61 61
     
    
    62 62
         /** Universe of touched references while visiting a data. */
    
    63
    -    protected T3EntityMap entitiesTouched;
    
    63
    +    private T3EntityMap entitiesTouched;
    
    64 64
     
    
    65 65
         private List<MissingForeignKey> missingForeignKeys;
    
    66 66
     
    
    67 67
         protected T3DataEntityVisitor(T3AccessDataSource dataSource, ReferenceEntityMap referentiel) {
    
    68 68
             super(dataSource, referentiel);
    
    69
    -        rows = new Stack<Map<String, Object>>();
    
    70
    -        stack = new Stack<T3AccessEntity>();
    
    69
    +        rows = new Stack<>();
    
    70
    +        stack = new Stack<>();
    
    71 71
         }
    
    72 72
     
    
    73 73
         public T3EntityMap getEntitiesTouched() {
    
    ... ... @@ -84,20 +84,15 @@ public class T3DataEntityVisitor extends AbstractT3EntityVisitor {
    84 84
     
    
    85 85
         @Override
    
    86 86
         public void onStart(T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    87
    -
    
    88 87
             super.onStart(entity, meta);
    
    89
    -
    
    90 88
             stack.push(entity);
    
    91 89
             rows.push(row);
    
    92
    -
    
    93 90
             getEntitiesTouched().addEntity(entity);
    
    94 91
         }
    
    95 92
     
    
    96 93
         @Override
    
    97 94
         public void onEnd(T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    98
    -
    
    99 95
             super.onEnd(entity, meta);
    
    100
    -
    
    101 96
             stack.pop();
    
    102 97
             rows.pop();
    
    103 98
             if (!rows.isEmpty()) {
    
    ... ... @@ -105,60 +100,40 @@ public class T3DataEntityVisitor extends AbstractT3EntityVisitor {
    105 100
             }
    
    106 101
         }
    
    107 102
     
    
    108
    -    @SuppressWarnings({"RawUseOfParameterizedType", "unchecked"})
    
    103
    +    @SuppressWarnings("unchecked")
    
    109 104
         @Override
    
    110
    -    protected TopiaEntity getReferenceEntity(T3AccessEntityMeta compoMeta,
    
    111
    -                                             Serializable newValue) {
    
    112
    -
    
    113
    -        T3ReferenceEntity e = (T3ReferenceEntity)
    
    114
    -                super.getReferenceEntity(compoMeta, newValue);
    
    115
    -
    
    105
    +    protected TopiaEntity getReferenceEntity(T3AccessEntityMeta compoMeta, Serializable newValue) {
    
    106
    +        T3ReferenceEntity e = (T3ReferenceEntity) super.getReferenceEntity(compoMeta, newValue);
    
    116 107
             if (e == null) {
    
    117
    -
    
    118 108
                 // reference entity not found
    
    119 109
                 // add the entity in touched refs (to be able to know it is
    
    120 110
                 // missing...)
    
    121 111
                 try {
    
    122
    -                T3ReferenceEntity e2 =
    
    123
    -                        (T3ReferenceEntity) compoMeta.getType().getImplementation().getConstructor().newInstance();
    
    112
    +                T3ReferenceEntity e2 = (T3ReferenceEntity) compoMeta.getType().getImplementation().getConstructor().newInstance();
    
    124 113
                     EntityOperator operator = T3EntityEnum.getOperator(compoMeta.getType().getContract());
    
    125 114
                     operator.set("code", e2, newValue);
    
    126 115
                     getEntitiesTouched().addUniqueEntity(e2);
    
    127 116
                 } catch (Exception eee) {
    
    128
    -                if (log.isErrorEnabled()) {
    
    129
    -                    log.error("Could not create dummy reference entity", eee);
    
    130
    -                }
    
    117
    +                log.error("Could not create dummy reference entity", eee);
    
    131 118
                 }
    
    132
    -
    
    133 119
                 // still returns null entity
    
    134 120
                 return null;
    
    135 121
             }
    
    136
    -
    
    137 122
             boolean added = getEntitiesTouched().addUniqueEntity(e);
    
    138
    -
    
    139 123
             if (added && log.isDebugEnabled()) {
    
    140
    -            log.debug("Touched reference " + e.getTopiaId() + " : " +
    
    141
    -                              e.getCode());
    
    124
    +            log.debug(String.format("Touched reference %s : %d", e.getTopiaId(), e.getCode()));
    
    142 125
             }
    
    143 126
             return e;
    
    144 127
         }
    
    145 128
     
    
    146 129
         @Override
    
    147
    -    public void onVisitSimpleProperty(String propertyName,
    
    148
    -                                      Class<?> type,
    
    149
    -                                      T3AccessEntity entity,
    
    150
    -                                      T3AccessEntityMeta meta) {
    
    151
    -
    
    130
    +    public void onVisitSimpleProperty(String propertyName, Class<?> type, T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    152 131
             // just set the property into the entity
    
    153
    -
    
    154 132
             Serializable newValue = getProperty(propertyName, meta, row);
    
    155
    -
    
    156 133
             if (newValue != null) {
    
    157 134
                 if (log.isDebugEnabled()) {
    
    158 135
                     String colName = meta.getPropertyColumnName(propertyName);
    
    159
    -                log.debug("get property [" + propertyName + "] (type:" +
    
    160
    -                                  type.getName() + ") (dbcol:" + colName + ") = " +
    
    161
    -                                  newValue);
    
    136
    +                log.debug(String.format("get property [%s] (type:%s) (dbcol:%s) = %s", propertyName, type.getName(), colName, newValue));
    
    162 137
                 }
    
    163 138
                 entity.setProperty(propertyName, newValue);
    
    164 139
             }
    
    ... ... @@ -166,145 +141,91 @@ public class T3DataEntityVisitor extends AbstractT3EntityVisitor {
    166 141
     
    
    167 142
     
    
    168 143
         @Override
    
    169
    -    public void onVisitComposition(String propertyName,
    
    170
    -                                   Class<?> type,
    
    171
    -                                   T3AccessEntity entity,
    
    172
    -                                   T3AccessEntityMeta meta) {
    
    173
    -
    
    144
    +    public void onVisitComposition(String propertyName, Class<?> type, T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    174 145
             if (!deepVisit) {
    
    175 146
                 return;
    
    176 147
             }
    
    177
    -
    
    178 148
             // find the reference entity to add as composition
    
    179
    -
    
    180 149
             Serializable newValue = getProperty(propertyName, meta, row);
    
    181
    -
    
    182 150
             if (newValue == null) {
    
    183
    -
    
    184 151
                 return;
    
    185 152
             }
    
    186 153
     
    
    187
    -        AbstractAccessEntityMeta.PropertyMapping mapping =
    
    188
    -                meta.getPropertyMapping(propertyName);
    
    154
    +        AbstractAccessEntityMeta.PropertyMapping mapping = meta.getPropertyMapping(propertyName);
    
    189 155
             Class<?> compositionType = mapping.getType();
    
    190 156
     
    
    191 157
             T3AccessEntityMeta compoMeta;
    
    192 158
     
    
    193
    -        T3AccessEntityMeta[] compoMetas =
    
    194
    -                dataSource.getMetaForType(compositionType);
    
    159
    +        T3AccessEntityMeta[] compoMetas = dataSource.getMetaForType(compositionType);
    
    195 160
     
    
    196 161
             if (compoMetas.length == 0) {
    
    197 162
                 throw new IllegalStateException(
    
    198
    -                    "Skip composition [" + meta.getType() + " - " +
    
    199
    -                            propertyName + ":" + type + "], meta of type [" +
    
    200
    -                            compositionType + "] not found...");
    
    163
    +                    String.format("Skip composition [%s - %s:%s], meta of type [%s] not found...", meta.getType(), propertyName, type, compositionType));
    
    201 164
             }
    
    202 165
     
    
    203 166
             if (compoMetas.length > 1) {
    
    204 167
     
    
    205
    -            // on n'autorise pas d'avoir plusieurs méta à traiter
    
    206
    -            // il s'agit d'une reférence sur un référentiel
    
    168
    +            // on n'autorise pas d'avoir plusieurs méta à traiter il s'agit d'une reférence sur un référentiel
    
    207 169
                 throw new IllegalStateException(
    
    208
    -                    "Found more than one meta for referentiel type [" +
    
    209
    -                            compositionType + "] : " + Arrays.toString(compoMetas));
    
    170
    +                    String.format("Found more than one meta for referentiel type [%s] : %s", compositionType, Arrays.toString(compoMetas)));
    
    210 171
             }
    
    211 172
     
    
    212 173
             compoMeta = compoMetas[0];
    
    213
    -
    
    214 174
             TopiaEntity compoEntity = getReferenceEntity(compoMeta, newValue);
    
    215
    -
    
    216 175
             if (compoEntity == null) {
    
    217 176
     
    
    218 177
                 // could not find the correct composition entity
    
    219
    -            if (log.isDebugEnabled()) {
    
    220
    -                log.debug("Could not find referentiel entity for composition [" +
    
    221
    -                                  propertyName + ":" + compoMeta.getType() + ":" + newValue +
    
    222
    -                                  "] to " + entity);
    
    223
    -            }
    
    178
    +            log.debug(String.format("Could not find referentiel entity for composition [%s:%s:%s] to %s", propertyName, compoMeta.getType(), newValue, entity));
    
    224 179
                 return;
    
    225 180
             }
    
    226
    -
    
    227
    -        if (log.isDebugEnabled()) {
    
    228
    -            log.debug("Will add composition [" +
    
    229
    -                              propertyName + ":" + compoEntity + "] to " + entity);
    
    230
    -        }
    
    231
    -
    
    181
    +        log.debug(String.format("Will add composition [%s:%s] to %s", propertyName, compoEntity, entity));
    
    232 182
             // then affect it to this entity for the given property
    
    233 183
             entity.setProperty(propertyName, compoEntity);
    
    234 184
         }
    
    235 185
     
    
    186
    +    @SuppressWarnings("unchecked")
    
    236 187
         @Override
    
    237
    -    public void onVisitReverseAssociation(String propertyName,
    
    238
    -                                          T3AccessEntity entity,
    
    239
    -                                          T3AccessEntityMeta meta) {
    
    240
    -
    
    188
    +    public void onVisitReverseAssociation(String propertyName, T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    241 189
             if (!deepVisit) {
    
    242 190
                 return;
    
    243 191
             }
    
    244
    -
    
    245 192
             // on recherche dans la pile des objets en cours de construction
    
    246
    -        // l'objet maitre de l'association y est forcement puisque la création
    
    247
    -        // de l'entité en cours en dépend.
    
    248
    -        T3AccessEntityMeta.AssociationMapping reverse =
    
    249
    -                meta.getReverseAssociationMapping(propertyName);
    
    250
    -
    
    251
    -        Class<? extends TopiaEntity> type =
    
    252
    -                (Class<? extends TopiaEntity>) reverse.getType();
    
    193
    +        // l'objet maitre de l'association y est forcement puisque la création de l'entité en cours en dépend.
    
    194
    +        T3AccessEntityMeta.AssociationMapping reverse = meta.getReverseAssociationMapping(propertyName);
    
    195
    +        Class<? extends TopiaEntity> type = (Class<? extends TopiaEntity>) reverse.getType();
    
    253 196
     
    
    254 197
             TopiaEntity parent = getEntityFromStack(type);
    
    255
    -
    
    256 198
             if (parent == null) {
    
    257 199
                 // ce cas ne devrait jamais arrivé
    
    258 200
                 throw new IllegalStateException(
    
    259
    -                    "Could not find reverse association [" + propertyName
    
    260
    -                            + ":" + type + "] for one of his child " + entity);
    
    261
    -        }
    
    262
    -        if (log.isDebugEnabled()) {
    
    263
    -            log.debug("Will add reverse composition [" + propertyName + ":" +
    
    264
    -                              parent + "] to " + entity);
    
    201
    +                    String.format("Could not find reverse association [%s:%s] for one of his child %s", propertyName, type, entity));
    
    265 202
             }
    
    203
    +        log.debug(String.format("Will add reverse composition [%s:%s] to %s", propertyName, parent, entity));
    
    266 204
             entity.setProperty(propertyName, parent);
    
    267 205
         }
    
    268 206
     
    
    269 207
         @Override
    
    270
    -    public void onVisitAssociation(String propertyName,
    
    271
    -                                   Class<?> type,
    
    272
    -                                   T3AccessEntity entity,
    
    273
    -                                   T3AccessEntityMeta meta) {
    
    274
    -
    
    208
    +    public void onVisitAssociation(String propertyName, Class<?> type, T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    275 209
             if (!deepVisit) {
    
    276 210
                 return;
    
    277 211
             }
    
    278
    -
    
    279 212
             T3EntityEnum constant = T3EntityEnum.valueOf(type);
    
    213
    +        T3AccessEntityMeta[] childMeta = dataSource.getMetaForType(constant.getContract());
    
    214
    +        List<TopiaEntity> childs = new ArrayList<>();
    
    280 215
             TopiaEntity[] tmp;
    
    281
    -
    
    282
    -        List<TopiaEntity> childs = Lists.newArrayList();
    
    283
    -
    
    284
    -        T3AccessEntityMeta[] childMeta =
    
    285
    -                dataSource.getMetaForType(constant.getContract());
    
    286
    -
    
    287 216
             for (T3AccessEntityMeta accessEntityMeta : childMeta) {
    
    288
    -
    
    289 217
                 tmp = getAssociation(entity, propertyName, meta, accessEntityMeta);
    
    290
    -            if (log.isDebugEnabled()) {
    
    291
    -                log.debug(toString(entity) + " load association [" + constant + "] (meta:" +
    
    292
    -                                  accessEntityMeta + ") : " + tmp.length);
    
    293
    -            }
    
    218
    +            log.debug(String.format("%s load association [%s] (meta:%s) : %d", toString(entity), constant, accessEntityMeta, tmp.length));
    
    294 219
                 if (tmp.length > 0) {
    
    295 220
                     childs.addAll(Arrays.asList(tmp));
    
    296 221
                 }
    
    297 222
             }
    
    298
    -
    
    299 223
             if (childs.isEmpty()) {
    
    300 224
                 return;
    
    301 225
             }
    
    302 226
     
    
    303 227
             for (TopiaEntity child : childs) {
    
    304
    -            if (log.isDebugEnabled()) {
    
    305
    -                log.debug("Add association " + child);
    
    306
    -            }
    
    307
    -
    
    228
    +            log.debug(String.format("Add association %s", child));
    
    308 229
                 // on lance la découverte du fils
    
    309 230
                 acceptEntity(child);
    
    310 231
             }
    
    ... ... @@ -318,8 +239,24 @@ public class T3DataEntityVisitor extends AbstractT3EntityVisitor {
    318 239
             rows.clear();
    
    319 240
         }
    
    320 241
     
    
    321
    -    @SuppressWarnings({"unchecked"})
    
    322
    -    protected <T extends TopiaEntity> T getEntityFromStack(Class<T> type) {
    
    242
    +    protected <P extends TopiaEntity, E extends TopiaEntity, C extends TopiaEntity> ReverseAssociationGetter<P, E, C> newReverseAssociationGetter(
    
    243
    +            Class<P> parentType,
    
    244
    +            Class<E> type,
    
    245
    +            Class<C> childType,
    
    246
    +            String reverseAssociation,
    
    247
    +            String parentAssociation
    
    248
    +    ) {
    
    249
    +        return new ReverseAssociationGetter<>(parentType, type, childType, parentAssociation, reverseAssociation);
    
    250
    +    }
    
    251
    +
    
    252
    +    public List<MissingForeignKey> getMissingForeignKeys() {
    
    253
    +        if (missingForeignKeys == null) {
    
    254
    +            missingForeignKeys = new ArrayList<>();
    
    255
    +        }
    
    256
    +        return missingForeignKeys;
    
    257
    +    }
    
    258
    +
    
    259
    +    private <T extends TopiaEntity> T getEntityFromStack(Class<T> type) {
    
    323 260
             TopiaEntity entity = null;
    
    324 261
             for (TopiaEntity e : stack) {
    
    325 262
                 if (type.isAssignableFrom(e.getClass())) {
    
    ... ... @@ -327,69 +264,36 @@ public class T3DataEntityVisitor extends AbstractT3EntityVisitor {
    327 264
                     break;
    
    328 265
                 }
    
    329 266
             }
    
    330
    -        return (T) entity;
    
    267
    +        return type.cast(entity);
    
    331 268
         }
    
    332 269
     
    
    333
    -    protected TopiaEntity[] getAssociation(TopiaEntity entity,
    
    334
    -                                           String propertyName,
    
    335
    -                                           T3AccessEntityMeta meta,
    
    336
    -                                           T3AccessEntityMeta childMeta) {
    
    270
    +    private TopiaEntity[] getAssociation(TopiaEntity entity, String propertyName, T3AccessEntityMeta meta, T3AccessEntityMeta childMeta) {
    
    337 271
             TopiaEntity[] childs;
    
    338 272
             try {
    
    339
    -            childs = dataSource.loadAssociation(
    
    340
    -                    childMeta,
    
    341
    -                    meta,
    
    342
    -                    ((T3AccessEntity) entity).getPkey()
    
    343
    -            );
    
    273
    +            childs = dataSource.loadAssociation(childMeta, meta, ((T3AccessEntity) entity).getPkey());
    
    344 274
             } catch (Exception e) {
    
    345
    -            throw new IllegalStateException(
    
    346
    -                    "Could not obtain association [" + propertyName + "]", e);
    
    275
    +            throw new IllegalStateException(String.format("Could not obtain association [%s]", propertyName), e);
    
    347 276
             }
    
    348 277
             return childs;
    
    349 278
         }
    
    350 279
     
    
    351
    -    protected <P extends TopiaEntity, E extends TopiaEntity, C extends TopiaEntity> ReverseAssociationGetter<P, E, C> newReverseAssociationGetter(
    
    352
    -            Class<P> parentType,
    
    353
    -            Class<E> type,
    
    354
    -            Class<C> childType,
    
    355
    -            String reverseAssociation,
    
    356
    -            String parentAssociation
    
    357
    -    ) {
    
    358
    -        return new ReverseAssociationGetter<P, E, C>(parentType, type, childType, parentAssociation, reverseAssociation);
    
    359
    -    }
    
    360
    -
    
    361
    -    public List<MissingForeignKey> getMissingForeignKeys() {
    
    362
    -        if (missingForeignKeys == null) {
    
    363
    -            missingForeignKeys = Lists.newArrayList();
    
    364
    -        }
    
    365
    -        return missingForeignKeys;
    
    366
    -    }
    
    367
    -
    
    368 280
         protected class ReverseAssociationGetter<P extends TopiaEntity, E extends TopiaEntity, C extends TopiaEntity> {
    
    369 281
     
    
    370 282
             protected final Class<E> type;
    
    371
    -
    
    372
    -        protected final Class<P> parentType;
    
    373
    -
    
    374
    -        protected final Class<C> childType;
    
    375
    -
    
    283
    +        final Class<P> parentType;
    
    284
    +        final Class<C> childType;
    
    376 285
             private final T3EntityEnum typeEnum;
    
    377
    -
    
    378 286
             private final T3EntityEnum childTypeEnum;
    
    379
    -
    
    380 287
             private final EntityOperator<P> parentOperator;
    
    381
    -
    
    382 288
             private final EntityOperator<E> operator;
    
    383
    -
    
    384 289
             private final String parentAssociation;
    
    385
    -
    
    386 290
             private final String reverseAssociation;
    
    387 291
     
    
    388
    -        protected ReverseAssociationGetter(Class<P> parentType,
    
    389
    -                                           Class<E> type,
    
    390
    -                                           Class<C> childType,
    
    391
    -                                           String parentAssociation,
    
    392
    -                                           String reverseAssociation) {
    
    292
    +        ReverseAssociationGetter(Class<P> parentType,
    
    293
    +                                 Class<E> type,
    
    294
    +                                 Class<C> childType,
    
    295
    +                                 String parentAssociation,
    
    296
    +                                 String reverseAssociation) {
    
    393 297
                 this.parentType = parentType;
    
    394 298
                 this.type = type;
    
    395 299
                 this.childType = childType;
    
    ... ... @@ -402,49 +306,27 @@ public class T3DataEntityVisitor extends AbstractT3EntityVisitor {
    402 306
             }
    
    403 307
     
    
    404 308
             @SuppressWarnings({"unchecked"})
    
    405
    -        public void attachReverseAssocation(T3AccessEntity entity) {
    
    406
    -
    
    407
    -            // get child pkey from the pkey of the current entity
    
    309
    +        public void attachReverseAssociation(T3AccessEntity entity) {
    
    310
    +            // get child pKey from the pKey of the current entity
    
    408 311
                 Object[] pKey = getPKey(childTypeEnum);
    
    409
    -
    
    410 312
                 // get the parent entity which contains the association
    
    411 313
                 P parent = getEntityFromStack(parentType);
    
    412
    -
    
    413 314
                 // get the association from the given parent
    
    414
    -            Collection<? extends TopiaEntity> childs =
    
    415
    -                    (Collection<? extends TopiaEntity>)
    
    416
    -                            parentOperator.get(parentAssociation, parent);
    
    417
    -
    
    315
    +            Collection<? extends TopiaEntity> children = (Collection<? extends TopiaEntity>) parentOperator.get(parentAssociation, parent);
    
    418 316
                 // get the exact reverse association found by his pKey
    
    419
    -            TopiaEntity reverse = getEntityForPKey(pKey, childs);
    
    420
    -
    
    317
    +            TopiaEntity reverse = getEntityForPKey(pKey, children);
    
    421 318
                 if (reverse == null) {
    
    422
    -
    
    423 319
                     onReverseNotFound(entity, pKey);
    
    424 320
                 } else {
    
    425
    -
    
    426
    -                E topiaEntity = (E) entity;
    
    427
    -
    
    321
    +                E topiaEntity = type.cast(entity);
    
    428 322
                     operator.set(reverseAssociation, topiaEntity, reverse);
    
    429 323
                 }
    
    430 324
             }
    
    431 325
     
    
    432
    -        protected void onReverseNotFound(T3AccessEntity entity, Object[] pKey) {
    
    433
    -
    
    434
    -            String message = "Could not find " + childType.getSimpleName() +
    
    435
    -                    " " +
    
    436
    -                    Arrays.toString(pKey) + " for " +
    
    437
    -                    type.getSimpleName() + " " +
    
    438
    -                    Arrays.toString(entity.getPkey());
    
    439
    -            if (log.isDebugEnabled()) {
    
    440
    -                log.debug(message);
    
    441
    -            }
    
    442
    -            MissingForeignKey missingFK = new MissingForeignKey(
    
    443
    -                    typeEnum,
    
    444
    -                    childTypeEnum,
    
    445
    -                    entity.getPkey(),
    
    446
    -                    pKey
    
    447
    -            );
    
    326
    +        void onReverseNotFound(T3AccessEntity entity, Object[] pKey) {
    
    327
    +            String message = String.format("Could not find %s %s for %s %s", childType.getSimpleName(), Arrays.toString(pKey), type.getSimpleName(), Arrays.toString(entity.getPkey()));
    
    328
    +            log.debug(message);
    
    329
    +            MissingForeignKey missingFK = new MissingForeignKey(typeEnum, childTypeEnum, entity.getPkey(), pKey);
    
    448 330
                 getMissingForeignKeys().add(missingFK);
    
    449 331
             }
    
    450 332
         }
    

  • t3-domain/src/main/java/fr/ird/t3/services/migration/T3MigrationCallbackV2_3.java
    1 1
     package fr.ird.t3.services.migration;
    
    2 2
     
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * T3 :: Domain
    
    6
    + * %%
    
    7
    + * Copyright (C) 2010 - 2018 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 Affero General Public License as published by
    
    11
    + * the Free Software Foundation, either version 3 of the License, or
    
    12
    + * (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 Affero General Public License
    
    20
    + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    21
    + * #L%
    
    22
    + */
    
    23
    +
    
    3 24
     import com.google.auto.service.AutoService;
    
    4 25
     import org.apache.commons.logging.Log;
    
    5 26
     import org.apache.commons.logging.LogFactory;
    

  • t3-input-avdthv33/pom.xml
    ... ... @@ -93,10 +93,6 @@
    93 93
           <groupId>org.nuiton</groupId>
    
    94 94
           <artifactId>nuiton-version</artifactId>
    
    95 95
         </dependency>
    
    96
    -    <dependency>
    
    97
    -      <groupId>org.nuiton.topia</groupId>
    
    98
    -      <artifactId>topia-persistence</artifactId>
    
    99
    -    </dependency>
    
    100 96
     
    
    101 97
         <!-- test dependencies -->
    
    102 98
     
    

  • t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3AccessEntityMetaProviderAvdth33.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -69,9 +69,7 @@ import java.util.Set;
    69 69
      */
    
    70 70
     public class T3AccessEntityMetaProviderAvdth33 implements T3AccessEntityMetaProvider {
    
    71 71
     
    
    72
    -    /** Logger. */
    
    73
    -    private static final Log log =
    
    74
    -            LogFactory.getLog(T3AccessEntityMetaProviderAvdth33.class);
    
    72
    +    private static final Log log = LogFactory.getLog(T3AccessEntityMetaProviderAvdth33.class);
    
    75 73
     
    
    76 74
         @Override
    
    77 75
         public Set<T3AccessEntityMeta> getMetas() {
    
    ... ... @@ -463,64 +461,32 @@ public class T3AccessEntityMetaProviderAvdth33 implements T3AccessEntityMetaProv
    463 461
                     WeightCategoryWellPlan.PROPERTY_CODE, Integer.class, "C_CAT_POIDS",
    
    464 462
                     WeightCategoryWellPlan.PROPERTY_LABEL1, String.class, "L_CAT_POIDS"
    
    465 463
             );
    
    466
    -
    
    467 464
             return result;
    
    468 465
         }
    
    469 466
     
    
    470
    -//    protected void registerReferentielMeta(Set<T3AccessEntityMeta> universe,
    
    471
    -//                                           T3EntityEnum type,
    
    472
    -//                                           String tableName,
    
    473
    -//                                           String pkey) {
    
    474
    -//        registerReferentielMeta(universe,
    
    475
    -//                                type,
    
    476
    -//                                tableName,
    
    477
    -//                                new String[]{pkey},
    
    478
    -//                                "code",
    
    479
    -//                                String.class,
    
    480
    -//                                pkey
    
    481
    -//        );
    
    482
    -//    }
    
    483
    -
    
    484
    -    protected void registerReferentielMeta(Set<T3AccessEntityMeta> universe,
    
    485
    -                                           T3EntityEnum type,
    
    486
    -                                           String tableName,
    
    487
    -                                           String[] pkeys,
    
    488
    -                                           Object... properties) {
    
    489
    -        T3AccessEntityMeta meta = new T3AccessReferentielEntityMeta(
    
    490
    -                type,
    
    491
    -                tableName,
    
    492
    -                pkeys,
    
    493
    -                properties
    
    494
    -        );
    
    467
    +    private void registerReferentielMeta(Set<T3AccessEntityMeta> universe,
    
    468
    +                                         T3EntityEnum type,
    
    469
    +                                         String tableName,
    
    470
    +                                         String[] pKeys,
    
    471
    +                                         Object... properties) {
    
    472
    +        T3AccessEntityMeta meta = new T3AccessReferentielEntityMeta(type, tableName, pKeys, properties);
    
    495 473
             registerMeta(universe, meta);
    
    496
    -
    
    497 474
         }
    
    498 475
     
    
    499
    -    protected void registerDataMeta(Set<T3AccessEntityMeta> universe,
    
    500
    -                                    T3EntityEnum type,
    
    501
    -                                    String tableName,
    
    502
    -                                    String[] pkeys,
    
    503
    -                                    Object[] association,
    
    504
    -                                    Object[] reverseProperties,
    
    505
    -                                    Object... properties) {
    
    506
    -        T3AccessEntityMeta meta = new T3AccessDataEntityMeta(
    
    507
    -                type,
    
    508
    -                tableName,
    
    509
    -                pkeys,
    
    510
    -                association,
    
    511
    -                reverseProperties,
    
    512
    -                properties
    
    513
    -        );
    
    476
    +    private void registerDataMeta(Set<T3AccessEntityMeta> universe,
    
    477
    +                                  T3EntityEnum type,
    
    478
    +                                  String tableName,
    
    479
    +                                  String[] pKeys,
    
    480
    +                                  Object[] association,
    
    481
    +                                  Object[] reverseProperties,
    
    482
    +                                  Object... properties) {
    
    483
    +        T3AccessEntityMeta meta = new T3AccessDataEntityMeta(type, tableName, pKeys, association, reverseProperties, properties);
    
    514 484
             registerMeta(universe, meta);
    
    515 485
         }
    
    516 486
     
    
    517 487
     
    
    518
    -    protected void registerMeta(Set<T3AccessEntityMeta> universe,
    
    519
    -                                T3AccessEntityMeta meta) {
    
    520
    -        if (log.isDebugEnabled()) {
    
    521
    -            log.debug("add " + meta.getType() + ":" + meta.getTableName() +
    
    522
    -                      " to universe");
    
    523
    -        }
    
    488
    +    private void registerMeta(Set<T3AccessEntityMeta> universe, T3AccessEntityMeta meta) {
    
    489
    +        log.debug(String.format("add %s:%s to universe", meta.getType(), meta.getTableName()));
    
    524 490
             universe.add(meta);
    
    525 491
         }
    
    526 492
     }

  • t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3DataEntityVisitorAvdth33.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -21,28 +21,9 @@
    21 21
     package fr.ird.t3.io.input.avdth.v33;
    
    22 22
     
    
    23 23
     import fr.ird.t3.entities.ReferenceEntityMap;
    
    24
    -import fr.ird.t3.entities.T3EntityEnum;
    
    25
    -import fr.ird.t3.entities.T3TopiaApplicationContext;
    
    26
    -import fr.ird.t3.entities.data.Activity;
    
    27
    -import fr.ird.t3.entities.data.ElementaryCatch;
    
    28
    -import fr.ird.t3.entities.data.ElementaryLanding;
    
    29
    -import fr.ird.t3.entities.data.Sample;
    
    30
    -import fr.ird.t3.entities.data.SampleSet;
    
    31
    -import fr.ird.t3.entities.data.Trip;
    
    32
    -import fr.ird.t3.entities.data.Well;
    
    33
    -import fr.ird.t3.entities.data.WellPlan;
    
    34
    -import fr.ird.t3.entities.reference.WeightCategoryLanding;
    
    35
    -import fr.ird.t3.entities.reference.WeightCategoryLogBook;
    
    36
    -import fr.ird.t3.io.input.MissingForeignKeyInT3;
    
    24
    +import fr.ird.t3.io.input.access.T3AvdthDataEntityVisitor;
    
    37 25
     import fr.ird.t3.io.input.access.T3AccessDataSource;
    
    38
    -import fr.ird.t3.io.input.access.T3AccessEntity;
    
    39
    -import fr.ird.t3.io.input.access.T3AccessEntityMeta;
    
    40 26
     import fr.ird.t3.io.input.access.T3DataEntityVisitor;
    
    41
    -import fr.ird.type.CoordinateHelper;
    
    42
    -import java.io.Serializable;
    
    43
    -import org.apache.commons.logging.Log;
    
    44
    -import org.apache.commons.logging.LogFactory;
    
    45
    -import org.nuiton.topia.persistence.TopiaEntity;
    
    46 27
     
    
    47 28
     /**
    
    48 29
      * Implementation of {@link T3DataEntityVisitor} for the avdth v33 db.
    
    ... ... @@ -50,218 +31,10 @@ import org.nuiton.topia.persistence.TopiaEntity;
    50 31
      * @author Tony Chemit - dev@tchemit.fr
    
    51 32
      * @since 1.0
    
    52 33
      */
    
    53
    -public class T3DataEntityVisitorAvdth33 extends T3DataEntityVisitor {
    
    54
    -
    
    55
    -    /** Logger. */
    
    56
    -    private static final Log log =
    
    57
    -            LogFactory.getLog(T3DataEntityVisitorAvdth33.class);
    
    58
    -
    
    59
    -    protected final ReverseAssociationGetter<Trip, WellPlan, Activity> wellPlanReverse;
    
    34
    +class T3DataEntityVisitorAvdth33 extends T3AvdthDataEntityVisitor {
    
    60 35
     
    
    61
    -    protected final ReverseAssociationGetter<Trip, Sample, Well> sampleReverse;
    
    62
    -
    
    63
    -    protected final ReverseAssociationGetter<Trip, SampleSet, Activity> sampleSetReverse;
    
    64
    -
    
    65
    -    public T3DataEntityVisitorAvdth33(T3TopiaApplicationContext topiaApplicationContext,
    
    66
    -                                      T3AccessDataSource dataSource,
    
    67
    -                                      ReferenceEntityMap referentiel) {
    
    36
    +    T3DataEntityVisitorAvdth33(T3AccessDataSource dataSource, ReferenceEntityMap referentiel) {
    
    68 37
             super(dataSource, referentiel);
    
    69
    -
    
    70
    -        wellPlanReverse = newReverseAssociationGetter(
    
    71
    -                Trip.class,
    
    72
    -                WellPlan.class,
    
    73
    -                Activity.class,
    
    74
    -                Trip.PROPERTY_ACTIVITY,
    
    75
    -                WellPlan.PROPERTY_ACTIVITY
    
    76
    -        );
    
    77
    -
    
    78
    -        sampleReverse = newReverseAssociationGetter(
    
    79
    -                Trip.class,
    
    80
    -                Sample.class,
    
    81
    -                Well.class,
    
    82
    -                Trip.PROPERTY_WELL,
    
    83
    -                Sample.PROPERTY_WELL
    
    84
    -        );
    
    85
    -
    
    86
    -        sampleSetReverse = newReverseAssociationGetter(
    
    87
    -                Trip.class,
    
    88
    -                SampleSet.class,
    
    89
    -                Activity.class,
    
    90
    -                Trip.PROPERTY_ACTIVITY,
    
    91
    -                SampleSet.PROPERTY_ACTIVITY
    
    92
    -        );
    
    93
    -    }
    
    94
    -
    
    95
    -    @Override
    
    96
    -    public void onEnd(T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    97
    -
    
    98
    -        super.onEnd(entity, meta);
    
    99
    -
    
    100
    -        if (!deepVisit) {
    
    101
    -            return;
    
    102
    -        }
    
    103
    -
    
    104
    -        T3EntityEnum type = meta.getType();
    
    105
    -
    
    106
    -        if (type == T3EntityEnum.Activity) {
    
    107
    -
    
    108
    -            Activity a = (Activity) entity;
    
    109
    -
    
    110
    -            Integer quadrant = a.getQuadrant();
    
    111
    -            Float latitude = CoordinateHelper.getSignedLatitude(
    
    112
    -                    quadrant, a.getLatitude());
    
    113
    -            Float longitude = CoordinateHelper.getSignedLongitude(
    
    114
    -                    quadrant, a.getLongitude());
    
    115
    -            a.setLatitude(latitude);
    
    116
    -            a.setLongitude(longitude);
    
    117
    -
    
    118
    -            if (log.isDebugEnabled()) {
    
    119
    -                log.debug("Will use for activity " + entity +
    
    120
    -                          " coordinates <" + a.getLongitude() + "," +
    
    121
    -                          a.getLatitude() + ">");
    
    122
    -            }
    
    123
    -        }
    
    124
    -    }
    
    125
    -
    
    126
    -    @Override
    
    127
    -    public void onVisitReverseAssociation(String propertyName,
    
    128
    -                                          T3AccessEntity entity,
    
    129
    -                                          T3AccessEntityMeta meta) {
    
    130
    -
    
    131
    -        if (!deepVisit) {
    
    132
    -            return;
    
    133
    -        }
    
    134
    -
    
    135
    -        if (SampleSet.PROPERTY_ACTIVITY.equals(propertyName) &&
    
    136
    -            entity instanceof SampleSet) {
    
    137
    -
    
    138
    -            // special case, must obtain the activity from the trip
    
    139
    -
    
    140
    -            sampleSetReverse.attachReverseAssocation(entity);
    
    141
    -            return;
    
    142
    -        }
    
    143
    -
    
    144
    -        if (WellPlan.PROPERTY_ACTIVITY.equals(propertyName) &&
    
    145
    -            entity instanceof WellPlan) {
    
    146
    -
    
    147
    -            // special case, must obtain the activity from the trip
    
    148
    -
    
    149
    -            wellPlanReverse.attachReverseAssocation(entity);
    
    150
    -            return;
    
    151
    -        }
    
    152
    -
    
    153
    -        if (Sample.PROPERTY_WELL.equals(propertyName) &&
    
    154
    -            entity instanceof Sample) {
    
    155
    -
    
    156
    -            // special case, must obtain the well from the trip
    
    157
    -
    
    158
    -            sampleReverse.attachReverseAssocation(entity);
    
    159
    -            return;
    
    160
    -        }
    
    161
    -
    
    162
    -        super.onVisitReverseAssociation(propertyName, entity, meta);
    
    163 38
         }
    
    164 39
     
    
    165
    -    @Override
    
    166
    -    public void onVisitComposition(String propertyName,
    
    167
    -                                   Class<?> type,
    
    168
    -                                   T3AccessEntity entity,
    
    169
    -                                   T3AccessEntityMeta meta) {
    
    170
    -
    
    171
    -        if (ElementaryLanding.PROPERTY_WEIGHT_CATEGORY_LANDING.equals(propertyName)
    
    172
    -            && entity instanceof ElementaryLanding) {
    
    173
    -
    
    174
    -            Serializable codeEspece = getProperty("C_ESP", row);
    
    175
    -            Serializable codeCate = getProperty("C_CAT_C", row);
    
    176
    -
    
    177
    -            // must found the species
    
    178
    -            T3AccessEntityMeta specieMeta =
    
    179
    -                    dataSource.getMeta(T3EntityEnum.Species);
    
    180
    -
    
    181
    -            TopiaEntity specie = getReferenceEntity(specieMeta, codeEspece);
    
    182
    -
    
    183
    -            T3AccessEntityMeta categoryMeta =
    
    184
    -                    dataSource.getMeta(T3EntityEnum.WeightCategoryLanding);
    
    185
    -
    
    186
    -            // special case : need to find a reference with two primary keys...
    
    187
    -            TopiaEntity ref = getReferenceEntity(
    
    188
    -                    categoryMeta,
    
    189
    -                    new String[]{WeightCategoryLanding.PROPERTY_CODE, WeightCategoryLanding.PROPERTY_SPECIES},
    
    190
    -                    codeCate, specie
    
    191
    -            );
    
    192
    -
    
    193
    -            if (ref == null) {
    
    194
    -
    
    195
    -                if (log.isWarnEnabled()) {
    
    196
    -                    log.warn("Can't find WeightCategoryLanding for speciesCode / categoryCode: " + codeEspece + "/" + codeCate);
    
    197
    -                }
    
    198
    -                getMissingForeignKeys().add(new MissingForeignKeyInT3(
    
    199
    -                        T3EntityEnum.ElementaryLanding,
    
    200
    -                        T3EntityEnum.WeightCategoryLanding,
    
    201
    -                        getPKey(T3EntityEnum.ElementaryLanding),
    
    202
    -                        new Object[]{codeEspece, codeCate}
    
    203
    -                ));
    
    204
    -
    
    205
    -            } else {
    
    206
    -
    
    207
    -                if (log.isDebugEnabled()) {
    
    208
    -                    log.debug("Detected landing catch weight category : " + ref);
    
    209
    -                }
    
    210
    -                entity.setProperty(propertyName, ref);
    
    211
    -
    
    212
    -            }
    
    213
    -
    
    214
    -            return;
    
    215
    -        }
    
    216
    -
    
    217
    -        if (ElementaryCatch.PROPERTY_WEIGHT_CATEGORY_LOG_BOOK.equals(propertyName)
    
    218
    -            && entity instanceof ElementaryCatch) {
    
    219
    -
    
    220
    -            // special case : need to find a reference with two primary keys...
    
    221
    -
    
    222
    -            Serializable codeEspece = getProperty("C_ESP", row);
    
    223
    -            Serializable codeCate = getProperty("C_CAT_T", row);
    
    224
    -
    
    225
    -            // must found the species
    
    226
    -            T3AccessEntityMeta specieMeta =
    
    227
    -                    dataSource.getMeta(T3EntityEnum.Species);
    
    228
    -
    
    229
    -            TopiaEntity specie = getReferenceEntity(specieMeta, codeEspece);
    
    230
    -
    
    231
    -            T3AccessEntityMeta categoryMeta =
    
    232
    -                    dataSource.getMeta(T3EntityEnum.WeightCategoryLogBook);
    
    233
    -
    
    234
    -            // special case : need to find a reference with two primary keys...
    
    235
    -            TopiaEntity ref = getReferenceEntity(
    
    236
    -                    categoryMeta,
    
    237
    -                    new String[]{WeightCategoryLogBook.PROPERTY_CODE, WeightCategoryLogBook.PROPERTY_SPECIES},
    
    238
    -                    codeCate, specie
    
    239
    -            );
    
    240
    -
    
    241
    -            if (ref == null) {
    
    242
    -
    
    243
    -                if (log.isWarnEnabled()) {
    
    244
    -                    log.warn("Can't find weightCategoryLogBook for speciesCode / categoryCode: " + codeEspece + "/" + codeCate);
    
    245
    -                }
    
    246
    -                getMissingForeignKeys().add(new MissingForeignKeyInT3(
    
    247
    -                        T3EntityEnum.ElementaryCatch,
    
    248
    -                        T3EntityEnum.WeightCategoryLogBook,
    
    249
    -                        getPKey(T3EntityEnum.ElementaryCatch),
    
    250
    -                        new Object[]{codeCate, codeEspece}
    
    251
    -                ));
    
    252
    -
    
    253
    -            } else {
    
    254
    -
    
    255
    -                if (log.isDebugEnabled()) {
    
    256
    -                    log.debug("Detected logBook catch weight category : " + ref);
    
    257
    -                }
    
    258
    -                entity.setProperty(propertyName, ref);
    
    259
    -
    
    260
    -            }
    
    261
    -
    
    262
    -            return;
    
    263
    -        }
    
    264
    -
    
    265
    -        super.onVisitComposition(propertyName, type, entity, meta);
    
    266
    -    }
    
    267 40
     }

  • t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputAvdth33.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -27,6 +27,7 @@ import fr.ird.t3.io.input.T3Input;
    27 27
     import fr.ird.t3.io.input.access.AbstractT3InputMSAccess;
    
    28 28
     import fr.ird.t3.io.input.access.T3AccessDataSource;
    
    29 29
     import fr.ird.t3.io.input.access.T3DataEntityVisitor;
    
    30
    +
    
    30 31
     import java.io.File;
    
    31 32
     
    
    32 33
     /**
    
    ... ... @@ -37,18 +38,7 @@ import java.io.File;
    37 38
      */
    
    38 39
     public class T3InputAvdth33 extends AbstractT3InputMSAccess {
    
    39 40
     
    
    40
    -    @Override
    
    41
    -    public T3AccessDataSource newDataSource(File inputFile) {
    
    42
    -        return new T3AccessDataSource(inputFile, T3AccessEntityMetaProviderAvdth33.class);
    
    43
    -    }
    
    44
    -
    
    45
    -    @Override
    
    46
    -    public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) {
    
    47
    -
    
    48
    -        return new T3DataEntityVisitorAvdth33(getConfiguration().getTopiaApplicationContext(), dataSource, safeReferences);
    
    49
    -    }
    
    50
    -
    
    51
    -    public static final ImmutableSet<T3EntityEnum> REFERENCE_TYPES =
    
    41
    +    private static final ImmutableSet<T3EntityEnum> REFERENCE_TYPES =
    
    52 42
                 ImmutableSet.of(
    
    53 43
                         T3EntityEnum.VesselActivity,
    
    54 44
                         T3EntityEnum.VesselSizeCategory,
    
    ... ... @@ -66,18 +56,12 @@ public class T3InputAvdth33 extends AbstractT3InputMSAccess {
    66 56
                         T3EntityEnum.WeightCategoryLogBook,
    
    67 57
                         T3EntityEnum.WellDestiny,
    
    68 58
                         T3EntityEnum.WeightCategoryWellPlan);
    
    69
    -
    
    70
    -    @Override
    
    71
    -    public ImmutableSet<T3EntityEnum> getReferenceTypes() {
    
    72
    -        return REFERENCE_TYPES;
    
    73
    -    }
    
    74
    -
    
    75 59
         /**
    
    76 60
          * Set of all importable data types from ms-access.
    
    77 61
          *
    
    78 62
          * @since 2.0
    
    79 63
          */
    
    80
    -    public static final ImmutableSet<T3EntityEnum> IMPORTABLE_DATA_TYPES =
    
    64
    +    private static final ImmutableSet<T3EntityEnum> IMPORTABLE_DATA_TYPES =
    
    81 65
                 ImmutableSet.of(
    
    82 66
                         T3EntityEnum.Activity,
    
    83 67
                         T3EntityEnum.ActivityFishingContext,
    
    ... ... @@ -92,6 +76,22 @@ public class T3InputAvdth33 extends AbstractT3InputMSAccess {
    92 76
                         T3EntityEnum.WellPlan);
    
    93 77
     
    
    94 78
         @Override
    
    79
    +    public T3AccessDataSource newDataSource(File inputFile) {
    
    80
    +        return new T3AccessDataSource(inputFile, T3AccessEntityMetaProviderAvdth33.class);
    
    81
    +    }
    
    82
    +
    
    83
    +    @Override
    
    84
    +    public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) {
    
    85
    +
    
    86
    +        return new T3DataEntityVisitorAvdth33(dataSource, safeReferences);
    
    87
    +    }
    
    88
    +
    
    89
    +    @Override
    
    90
    +    public ImmutableSet<T3EntityEnum> getReferenceTypes() {
    
    91
    +        return REFERENCE_TYPES;
    
    92
    +    }
    
    93
    +
    
    94
    +    @Override
    
    95 95
         public ImmutableSet<T3EntityEnum> getDataTypes() {
    
    96 96
             return IMPORTABLE_DATA_TYPES;
    
    97 97
         }
    

  • t3-input-avdthv33/src/main/java/fr/ird/t3/io/input/avdth/v33/T3InputProviderAvdth33.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -23,10 +23,11 @@ package fr.ird.t3.io.input.avdth.v33;
    23 23
     import com.google.auto.service.AutoService;
    
    24 24
     import fr.ird.t3.io.input.T3Input;
    
    25 25
     import fr.ird.t3.io.input.T3InputProvider;
    
    26
    -import java.io.File;
    
    27 26
     import org.nuiton.version.Version;
    
    28 27
     import org.nuiton.version.Versions;
    
    29 28
     
    
    29
    +import java.io.File;
    
    30
    +
    
    30 31
     /**
    
    31 32
      * Provides input for avdth.
    
    32 33
      *
    
    ... ... @@ -37,11 +38,8 @@ import org.nuiton.version.Versions;
    37 38
     public class T3InputProviderAvdth33 implements T3InputProvider {
    
    38 39
     
    
    39 40
         private static final long serialVersionUID = 1L;
    
    40
    -
    
    41
    -    public static final Version VERSION = Versions.valueOf("3.3");
    
    42
    -
    
    43
    -    public static final String NAME = "AVDTH";
    
    44
    -
    
    41
    +    private static final Version VERSION = Versions.valueOf("3.3");
    
    42
    +    private static final String NAME = "AVDTH";
    
    45 43
         public static final String ID = NAME + "__" + VERSION;
    
    46 44
     
    
    47 45
         @Override
    
    ... ... @@ -65,8 +63,8 @@ public class T3InputProviderAvdth33 implements T3InputProvider {
    65 63
         }
    
    66 64
     
    
    67 65
         @Override
    
    68
    -    public String getLibelle() {
    
    69
    -        return getName() + " - v." + getVersion() + " (" + getInputType() + ")";
    
    66
    +    public String getLabel() {
    
    67
    +        return String.format("%s - v.%s (%s)", getName(), getVersion(), getInputType());
    
    70 68
         }
    
    71 69
     
    
    72 70
         @Override
    
    ... ... @@ -82,9 +80,7 @@ public class T3InputProviderAvdth33 implements T3InputProvider {
    82 80
             if (!(o instanceof T3InputProvider)) {
    
    83 81
                 return false;
    
    84 82
             }
    
    85
    -
    
    86 83
             T3InputProvider that = (T3InputProvider) o;
    
    87
    -
    
    88 84
             return ID.equals(that.getId());
    
    89 85
         }
    
    90 86
     
    

  • t3-input-avdthv35/pom.xml
    ... ... @@ -94,11 +94,6 @@
    94 94
           <artifactId>nuiton-version</artifactId>
    
    95 95
         </dependency>
    
    96 96
     
    
    97
    -    <dependency>
    
    98
    -      <groupId>org.nuiton.topia</groupId>
    
    99
    -      <artifactId>topia-persistence</artifactId>
    
    100
    -    </dependency>
    
    101
    -
    
    102 97
         <!-- test dependencies -->
    
    103 98
     
    
    104 99
         <dependency>
    

  • t3-input-avdthv35/src/main/java/fr/ird/t3/io/input/avdth/v35/T3AccessEntityMetaProviderAvdth35.java
    ... ... @@ -20,7 +20,6 @@
    20 20
      */
    
    21 21
     package fr.ird.t3.io.input.avdth.v35;
    
    22 22
     
    
    23
    -import com.google.common.collect.Sets;
    
    24 23
     import fr.ird.msaccess.type.IntToCoordonne;
    
    25 24
     import fr.ird.t3.entities.T3EntityEnum;
    
    26 25
     import fr.ird.t3.entities.data.Activity;
    
    ... ... @@ -71,6 +70,7 @@ import org.apache.commons.logging.Log;
    71 70
     import org.apache.commons.logging.LogFactory;
    
    72 71
     
    
    73 72
     import java.util.Date;
    
    73
    +import java.util.LinkedHashSet;
    
    74 74
     import java.util.Set;
    
    75 75
     
    
    76 76
     /**
    
    ... ... @@ -81,12 +81,11 @@ import java.util.Set;
    81 81
      */
    
    82 82
     public class T3AccessEntityMetaProviderAvdth35 implements T3AccessEntityMetaProvider {
    
    83 83
     
    
    84
    -    /** Logger. */
    
    85 84
         private static final Log log = LogFactory.getLog(T3AccessEntityMetaProviderAvdth35.class);
    
    86 85
     
    
    87 86
         @Override
    
    88 87
         public Set<T3AccessEntityMeta> getMetas() {
    
    89
    -        Set<T3AccessEntityMeta> result = Sets.newLinkedHashSet();
    
    88
    +        Set<T3AccessEntityMeta> result = new LinkedHashSet<>();
    
    90 89
     
    
    91 90
             // ACTIVITE : [C_BAT, C_OCEA, C_OPERA, C_TBANC, D_ACT, D_DBQ, F_CUVE_C, F_DON_ORG, F_EXPERT, F_OBS, F_POS_COR, F_POS_VMS_D, H_ACT, N_ACT, Q_ACT, V_COUR_DIR, V_COUR_VIT, V_LAT, V_LON, V_NB_OP, V_POIDS_CAP, V_TEMP_S, V_TMER, V_TPEC]
    
    92 91
             registerDataMeta(
    
    ... ... @@ -655,45 +654,30 @@ public class T3AccessEntityMetaProviderAvdth35 implements T3AccessEntityMetaProv
    655 654
             return result;
    
    656 655
         }
    
    657 656
     
    
    658
    -    protected void registerReferentielMeta(Set<T3AccessEntityMeta> universe,
    
    659
    -                                           T3EntityEnum type,
    
    660
    -                                           String tableName,
    
    661
    -                                           String[] pkeys,
    
    662
    -                                           Object... properties) {
    
    663
    -        T3AccessEntityMeta meta = new T3AccessReferentielEntityMeta(
    
    664
    -                type,
    
    665
    -                tableName,
    
    666
    -                pkeys,
    
    667
    -                properties
    
    668
    -        );
    
    657
    +    private void registerReferentielMeta(Set<T3AccessEntityMeta> universe,
    
    658
    +                                         T3EntityEnum type,
    
    659
    +                                         String tableName,
    
    660
    +                                         String[] pKeys,
    
    661
    +                                         Object... properties) {
    
    662
    +        T3AccessEntityMeta meta = new T3AccessReferentielEntityMeta(type, tableName, pKeys, properties);
    
    669 663
             registerMeta(universe, meta);
    
    670 664
     
    
    671 665
         }
    
    672 666
     
    
    673
    -    protected void registerDataMeta(Set<T3AccessEntityMeta> universe,
    
    674
    -                                    T3EntityEnum type,
    
    675
    -                                    String tableName,
    
    676
    -                                    String[] pkeys,
    
    677
    -                                    Object[] association,
    
    678
    -                                    Object[] reverseProperties,
    
    679
    -                                    Object... properties) {
    
    680
    -        T3AccessEntityMeta meta = new T3AccessDataEntityMeta(
    
    681
    -                type,
    
    682
    -                tableName,
    
    683
    -                pkeys,
    
    684
    -                association,
    
    685
    -                reverseProperties,
    
    686
    -                properties
    
    687
    -        );
    
    667
    +    private void registerDataMeta(Set<T3AccessEntityMeta> universe,
    
    668
    +                                  T3EntityEnum type,
    
    669
    +                                  String tableName,
    
    670
    +                                  String[] pKeys,
    
    671
    +                                  Object[] association,
    
    672
    +                                  Object[] reverseProperties,
    
    673
    +                                  Object... properties) {
    
    674
    +        T3AccessEntityMeta meta = new T3AccessDataEntityMeta(type, tableName, pKeys, association, reverseProperties, properties);
    
    688 675
             registerMeta(universe, meta);
    
    689 676
         }
    
    690 677
     
    
    691 678
     
    
    692
    -    protected void registerMeta(Set<T3AccessEntityMeta> universe,
    
    693
    -                                T3AccessEntityMeta meta) {
    
    694
    -        if (log.isDebugEnabled()) {
    
    695
    -            log.debug("add " + meta.getType() + ":" + meta.getTableName() + " to universe");
    
    696
    -        }
    
    679
    +    private void registerMeta(Set<T3AccessEntityMeta> universe, T3AccessEntityMeta meta) {
    
    680
    +        log.debug(String.format("add %s:%s to universe", meta.getType(), meta.getTableName()));
    
    697 681
             universe.add(meta);
    
    698 682
         }
    
    699 683
     }

  • t3-input-avdthv35/src/main/java/fr/ird/t3/io/input/avdth/v35/T3DataEntityVisitorAvdth35.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -21,28 +21,9 @@
    21 21
     package fr.ird.t3.io.input.avdth.v35;
    
    22 22
     
    
    23 23
     import fr.ird.t3.entities.ReferenceEntityMap;
    
    24
    -import fr.ird.t3.entities.T3EntityEnum;
    
    25
    -import fr.ird.t3.entities.T3TopiaApplicationContext;
    
    26
    -import fr.ird.t3.entities.data.Activity;
    
    27
    -import fr.ird.t3.entities.data.ElementaryCatch;
    
    28
    -import fr.ird.t3.entities.data.ElementaryLanding;
    
    29
    -import fr.ird.t3.entities.data.Sample;
    
    30
    -import fr.ird.t3.entities.data.SampleSet;
    
    31
    -import fr.ird.t3.entities.data.Trip;
    
    32
    -import fr.ird.t3.entities.data.Well;
    
    33
    -import fr.ird.t3.entities.data.WellPlan;
    
    34
    -import fr.ird.t3.entities.reference.WeightCategoryLanding;
    
    35
    -import fr.ird.t3.entities.reference.WeightCategoryLogBook;
    
    36
    -import fr.ird.t3.io.input.MissingForeignKeyInT3;
    
    24
    +import fr.ird.t3.io.input.access.T3AvdthDataEntityVisitor;
    
    37 25
     import fr.ird.t3.io.input.access.T3AccessDataSource;
    
    38
    -import fr.ird.t3.io.input.access.T3AccessEntity;
    
    39
    -import fr.ird.t3.io.input.access.T3AccessEntityMeta;
    
    40 26
     import fr.ird.t3.io.input.access.T3DataEntityVisitor;
    
    41
    -import fr.ird.type.CoordinateHelper;
    
    42
    -import java.io.Serializable;
    
    43
    -import org.apache.commons.logging.Log;
    
    44
    -import org.apache.commons.logging.LogFactory;
    
    45
    -import org.nuiton.topia.persistence.TopiaEntity;
    
    46 27
     
    
    47 28
     /**
    
    48 29
      * Implementation of {@link T3DataEntityVisitor} for the avdth v35 db.
    
    ... ... @@ -50,217 +31,9 @@ import org.nuiton.topia.persistence.TopiaEntity;
    50 31
      * @author Tony Chemit - dev@tchemit.fr
    
    51 32
      * @since 1.0
    
    52 33
      */
    
    53
    -public class T3DataEntityVisitorAvdth35 extends T3DataEntityVisitor {
    
    54
    -
    
    55
    -    /** Logger. */
    
    56
    -    private static final Log log = LogFactory.getLog(T3DataEntityVisitorAvdth35.class);
    
    57
    -
    
    58
    -    protected final ReverseAssociationGetter<Trip, WellPlan, Activity> wellPlanReverse;
    
    34
    +class T3DataEntityVisitorAvdth35 extends T3AvdthDataEntityVisitor {
    
    59 35
     
    
    60
    -    protected final ReverseAssociationGetter<Trip, Sample, Well> sampleReverse;
    
    61
    -
    
    62
    -    protected final ReverseAssociationGetter<Trip, SampleSet, Activity> sampleSetReverse;
    
    63
    -
    
    64
    -    public T3DataEntityVisitorAvdth35(T3TopiaApplicationContext topiaApplicationContext,
    
    65
    -                                      T3AccessDataSource dataSource,
    
    66
    -                                      ReferenceEntityMap referentiel) {
    
    36
    +    T3DataEntityVisitorAvdth35(T3AccessDataSource dataSource, ReferenceEntityMap referentiel) {
    
    67 37
             super(dataSource, referentiel);
    
    68
    -
    
    69
    -        wellPlanReverse = newReverseAssociationGetter(
    
    70
    -                Trip.class,
    
    71
    -                WellPlan.class,
    
    72
    -                Activity.class,
    
    73
    -                Trip.PROPERTY_ACTIVITY,
    
    74
    -                WellPlan.PROPERTY_ACTIVITY
    
    75
    -        );
    
    76
    -
    
    77
    -        sampleReverse = newReverseAssociationGetter(
    
    78
    -                Trip.class,
    
    79
    -                Sample.class,
    
    80
    -                Well.class,
    
    81
    -                Trip.PROPERTY_WELL,
    
    82
    -                Sample.PROPERTY_WELL
    
    83
    -        );
    
    84
    -
    
    85
    -        sampleSetReverse = newReverseAssociationGetter(
    
    86
    -                Trip.class,
    
    87
    -                SampleSet.class,
    
    88
    -                Activity.class,
    
    89
    -                Trip.PROPERTY_ACTIVITY,
    
    90
    -                SampleSet.PROPERTY_ACTIVITY
    
    91
    -        );
    
    92
    -    }
    
    93
    -
    
    94
    -    @Override
    
    95
    -    public void onEnd(T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    96
    -
    
    97
    -        super.onEnd(entity, meta);
    
    98
    -
    
    99
    -        if (!deepVisit) {
    
    100
    -            return;
    
    101
    -        }
    
    102
    -
    
    103
    -        T3EntityEnum type = meta.getType();
    
    104
    -
    
    105
    -        if (type == T3EntityEnum.Activity) {
    
    106
    -
    
    107
    -            Activity a = (Activity) entity;
    
    108
    -
    
    109
    -            Integer quadrant = a.getQuadrant();
    
    110
    -            Float latitude = CoordinateHelper.getSignedLatitude(
    
    111
    -                    quadrant, a.getLatitude());
    
    112
    -            Float longitude = CoordinateHelper.getSignedLongitude(
    
    113
    -                    quadrant, a.getLongitude());
    
    114
    -            a.setLatitude(latitude);
    
    115
    -            a.setLongitude(longitude);
    
    116
    -
    
    117
    -            if (log.isDebugEnabled()) {
    
    118
    -                log.debug("Will use for activity " + entity +
    
    119
    -                          " coordinates <" + a.getLongitude() + "," +
    
    120
    -                          a.getLatitude() + ">");
    
    121
    -            }
    
    122
    -        }
    
    123
    -    }
    
    124
    -
    
    125
    -    @Override
    
    126
    -    public void onVisitReverseAssociation(String propertyName,
    
    127
    -                                          T3AccessEntity entity,
    
    128
    -                                          T3AccessEntityMeta meta) {
    
    129
    -
    
    130
    -        if (!deepVisit) {
    
    131
    -            return;
    
    132
    -        }
    
    133
    -
    
    134
    -        if (SampleSet.PROPERTY_ACTIVITY.equals(propertyName) &&
    
    135
    -            entity instanceof SampleSet) {
    
    136
    -
    
    137
    -            // special case, must obtain the activity from the trip
    
    138
    -
    
    139
    -            sampleSetReverse.attachReverseAssocation(entity);
    
    140
    -            return;
    
    141
    -        }
    
    142
    -
    
    143
    -        if (WellPlan.PROPERTY_ACTIVITY.equals(propertyName) &&
    
    144
    -            entity instanceof WellPlan) {
    
    145
    -
    
    146
    -            // special case, must obtain the activity from the trip
    
    147
    -
    
    148
    -            wellPlanReverse.attachReverseAssocation(entity);
    
    149
    -            return;
    
    150
    -        }
    
    151
    -
    
    152
    -        if (Sample.PROPERTY_WELL.equals(propertyName) &&
    
    153
    -            entity instanceof Sample) {
    
    154
    -
    
    155
    -            // special case, must obtain the well from the trip
    
    156
    -
    
    157
    -            sampleReverse.attachReverseAssocation(entity);
    
    158
    -            return;
    
    159
    -        }
    
    160
    -
    
    161
    -        super.onVisitReverseAssociation(propertyName, entity, meta);
    
    162
    -    }
    
    163
    -
    
    164
    -    @Override
    
    165
    -    public void onVisitComposition(String propertyName,
    
    166
    -                                   Class<?> type,
    
    167
    -                                   T3AccessEntity entity,
    
    168
    -                                   T3AccessEntityMeta meta) {
    
    169
    -
    
    170
    -        if (ElementaryLanding.PROPERTY_WEIGHT_CATEGORY_LANDING.equals(propertyName)
    
    171
    -            && entity instanceof ElementaryLanding) {
    
    172
    -
    
    173
    -            Serializable codeEspece = getProperty("C_ESP", row);
    
    174
    -            Serializable codeCate = getProperty("C_CAT_C", row);
    
    175
    -
    
    176
    -            // must found the species
    
    177
    -            T3AccessEntityMeta specieMeta =
    
    178
    -                    dataSource.getMeta(T3EntityEnum.Species);
    
    179
    -
    
    180
    -            TopiaEntity specie = getReferenceEntity(specieMeta, codeEspece);
    
    181
    -
    
    182
    -            T3AccessEntityMeta categoryMeta =
    
    183
    -                    dataSource.getMeta(T3EntityEnum.WeightCategoryLanding);
    
    184
    -
    
    185
    -            // special case : need to find a reference with two primary keys...
    
    186
    -            TopiaEntity ref = getReferenceEntity(
    
    187
    -                    categoryMeta,
    
    188
    -                    new String[]{WeightCategoryLanding.PROPERTY_CODE, WeightCategoryLanding.PROPERTY_SPECIES},
    
    189
    -                    codeCate, specie
    
    190
    -            );
    
    191
    -
    
    192
    -            if (ref == null) {
    
    193
    -
    
    194
    -                if (log.isWarnEnabled()) {
    
    195
    -                    log.warn("Can't find WeightCategoryLanding for speciesCode / categoryCode: " + codeEspece + "/" + codeCate);
    
    196
    -                }
    
    197
    -                getMissingForeignKeys().add(new MissingForeignKeyInT3(
    
    198
    -                        T3EntityEnum.ElementaryLanding,
    
    199
    -                        T3EntityEnum.WeightCategoryLanding,
    
    200
    -                        getPKey(T3EntityEnum.ElementaryLanding),
    
    201
    -                        new Object[]{codeEspece, codeCate}
    
    202
    -                ));
    
    203
    -
    
    204
    -            } else {
    
    205
    -
    
    206
    -                if (log.isDebugEnabled()) {
    
    207
    -                    log.debug("Detected landing catch weight category : " + ref);
    
    208
    -                }
    
    209
    -                entity.setProperty(propertyName, ref);
    
    210
    -
    
    211
    -            }
    
    212
    -
    
    213
    -            return;
    
    214
    -        }
    
    215
    -
    
    216
    -        if (ElementaryCatch.PROPERTY_WEIGHT_CATEGORY_LOG_BOOK.equals(propertyName)
    
    217
    -            && entity instanceof ElementaryCatch) {
    
    218
    -
    
    219
    -            // special case : need to find a reference with two primary keys...
    
    220
    -
    
    221
    -            Serializable codeEspece = getProperty("C_ESP", row);
    
    222
    -            Serializable codeCate = getProperty("C_CAT_T", row);
    
    223
    -
    
    224
    -            // must found the species
    
    225
    -            T3AccessEntityMeta specieMeta =
    
    226
    -                    dataSource.getMeta(T3EntityEnum.Species);
    
    227
    -
    
    228
    -            TopiaEntity specie = getReferenceEntity(specieMeta, codeEspece);
    
    229
    -
    
    230
    -            T3AccessEntityMeta categoryMeta =
    
    231
    -                    dataSource.getMeta(T3EntityEnum.WeightCategoryLogBook);
    
    232
    -
    
    233
    -            // special case : need to find a reference with two primary keys...
    
    234
    -            TopiaEntity ref = getReferenceEntity(
    
    235
    -                    categoryMeta,
    
    236
    -                    new String[]{WeightCategoryLogBook.PROPERTY_CODE, WeightCategoryLogBook.PROPERTY_SPECIES},
    
    237
    -                    codeCate, specie
    
    238
    -            );
    
    239
    -
    
    240
    -            if (ref == null) {
    
    241
    -
    
    242
    -                if (log.isWarnEnabled()) {
    
    243
    -                    log.warn("Can't find weightCategoryLogBook for speciesCode / categoryCode: " + codeEspece + "/" + codeCate);
    
    244
    -                }
    
    245
    -                getMissingForeignKeys().add(new MissingForeignKeyInT3(
    
    246
    -                        T3EntityEnum.ElementaryCatch,
    
    247
    -                        T3EntityEnum.WeightCategoryLogBook,
    
    248
    -                        getPKey(T3EntityEnum.ElementaryCatch),
    
    249
    -                        new Object[]{codeCate, codeEspece}
    
    250
    -                ));
    
    251
    -
    
    252
    -            } else {
    
    253
    -
    
    254
    -                if (log.isDebugEnabled()) {
    
    255
    -                    log.debug("Detected logBook catch weight category : " + ref);
    
    256
    -                }
    
    257
    -                entity.setProperty(propertyName, ref);
    
    258
    -
    
    259
    -            }
    
    260
    -
    
    261
    -            return;
    
    262
    -        }
    
    263
    -
    
    264
    -        super.onVisitComposition(propertyName, type, entity, meta);
    
    265 38
         }
    
    266 39
     }

  • t3-input-avdthv35/src/main/java/fr/ird/t3/io/input/avdth/v35/T3InputAvdth35.java
    ... ... @@ -27,6 +27,7 @@ import fr.ird.t3.io.input.T3Input;
    27 27
     import fr.ird.t3.io.input.access.AbstractT3InputMSAccess;
    
    28 28
     import fr.ird.t3.io.input.access.T3AccessDataSource;
    
    29 29
     import fr.ird.t3.io.input.access.T3DataEntityVisitor;
    
    30
    +
    
    30 31
     import java.io.File;
    
    31 32
     
    
    32 33
     /**
    
    ... ... @@ -37,21 +38,7 @@ import java.io.File;
    37 38
      */
    
    38 39
     public class T3InputAvdth35 extends AbstractT3InputMSAccess {
    
    39 40
     
    
    40
    -    @Override
    
    41
    -    public T3AccessDataSource newDataSource(File inputFile) {
    
    42
    -        return new T3AccessDataSource(inputFile,
    
    43
    -                                      T3AccessEntityMetaProviderAvdth35.class
    
    44
    -        );
    
    45
    -    }
    
    46
    -
    
    47
    -    @Override
    
    48
    -    public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource,
    
    49
    -                                              ReferenceEntityMap safeReferences) {
    
    50
    -
    
    51
    -        return new T3DataEntityVisitorAvdth35(getConfiguration().getTopiaApplicationContext(), dataSource, safeReferences);
    
    52
    -    }
    
    53
    -
    
    54
    -    public static final ImmutableSet<T3EntityEnum> REFERENCE_TYPES =
    
    41
    +    private static final ImmutableSet<T3EntityEnum> REFERENCE_TYPES =
    
    55 42
                 ImmutableSet.of(
    
    56 43
                         T3EntityEnum.VesselActivity,
    
    57 44
                         T3EntityEnum.VesselSizeCategory,
    
    ... ... @@ -75,19 +62,12 @@ public class T3InputAvdth35 extends AbstractT3InputMSAccess {
    75 62
                         T3EntityEnum.FpaZone,
    
    76 63
                         T3EntityEnum.LocalMarketPackagingType,
    
    77 64
                         T3EntityEnum.LocalMarketPackaging);
    
    78
    -
    
    79
    -
    
    80
    -    @Override
    
    81
    -    public ImmutableSet<T3EntityEnum> getReferenceTypes() {
    
    82
    -        return REFERENCE_TYPES;
    
    83
    -    }
    
    84
    -
    
    85 65
         /**
    
    86 66
          * Set of all importable data types from ms-access.
    
    87 67
          *
    
    88 68
          * @since 2.0
    
    89 69
          */
    
    90
    -    public static final ImmutableSet<T3EntityEnum> IMPORTABLE_DATA_TYPES =
    
    70
    +    private static final ImmutableSet<T3EntityEnum> IMPORTABLE_DATA_TYPES =
    
    91 71
                 ImmutableSet.of(
    
    92 72
                         T3EntityEnum.Activity,
    
    93 73
                         T3EntityEnum.ActivityFishingContext,
    
    ... ... @@ -108,6 +88,21 @@ public class T3InputAvdth35 extends AbstractT3InputMSAccess {
    108 88
                         T3EntityEnum.LocalMarketSurvey);
    
    109 89
     
    
    110 90
         @Override
    
    91
    +    public T3AccessDataSource newDataSource(File inputFile) {
    
    92
    +        return new T3AccessDataSource(inputFile, T3AccessEntityMetaProviderAvdth35.class);
    
    93
    +    }
    
    94
    +
    
    95
    +    @Override
    
    96
    +    public ImmutableSet<T3EntityEnum> getReferenceTypes() {
    
    97
    +        return REFERENCE_TYPES;
    
    98
    +    }
    
    99
    +
    
    100
    +    @Override
    
    101
    +    public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) {
    
    102
    +        return new T3DataEntityVisitorAvdth35(dataSource, safeReferences);
    
    103
    +    }
    
    104
    +
    
    105
    +    @Override
    
    111 106
         public ImmutableSet<T3EntityEnum> getDataTypes() {
    
    112 107
             return IMPORTABLE_DATA_TYPES;
    
    113 108
         }
    

  • t3-input-avdthv35/src/main/java/fr/ird/t3/io/input/avdth/v35/T3InputProviderAvdth35.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -23,10 +23,11 @@ package fr.ird.t3.io.input.avdth.v35;
    23 23
     import com.google.auto.service.AutoService;
    
    24 24
     import fr.ird.t3.io.input.T3Input;
    
    25 25
     import fr.ird.t3.io.input.T3InputProvider;
    
    26
    -import java.io.File;
    
    27 26
     import org.nuiton.version.Version;
    
    28 27
     import org.nuiton.version.Versions;
    
    29 28
     
    
    29
    +import java.io.File;
    
    30
    +
    
    30 31
     /**
    
    31 32
      * Provides input for avdth.
    
    32 33
      *
    
    ... ... @@ -38,9 +39,9 @@ public class T3InputProviderAvdth35 implements T3InputProvider {
    38 39
     
    
    39 40
         private static final long serialVersionUID = 1L;
    
    40 41
     
    
    41
    -    public static final Version VERSION = Versions.valueOf("3.5");
    
    42
    +    private static final Version VERSION = Versions.valueOf("3.5");
    
    42 43
     
    
    43
    -    public static final String NAME = "AVDTH";
    
    44
    +    private static final String NAME = "AVDTH";
    
    44 45
     
    
    45 46
         public static final String ID = NAME + "__" + VERSION;
    
    46 47
     
    
    ... ... @@ -65,8 +66,8 @@ public class T3InputProviderAvdth35 implements T3InputProvider {
    65 66
         }
    
    66 67
     
    
    67 68
         @Override
    
    68
    -    public String getLibelle() {
    
    69
    -        return getName() + " - v." + getVersion() + " (" + getInputType() + ")";
    
    69
    +    public String getLabel() {
    
    70
    +        return String.format("%s - v.%s (%s)", getName(), getVersion(), getInputType());
    
    70 71
         }
    
    71 72
     
    
    72 73
         @Override
    

  • t3-input-avdthv36/pom.xml
    ... ... @@ -88,11 +88,6 @@
    88 88
         </dependency>
    
    89 89
     
    
    90 90
         <dependency>
    
    91
    -      <groupId>org.nuiton.topia</groupId>
    
    92
    -      <artifactId>topia-persistence</artifactId>
    
    93
    -    </dependency>
    
    94
    -
    
    95
    -    <dependency>
    
    96 91
           <groupId>com.google.auto.service</groupId>
    
    97 92
           <artifactId>auto-service</artifactId>
    
    98 93
           <scope>provided</scope>
    

  • t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3AccessEntityMetaProviderAvdth36.java
    ... ... @@ -8,19 +8,18 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    20 20
      */
    
    21 21
     package fr.ird.t3.io.input.avdth.v36;
    
    22 22
     
    
    23
    -import com.google.common.collect.Sets;
    
    24 23
     import fr.ird.msaccess.type.IntToCoordonne;
    
    25 24
     import fr.ird.t3.entities.T3EntityEnum;
    
    26 25
     import fr.ird.t3.entities.data.Activity;
    
    ... ... @@ -73,6 +72,7 @@ import org.apache.commons.logging.Log;
    73 72
     import org.apache.commons.logging.LogFactory;
    
    74 73
     
    
    75 74
     import java.util.Date;
    
    75
    +import java.util.LinkedHashSet;
    
    76 76
     import java.util.Set;
    
    77 77
     
    
    78 78
     /**
    
    ... ... @@ -83,12 +83,11 @@ import java.util.Set;
    83 83
      */
    
    84 84
     public class T3AccessEntityMetaProviderAvdth36 implements T3AccessEntityMetaProvider {
    
    85 85
     
    
    86
    -    /** Logger. */
    
    87 86
         private static final Log log = LogFactory.getLog(T3AccessEntityMetaProviderAvdth36.class);
    
    88 87
     
    
    89 88
         @Override
    
    90 89
         public Set<T3AccessEntityMeta> getMetas() {
    
    91
    -        Set<T3AccessEntityMeta> result = Sets.newLinkedHashSet();
    
    90
    +        Set<T3AccessEntityMeta> result = new LinkedHashSet<>();
    
    92 91
     
    
    93 92
             // ACTIVITE : [C_BAT, C_OCEA, C_OPERA, C_TBANC, D_ACT, D_DBQ, F_CUVE_C, F_DON_ORG, F_EXPERT, F_OBS, F_POS_COR, F_POS_VMS_D, H_ACT, N_ACT, Q_ACT, V_COUR_DIR, V_COUR_VIT, V_LAT, V_LON, V_NB_OP, V_POIDS_CAP, V_TEMP_S, V_TMER, V_TPEC]
    
    94 93
             registerDataMeta(
    
    ... ... @@ -681,45 +680,30 @@ public class T3AccessEntityMetaProviderAvdth36 implements T3AccessEntityMetaProv
    681 680
             return result;
    
    682 681
         }
    
    683 682
     
    
    684
    -    protected void registerReferentielMeta(Set<T3AccessEntityMeta> universe,
    
    685
    -                                           T3EntityEnum type,
    
    686
    -                                           String tableName,
    
    687
    -                                           String[] pkeys,
    
    688
    -                                           Object... properties) {
    
    689
    -        T3AccessEntityMeta meta = new T3AccessReferentielEntityMeta(
    
    690
    -                type,
    
    691
    -                tableName,
    
    692
    -                pkeys,
    
    693
    -                properties
    
    694
    -        );
    
    683
    +    private void registerReferentielMeta(Set<T3AccessEntityMeta> universe,
    
    684
    +                                         T3EntityEnum type,
    
    685
    +                                         String tableName,
    
    686
    +                                         String[] pKeys,
    
    687
    +                                         Object... properties) {
    
    688
    +        T3AccessEntityMeta meta = new T3AccessReferentielEntityMeta(type, tableName, pKeys, properties);
    
    695 689
             registerMeta(universe, meta);
    
    696 690
     
    
    697 691
         }
    
    698 692
     
    
    699
    -    protected void registerDataMeta(Set<T3AccessEntityMeta> universe,
    
    700
    -                                    T3EntityEnum type,
    
    701
    -                                    String tableName,
    
    702
    -                                    String[] pkeys,
    
    703
    -                                    Object[] association,
    
    704
    -                                    Object[] reverseProperties,
    
    705
    -                                    Object... properties) {
    
    706
    -        T3AccessEntityMeta meta = new T3AccessDataEntityMeta(
    
    707
    -                type,
    
    708
    -                tableName,
    
    709
    -                pkeys,
    
    710
    -                association,
    
    711
    -                reverseProperties,
    
    712
    -                properties
    
    713
    -        );
    
    693
    +    private void registerDataMeta(Set<T3AccessEntityMeta> universe,
    
    694
    +                                  T3EntityEnum type,
    
    695
    +                                  String tableName,
    
    696
    +                                  String[] pKeys,
    
    697
    +                                  Object[] association,
    
    698
    +                                  Object[] reverseProperties,
    
    699
    +                                  Object... properties) {
    
    700
    +        T3AccessEntityMeta meta = new T3AccessDataEntityMeta(type, tableName, pKeys, association, reverseProperties, properties);
    
    714 701
             registerMeta(universe, meta);
    
    715 702
         }
    
    716 703
     
    
    717 704
     
    
    718
    -    protected void registerMeta(Set<T3AccessEntityMeta> universe,
    
    719
    -                                T3AccessEntityMeta meta) {
    
    720
    -        if (log.isDebugEnabled()) {
    
    721
    -            log.debug("add " + meta.getType() + ":" + meta.getTableName() + " to universe");
    
    722
    -        }
    
    705
    +    private void registerMeta(Set<T3AccessEntityMeta> universe, T3AccessEntityMeta meta) {
    
    706
    +        log.debug(String.format("add %s:%s to universe", meta.getType(), meta.getTableName()));
    
    723 707
             universe.add(meta);
    
    724 708
         }
    
    725 709
     }

  • t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3DataEntityVisitorAvdth36.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -21,28 +21,9 @@
    21 21
     package fr.ird.t3.io.input.avdth.v36;
    
    22 22
     
    
    23 23
     import fr.ird.t3.entities.ReferenceEntityMap;
    
    24
    -import fr.ird.t3.entities.T3EntityEnum;
    
    25
    -import fr.ird.t3.entities.T3TopiaApplicationContext;
    
    26
    -import fr.ird.t3.entities.data.Activity;
    
    27
    -import fr.ird.t3.entities.data.ElementaryCatch;
    
    28
    -import fr.ird.t3.entities.data.ElementaryLanding;
    
    29
    -import fr.ird.t3.entities.data.Sample;
    
    30
    -import fr.ird.t3.entities.data.SampleSet;
    
    31
    -import fr.ird.t3.entities.data.Trip;
    
    32
    -import fr.ird.t3.entities.data.Well;
    
    33
    -import fr.ird.t3.entities.data.WellPlan;
    
    34
    -import fr.ird.t3.entities.reference.WeightCategoryLanding;
    
    35
    -import fr.ird.t3.entities.reference.WeightCategoryLogBook;
    
    36
    -import fr.ird.t3.io.input.MissingForeignKeyInT3;
    
    37 24
     import fr.ird.t3.io.input.access.T3AccessDataSource;
    
    38
    -import fr.ird.t3.io.input.access.T3AccessEntity;
    
    39
    -import fr.ird.t3.io.input.access.T3AccessEntityMeta;
    
    25
    +import fr.ird.t3.io.input.access.T3AvdthDataEntityVisitor;
    
    40 26
     import fr.ird.t3.io.input.access.T3DataEntityVisitor;
    
    41
    -import fr.ird.type.CoordinateHelper;
    
    42
    -import java.io.Serializable;
    
    43
    -import org.apache.commons.logging.Log;
    
    44
    -import org.apache.commons.logging.LogFactory;
    
    45
    -import org.nuiton.topia.persistence.TopiaEntity;
    
    46 27
     
    
    47 28
     /**
    
    48 29
      * Implementation of {@link T3DataEntityVisitor} for the avdth v36 db.
    
    ... ... @@ -50,216 +31,8 @@ import org.nuiton.topia.persistence.TopiaEntity;
    50 31
      * @author Tony Chemit - dev@tchemit.fr
    
    51 32
      * @since 2.0
    
    52 33
      */
    
    53
    -public class T3DataEntityVisitorAvdth36 extends T3DataEntityVisitor {
    
    54
    -
    
    55
    -    /** Logger. */
    
    56
    -    private static final Log log = LogFactory.getLog(T3DataEntityVisitorAvdth36.class);
    
    57
    -
    
    58
    -    protected final ReverseAssociationGetter<Trip, WellPlan, Activity> wellPlanReverse;
    
    59
    -
    
    60
    -    protected final ReverseAssociationGetter<Trip, Sample, Well> sampleReverse;
    
    61
    -
    
    62
    -    protected final ReverseAssociationGetter<Trip, SampleSet, Activity> sampleSetReverse;
    
    63
    -
    
    64
    -    public T3DataEntityVisitorAvdth36(T3TopiaApplicationContext topiaApplicationContext,
    
    65
    -                                      T3AccessDataSource dataSource,
    
    66
    -                                      ReferenceEntityMap referentiel) {
    
    34
    +class T3DataEntityVisitorAvdth36 extends T3AvdthDataEntityVisitor {
    
    35
    +    T3DataEntityVisitorAvdth36(T3AccessDataSource dataSource, ReferenceEntityMap referentiel) {
    
    67 36
             super(dataSource, referentiel);
    
    68
    -
    
    69
    -        wellPlanReverse = newReverseAssociationGetter(
    
    70
    -                Trip.class,
    
    71
    -                WellPlan.class,
    
    72
    -                Activity.class,
    
    73
    -                Trip.PROPERTY_ACTIVITY,
    
    74
    -                WellPlan.PROPERTY_ACTIVITY
    
    75
    -        );
    
    76
    -
    
    77
    -        sampleReverse = newReverseAssociationGetter(
    
    78
    -                Trip.class,
    
    79
    -                Sample.class,
    
    80
    -                Well.class,
    
    81
    -                Trip.PROPERTY_WELL,
    
    82
    -                Sample.PROPERTY_WELL
    
    83
    -        );
    
    84
    -
    
    85
    -        sampleSetReverse = newReverseAssociationGetter(
    
    86
    -                Trip.class,
    
    87
    -                SampleSet.class,
    
    88
    -                Activity.class,
    
    89
    -                Trip.PROPERTY_ACTIVITY,
    
    90
    -                SampleSet.PROPERTY_ACTIVITY
    
    91
    -        );
    
    92
    -    }
    
    93
    -
    
    94
    -    @Override
    
    95
    -    public void onEnd(T3AccessEntity entity, T3AccessEntityMeta meta) {
    
    96
    -
    
    97
    -        super.onEnd(entity, meta);
    
    98
    -
    
    99
    -        if (!deepVisit) {
    
    100
    -            return;
    
    101
    -        }
    
    102
    -
    
    103
    -        T3EntityEnum type = meta.getType();
    
    104
    -
    
    105
    -        if (type == T3EntityEnum.Activity) {
    
    106
    -
    
    107
    -            Activity a = (Activity) entity;
    
    108
    -
    
    109
    -            Integer quadrant = a.getQuadrant();
    
    110
    -            Float latitude = CoordinateHelper.getSignedLatitude(
    
    111
    -                    quadrant, a.getLatitude());
    
    112
    -            Float longitude = CoordinateHelper.getSignedLongitude(
    
    113
    -                    quadrant, a.getLongitude());
    
    114
    -            a.setLatitude(latitude);
    
    115
    -            a.setLongitude(longitude);
    
    116
    -
    
    117
    -            if (log.isDebugEnabled()) {
    
    118
    -                log.debug("Will use for activity " + entity +
    
    119
    -                          " coordinates <" + a.getLongitude() + "," + a.getLatitude() + ">");
    
    120
    -            }
    
    121
    -        }
    
    122
    -    }
    
    123
    -
    
    124
    -    @Override
    
    125
    -    public void onVisitReverseAssociation(String propertyName,
    
    126
    -                                          T3AccessEntity entity,
    
    127
    -                                          T3AccessEntityMeta meta) {
    
    128
    -
    
    129
    -        if (!deepVisit) {
    
    130
    -            return;
    
    131
    -        }
    
    132
    -
    
    133
    -        if (SampleSet.PROPERTY_ACTIVITY.equals(propertyName) &&
    
    134
    -            entity instanceof SampleSet) {
    
    135
    -
    
    136
    -            // special case, must obtain the activity from the trip
    
    137
    -
    
    138
    -            sampleSetReverse.attachReverseAssocation(entity);
    
    139
    -            return;
    
    140
    -        }
    
    141
    -
    
    142
    -        if (WellPlan.PROPERTY_ACTIVITY.equals(propertyName) &&
    
    143
    -            entity instanceof WellPlan) {
    
    144
    -
    
    145
    -            // special case, must obtain the activity from the trip
    
    146
    -
    
    147
    -            wellPlanReverse.attachReverseAssocation(entity);
    
    148
    -            return;
    
    149
    -        }
    
    150
    -
    
    151
    -        if (Sample.PROPERTY_WELL.equals(propertyName) &&
    
    152
    -            entity instanceof Sample) {
    
    153
    -
    
    154
    -            // special case, must obtain the well from the trip
    
    155
    -
    
    156
    -            sampleReverse.attachReverseAssocation(entity);
    
    157
    -            return;
    
    158
    -        }
    
    159
    -
    
    160
    -        super.onVisitReverseAssociation(propertyName, entity, meta);
    
    161
    -    }
    
    162
    -
    
    163
    -    @Override
    
    164
    -    public void onVisitComposition(String propertyName,
    
    165
    -                                   Class<?> type,
    
    166
    -                                   T3AccessEntity entity,
    
    167
    -                                   T3AccessEntityMeta meta) {
    
    168
    -
    
    169
    -        if (ElementaryLanding.PROPERTY_WEIGHT_CATEGORY_LANDING.equals(propertyName)
    
    170
    -            && entity instanceof ElementaryLanding) {
    
    171
    -
    
    172
    -            Serializable codeEspece = getProperty("C_ESP", row);
    
    173
    -            Serializable codeCate = getProperty("C_CAT_C", row);
    
    174
    -
    
    175
    -            // must found the species
    
    176
    -            T3AccessEntityMeta specieMeta =
    
    177
    -                    dataSource.getMeta(T3EntityEnum.Species);
    
    178
    -
    
    179
    -            TopiaEntity specie = getReferenceEntity(specieMeta, codeEspece);
    
    180
    -
    
    181
    -            T3AccessEntityMeta categoryMeta =
    
    182
    -                    dataSource.getMeta(T3EntityEnum.WeightCategoryLanding);
    
    183
    -
    
    184
    -            // special case : need to find a reference with two primary keys...
    
    185
    -            TopiaEntity ref = getReferenceEntity(
    
    186
    -                    categoryMeta,
    
    187
    -                    new String[]{WeightCategoryLanding.PROPERTY_CODE, WeightCategoryLanding.PROPERTY_SPECIES},
    
    188
    -                    codeCate, specie
    
    189
    -            );
    
    190
    -
    
    191
    -            if (ref == null) {
    
    192
    -
    
    193
    -                if (log.isWarnEnabled()) {
    
    194
    -                    log.warn("Can't find WeightCategoryLanding for speciesCode / categoryCode: " + codeEspece + "/" + codeCate);
    
    195
    -                }
    
    196
    -                getMissingForeignKeys().add(new MissingForeignKeyInT3(
    
    197
    -                        T3EntityEnum.ElementaryLanding,
    
    198
    -                        T3EntityEnum.WeightCategoryLanding,
    
    199
    -                        getPKey(T3EntityEnum.ElementaryLanding),
    
    200
    -                        new Object[]{codeEspece, codeCate}
    
    201
    -                ));
    
    202
    -
    
    203
    -            } else {
    
    204
    -
    
    205
    -                if (log.isDebugEnabled()) {
    
    206
    -                    log.debug("Detected landing catch weight category : " + ref);
    
    207
    -                }
    
    208
    -                entity.setProperty(propertyName, ref);
    
    209
    -
    
    210
    -            }
    
    211
    -
    
    212
    -            return;
    
    213
    -        }
    
    214
    -
    
    215
    -        if (ElementaryCatch.PROPERTY_WEIGHT_CATEGORY_LOG_BOOK.equals(propertyName)
    
    216
    -            && entity instanceof ElementaryCatch) {
    
    217
    -
    
    218
    -            // special case : need to find a reference with two primary keys...
    
    219
    -
    
    220
    -            Serializable codeEspece = getProperty("C_ESP", row);
    
    221
    -            Serializable codeCate = getProperty("C_CAT_T", row);
    
    222
    -
    
    223
    -            // must found the species
    
    224
    -            T3AccessEntityMeta specieMeta =
    
    225
    -                    dataSource.getMeta(T3EntityEnum.Species);
    
    226
    -
    
    227
    -            TopiaEntity specie = getReferenceEntity(specieMeta, codeEspece);
    
    228
    -
    
    229
    -            T3AccessEntityMeta categoryMeta =
    
    230
    -                    dataSource.getMeta(T3EntityEnum.WeightCategoryLogBook);
    
    231
    -
    
    232
    -            // special case : need to find a reference with two primary keys...
    
    233
    -            TopiaEntity ref = getReferenceEntity(
    
    234
    -                    categoryMeta,
    
    235
    -                    new String[]{WeightCategoryLogBook.PROPERTY_CODE, WeightCategoryLogBook.PROPERTY_SPECIES},
    
    236
    -                    codeCate, specie
    
    237
    -            );
    
    238
    -
    
    239
    -            if (ref == null) {
    
    240
    -
    
    241
    -                if (log.isWarnEnabled()) {
    
    242
    -                    log.warn("Can't find weightCategoryLogBook for speciesCode / categoryCode: " + codeEspece + "/" + codeCate);
    
    243
    -                }
    
    244
    -                getMissingForeignKeys().add(new MissingForeignKeyInT3(
    
    245
    -                        T3EntityEnum.ElementaryCatch,
    
    246
    -                        T3EntityEnum.WeightCategoryLogBook,
    
    247
    -                        getPKey(T3EntityEnum.ElementaryCatch),
    
    248
    -                        new Object[]{codeCate, codeEspece}
    
    249
    -                ));
    
    250
    -
    
    251
    -            } else {
    
    252
    -
    
    253
    -                if (log.isDebugEnabled()) {
    
    254
    -                    log.debug("Detected logBook catch weight category : " + ref);
    
    255
    -                }
    
    256
    -                entity.setProperty(propertyName, ref);
    
    257
    -
    
    258
    -            }
    
    259
    -
    
    260
    -            return;
    
    261
    -        }
    
    262
    -
    
    263
    -        super.onVisitComposition(propertyName, type, entity, meta);
    
    264 37
         }
    
    265 38
     }

  • t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputAvdth36.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -27,6 +27,7 @@ import fr.ird.t3.io.input.T3Input;
    27 27
     import fr.ird.t3.io.input.access.AbstractT3InputMSAccess;
    
    28 28
     import fr.ird.t3.io.input.access.T3AccessDataSource;
    
    29 29
     import fr.ird.t3.io.input.access.T3DataEntityVisitor;
    
    30
    +
    
    30 31
     import java.io.File;
    
    31 32
     
    
    32 33
     /**
    
    ... ... @@ -37,21 +38,7 @@ import java.io.File;
    37 38
      */
    
    38 39
     public class T3InputAvdth36 extends AbstractT3InputMSAccess {
    
    39 40
     
    
    40
    -    @Override
    
    41
    -    public T3AccessDataSource newDataSource(File inputFile) {
    
    42
    -        return new T3AccessDataSource(inputFile, T3AccessEntityMetaProviderAvdth36.class);
    
    43
    -    }
    
    44
    -
    
    45
    -    @Override
    
    46
    -    public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource,
    
    47
    -                                              ReferenceEntityMap safeReferences) {
    
    48
    -
    
    49
    -        return new T3DataEntityVisitorAvdth36(getConfiguration().getTopiaApplicationContext(),
    
    50
    -                                              dataSource,
    
    51
    -                                              safeReferences);
    
    52
    -    }
    
    53
    -
    
    54
    -    public static final ImmutableSet<T3EntityEnum> REFERENCE_TYPES =
    
    41
    +    private static final ImmutableSet<T3EntityEnum> REFERENCE_TYPES =
    
    55 42
                 ImmutableSet.of(
    
    56 43
                         T3EntityEnum.VesselActivity,
    
    57 44
                         T3EntityEnum.VesselSizeCategory,
    
    ... ... @@ -77,19 +64,12 @@ public class T3InputAvdth36 extends AbstractT3InputMSAccess {
    77 64
                         T3EntityEnum.LocalMarketPackaging,
    
    78 65
                         T3EntityEnum.ElementaryCatchFate,
    
    79 66
                         T3EntityEnum.Company);
    
    80
    -
    
    81
    -
    
    82
    -    @Override
    
    83
    -    public ImmutableSet<T3EntityEnum> getReferenceTypes() {
    
    84
    -        return REFERENCE_TYPES;
    
    85
    -    }
    
    86
    -
    
    87 67
         /**
    
    88 68
          * Set of all importable data types from ms-access.
    
    89 69
          *
    
    90 70
          * @since 2.0
    
    91 71
          */
    
    92
    -    public static final ImmutableSet<T3EntityEnum> IMPORTABLE_DATA_TYPES =
    
    72
    +    private static final ImmutableSet<T3EntityEnum> IMPORTABLE_DATA_TYPES =
    
    93 73
                 ImmutableSet.of(
    
    94 74
                         T3EntityEnum.Activity,
    
    95 75
                         T3EntityEnum.ActivityFishingContext,
    
    ... ... @@ -110,6 +90,21 @@ public class T3InputAvdth36 extends AbstractT3InputMSAccess {
    110 90
                         T3EntityEnum.LocalMarketSurvey);
    
    111 91
     
    
    112 92
         @Override
    
    93
    +    public T3AccessDataSource newDataSource(File inputFile) {
    
    94
    +        return new T3AccessDataSource(inputFile, T3AccessEntityMetaProviderAvdth36.class);
    
    95
    +    }
    
    96
    +
    
    97
    +    @Override
    
    98
    +    public T3DataEntityVisitor newDataVisitor(T3AccessDataSource dataSource, ReferenceEntityMap safeReferences) {
    
    99
    +        return new T3DataEntityVisitorAvdth36(dataSource, safeReferences);
    
    100
    +    }
    
    101
    +
    
    102
    +    @Override
    
    103
    +    public ImmutableSet<T3EntityEnum> getReferenceTypes() {
    
    104
    +        return REFERENCE_TYPES;
    
    105
    +    }
    
    106
    +
    
    107
    +    @Override
    
    113 108
         public ImmutableSet<T3EntityEnum> getDataTypes() {
    
    114 109
             return IMPORTABLE_DATA_TYPES;
    
    115 110
         }
    

  • t3-input-avdthv36/src/main/java/fr/ird/t3/io/input/avdth/v36/T3InputProviderAvdth36.java
    ... ... @@ -8,12 +8,12 @@
    8 8
      * it under the terms of the GNU Affero General Public License as published by
    
    9 9
      * the Free Software Foundation, either version 3 of the License, or
    
    10 10
      * (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 Affero General Public License
    
    18 18
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19 19
      * #L%
    
    ... ... @@ -23,10 +23,11 @@ package fr.ird.t3.io.input.avdth.v36;
    23 23
     import com.google.auto.service.AutoService;
    
    24 24
     import fr.ird.t3.io.input.T3Input;
    
    25 25
     import fr.ird.t3.io.input.T3InputProvider;
    
    26
    -import java.io.File;
    
    27 26
     import org.nuiton.version.Version;
    
    28 27
     import org.nuiton.version.Versions;
    
    29 28
     
    
    29
    +import java.io.File;
    
    30
    +
    
    30 31
     /**
    
    31 32
      * Provides input for avdth.
    
    32 33
      *
    
    ... ... @@ -37,11 +38,8 @@ import org.nuiton.version.Versions;
    37 38
     public class T3InputProviderAvdth36 implements T3InputProvider {
    
    38 39
     
    
    39 40
         private static final long serialVersionUID = 1L;
    
    40
    -
    
    41
    -    public static final Version VERSION = Versions.valueOf("3.6");
    
    42
    -
    
    43
    -    public static final String NAME = "AVDTH";
    
    44
    -
    
    41
    +    private static final Version VERSION = Versions.valueOf("3.6");
    
    42
    +    private static final String NAME = "AVDTH";
    
    45 43
         public static final String ID = NAME + "__" + VERSION;
    
    46 44
     
    
    47 45
         @Override
    
    ... ... @@ -65,8 +63,8 @@ public class T3InputProviderAvdth36 implements T3InputProvider {
    65 63
         }
    
    66 64
     
    
    67 65
         @Override
    
    68
    -    public String getLibelle() {
    
    69
    -        return getName() + " - v." + getVersion() + " (" + getInputType() + ")";
    
    66
    +    public String getLabel() {
    
    67
    +        return String.format("%s - v.%s (%s)", getName(), getVersion(), getInputType());
    
    70 68
         }
    
    71 69
     
    
    72 70
         @Override
    
    ... ... @@ -82,9 +80,7 @@ public class T3InputProviderAvdth36 implements T3InputProvider {
    82 80
             if (!(o instanceof T3InputProvider)) {
    
    83 81
                 return false;
    
    84 82
             }
    
    85
    -
    
    86 83
             T3InputProvider that = (T3InputProvider) o;
    
    87
    -
    
    88 84
             return ID.equals(that.getId());
    
    89 85
         }
    
    90 86