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

Commits:

3 changed files:

Changes:

  • t3-domain/src/main/java/fr/ird/t3/entities/reference/AbstractVesselSimpleTypeTopiaDao.java
    ... ... @@ -21,9 +21,10 @@
    21 21
     package fr.ird.t3.entities.reference;
    
    22 22
     
    
    23 23
     
    
    24
    +import org.nuiton.topia.persistence.TopiaException;
    
    25
    +
    
    24 26
     import java.util.HashSet;
    
    25 27
     import java.util.Set;
    
    26
    -import org.nuiton.topia.persistence.TopiaException;
    
    27 28
     
    
    28 29
     /**
    
    29 30
      * {@link VesselSimpleType} user dao operations.
    
    ... ... @@ -36,10 +37,11 @@ public class AbstractVesselSimpleTypeTopiaDao<E extends VesselSimpleType> extend
    36 37
         /**
    
    37 38
          * Obtains all vessel simple types used by all trips in the database.
    
    38 39
          *
    
    40
    +     * @param sampleOnly if null no filter else filter on value
    
    39 41
          * @return the set of used vessel simple types in trips in the database
    
    40 42
          * @throws TopiaException if any problem while querying the database
    
    41 43
          */
    
    42
    -    public Set<E> findAllUsedInTrip() throws TopiaException {
    
    44
    +    public Set<E> findAllUsedInTrip(Boolean sampleOnly) throws TopiaException {
    
    43 45
     
    
    44 46
     //        TopiaQuery query = createQuery("vst")
    
    45 47
     //                .addFrom(Trip.class, "t")
    
    ... ... @@ -48,7 +50,8 @@ public class AbstractVesselSimpleTypeTopiaDao<E extends VesselSimpleType> extend
    48 50
     //                          Vessel.PROPERTY_VESSEL_TYPE + "." +
    
    49 51
     //                          VesselType.PROPERTY_VESSEL_SIMPLE_TYPE + " = vst.id");
    
    50 52
     
    
    51
    -        String hql = "SELECT DISTINCT(vst) FROM VesselSimpleTypeImpl vst, TripImpl t WHERE t.vessel.vesselType.vesselSimpleType = vst.id";
    
    53
    +        String sampleOnlyFilter = sampleOnly == null ? "" : (" AND t.sampleOnly = " + sampleOnly);
    
    54
    +        String hql = "SELECT DISTINCT(vst) FROM VesselSimpleTypeImpl vst, TripImpl t WHERE t.vessel.vesselType.vesselSimpleType = vst.id" + sampleOnlyFilter;
    
    52 55
             return new HashSet<>(findAll(hql));
    
    53 56
     //        return T3EntityHelper.querytoSet(hql, this);
    
    54 57
         }
    

  • t3-domain/src/test/java/fr/ird/t3/entities/reference/VesselSimpleTypeTopiaDaoTest.java
    ... ... @@ -55,7 +55,7 @@ public class VesselSimpleTypeTopiaDaoTest extends AbstractDatabaseTest {
    55 55
             Trip trip = tx.getTripDao().create(
    
    56 56
                     Trip.PROPERTY_VESSEL, vessel
    
    57 57
             );
    
    58
    -        Set<VesselSimpleType> result = dao.findAllUsedInTrip();
    
    58
    +        Set<VesselSimpleType> result = dao.findAllUsedInTrip(null);
    
    59 59
             Assert.assertNotNull(result);
    
    60 60
             Assert.assertEquals(1, result.size());
    
    61 61
             Assert.assertEquals(vesselSimpleType, result.iterator().next());
    

  • t3-web/src/main/java/fr/ird/t3/web/actions/data/level0/AbstractLevel0ConfigureAction.java
    ... ... @@ -67,7 +67,7 @@ public abstract class AbstractLevel0ConfigureAction<C extends AbstractLevel0Conf
    67 67
         @InjectDecoratedBeans(beanType = VesselSimpleType.class)
    
    68 68
         protected Map<String, String> vesselSimpleTypes;
    
    69 69
     
    
    70
    -    @InjectDecoratedBeans(beanType = Country.class)
    
    70
    +    @InjectDecoratedBeans(beanType = Country.class, pathIds = "configuration.")
    
    71 71
         protected Map<String, String> fleets;
    
    72 72
     
    
    73 73
         protected AbstractLevel0ConfigureAction(Class<C> configurationType) {
    
    ... ... @@ -142,7 +142,7 @@ public abstract class AbstractLevel0ConfigureAction<C extends AbstractLevel0Conf
    142 142
             T3Date maxDate = tripDAO.getLastLandingDate();
    
    143 143
             config.setMaxDate(maxDate);
    
    144 144
             config.setEndDate(maxDate);
    
    145
    -        config.setVesselSimpleTypes(sortToList(vesselSimpleTypeDAO.findAllUsedInTrip()));
    
    145
    +        config.setVesselSimpleTypes(sortToList(vesselSimpleTypeDAO.findAllUsedInTrip(false)));
    
    146 146
             config.setFleets(sortToList(countryDAO.findAllFleetUsedInTrip()));
    
    147 147
     
    
    148 148
             if (log.isInfoEnabled()) {