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

Commits:

14 changed files:

Changes:

  • t3-actions/src/main/java/fr/ird/t3/actions/io/input/AnalyzeInputSourceConfiguration.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%
    
    ... ... @@ -43,22 +43,42 @@ public class AnalyzeInputSourceConfiguration implements InputSourceConfiguration
    43 43
         protected boolean createVirtualVessel;
    
    44 44
         protected T3InputProvider inputProvider;
    
    45 45
         protected File inputFile;
    
    46
    +    /**
    
    47
    +     * Flag to load only samples only trips
    
    48
    +     *
    
    49
    +     * @see TripType#SAMPLEONLY
    
    50
    +     */
    
    51
    +    private boolean useSamplesOnly;
    
    52
    +    /**
    
    53
    +     * Flag to authorize virtual activity creation (when logbooks are missing).
    
    54
    +     * <p>
    
    55
    +     * By default, let's always authorize it.
    
    56
    +     * <p>
    
    57
    +     * <b>Note:</b> This option is always at false if {@link #useSamplesOnly} is on.
    
    58
    +     *
    
    59
    +     * @see TripType#LOGBOOKMISSING
    
    60
    +     * @see TripType#STANDARD
    
    61
    +     */
    
    62
    +    private boolean canCreateVirtualActivity;
    
    46 63
         private TripType tripType;
    
    47 64
     
    
    48 65
         public static AnalyzeInputSourceConfiguration newConfiguration(
    
    49 66
                 T3InputProvider inputProvider,
    
    50 67
                 File inputFile,
    
    51 68
                 boolean useWells,
    
    52
    -            TripType tripType,
    
    53 69
                 boolean canCreateVessel,
    
    54
    -            boolean createVirtualVessel) {
    
    70
    +            boolean createVirtualVessel,
    
    71
    +            boolean useSamplesOnly,
    
    72
    +            boolean canCreateVirtualActivity) {
    
    55 73
             AnalyzeInputSourceConfiguration result = new AnalyzeInputSourceConfiguration();
    
    56 74
             result.setInputFile(inputFile);
    
    57 75
             result.setInputProvider(inputProvider);
    
    58 76
             result.setUseWells(useWells);
    
    59
    -        result.setTripType(tripType);
    
    77
    +        result.setTripType(TripType.getTripType(useSamplesOnly, canCreateVirtualActivity));
    
    60 78
             result.setCanCreateVessel(canCreateVessel);
    
    61 79
             result.setCreateVirtualVessel(createVirtualVessel);
    
    80
    +        result.setCanCreateVirtualActivity(canCreateVirtualActivity);
    
    81
    +        result.setUseSamplesOnly(useSamplesOnly);
    
    62 82
             return result;
    
    63 83
         }
    
    64 84
     
    
    ... ... @@ -127,12 +147,34 @@ public class AnalyzeInputSourceConfiguration implements InputSourceConfiguration
    127 147
             return l(locale, "t3.input.AnalyzeInputSource");
    
    128 148
         }
    
    129 149
     
    
    150
    +    @Override
    
    151
    +    public boolean isUseSamplesOnly() {
    
    152
    +        return useSamplesOnly;
    
    153
    +    }
    
    154
    +
    
    155
    +    @Override
    
    156
    +    public void setUseSamplesOnly(boolean useSamplesOnly) {
    
    157
    +        this.useSamplesOnly = useSamplesOnly;
    
    158
    +    }
    
    159
    +
    
    160
    +    @Override
    
    161
    +    public boolean isCanCreateVirtualActivity() {
    
    162
    +        return canCreateVirtualActivity;
    
    163
    +    }
    
    164
    +
    
    165
    +    @Override
    
    166
    +    public void setCanCreateVirtualActivity(boolean canCreateVirtualActivity) {
    
    167
    +        this.canCreateVirtualActivity = canCreateVirtualActivity;
    
    168
    +    }
    
    169
    +
    
    130 170
         T3InputConfiguration toInputConfiguration() {
    
    131 171
             T3InputConfiguration result = new T3InputConfiguration();
    
    132 172
             result.setCanCreateVessel(canCreateVessel);
    
    133 173
             result.setCreateVirtualVessel(createVirtualVessel);
    
    134 174
             result.setTripType(tripType);
    
    135 175
             result.setUseWells(useWells);
    
    176
    +        result.setCanCreateVirtualActivity(canCreateVirtualActivity);
    
    177
    +        result.setUseSamplesOnly(useSamplesOnly);
    
    136 178
             result.setInputFile(inputFile);
    
    137 179
             return result;
    
    138 180
         }
    

  • t3-actions/src/main/java/fr/ird/t3/actions/io/input/ImportInputSourceAction.java
    ... ... @@ -25,7 +25,6 @@ import fr.ird.t3.entities.T3EntityEnum;
    25 25
     import fr.ird.t3.entities.T3TopiaApplicationContext;
    
    26 26
     import fr.ird.t3.entities.T3TopiaPersistenceContext;
    
    27 27
     import fr.ird.t3.entities.data.Activity;
    
    28
    -import fr.ird.t3.entities.data.ActivityTopiaDao;
    
    29 28
     import fr.ird.t3.entities.data.T3DataEntity;
    
    30 29
     import fr.ird.t3.entities.data.Trip;
    
    31 30
     import fr.ird.t3.entities.data.TripTopiaDao;
    
    ... ... @@ -60,15 +59,11 @@ import static org.nuiton.i18n.I18n.l;
    60 59
      */
    
    61 60
     public class ImportInputSourceAction extends T3Action<ImportInputSourceConfiguration> {
    
    62 61
     
    
    63
    -    //    public static final String PARAM_TRIPS_TO_IMPORT = "tripsToImport";
    
    64
    -//    public static final String PARAM_TRIPS_TO_DELETE = "tripsToDelete";
    
    65 62
         private static final Log log = LogFactory.getLog(ImportInputSourceAction.class);
    
    66 63
         @InjectDAO(entityType = Trip.class)
    
    67 64
         private TripTopiaDao tripDAO;
    
    68 65
         @InjectDAO(entityType = Vessel.class)
    
    69 66
         private VesselTopiaDao vesselDAO;
    
    70
    -    @InjectDAO(entityType = Activity.class)
    
    71
    -    private ActivityTopiaDao activityDAO;
    
    72 67
         @InjectDAO(entityType = Ocean.class)
    
    73 68
         private OceanTopiaDao oceanDAO;
    
    74 69
         private Set<Trip> tripToDelete;
    
    ... ... @@ -88,13 +83,10 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
    88 83
     
    
    89 84
         @Override
    
    90 85
         protected boolean executeAction() {
    
    91
    -
    
    92 86
             if (CollectionUtils.isEmpty(trips)) {
    
    93
    -            // no trips at all to import
    
    94
    -            // no commit to do, skip the action
    
    87
    +            // no trips at all to import, no commit to do, skip the action
    
    95 88
                 return false;
    
    96 89
             }
    
    97
    -
    
    98 90
             int nbSteps = 0;
    
    99 91
             if (CollectionUtils.isNotEmpty(trips)) {
    
    100 92
                 nbSteps += trips.size();
    
    ... ... @@ -102,7 +94,6 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
    102 94
             if (CollectionUtils.isNotEmpty(tripToDelete)) {
    
    103 95
                 nbSteps += tripToDelete.size();
    
    104 96
             }
    
    105
    -
    
    106 97
             setNbSteps(nbSteps);
    
    107 98
             log.info(String.format("Nb steps : %d", getNbSteps()));
    
    108 99
             if (CollectionUtils.isNotEmpty(tripToDelete)) {
    
    ... ... @@ -154,8 +145,6 @@ public class ImportInputSourceAction extends T3Action<ImportInputSourceConfigura
    154 145
     
    
    155 146
             // Need to flush as we are going to query new data
    
    156 147
             getT3TopiaPersistenceContext().get().getHibernateSupport().getHibernateSession().flush();
    
    157
    -
    
    158
    -        String prefix = Activity.class.getName() + "#";
    
    159 148
             for (Activity activity : ids) {
    
    160 149
                 Ocean ocean = oceanDAO.findOceanByActivity(activity);
    
    161 150
                 activity.setOcean(ocean);
    

  • t3-actions/src/main/java/fr/ird/t3/actions/io/input/ImportInputSourceConfiguration.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%
    
    ... ... @@ -45,6 +45,23 @@ public class ImportInputSourceConfiguration implements InputSourceConfiguration
    45 45
         protected boolean createVirtualVessel;
    
    46 46
         protected T3InputProvider inputProvider;
    
    47 47
         protected File inputFile;
    
    48
    +    /**
    
    49
    +     * Flag to load only samples only trips
    
    50
    +     *
    
    51
    +     * @see TripType#SAMPLEONLY
    
    52
    +     */
    
    53
    +    private boolean useSamplesOnly;
    
    54
    +    /**
    
    55
    +     * Flag to authorize virtual activity creation (when logbooks are missing).
    
    56
    +     * <p>
    
    57
    +     * By default, let's always authorize it.
    
    58
    +     * <p>
    
    59
    +     * <b>Note:</b> This option is always at false if {@link #useSamplesOnly} is on.
    
    60
    +     *
    
    61
    +     * @see TripType#LOGBOOKMISSING
    
    62
    +     * @see TripType#STANDARD
    
    63
    +     */
    
    64
    +    private boolean canCreateVirtualActivity;
    
    48 65
         private Set<Trip> tripsToImport;
    
    49 66
         private Set<Trip> tripsToDelete;
    
    50 67
     
    
    ... ... @@ -124,6 +141,27 @@ public class ImportInputSourceConfiguration implements InputSourceConfiguration
    124 141
             return l(locale, "t3.input.ImportInputSource");
    
    125 142
         }
    
    126 143
     
    
    144
    +
    
    145
    +    @Override
    
    146
    +    public boolean isUseSamplesOnly() {
    
    147
    +        return useSamplesOnly;
    
    148
    +    }
    
    149
    +
    
    150
    +    @Override
    
    151
    +    public void setUseSamplesOnly(boolean useSamplesOnly) {
    
    152
    +        this.useSamplesOnly = useSamplesOnly;
    
    153
    +    }
    
    154
    +
    
    155
    +    @Override
    
    156
    +    public boolean isCanCreateVirtualActivity() {
    
    157
    +        return canCreateVirtualActivity;
    
    158
    +    }
    
    159
    +
    
    160
    +    @Override
    
    161
    +    public void setCanCreateVirtualActivity(boolean canCreateVirtualActivity) {
    
    162
    +        this.canCreateVirtualActivity = canCreateVirtualActivity;
    
    163
    +    }
    
    164
    +
    
    127 165
         public Set<Trip> getTripsToImport() {
    
    128 166
             return tripsToImport;
    
    129 167
         }
    

  • t3-actions/src/main/java/fr/ird/t3/actions/io/input/InputSourceConfiguration.java
    ... ... @@ -50,6 +50,14 @@ public interface InputSourceConfiguration extends T3ActionConfiguration {
    50 50
     
    
    51 51
         void setCreateVirtualVessel(boolean createVirtualVessel);
    
    52 52
     
    
    53
    +    boolean isUseSamplesOnly();
    
    54
    +
    
    55
    +    void setUseSamplesOnly(boolean useSamplesOnly);
    
    56
    +
    
    57
    +    boolean isCanCreateVirtualActivity();
    
    58
    +
    
    59
    +    void setCanCreateVirtualActivity(boolean canCreateVirtualActivity);
    
    60
    +
    
    53 61
         T3InputProvider getInputProvider();
    
    54 62
     
    
    55 63
         void setInputProvider(T3InputProvider inputProvider);
    

  • t3-domain/src/main/java/fr/ird/t3/entities/data/TripType.java
    ... ... @@ -10,12 +10,12 @@ package fr.ird.t3.entities.data;
    10 10
      * it under the terms of the GNU Affero General Public License as published by
    
    11 11
      * the Free Software Foundation, either version 3 of the License, or
    
    12 12
      * (at your option) any later version.
    
    13
    - * 
    
    13
    + *
    
    14 14
      * This program is distributed in the hope that it will be useful,
    
    15 15
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16 16
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17 17
      * GNU General Public License for more details.
    
    18
    - * 
    
    18
    + *
    
    19 19
      * You should have received a copy of the GNU Affero General Public License
    
    20 20
      * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    21 21
      * #L%
    
    ... ... @@ -23,13 +23,21 @@ package fr.ird.t3.entities.data;
    23 23
     
    
    24 24
     import fr.ird.t3.t3.domain.I18nEnumHelper;
    
    25 25
     
    
    26
    -import static org.nuiton.i18n.I18n.t;
    
    27
    -
    
    28 26
     public enum TripType {
    
    29 27
         STANDARD,
    
    30 28
         SAMPLEONLY,
    
    31 29
         LOGBOOKMISSING;
    
    32 30
     
    
    31
    +    public static TripType getTripType(boolean useSamplesOnly, boolean canCreateVirtualActivity) {
    
    32
    +        TripType tripType;
    
    33
    +        if (useSamplesOnly) {
    
    34
    +            tripType = SAMPLEONLY;
    
    35
    +        } else {
    
    36
    +            tripType = canCreateVirtualActivity ? LOGBOOKMISSING : STANDARD;
    
    37
    +        }
    
    38
    +        return tripType;
    
    39
    +    }
    
    40
    +
    
    33 41
         public String getLabel() {
    
    34 42
             return I18nEnumHelper.getLabel(this);
    
    35 43
         }
    

  • t3-domain/src/main/java/fr/ird/t3/io/input/T3InputConfiguration.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%
    
    ... ... @@ -33,15 +33,13 @@ import java.io.File;
    33 33
      */
    
    34 34
     public class T3InputConfiguration {
    
    35 35
     
    
    36
    -    protected boolean useWells;
    
    37
    -
    
    38
    -    protected boolean canCreateVessel;
    
    39
    -
    
    40
    -    protected boolean createVirtualVessel;
    
    41
    -
    
    42
    -    protected TripType tripType;
    
    43
    -
    
    44
    -    protected File inputFile;
    
    36
    +    private boolean useWells;
    
    37
    +    private boolean canCreateVessel;
    
    38
    +    private boolean createVirtualVessel;
    
    39
    +    private boolean useSamplesOnly;
    
    40
    +    private boolean canCreateVirtualActivity;
    
    41
    +    private TripType tripType;
    
    42
    +    private File inputFile;
    
    45 43
     
    
    46 44
         private T3TopiaApplicationContext topiaApplicationContext;
    
    47 45
     
    
    ... ... @@ -85,6 +83,22 @@ public class T3InputConfiguration {
    85 83
             this.inputFile = inputFile;
    
    86 84
         }
    
    87 85
     
    
    86
    +    public boolean isUseSamplesOnly() {
    
    87
    +        return useSamplesOnly;
    
    88
    +    }
    
    89
    +
    
    90
    +    public void setUseSamplesOnly(boolean useSamplesOnly) {
    
    91
    +        this.useSamplesOnly = useSamplesOnly;
    
    92
    +    }
    
    93
    +
    
    94
    +    public boolean isCanCreateVirtualActivity() {
    
    95
    +        return canCreateVirtualActivity;
    
    96
    +    }
    
    97
    +
    
    98
    +    public void setCanCreateVirtualActivity(boolean canCreateVirtualActivity) {
    
    99
    +        this.canCreateVirtualActivity = canCreateVirtualActivity;
    
    100
    +    }
    
    101
    +
    
    88 102
         public T3TopiaApplicationContext getTopiaApplicationContext() {
    
    89 103
             return topiaApplicationContext;
    
    90 104
         }
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/io/input/AnalyzeImportDataAction.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,13 +27,14 @@ import fr.ird.t3.entities.data.Trip;
    27 27
     import fr.ird.t3.io.input.T3InputProvider;
    
    28 28
     import fr.ird.t3.services.DecoratorService;
    
    29 29
     import fr.ird.t3.web.actions.AbstractRunAction;
    
    30
    +import org.apache.commons.collections.CollectionUtils;
    
    31
    +import org.apache.commons.collections.MapUtils;
    
    32
    +
    
    30 33
     import java.util.Collections;
    
    31 34
     import java.util.Date;
    
    32 35
     import java.util.List;
    
    33 36
     import java.util.Map;
    
    34 37
     import java.util.Set;
    
    35
    -import org.apache.commons.collections.CollectionUtils;
    
    36
    -import org.apache.commons.collections.MapUtils;
    
    37 38
     
    
    38 39
     /**
    
    39 40
      * Analyze the given input source.
    
    ... ... @@ -45,15 +46,11 @@ public class AnalyzeImportDataAction extends AbstractRunAction<AnalyzeInputSourc
    45 46
     
    
    46 47
         private static final long serialVersionUID = 1L;
    
    47 48
     
    
    48
    -    protected int nbUnsafeTrips;
    
    49
    -
    
    50
    -    protected int nbSafeTrips;
    
    51
    -
    
    52
    -    protected int nbTripsToReplace;
    
    53
    -
    
    54
    -    protected boolean needReplace;
    
    55
    -
    
    56
    -    protected boolean valid;
    
    49
    +    private int nbUnsafeTrips;
    
    50
    +    private int nbSafeTrips;
    
    51
    +    private int nbTripsToReplace;
    
    52
    +    private boolean needReplace;
    
    53
    +    private boolean valid;
    
    57 54
     
    
    58 55
         /** List of all known input providers. */
    
    59 56
         private List<T3InputProvider> inputProviders;
    
    ... ... @@ -64,111 +61,75 @@ public class AnalyzeImportDataAction extends AbstractRunAction<AnalyzeInputSourc
    64 61
     
    
    65 62
         @Override
    
    66 63
         public void prepare() throws Exception {
    
    67
    -
    
    68 64
             getT3Session().removeTripListModel();
    
    69
    -
    
    70 65
             super.prepare();
    
    71
    -
    
    72 66
             inputProviders = Collections.singletonList(getConfiguration().getInputProvider());
    
    73 67
         }
    
    74 68
     
    
    75
    -    public final List<T3InputProvider> getInputProviders() {
    
    76
    -        return inputProviders;
    
    77
    -    }
    
    78
    -
    
    79 69
         public String prepareResult() {
    
    80
    -
    
    81
    -        T3ActionContext<AnalyzeInputSourceConfiguration> context =
    
    82
    -                getT3ActionContext();
    
    83
    -
    
    84
    -        Set<Trip> safeTrips = context.getResultAsSet(
    
    85
    -                AnalyzeInputSourceAction.RESULT_SAFE_TRIPS,
    
    86
    -                Trip.class
    
    87
    -        );
    
    70
    +        T3ActionContext<AnalyzeInputSourceConfiguration> context = getT3ActionContext();
    
    71
    +        Set<Trip> safeTrips = context.getResultAsSet(AnalyzeInputSourceAction.RESULT_SAFE_TRIPS, Trip.class);
    
    88 72
             nbSafeTrips = safeTrips.size();
    
    89
    -
    
    90
    -        Set<Trip> unsafeTrips = context.getResultAsSet(
    
    91
    -                AnalyzeInputSourceAction.RESULT_UNSAFE_TRIPS,
    
    92
    -                Trip.class
    
    93
    -        );
    
    73
    +        Set<Trip> unsafeTrips = context.getResultAsSet(AnalyzeInputSourceAction.RESULT_UNSAFE_TRIPS, Trip.class);
    
    94 74
             nbUnsafeTrips = unsafeTrips.size();
    
    95
    -
    
    96
    -        boolean canImport = CollectionUtils.isEmpty(unsafeTrips) &&
    
    97
    -                            CollectionUtils.isNotEmpty(safeTrips);
    
    98
    -
    
    75
    +        boolean canImport = CollectionUtils.isEmpty(unsafeTrips) && CollectionUtils.isNotEmpty(safeTrips);
    
    99 76
             // action is valid, only if there is some safe trips and no unsafe trip
    
    100 77
             valid = canImport;
    
    101
    -
    
    102 78
             Map<Trip, Trip> tripsToReplace;
    
    103
    -
    
    104 79
             if (canImport) {
    
    105
    -
    
    106 80
                 // find out if there is some existing trip to re-import
    
    107
    -
    
    108
    -            tripsToReplace = context.getResultAsMap(
    
    109
    -                    AnalyzeInputSourceAction.RESULT_TRIPS_TO_REPLACE
    
    110
    -            );
    
    81
    +            tripsToReplace = context.getResultAsMap(AnalyzeInputSourceAction.RESULT_TRIPS_TO_REPLACE);
    
    111 82
             } else {
    
    112
    -
    
    113 83
                 // no trip to replace
    
    114 84
                 tripsToReplace = Collections.emptyMap();
    
    115 85
             }
    
    116
    -
    
    117 86
             nbTripsToReplace = tripsToReplace.size();
    
    118
    -
    
    119 87
             needReplace = MapUtils.isNotEmpty(tripsToReplace);
    
    120
    -
    
    121 88
             return INPUT;
    
    122 89
         }
    
    123 90
     
    
    91
    +    @Override
    
    92
    +    protected Map<String, Object> prepareResumeParameters(AnalyzeInputSourceAction action, Exception error, Date startDate, Date endDate) {
    
    93
    +        Map<String, Object> map = super.prepareResumeParameters(action, error, startDate, endDate);
    
    94
    +        T3ActionContext<AnalyzeInputSourceConfiguration> actionContext = getT3ActionContext();
    
    95
    +        Set<Trip> safeTrips = actionContext.getResultAsSet(AnalyzeInputSourceAction.RESULT_SAFE_TRIPS, Trip.class);
    
    96
    +        map.put(AnalyzeInputSourceAction.RESULT_SAFE_TRIPS, safeTrips);
    
    97
    +        Set<Trip> unsafeTrips = actionContext.getResultAsSet(AnalyzeInputSourceAction.RESULT_UNSAFE_TRIPS, Trip.class);
    
    98
    +        map.put(AnalyzeInputSourceAction.RESULT_UNSAFE_TRIPS, unsafeTrips);
    
    99
    +        Map<Trip, Trip> tripsToReplace = actionContext.getResultAsMap(AnalyzeInputSourceAction.RESULT_TRIPS_TO_REPLACE);
    
    100
    +        map.put(AnalyzeInputSourceAction.RESULT_TRIPS_TO_REPLACE, tripsToReplace);
    
    101
    +        map.put("tripDecorator", getDecorator(Trip.class));
    
    102
    +        map.put("tripDecorator2", getDecorator(Trip.class, DecoratorService.WITH_ID));
    
    103
    +        return map;
    
    104
    +    }
    
    105
    +
    
    106
    +    @SuppressWarnings("unused")
    
    107
    +    public List<T3InputProvider> getInputProviders() {
    
    108
    +        return inputProviders;
    
    109
    +    }
    
    110
    +
    
    111
    +    @SuppressWarnings("unused")
    
    124 112
         public int getNbUnsafeTrips() {
    
    125 113
             return nbUnsafeTrips;
    
    126 114
         }
    
    127 115
     
    
    116
    +    @SuppressWarnings("unused")
    
    128 117
         public int getNbSafeTrips() {
    
    129 118
             return nbSafeTrips;
    
    130 119
         }
    
    131 120
     
    
    121
    +    @SuppressWarnings("unused")
    
    132 122
         public int getNbTripsToReplace() {
    
    133 123
             return nbTripsToReplace;
    
    134 124
         }
    
    135 125
     
    
    126
    +    @SuppressWarnings("unused")
    
    136 127
         public boolean isValid() {
    
    137 128
             return valid;
    
    138 129
         }
    
    139 130
     
    
    131
    +    @SuppressWarnings("unused")
    
    140 132
         public boolean isNeedReplace() {
    
    141 133
             return needReplace;
    
    142 134
         }
    
    143
    -
    
    144
    -    @Override
    
    145
    -    protected Map<String, Object> prepareResumeParameters(AnalyzeInputSourceAction action,
    
    146
    -                                                          Exception error,
    
    147
    -                                                          Date startDate,
    
    148
    -                                                          Date endDate) {
    
    149
    -        Map<String, Object> map = super.prepareResumeParameters(action, error, startDate, endDate);
    
    150
    -
    
    151
    -        T3ActionContext<AnalyzeInputSourceConfiguration> actionContext = getT3ActionContext();
    
    152
    -
    
    153
    -        Set<Trip> safeTrips = actionContext.getResultAsSet(
    
    154
    -                AnalyzeInputSourceAction.RESULT_SAFE_TRIPS,
    
    155
    -                Trip.class
    
    156
    -        );
    
    157
    -        map.put(AnalyzeInputSourceAction.RESULT_SAFE_TRIPS, safeTrips);
    
    158
    -        Set<Trip> unsafeTrips = actionContext.getResultAsSet(
    
    159
    -                AnalyzeInputSourceAction.RESULT_UNSAFE_TRIPS,
    
    160
    -                Trip.class
    
    161
    -        );
    
    162
    -        map.put(AnalyzeInputSourceAction.RESULT_UNSAFE_TRIPS, unsafeTrips);
    
    163
    -        Map<Trip, Trip> tripsToReplace = actionContext.getResultAsMap(
    
    164
    -                AnalyzeInputSourceAction.RESULT_TRIPS_TO_REPLACE
    
    165
    -        );
    
    166
    -        map.put(AnalyzeInputSourceAction.RESULT_TRIPS_TO_REPLACE, tripsToReplace);
    
    167
    -
    
    168
    -        map.put("tripDecorator", getDecorator(Trip.class));
    
    169
    -
    
    170
    -        map.put("tripDecorator2",
    
    171
    -                getDecorator(Trip.class, DecoratorService.WITH_ID));
    
    172
    -        return map;
    
    173
    -    }
    
    174 135
     }

  • t3-web/src/main/java/fr/ird/t3/web/actions/io/input/ConfigureImportDataAction.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%
    
    ... ... @@ -55,22 +55,21 @@ import java.util.zip.ZipFile;
    55 55
      */
    
    56 56
     public class ConfigureImportDataAction extends AbstractConfigureAction<AnalyzeInputSourceConfiguration> {
    
    57 57
     
    
    58
    -    //    public static final String RELOAD_ACTION = "reload";
    
    59 58
         private static final long serialVersionUID = 1L;
    
    60 59
         private static final Log log = LogFactory.getLog(ConfigureImportDataAction.class);
    
    61 60
     
    
    62
    -    /** Input file that was just uploaded on server */
    
    61
    +    /**
    
    62
    +     * Input file that was just uploaded on server.
    
    63
    +     */
    
    63 64
         private File sourceToLoad;
    
    64
    -    /** Name of file to upload */
    
    65
    +    /**
    
    66
    +     * Name of file to upload.
    
    67
    +     */
    
    65 68
         private String sourceToLoadFileName;
    
    66
    -    /** flag to use strict mode with wells. */
    
    67
    -    private boolean useWells;
    
    68 69
         /**
    
    69
    -     * Trip type to use
    
    70
    -     *
    
    71
    -     * @since 2.3
    
    70
    +     * Flag to use strict mode with wells.
    
    72 71
          */
    
    73
    -    private TripType tripType = TripType.STANDARD;
    
    72
    +    private boolean useWells;
    
    74 73
         /**
    
    75 74
          * flag to authorize creation of missing vessels.
    
    76 75
          *
    
    ... ... @@ -83,6 +82,24 @@ public class ConfigureImportDataAction extends AbstractConfigureAction<AnalyzeIn
    83 82
          * @since 1.3.1
    
    84 83
          */
    
    85 84
         private boolean createVirtualVessel;
    
    85
    +    /**
    
    86
    +     * Flag to load only samples only trips
    
    87
    +     *
    
    88
    +     * @see TripType#SAMPLEONLY
    
    89
    +     */
    
    90
    +    private boolean useSamplesOnly;
    
    91
    +    /**
    
    92
    +     * Flag to authorize virtual activity creation (when logbooks are missing).
    
    93
    +     * <p>
    
    94
    +     * By default, let's always authorize it.
    
    95
    +     * <p>
    
    96
    +     * <b>Note:</b> This option is always at false if {@link #useSamplesOnly} is on.
    
    97
    +     *
    
    98
    +     * @see TripType#LOGBOOKMISSING
    
    99
    +     * @see TripType#STANDARD
    
    100
    +     */
    
    101
    +    private boolean canCreateVirtualActivity;
    
    102
    +
    
    86 103
         private long maxSize;
    
    87 104
         /** List of all known input providers. */
    
    88 105
         private List<T3InputProvider> inputProviders;
    
    ... ... @@ -100,139 +117,79 @@ public class ConfigureImportDataAction extends AbstractConfigureAction<AnalyzeIn
    100 117
             super(AnalyzeInputSourceConfiguration.class);
    
    101 118
         }
    
    102 119
     
    
    103
    -    public String getMaxSize() {
    
    104
    -        return StringUtil.convertMemory(maxSize);
    
    105
    -    }
    
    106
    -
    
    107
    -    @Inject(StrutsConstants.STRUTS_MULTIPART_MAXSIZE)
    
    108
    -    public void setMaxSize(String maxSize) {
    
    109
    -        this.maxSize = Long.parseLong(maxSize);
    
    110
    -    }
    
    111
    -
    
    112 120
         @Override
    
    113 121
         public void prepare() throws Exception {
    
    114
    -
    
    115 122
             injectOnly(InjectDAO.class);
    
    116
    -
    
    117 123
             if (!isConfigurationInSession()) {
    
    118
    -
    
    119 124
                 // no yet configuration, can use all input providers
    
    120 125
                 inputProviders = Arrays.asList(getT3InputService().getProviders());
    
    121
    -
    
    122 126
             } else {
    
    123
    -            // as soon as there is a configuration, can only use the
    
    124
    -            // inputProvider from it
    
    125
    -
    
    127
    +            // as soon as there is a configuration, can only use the inputProvider from it
    
    126 128
                 inputProviders = Collections.singletonList(getConfiguration().getInputProvider());
    
    127 129
             }
    
    128
    -
    
    129 130
             injectOnly(InjectDecoratedBeans.class);
    
    130
    -
    
    131 131
             if (getTreatmentDirectoryPath() == null) {
    
    132
    -
    
    133 132
                 // first time coming here get a new treatment directory path
    
    134
    -
    
    135 133
                 File workingDirectory = getApplicationConfig().getTreatmentWorkingDirectory();
    
    136
    -
    
    137 134
                 long l = System.nanoTime();
    
    138
    -
    
    139 135
                 File treatmentDirectory = new File(workingDirectory, "importData-" + l);
    
    140
    -
    
    141 136
                 FileUtil.createDirectoryIfNecessary(treatmentDirectory);
    
    142
    -
    
    143
    -            if (log.isInfoEnabled()) {
    
    144
    -                log.info(String.format("Create a new treatment directory path : %s", treatmentDirectory));
    
    145
    -            }
    
    146
    -
    
    137
    +            log.info(String.format("Create a new treatment directory path : %s", treatmentDirectory));
    
    147 138
                 setTreatmentDirectoryPath(treatmentDirectory.getAbsolutePath());
    
    148 139
             } else {
    
    149
    -
    
    150
    -            if (log.isInfoEnabled()) {
    
    151
    -                log.info(String.format("Use existing treatment directory %s", getTreatmentDirectoryPath()));
    
    152
    -            }
    
    140
    +            log.info(String.format("Use existing treatment directory %s", getTreatmentDirectoryPath()));
    
    153 141
             }
    
    154 142
         }
    
    155 143
     
    
    156 144
         public String doAddSource() throws Exception {
    
    157
    -
    
    158
    -        // this action execution purpose is to add a new source to the
    
    159
    -        // treatment configuration
    
    160
    -        // It will upload the file and place it the correct place (says the
    
    161
    -        // temporary directory of the treatment configuration)
    
    162
    -
    
    163
    -        // file uploaded on server
    
    145
    +        // this action execution purpose is to add a new source to the treatment configuration
    
    146
    +        // It will upload the file and place it the correct place (says the temporary directory of the treatment configuration)
    
    164 147
             File upload = getSourceToLoad();
    
    165
    -
    
    166 148
             if (upload == null) {
    
    167
    -
    
    168 149
                 String message = t("t3.error.required.file.to.upload");
    
    169 150
                 addFieldError("sourceToLoad", message);
    
    170 151
                 log.error(message);
    
    171 152
                 return ERROR;
    
    172 153
             }
    
    173
    -
    
    174 154
             // treatment directory
    
    175 155
             File targetDirectory = getTreatmentDirectory();
    
    176
    -
    
    177 156
             String filename = getSourceToLoadFileName();
    
    178
    -
    
    179 157
             if (ZipUtil.isZipFile(upload)) {
    
    180
    -
    
    181 158
                 // let's decompress input stream it
    
    182 159
                 ZipFile zipfile = new ZipFile(upload);
    
    183
    -
    
    184 160
                 Enumeration<? extends ZipEntry> entries = zipfile.entries();
    
    185
    -
    
    186 161
                 if (!entries.hasMoreElements()) {
    
    187 162
                     String message = t("t3.error.required.one.entry.in.zip.to.upload");
    
    188 163
                     addFieldError("sourceToLoad", message);
    
    189 164
                     log.error(message);
    
    190 165
                     return ERROR;
    
    191 166
                 }
    
    192
    -
    
    193 167
                 // get first entry
    
    194 168
                 ZipEntry zipEntry = entries.nextElement();
    
    195
    -
    
    196 169
                 // keep the filename of the zip entry
    
    197 170
                 filename = zipEntry.getName();
    
    198
    -
    
    199 171
                 File target = new File(targetDirectory, filename);
    
    200
    -
    
    201
    -            if (log.isInfoEnabled()) {
    
    202
    -                log.info(String.format("Will copy loaded zipped entry file %s to treatment configuration directory %s", filename, target));
    
    203
    -            }
    
    172
    +            log.info(String.format("Will copy loaded zipped entry file %s to treatment configuration directory %s", filename, target));
    
    204 173
                 try (InputStream in = zipfile.getInputStream(zipEntry)) {
    
    205 174
                     FileUtils.copyInputStreamToFile(in, target);
    
    206 175
                 }
    
    207 176
             } else {
    
    208
    -
    
    209 177
                 // target file
    
    210 178
                 File target = new File(targetDirectory, filename);
    
    211
    -
    
    212
    -            if (log.isInfoEnabled()) {
    
    213
    -                log.info(String.format("Will copy loaded file %s to treatment configuration directory %s", upload, target));
    
    214
    -            }
    
    215
    -
    
    179
    +            log.info(String.format("Will copy loaded file %s to treatment configuration directory %s", upload, target));
    
    216 180
                 // just copy file
    
    217 181
                 FileUtils.copyFile(upload, target);
    
    218 182
             }
    
    219
    -
    
    220 183
             // add the new file to the sources
    
    221 184
             setLoadedSource(filename);
    
    222
    -
    
    223 185
             // go back to the configuration definition
    
    224 186
             return INPUT;
    
    225 187
         }
    
    226 188
     
    
    227 189
         public String doDeleteSource() throws Exception {
    
    228
    -
    
    229 190
             String filename = getLoadedSource();
    
    230
    -
    
    231 191
             File targetDirectory = getTreatmentDirectory();
    
    232
    -
    
    233
    -        if (log.isInfoEnabled()) {
    
    234
    -            log.info(String.format("Will delete loaded file %s from %s", filename, targetDirectory));
    
    235
    -        }
    
    192
    +        log.info(String.format("Will delete loaded file %s from %s", filename, targetDirectory));
    
    236 193
             File f = new File(targetDirectory, filename);
    
    237 194
             if (f.exists()) {
    
    238 195
                 boolean delete = f.delete();
    
    ... ... @@ -240,9 +197,7 @@ public class ConfigureImportDataAction extends AbstractConfigureAction<AnalyzeIn
    240 197
                     throw new IOException(String.format("Could not delete file %s on server.", f));
    
    241 198
                 }
    
    242 199
             }
    
    243
    -
    
    244 200
             setLoadedSource(null);
    
    245
    -
    
    246 201
             // go back to the configuration definition
    
    247 202
             return INPUT;
    
    248 203
         }
    
    ... ... @@ -251,107 +206,143 @@ public class ConfigureImportDataAction extends AbstractConfigureAction<AnalyzeIn
    251 206
             T3InputProvider inputProvider = getT3InputService().getProvider(getInputProviderId());
    
    252 207
             File path = getTreatmentDirectory();
    
    253 208
             String name = getLoadedSource();
    
    254
    -
    
    255 209
             File inputFile = new File(path, name);
    
    256
    -
    
    257
    -        if (log.isInfoEnabled()) {
    
    258
    -            log.info(String.format("Will use input provider : %s", inputProvider));
    
    259
    -            log.info(String.format("Will use input file     : %s", inputFile));
    
    260
    -        }
    
    261
    -
    
    262
    -        // prepare a new action configuration
    
    263
    -        configuration = AnalyzeInputSourceConfiguration.newConfiguration(
    
    264
    -                inputProvider,
    
    265
    -                inputFile,
    
    266
    -                useWells,
    
    267
    -                tripType,
    
    268
    -                canCreateVessel,
    
    269
    -                createVirtualVessel);
    
    270
    -
    
    210
    +        TripType tripType = TripType.getTripType(useSamplesOnly, canCreateVirtualActivity);
    
    211
    +        log.info(String.format("input provider           : %s", inputProvider));
    
    212
    +        log.info(String.format("input file               : %s", inputFile));
    
    213
    +        log.info(String.format("userWells                : %s", useWells));
    
    214
    +        log.info(String.format("tripType                 : %s", tripType));
    
    215
    +        log.info(String.format("canCreateVessel          : %s", canCreateVessel));
    
    216
    +        log.info(String.format("createVirtualVessel      : %s", createVirtualVessel));
    
    217
    +        log.info(String.format("canCreateVirtualActivity : %s", canCreateVirtualActivity));
    
    218
    +        log.info(String.format("useSamplesOnly           : %s", useSamplesOnly));
    
    219
    +        configuration = AnalyzeInputSourceConfiguration.newConfiguration(inputProvider, inputFile, useWells, canCreateVessel, createVirtualVessel, useSamplesOnly, canCreateVirtualActivity);
    
    271 220
             prepareActionContext();
    
    272 221
             return SUCCESS;
    
    273 222
         }
    
    274 223
     
    
    275
    -    public TripType getTripType() {
    
    276
    -        return tripType;
    
    224
    +    @SuppressWarnings("unused")
    
    225
    +    public String getMaxSize() {
    
    226
    +        return StringUtil.convertMemory(maxSize);
    
    277 227
         }
    
    278 228
     
    
    279
    -    public void setTripType(TripType tripType) {
    
    280
    -        this.tripType = tripType;
    
    229
    +    @SuppressWarnings("unused")
    
    230
    +    @Inject(StrutsConstants.STRUTS_MULTIPART_MAXSIZE)
    
    231
    +    public void setMaxSize(String maxSize) {
    
    232
    +        this.maxSize = Long.parseLong(maxSize);
    
    281 233
         }
    
    282 234
     
    
    235
    +    @SuppressWarnings("unused")
    
    283 236
         public Map<String, String> getTripTypes() {
    
    284 237
             return tripTypes;
    
    285 238
         }
    
    286 239
     
    
    240
    +    @SuppressWarnings("unused")
    
    287 241
         public void setTripTypes(Map<String, String> tripTypes) {
    
    288 242
             this.tripTypes = tripTypes;
    
    289 243
         }
    
    290 244
     
    
    245
    +    @SuppressWarnings({"unused", "WeakerAccess"})
    
    291 246
         public File getSourceToLoad() {
    
    292 247
             return sourceToLoad;
    
    293 248
         }
    
    294 249
     
    
    250
    +    @SuppressWarnings("unused")
    
    295 251
         public void setSourceToLoad(File sourceToLoad) {
    
    296 252
             this.sourceToLoad = sourceToLoad;
    
    297 253
         }
    
    298 254
     
    
    255
    +    @SuppressWarnings({"unused", "WeakerAccess"})
    
    299 256
         public String getSourceToLoadFileName() {
    
    300 257
             return sourceToLoadFileName;
    
    301 258
         }
    
    302 259
     
    
    260
    +    @SuppressWarnings("unused")
    
    303 261
         public void setSourceToLoadFileName(String sourceToLoadFileName) {
    
    304 262
             this.sourceToLoadFileName = sourceToLoadFileName;
    
    305 263
         }
    
    306 264
     
    
    265
    +    @SuppressWarnings("unused")
    
    307 266
         public boolean isUseWells() {
    
    308 267
             return useWells;
    
    309 268
         }
    
    310 269
     
    
    270
    +    @SuppressWarnings("unused")
    
    311 271
         public void setUseWells(boolean useWells) {
    
    312 272
             this.useWells = useWells;
    
    313 273
         }
    
    314 274
     
    
    275
    +    @SuppressWarnings("unused")
    
    315 276
         public boolean isCanCreateVessel() {
    
    316 277
             return canCreateVessel;
    
    317 278
         }
    
    318 279
     
    
    280
    +    @SuppressWarnings("unused")
    
    319 281
         public void setCanCreateVessel(boolean canCreateVessel) {
    
    320 282
             this.canCreateVessel = canCreateVessel;
    
    321 283
         }
    
    322 284
     
    
    285
    +    @SuppressWarnings("unused")
    
    323 286
         public boolean isCreateVirtualVessel() {
    
    324 287
             return createVirtualVessel;
    
    325 288
         }
    
    326 289
     
    
    290
    +    @SuppressWarnings("unused")
    
    327 291
         public void setCreateVirtualVessel(boolean createVirtualVessel) {
    
    328 292
             this.createVirtualVessel = createVirtualVessel;
    
    329 293
         }
    
    330 294
     
    
    295
    +    @SuppressWarnings({"unused", "WeakerAccess"})
    
    331 296
         public String getInputProviderId() {
    
    332 297
             return inputProviderId;
    
    333 298
         }
    
    334 299
     
    
    300
    +    @SuppressWarnings("unused")
    
    335 301
         public void setInputProviderId(String inputProviderId) {
    
    336 302
             this.inputProviderId = inputProviderId;
    
    337 303
         }
    
    338 304
     
    
    305
    +    @SuppressWarnings({"unused", "WeakerAccess"})
    
    339 306
         public String getLoadedSource() {
    
    340 307
             return loadedSource;
    
    341 308
         }
    
    342 309
     
    
    310
    +    @SuppressWarnings({"unused", "WeakerAccess"})
    
    343 311
         public void setLoadedSource(String loadedSource) {
    
    344 312
             this.loadedSource = loadedSource;
    
    345 313
         }
    
    346 314
     
    
    315
    +    @SuppressWarnings({"unused", "WeakerAccess"})
    
    347 316
         public String getTreatmentDirectoryPath() {
    
    348 317
             return treatmentDirectoryPath;
    
    349 318
         }
    
    350 319
     
    
    320
    +    @SuppressWarnings({"unused", "WeakerAccess"})
    
    351 321
         public void setTreatmentDirectoryPath(String treatmentDirectoryPath) {
    
    352 322
             this.treatmentDirectoryPath = treatmentDirectoryPath;
    
    353 323
         }
    
    354 324
     
    
    325
    +    @SuppressWarnings("unused")
    
    326
    +    public boolean isUseSamplesOnly() {
    
    327
    +        return useSamplesOnly;
    
    328
    +    }
    
    329
    +
    
    330
    +    @SuppressWarnings("unused")
    
    331
    +    public void setUseSamplesOnly(boolean useSamplesOnly) {
    
    332
    +        this.useSamplesOnly = useSamplesOnly;
    
    333
    +    }
    
    334
    +
    
    335
    +    @SuppressWarnings("unused")
    
    336
    +    public boolean isCanCreateVirtualActivity() {
    
    337
    +        return canCreateVirtualActivity;
    
    338
    +    }
    
    339
    +
    
    340
    +    @SuppressWarnings("unused")
    
    341
    +    public void setCanCreateVirtualActivity(boolean canCreateVirtualActivity) {
    
    342
    +        this.canCreateVirtualActivity = canCreateVirtualActivity;
    
    343
    +    }
    
    344
    +
    
    345
    +    @SuppressWarnings("unused")
    
    355 346
         public final List<T3InputProvider> getInputProviders() {
    
    356 347
             return inputProviders;
    
    357 348
         }
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/io/input/ImportDataAction.java
    ... ... @@ -49,15 +49,15 @@ import java.util.Set;
    49 49
     public class ImportDataAction extends AbstractRunAction<ImportInputSourceConfiguration, ImportInputSourceAction> {
    
    50 50
     
    
    51 51
         private static final long serialVersionUID = 1L;
    
    52
    -
    
    53 52
         private static final Log log = LogFactory.getLog(ImportDataAction.class);
    
    54 53
     
    
    55 54
         private boolean replaceTrip;
    
    56 55
         private boolean valid;
    
    57 56
         private int nbImportedTrips;
    
    58 57
         private int nbDeletedTrips;
    
    59
    -
    
    60
    -    /** List of all known input providers. */
    
    58
    +    /**
    
    59
    +     * List of all known input providers.
    
    60
    +     */
    
    61 61
         private List<T3InputProvider> inputProviders;
    
    62 62
     
    
    63 63
         public ImportDataAction() {
    
    ... ... @@ -70,132 +70,101 @@ public class ImportDataAction extends AbstractRunAction<ImportInputSourceConfigu
    70 70
             inputProviders = Collections.singletonList(getIncomingConfiguration().getInputProvider());
    
    71 71
         }
    
    72 72
     
    
    73
    -    public final List<T3InputProvider> getInputProviders() {
    
    74
    -        return inputProviders;
    
    75
    -    }
    
    76
    -
    
    77
    -    public InputSourceConfiguration getIncomingConfiguration() {
    
    78
    -        Object configuration = getT3ActionContext().getConfiguration();
    
    79
    -        return (InputSourceConfiguration) configuration;
    
    80
    -    }
    
    81
    -
    
    82 73
         public String prepareImport() {
    
    83
    -
    
    84 74
             // get the action context from analyze
    
    85
    -
    
    86
    -        T3ActionContext<ImportInputSourceConfiguration> actionContext =
    
    87
    -                getT3ActionContext();
    
    88
    -
    
    89
    -        Set<Trip> safeTrips = actionContext.getResultAsSet(
    
    90
    -                AnalyzeInputSourceAction.RESULT_SAFE_TRIPS,
    
    91
    -                Trip.class);
    
    92
    -
    
    93
    -        Map<Trip, Trip> tripToReplace = actionContext.getResultAsMap(
    
    94
    -                AnalyzeInputSourceAction.RESULT_TRIPS_TO_REPLACE
    
    95
    -        );
    
    96
    -
    
    97
    -        if (log.isInfoEnabled()) {
    
    98
    -            log.info("--> Prepare import");
    
    99
    -            log.info("Input provider   : " + getIncomingConfiguration().getInputProvider());
    
    100
    -            log.info("Input file       : " + getIncomingConfiguration().getInputFile());
    
    101
    -            log.info("Use well         : " + getIncomingConfiguration().isUseWells());
    
    102
    -            log.info("Trip type        : " + getIncomingConfiguration().getTripType());
    
    103
    -            log.info("Can Create vessel: " + getIncomingConfiguration().isCanCreateVessel());
    
    104
    -            if (getIncomingConfiguration().isCanCreateVessel()) {
    
    105
    -                log.info("Create virtual vessel: " + getIncomingConfiguration().isCreateVirtualVessel());
    
    106
    -            }
    
    107
    -            log.info("Trips to import  : " + safeTrips.size());
    
    108
    -            log.info("Trips to replace : " + tripToReplace.size());
    
    75
    +        T3ActionContext<ImportInputSourceConfiguration> actionContext = getT3ActionContext();
    
    76
    +        Set<Trip> safeTrips = actionContext.getResultAsSet(AnalyzeInputSourceAction.RESULT_SAFE_TRIPS, Trip.class);
    
    77
    +        Map<Trip, Trip> tripToReplace = actionContext.getResultAsMap(AnalyzeInputSourceAction.RESULT_TRIPS_TO_REPLACE);
    
    78
    +        log.info("--> Prepare import");
    
    79
    +        log.info("Input provider   : " + getIncomingConfiguration().getInputProvider());
    
    80
    +        log.info("Input file       : " + getIncomingConfiguration().getInputFile());
    
    81
    +        log.info("Use well         : " + getIncomingConfiguration().isUseWells());
    
    82
    +        log.info("Trip type        : " + getIncomingConfiguration().getTripType());
    
    83
    +        log.info("Can Create vessel: " + getIncomingConfiguration().isCanCreateVessel());
    
    84
    +        if (getIncomingConfiguration().isCanCreateVessel()) {
    
    85
    +            log.info("Create virtual vessel: " + getIncomingConfiguration().isCreateVirtualVessel());
    
    109 86
             }
    
    110
    -
    
    87
    +        log.info("Trips to import  : " + safeTrips.size());
    
    88
    +        log.info("Trips to replace : " + tripToReplace.size());
    
    111 89
             Set<Trip> toImportTrips = new HashSet<>();
    
    112 90
             Set<Trip> toDeleteTrips = new HashSet<>();
    
    113
    -
    
    114 91
             if (isReplaceTrip()) {
    
    115
    -
    
    116
    -            // will replace existing trips
    
    117
    -            // so need to delete before all old trips
    
    92
    +            // will replace existing trips, so need to delete before all old trips
    
    118 93
                 toDeleteTrips.addAll(tripToReplace.keySet());
    
    119
    -
    
    120 94
                 // can import all safe trips
    
    121 95
                 toImportTrips.addAll(safeTrips);
    
    122
    -
    
    123 96
             } else {
    
    124
    -
    
    125 97
                 // do NOT replace old trip
    
    126
    -
    
    127 98
                 // get all importable trips
    
    128 99
                 toImportTrips.addAll(safeTrips);
    
    129
    -
    
    130 100
                 if (MapUtils.isNotEmpty(tripToReplace)) {
    
    131
    -
    
    132 101
                     // remove the one which reflect existing trips
    
    133 102
                     toImportTrips.removeAll(tripToReplace.values());
    
    134 103
                 }
    
    135 104
             }
    
    136
    -
    
    137 105
             // creates the new configuration
    
    138
    -
    
    139 106
             ImportInputSourceConfiguration configuration = ImportInputSourceConfiguration.newConfiguration(getIncomingConfiguration());
    
    140
    -
    
    141 107
             configuration.setTripsToImport(toImportTrips);
    
    142
    -
    
    143 108
             configuration.setTripsToDelete(toDeleteTrips);
    
    144
    -
    
    145
    -        t3ActionContext = getServiceFactory().newT3ActionContext(configuration, getServiceContext()
    
    146
    -        );
    
    147
    -        if (log.isInfoEnabled()) {
    
    148
    -            log.info("Created action context " + t3ActionContext);
    
    149
    -        }
    
    109
    +        t3ActionContext = getServiceFactory().newT3ActionContext(configuration, getServiceContext());
    
    110
    +        log.info("Created action context " + t3ActionContext);
    
    150 111
             getT3Session().setActionContext(t3ActionContext);
    
    151
    -
    
    152 112
             return SUCCESS;
    
    153 113
         }
    
    154 114
     
    
    155 115
         public String prepareResult() {
    
    156
    -
    
    157 116
             Set<Trip> importedTrips = getConfiguration().getTripsToImport();
    
    158
    -
    
    159 117
             nbImportedTrips = importedTrips.size();
    
    118
    +        Set<Trip> deletedTrips = getConfiguration().getTripsToDelete();
    
    119
    +        nbDeletedTrips = deletedTrips.size();
    
    120
    +        return INPUT;
    
    121
    +    }
    
    160 122
     
    
    161
    -        Set<Trip> deletedeTrips = getConfiguration().getTripsToDelete();
    
    123
    +    @Override
    
    124
    +    protected Map<String, Object> prepareResumeParameters(ImportInputSourceAction action, Exception error, Date startDate, Date endDate) {
    
    125
    +        Map<String, Object> map = super.prepareResumeParameters(action, error, startDate, endDate);
    
    126
    +        map.put("tripDecorator", getDecorator(Trip.class, DecoratorService.WITH_ID));
    
    127
    +        return map;
    
    128
    +    }
    
    162 129
     
    
    163
    -        nbDeletedTrips = deletedeTrips.size();
    
    130
    +    @SuppressWarnings("unused")
    
    131
    +    public List<T3InputProvider> getInputProviders() {
    
    132
    +        return inputProviders;
    
    133
    +    }
    
    164 134
     
    
    165
    -        return INPUT;
    
    135
    +    @SuppressWarnings("WeakerAccess")
    
    136
    +    public InputSourceConfiguration getIncomingConfiguration() {
    
    137
    +        Object configuration = getT3ActionContext().getConfiguration();
    
    138
    +        return (InputSourceConfiguration) configuration;
    
    166 139
         }
    
    167 140
     
    
    141
    +    @SuppressWarnings("unused")
    
    168 142
         public boolean isValid() {
    
    169 143
             return valid;
    
    170 144
         }
    
    171 145
     
    
    146
    +    @SuppressWarnings("unused")
    
    172 147
         public void setValid(boolean valid) {
    
    173 148
             this.valid = valid;
    
    174 149
         }
    
    175 150
     
    
    151
    +    @SuppressWarnings("unused")
    
    176 152
         public int getNbImportedTrips() {
    
    177 153
             return nbImportedTrips;
    
    178 154
         }
    
    179 155
     
    
    156
    +    @SuppressWarnings("unused")
    
    180 157
         public int getNbDeletedTrips() {
    
    181 158
             return nbDeletedTrips;
    
    182 159
         }
    
    183 160
     
    
    161
    +    @SuppressWarnings("WeakerAccess")
    
    184 162
         public boolean isReplaceTrip() {
    
    185 163
             return replaceTrip;
    
    186 164
         }
    
    187 165
     
    
    166
    +    @SuppressWarnings("unused")
    
    188 167
         public void setReplaceTrip(boolean replaceTrip) {
    
    189 168
             this.replaceTrip = replaceTrip;
    
    190 169
         }
    
    191
    -
    
    192
    -    @Override
    
    193
    -    protected Map<String, Object> prepareResumeParameters(ImportInputSourceAction action,
    
    194
    -                                                          Exception error,
    
    195
    -                                                          Date startDate,
    
    196
    -                                                          Date endDate) {
    
    197
    -        Map<String, Object> map = super.prepareResumeParameters(action, error, startDate, endDate);
    
    198
    -        map.put("tripDecorator", getDecorator(Trip.class, DecoratorService.WITH_ID));
    
    199
    -        return map;
    
    200
    -    }
    
    201 170
     }

  • t3-web/src/main/resources/i18n/t3-web_en_GB.properties
    1
    +t3.common.canCreateVirtualActivity=Authorize to create virtaul activities (for trips with missing logbook)
    
    1 2
     t3.action.applyFilter=Apply
    
    2 3
     t3.action.back.to.configuration.step1=Back to step 1 of configuration
    
    3 4
     t3.action.back.to.configuration.step2=Back to step 2 of configuration
    

  • t3-web/src/main/resources/i18n/t3-web_fr_FR.properties
    ... ... @@ -13,6 +13,7 @@ t3.action.delete=Supprimer
    13 13
     t3.action.deleteComputedData=Suppression des données calculées
    
    14 14
     t3.action.deleteTrips=Suppression des marées
    
    15 15
     t3.action.detail=Détails
    
    16
    +t3.common.canCreateVirtualActivity=Autoriser la création d'acitivités fictive (pour les marées sans livre de bord)
    
    16 17
     t3.action.dolog=S'authentifier
    
    17 18
     t3.action.edit=Editer
    
    18 19
     t3.action.getUserLog=Télécharger le fichier de logs
    

  • t3-web/src/main/webapp/WEB-INF/jsp/io/input/analyzeImportDataResult.jsp
    ... ... @@ -29,9 +29,7 @@
    29 29
     <jsp:include page="importDataConfigResume.jsp"/>
    
    30 30
     
    
    31 31
     <s:if test="valid">
    
    32
    -
    
    33 32
       <%-- Can do the import --%>
    
    34
    -
    
    35 33
       <p>
    
    36 34
         <s:text name="t3.label.message.trips.safe.to.import">
    
    37 35
           <s:param>
    
    ... ... @@ -39,27 +37,20 @@
    39 37
           </s:param>
    
    40 38
         </s:text>
    
    41 39
       </p>
    
    42
    -  
    
    43
    -  <s:form method="post" validate="true" namespace="/io">
    
    44 40
     
    
    41
    +  <s:form method="post" validate="true" namespace="/io">
    
    45 42
         <s:if test="needReplace">
    
    46 43
           <strong>
    
    47
    -      <s:text name="t3.label.message.trips.to.replace">
    
    48
    -        <s:param>
    
    49
    -          <s:property value="%{nbTripsToReplace}"/>
    
    50
    -        </s:param>
    
    51
    -      </s:text>
    
    44
    +        <s:text name="t3.label.message.trips.to.replace">
    
    45
    +          <s:param>
    
    46
    +            <s:property value="%{nbTripsToReplace}"/>
    
    47
    +          </s:param>
    
    48
    +        </s:text>
    
    52 49
           </strong>
    
    53 50
           <s:checkbox name="replaceTrip" key="t3.question.confirm.to.replace.trip" value="%{false}"/>
    
    54
    -
    
    55 51
         </s:if>
    
    56
    -
    
    57
    -    <s:submit action="prepareImportData"
    
    58
    -              key="t3.action.importData.doImport"
    
    59
    -              align="right"/>
    
    60
    -
    
    52
    +    <s:submit action="prepareImportData" key="t3.action.importData.doImport" align="right"/>
    
    61 53
       </s:form>
    
    62
    -
    
    63 54
     </s:if>
    
    64 55
     <s:else>
    
    65 56
       <p>
    

  • t3-web/src/main/webapp/WEB-INF/jsp/io/input/configureImportData.jsp
    ... ... @@ -25,41 +25,47 @@
    25 25
     
    
    26 26
     <script type="text/javascript">
    
    27 27
     
    
    28
    -  jQuery(document).ready(function () {
    
    29
    -
    
    30
    -    function changeCanCreateVessel(val) {
    
    31
    -      var container = $('[name="createVirtualVessel"]');
    
    32
    -      if (val) {
    
    33
    -        container.attr('disabled', false);
    
    34
    -        container.prop('checked', true);
    
    35
    -      } else {
    
    36
    -        container.attr('disabled', true);
    
    37
    -      }
    
    38
    -    }
    
    39
    -
    
    40
    -    $('[name="canCreateVessel"]').change(function () {
    
    41
    -      changeCanCreateVessel($(this).prop('checked'));
    
    28
    +    jQuery(document).ready(function () {
    
    29
    +        function changeCanCreateVessel(val) {
    
    30
    +            var container = $('[name="createVirtualVessel"]');
    
    31
    +            if (val) {
    
    32
    +                container.attr('disabled', false);
    
    33
    +                container.prop('checked', true);
    
    34
    +            } else {
    
    35
    +                container.attr('disabled', true);
    
    36
    +            }
    
    37
    +        }
    
    38
    +        function changeUseSamplesOnly(val) {
    
    39
    +            var container = $('[name="canCreateVirtualActivity"]');
    
    40
    +            if (val) {
    
    41
    +                container.attr('disabled', false);
    
    42
    +                container.prop('checked', true);
    
    43
    +            } else {
    
    44
    +                container.attr('disabled', true);
    
    45
    +                container.attr('checked', true);
    
    46
    +            }
    
    47
    +        }
    
    48
    +
    
    49
    +        $('[name="canCreateVessel"]').change(function () {
    
    50
    +            changeCanCreateVessel($(this).prop('checked'));
    
    51
    +        });
    
    52
    +        $('[name="useSamplesOnly"]').change(function () {
    
    53
    +            changeUseSamplesOnly($(this).prop('checked'));
    
    54
    +        });
    
    55
    +        changeCanCreateVessel(<s:property value="%{canCreateVessel}"/>);
    
    56
    +        changeUseSamplesOnly(<s:property value="%{useSamplesOnly}"/>);
    
    42 57
         });
    
    43
    -
    
    44
    -    changeCanCreateVessel(<s:property value="%{canCreateVessel}"/>);
    
    45
    -  });
    
    46 58
     </script>
    
    47 59
     <title><s:text name="t3.label.data.configureImportData"/></title>
    
    48
    -
    
    49 60
     <h2><s:text name="t3.label.data.configureImportData"/></h2>
    
    50 61
     
    
    51 62
     <s:form method="post" validate="true" enctype="multipart/form-data" namespace="/io">
    
    52
    -
    
    53 63
       <s:hidden key="treatmentDirectoryPath" label=''/>
    
    54
    -
    
    55
    -  <s:select key="inputProviderId" list="inputProviders" label='%{getText("t3.common.inputProvider")}' listKey="id" listValue="libelle" requiredLabel="true"/>
    
    56
    -
    
    64
    +  <s:select key="inputProviderId" list="inputProviders" label='%{getText("t3.common.inputProvider")}' listKey="id"
    
    65
    +            listValue="libelle" requiredLabel="true"/>
    
    57 66
       <s:if test="loadedSource==null">
    
    58
    -
    
    59 67
         <s:hidden name="useWells" value="%{useWells}"/>
    
    60
    -
    
    61 68
         <s:file name="sourceToLoad" requiredLabel="true" label='%{getText("t3.common.sourceToUpload")} (*)'/>
    
    62
    -
    
    63 69
         <s:submit action="configureImportData!doAddSource" key="t3.action.importData.addSource" align="right"/>
    
    64 70
         <br/>
    
    65 71
     
    
    ... ... @@ -68,17 +74,14 @@
    68 74
           <s:param value="%{maxSize}"/>
    
    69 75
         </s:text>
    
    70 76
         </div>
    
    71
    -
    
    72 77
       </s:if>
    
    73 78
       <s:else>
    
    74
    -
    
    75 79
         <s:hidden key="loadedSource" label=''/>
    
    76
    -
    
    77
    -    <s:textfield value="%{loadedSource}" key="t3.common.uploaded.source" disabled="true" requiredLabel="true" size="40"/>
    
    78
    -
    
    80
    +    <s:textfield value="%{loadedSource}" key="t3.common.uploaded.source" disabled="true" requiredLabel="true"
    
    81
    +                 size="40"/>
    
    79 82
         <s:checkbox key="useWells" label='%{getText("t3.common.force.useWells")}'/>
    
    80
    -
    
    81
    -    <s:select key="tripType" list="tripTypes" label='%{getText("t3.common.tripType")}' requiredLabel="true"/>
    
    83
    +    <s:checkbox key="samplesOnly" label='%{getText("t3.common.useSamplesOnly")}'/>
    
    84
    +    <s:checkbox key="canCreateVirtualActivity" label='%{getText("t3.common.canCreateVirtualActivity")}'/>
    
    82 85
         <s:checkbox key="canCreateVessel" label='%{getText("t3.common.canCreateVessel")}'/>
    
    83 86
         <s:checkbox key="createVirtualVessel" label='%{getText("t3.common.createVirtualVessel")}'/>
    
    84 87
         <s:submit action="configureImportData!doDeleteSource" key="t3.action.importData.deleteSource" align="right"/>
    

  • t3-web/src/main/webapp/WEB-INF/jsp/io/input/importDataConfigResume.jsp
    ... ... @@ -22,21 +22,23 @@
    22 22
     <%@ taglib prefix="s" uri="/struts-tags" %>
    
    23 23
     <%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
    
    24 24
     <fieldset>
    
    25
    -
    
    26 25
       <legend>
    
    27 26
         <s:text name="t3.label.importData.config.resume"/>
    
    28 27
       </legend>
    
    29
    -
    
    30 28
       <s:form>
    
    31
    -    <s:select key="t3.common.inputProvider" list="inputProviders" listKey="id" listValue="libelle" value="%{configuration.inputProvider.id}" disabled="true"/>
    
    29
    +    <s:select key="t3.common.inputProvider" list="inputProviders" listKey="id" listValue="libelle"
    
    30
    +              value="%{configuration.inputProvider.id}" disabled="true"/>
    
    32 31
         <s:textfield value="%{configuration.inputFile.name}" key="t3.common.uploaded.source" disabled="true" size="40"/>
    
    33 32
         <s:label key="t3.common.useWells" value=""/>
    
    34 33
         <s:checkbox name="useWells" value="%{configuration.useWells}" disabled="true" key="t3.common.force.useWells"/>
    
    35
    -    <s:select key="tripType" list="tripTypes" label='%{getText("t3.common.tripType")}' disabled="true" value="%{configuration.tripType}" />
    
    36
    -    <s:checkbox name="canCreateVessel" value="%{configuration.canCreateVessel}" disabled="true" key="t3.common.canCreateVessel"/>
    
    34
    +    <s:checkbox name="samplesOnly" value="%{configuration.samplesOnly}" disabled="true" key="t3.common.samplesOnly"/>
    
    35
    +    <s:checkbox name="canCreateVirtualActivity" value="%{configuration.canCreateVirtualActivity}" disabled="true"
    
    36
    +                key="t3.common.canCreateVirtualActivity"/>
    
    37
    +    <s:checkbox name="canCreateVessel" value="%{configuration.canCreateVessel}" disabled="true"
    
    38
    +                key="t3.common.canCreateVessel"/>
    
    37 39
         <s:if test="configuration.canCreateVessel">
    
    38
    -      <s:checkbox name="createVirtualVessel" value="%{configuration.createVirtualVessel}" disabled="true" key="t3.common.createVirtualVessel"/>
    
    40
    +      <s:checkbox name="createVirtualVessel" value="%{configuration.createVirtualVessel}" disabled="true"
    
    41
    +                  key="t3.common.createVirtualVessel"/>
    
    39 42
         </s:if>
    
    40 43
       </s:form>
    
    41
    -
    
    42 44
     </fieldset>