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

Commits:

4 changed files:

Changes:

  • t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java
    ... ... @@ -234,8 +234,7 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<
    234 234
         }
    
    235 235
     
    
    236 236
         /**
    
    237
    -     * Obtains all trips usable for a level 1 configuration, says :
    
    238
    -     * <p/>
    
    237
    +     * Obtains all trips usable for a level 1 configuration, says:
    
    239 238
          * <ul>
    
    240 239
          * <li>Only for senneur vessel simple type</li>
    
    241 240
          * <li>samplesOnly = true or completionStatus >0</li>
    
    ... ... @@ -247,8 +246,7 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao<
    247 246
          */
    
    248 247
         @SuppressWarnings("unused")
    
    249 248
         public List<E> findAllForLevel1() {
    
    250
    -        String hql = "SELECT t FROM TripImpl t WHERE t.vessel.vesselType.vesselSimpleType.code = 1 " +
    
    251
    -                "AND (t.tripType = 1 OR (t.completionStatus IS NOT NULL AND t.completionStatus > 0))";
    
    249
    +        String hql = "SELECT t FROM TripImpl t WHERE t.vessel.vesselType.vesselSimpleType.code = 1";
    
    252 250
             List<E> result = findAll(hql);
    
    253 251
             sortTrips(result);
    
    254 252
             return result;
    

  • t3-web/src/main/java/fr/ird/t3/web/validators/Level1ConfigurationFieldValidator.java deleted
    1
    -/*
    
    2
    - * #%L
    
    3
    - * T3 :: Web
    
    4
    - * %%
    
    5
    - * Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io
    
    6
    - * %%
    
    7
    - * This program is free software: you can redistribute it and/or modify
    
    8
    - * it under the terms of the GNU Affero General Public License as published by
    
    9
    - * the Free Software Foundation, either version 3 of the License, or
    
    10
    - * (at your option) any later version.
    
    11
    - * 
    
    12
    - * This program is distributed in the hope that it will be useful,
    
    13
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    14
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    15
    - * GNU General Public License for more details.
    
    16
    - * 
    
    17
    - * You should have received a copy of the GNU Affero General Public License
    
    18
    - * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    19
    - * #L%
    
    20
    - */
    
    21
    -package fr.ird.t3.web.validators;
    
    22
    -
    
    23
    -import com.google.common.collect.ArrayListMultimap;
    
    24
    -import com.google.common.collect.Multimap;
    
    25
    -import com.opensymphony.xwork2.validator.ValidationException;
    
    26
    -import fr.ird.t3.actions.data.level0.Level0Step;
    
    27
    -import fr.ird.t3.actions.data.level1.Level1Configuration;
    
    28
    -import fr.ird.t3.entities.data.Trip;
    
    29
    -import org.nuiton.decorator.Decorator;
    
    30
    -
    
    31
    -import java.util.Collection;
    
    32
    -import java.util.Map;
    
    33
    -import java.util.Set;
    
    34
    -
    
    35
    -import static org.nuiton.i18n.I18n.t;
    
    36
    -
    
    37
    -/**
    
    38
    - * Validate that a level 1 configuration have all his trips ok for a
    
    39
    - * level 1 treatment.
    
    40
    - *
    
    41
    - * @author Tony Chemit - dev@tchemit.fr
    
    42
    - * @since 1.0
    
    43
    - */
    
    44
    -public class Level1ConfigurationFieldValidator extends T3BaseFieldValidatorSupport {
    
    45
    -
    
    46
    -    @SuppressWarnings("unchecked")
    
    47
    -    @Override
    
    48
    -    protected void validateWhenNotSkip(Object object) throws ValidationException {
    
    49
    -        if (getValidatorContext().hasFieldErrors()) {
    
    50
    -            // do not continue
    
    51
    -            return;
    
    52
    -        }
    
    53
    -
    
    54
    -        Level1Configuration configuration = (Level1Configuration) getFieldValue("configuration", object);
    
    55
    -
    
    56
    -        Map<String, Trip> tripByTopiaIds = (Map<String, Trip>) getFieldValue("tripByTopiaIds", object);
    
    57
    -
    
    58
    -        // check that every selected trip has his level 0 done.
    
    59
    -        Set<String> tripIds = configuration.getSampleIdsByTripId().keySet();
    
    60
    -
    
    61
    -        Decorator<Trip> decoratorByType = (Decorator<Trip>) getFieldValue("tripDecorator", object);
    
    62
    -
    
    63
    -        Level0Step[] level0Steps = Level0Step.values();
    
    64
    -        Multimap<String, Level0Step> m = ArrayListMultimap.create();
    
    65
    -        for (String tripId : tripIds) {
    
    66
    -
    
    67
    -            Trip trip = tripByTopiaIds.get(tripId);
    
    68
    -
    
    69
    -            if (!trip.isSamplesOnly()) {
    
    70
    -
    
    71
    -                // only check level0Step done only if Trip#tripType = 1
    
    72
    -                String key = decoratorByType.toString(trip);
    
    73
    -                for (Level0Step level0Step : level0Steps) {
    
    74
    -
    
    75
    -                    boolean tripState = level0Step.getTripState(trip);
    
    76
    -                    if (!tripState) {
    
    77
    -                        m.put(key, level0Step);
    
    78
    -                    }
    
    79
    -                }
    
    80
    -            }
    
    81
    -        }
    
    82
    -
    
    83
    -        if (!m.isEmpty()) {
    
    84
    -
    
    85
    -            // there is some trips without full level0 done
    
    86
    -
    
    87
    -            for (String tripStr : m.keySet()) {
    
    88
    -                Collection<Level0Step> steps = m.get(tripStr);
    
    89
    -                addFieldError("matchingTripCount",
    
    90
    -                              t("t3.error.missing.level0.steps.for.trip", tripStr, steps));
    
    91
    -            }
    
    92
    -        }
    
    93
    -    }
    
    94
    -
    
    95
    -    @Override
    
    96
    -    public String getValidatorType() {
    
    97
    -        return "level1Configuration";
    
    98
    -    }
    
    99
    -}

  • t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml
    ... ... @@ -80,12 +80,4 @@
    80 80
     
    
    81 81
       </field>
    
    82 82
     
    
    83
    -  <field name="matchingSampleCount">
    
    84
    -
    
    85
    -    <field-validator type="level1Configuration">
    
    86
    -      <message/>
    
    87
    -    </field-validator>
    
    88
    -
    
    89
    -  </field>
    
    90
    -
    
    91 83
     </validators>

  • t3-web/src/main/resources/validators.xml
    ... ... @@ -43,6 +43,5 @@
    43 43
       <!-- T3+ validators -->
    
    44 44
       <validator name="login" class="fr.ird.t3.web.validators.LoginValidator"/>
    
    45 45
       <validator name="checkJdbcConnection" class="fr.ird.t3.web.validators.CheckJdbcConnectionValidator"/>
    
    46
    -  <validator name="level1Configuration" class="fr.ird.t3.web.validators.Level1ConfigurationFieldValidator"/>
    
    47 46
     
    
    48 47
     </validators>