[Git][ultreiaio/ird-t3][develop] Règles d'acceptation des marées dans les traitements (closes #276)
Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3 Commits: e46c2d8f by Tony CHEMIT at 2018-03-06T15:44:21Z Règles d'acceptation des marées dans les traitements (closes #276) - - - - - 4 changed files: - t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java - − t3-web/src/main/java/fr/ird/t3/web/validators/Level1ConfigurationFieldValidator.java - t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml - t3-web/src/main/resources/validators.xml Changes: ===================================== t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java ===================================== --- a/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java +++ b/t3-domain/src/main/java/fr/ird/t3/entities/data/AbstractTripTopiaDao.java @@ -234,8 +234,7 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao< } /** - * Obtains all trips usable for a level 1 configuration, says : - * <p/> + * Obtains all trips usable for a level 1 configuration, says: * <ul> * <li>Only for senneur vessel simple type</li> * <li>samplesOnly = true or completionStatus >0</li> @@ -247,8 +246,7 @@ public class AbstractTripTopiaDao<E extends Trip> extends GeneratedTripTopiaDao< */ @SuppressWarnings("unused") public List<E> findAllForLevel1() { - String hql = "SELECT t FROM TripImpl t WHERE t.vessel.vesselType.vesselSimpleType.code = 1 " + - "AND (t.tripType = 1 OR (t.completionStatus IS NOT NULL AND t.completionStatus > 0))"; + String hql = "SELECT t FROM TripImpl t WHERE t.vessel.vesselType.vesselSimpleType.code = 1"; List<E> result = findAll(hql); sortTrips(result); return result; ===================================== t3-web/src/main/java/fr/ird/t3/web/validators/Level1ConfigurationFieldValidator.java deleted ===================================== --- a/t3-web/src/main/java/fr/ird/t3/web/validators/Level1ConfigurationFieldValidator.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * #%L - * T3 :: Web - * %% - * Copyright (C) 2010 - 2018 IRD, Code Lutin, Ultreia.io - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ird.t3.web.validators; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import com.opensymphony.xwork2.validator.ValidationException; -import fr.ird.t3.actions.data.level0.Level0Step; -import fr.ird.t3.actions.data.level1.Level1Configuration; -import fr.ird.t3.entities.data.Trip; -import org.nuiton.decorator.Decorator; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import static org.nuiton.i18n.I18n.t; - -/** - * Validate that a level 1 configuration have all his trips ok for a - * level 1 treatment. - * - * @author Tony Chemit - dev@tchemit.fr - * @since 1.0 - */ -public class Level1ConfigurationFieldValidator extends T3BaseFieldValidatorSupport { - - @SuppressWarnings("unchecked") - @Override - protected void validateWhenNotSkip(Object object) throws ValidationException { - if (getValidatorContext().hasFieldErrors()) { - // do not continue - return; - } - - Level1Configuration configuration = (Level1Configuration) getFieldValue("configuration", object); - - Map<String, Trip> tripByTopiaIds = (Map<String, Trip>) getFieldValue("tripByTopiaIds", object); - - // check that every selected trip has his level 0 done. - Set<String> tripIds = configuration.getSampleIdsByTripId().keySet(); - - Decorator<Trip> decoratorByType = (Decorator<Trip>) getFieldValue("tripDecorator", object); - - Level0Step[] level0Steps = Level0Step.values(); - Multimap<String, Level0Step> m = ArrayListMultimap.create(); - for (String tripId : tripIds) { - - Trip trip = tripByTopiaIds.get(tripId); - - if (!trip.isSamplesOnly()) { - - // only check level0Step done only if Trip#tripType = 1 - String key = decoratorByType.toString(trip); - for (Level0Step level0Step : level0Steps) { - - boolean tripState = level0Step.getTripState(trip); - if (!tripState) { - m.put(key, level0Step); - } - } - } - } - - if (!m.isEmpty()) { - - // there is some trips without full level0 done - - for (String tripStr : m.keySet()) { - Collection<Level0Step> steps = m.get(tripStr); - addFieldError("matchingTripCount", - t("t3.error.missing.level0.steps.for.trip", tripStr, steps)); - } - } - } - - @Override - public String getValidatorType() { - return "level1Configuration"; - } -} ===================================== t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml ===================================== --- a/t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml +++ b/t3-web/src/main/resources/fr/ird/t3/web/actions/data/level1/ManageLevel1ConfigurationAction-validateLevel1Configuration-validation.xml @@ -80,12 +80,4 @@ </field> - <field name="matchingSampleCount"> - - <field-validator type="level1Configuration"> - <message/> - </field-validator> - - </field> - </validators> ===================================== t3-web/src/main/resources/validators.xml ===================================== --- a/t3-web/src/main/resources/validators.xml +++ b/t3-web/src/main/resources/validators.xml @@ -43,6 +43,5 @@ <!-- T3+ validators --> <validator name="login" class="fr.ird.t3.web.validators.LoginValidator"/> <validator name="checkJdbcConnection" class="fr.ird.t3.web.validators.CheckJdbcConnectionValidator"/> - <validator name="level1Configuration" class="fr.ird.t3.web.validators.Level1ConfigurationFieldValidator"/> </validators> View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/e46c2d8fb4e2566e6c6a0139beea4ee18... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-t3/commit/e46c2d8fb4e2566e6c6a0139beea4ee18... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT