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

Commits:

14 changed files:

Changes:

  • client/src/main/java/fr/ird/observe/client/ui/admin/validate/ValidateUIHandler.java
    ... ... @@ -25,6 +25,7 @@ import com.google.common.base.Charsets;
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26 26
     import com.google.common.collect.Iterables;
    
    27 27
     import fr.ird.observe.client.ObserveSwingApplicationContext;
    
    28
    +import fr.ird.observe.client.configuration.ClientConfig;
    
    28 29
     import fr.ird.observe.client.constants.ValidationModelMode;
    
    29 30
     import fr.ird.observe.client.db.ObserveSwingDataSource;
    
    30 31
     import fr.ird.observe.client.ui.ObserveKeyStrokes;
    
    ... ... @@ -261,7 +262,7 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements
    261 262
                 return;
    
    262 263
             }
    
    263 264
     
    
    264
    -        DtoReference<?,?> ref = (DtoReference) o;
    
    265
    +        DtoReference<?, ?> ref = (DtoReference) o;
    
    265 266
     
    
    266 267
             if (log.isDebugEnabled()) {
    
    267 268
                 log.debug(ref);
    
    ... ... @@ -377,6 +378,8 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements
    377 378
             ImmutableSet<NuitonValidatorScope> scopes = ImmutableSet.copyOf(stepModel.getScopes());
    
    378 379
             String contextName = stepModel.getContextName();
    
    379 380
     
    
    381
    +        ClientConfig config = ObserveSwingApplicationContext.get().getConfig();
    
    382
    +
    
    380 383
             ValidationResult<?> result;
    
    381 384
     
    
    382 385
             if (dataModel.isLoadReferential()) {
    
    ... ... @@ -387,6 +390,9 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements
    387 390
                 request.setReferentialTypes(dataModel.getSelectedReferentiel());
    
    388 391
                 request.setScopes(scopes);
    
    389 392
                 request.setValidationContext(contextName);
    
    393
    +            request.setValidationSpeedMaxValue(config.getValidationSpeedMaxValue());
    
    394
    +            request.setValidationSpeedEnable(config.getValidationSpeedEnable());
    
    395
    +            request.setValidationLengthWeightEnable(config.getValidationLengthWeightEnable());
    
    390 396
     
    
    391 397
                 progressModel.incrementsCurrentStep();
    
    392 398
     
    
    ... ... @@ -394,12 +400,16 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements
    394 400
     
    
    395 401
             } else if (dataModel.isUseData()) {
    
    396 402
     
    
    403
    +
    
    397 404
                 DataValidationRequest mainRequest = new DataValidationRequest();
    
    398 405
                 mainRequest.setDataIds(ImmutableSet.copyOf(dataModel.getSelectedData().stream().map(DataDtoReference::getId).collect(Collectors.toSet())));
    
    399 406
                 mainRequest.setScopes(scopes);
    
    400 407
                 mainRequest.setValidationContext(contextName);
    
    408
    +            mainRequest.setValidationSpeedMaxValue(config.getValidationSpeedMaxValue());
    
    409
    +            mainRequest.setValidationSpeedEnable(config.getValidationSpeedEnable());
    
    410
    +            mainRequest.setValidationLengthWeightEnable(config.getValidationLengthWeightEnable());
    
    401 411
     
    
    402
    -            ValidationResult.Builder<DataValidationRequest> resultBuilder = ValidationResult.builder(ReferentialLocale.valueOf(ObserveSwingApplicationContext.get().getConfig().getDbLocale()), mainRequest);
    
    412
    +            ValidationResult.Builder<DataValidationRequest> resultBuilder = ValidationResult.builder(ReferentialLocale.valueOf(config.getDbLocale()), mainRequest);
    
    403 413
     
    
    404 414
                 for (DataDtoReference<?, ?> dataReference : dataModel.getSelectedData()) {
    
    405 415
     
    
    ... ... @@ -409,9 +419,12 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements
    409 419
                     request.setDataIds(ImmutableSet.of(id));
    
    410 420
                     request.setScopes(scopes);
    
    411 421
                     request.setValidationContext(contextName);
    
    422
    +                request.setValidationSpeedMaxValue(config.getValidationSpeedMaxValue());
    
    423
    +                request.setValidationSpeedEnable(config.getValidationSpeedEnable());
    
    424
    +                request.setValidationLengthWeightEnable(config.getValidationLengthWeightEnable());
    
    412 425
     
    
    413 426
                     //noinspection unchecked
    
    414
    -                sendMessage(t("observe.actions.validate.message.validate.trip", getDecoratorService().getDataReferenceDecorator((Class) dataReference.getDtoType()).toString(dataReference)));
    
    427
    +                sendMessage(t("observe.actions.validate.message.validate.trip", getDecoratorService().getDataReferenceDecorator((Class) dataReference.getReferenceType()).toString(dataReference)));
    
    415 428
                     progressModel.incrementsCurrentStep();
    
    416 429
     
    
    417 430
                     result = validateService.validateData(request);
    

  • client/src/main/java/fr/ird/observe/client/ui/content/ContentUIHandler.java
    ... ... @@ -656,12 +656,12 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U
    656 656
     
    
    657 657
         }
    
    658 658
     
    
    659
    -    public <E extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<E> formDefinition) {
    
    659
    +    public <F extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<F> formDefinition) {
    
    660 660
             loadReferentialReferenceSetsInModel(formDefinition, true);
    
    661 661
         }
    
    662
    -    protected <E extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<E> formDefinition, boolean clear) {
    
    662
    +    protected <F extends IdDto> void loadReferentialReferenceSetsInModel(FormDefinition<F> formDefinition, boolean clear) {
    
    663 663
     
    
    664
    -        Class<E> dtoType = formDefinition.getType();
    
    664
    +        Class<F> dtoType = formDefinition.getType();
    
    665 665
     
    
    666 666
             ImmutableMap.Builder<String, ReferentialDtoReferenceSet<?>> modelReferentialReferenceSets = ImmutableMap.builder();
    
    667 667
     
    
    ... ... @@ -1136,12 +1136,12 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U
    1136 1136
             comboBox.setData(data);
    
    1137 1137
         }
    
    1138 1138
     
    
    1139
    -    protected <R extends DataDtoReference> DataReferenceDecorator<R> getDataReferenceDecorator(Class<R> dtoType) {
    
    1140
    -        return getDecoratorService().getDataReferenceDecorator(dtoType);
    
    1139
    +    protected <R extends DataDtoReference> DataReferenceDecorator<R> getDataReferenceDecorator(Class<R> referenceType) {
    
    1140
    +        return getDecoratorService().getDataReferenceDecorator(referenceType);
    
    1141 1141
         }
    
    1142 1142
     
    
    1143
    -    protected <D extends ReferentialDtoReference> ReferentialReferenceDecorator<D> getReferentialReferenceDecorator(Class<D> dtoType) {
    
    1144
    -        return getDecoratorService().getReferentialReferenceDecorator(dtoType);
    
    1143
    +    protected <R extends ReferentialDtoReference> ReferentialReferenceDecorator<R> getReferentialReferenceDecorator(Class<R> referenceType) {
    
    1144
    +        return getDecoratorService().getReferentialReferenceDecorator(referenceType);
    
    1145 1145
         }
    
    1146 1146
     
    
    1147 1147
         private <D extends ReferentialDto, R extends ReferentialDtoReference<D, R>> ReferentialDtoReferenceSet<R> filterReferentialReferenceSet(String propertyName, DtoReferenceDefinition<D, R> propertyDefinition,
    
    ... ... @@ -1248,7 +1248,7 @@ public abstract class ContentUIHandler<E extends IdDto, U extends ContentUI<E, U
    1248 1248
     
    
    1249 1249
         }
    
    1250 1250
     
    
    1251
    -//    protected <D extends ReferentialDto> Optional<FormDefinition<D>> getReferentialFormRequest(Class<D> type) {
    
    1251
    +//    protected <R extends ReferentialDto> Optional<FormDefinition<R>> getReferentialFormRequest(Class<R> type) {
    
    1252 1252
     //        return DtoModelHelper.fromReferentialForm(type).toFormDefinition();
    
    1253 1253
     //    }
    
    1254 1254
     
    

  • client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeaderHandler.java
    ... ... @@ -67,10 +67,10 @@ public class NavigationTreeHeaderHandler implements UIHandler<NavigationTreeHead
    67 67
         @Override
    
    68 68
         public void afterInit(NavigationTreeHeader ui) {
    
    69 69
     
    
    70
    -        ui.getShowSeine().setIcon(UIHelper.getUIManagerIcon("navigation." + ProgramDto.class.getName() + "-16"));
    
    71
    -        ui.getShowLongline().setIcon(UIHelper.getUIManagerIcon("navigation." + ProgramDto.class.getName() + "-16"));
    
    70
    +        ui.getShowSeine().setIcon(UIHelper.getUIManagerIcon("navigation.referential.Program-16"));
    
    71
    +        ui.getShowLongline().setIcon(UIHelper.getUIManagerIcon("navigation.referential.Program-16"));
    
    72 72
             ui.getShowReferential().setIcon(UIHelper.getUIManagerIcon("navigation.referentiel-16"));
    
    73
    -        ui.getShowEmptyProgram().setIcon(UIHelper.getUIManagerIcon("navigation." + TripSeineDto.class.getName() + "-16"));
    
    73
    +        ui.getShowEmptyProgram().setIcon(UIHelper.getUIManagerIcon("navigation.data.seine.TripSeine-16"));
    
    74 74
     
    
    75 75
             NavigationTree tree = ui.getTree();
    
    76 76
             TreeSearchable searchable = new TreeSearchable(tree);
    

  • client/src/main/java/fr/ird/observe/client/ui/tree/selection/nodes/ReferenceSelectionTreeNodeSupport.java
    ... ... @@ -24,6 +24,7 @@ package fr.ird.observe.client.ui.tree.selection.nodes;
    24 24
     
    
    25 25
     import fr.ird.observe.client.ObserveSwingApplicationContext;
    
    26 26
     import fr.ird.observe.dto.IdDto;
    
    27
    +import fr.ird.observe.dto.IdHelper;
    
    27 28
     import fr.ird.observe.dto.reference.DtoReference;
    
    28 29
     import org.nuiton.decorator.Decorator;
    
    29 30
     
    
    ... ... @@ -33,7 +34,7 @@ import org.nuiton.decorator.Decorator;
    33 34
      * @author Tony Chemit - dev@tchemit.fr
    
    34 35
      * @since 6.0
    
    35 36
      */
    
    36
    -public abstract class ReferenceSelectionTreeNodeSupport<D extends IdDto, R extends DtoReference<D,R>> extends SelectionTreeNodeSupport<R> {
    
    37
    +public abstract class ReferenceSelectionTreeNodeSupport<D extends IdDto, R extends DtoReference<D, R>> extends SelectionTreeNodeSupport<R> {
    
    37 38
     
    
    38 39
         private boolean selected;
    
    39 40
     
    
    ... ... @@ -56,7 +57,7 @@ public abstract class ReferenceSelectionTreeNodeSupport<D extends IdDto, R exten
    56 57
     
    
    57 58
         @Override
    
    58 59
         public String getIconPath() {
    
    59
    -        return "navigation." + getData().getDtoType().getName();
    
    60
    +        return "navigation." + IdHelper.getDtoSimplifiedName(getData().getDtoType());
    
    60 61
         }
    
    61 62
     
    
    62 63
         @Override
    

  • client/src/main/java/fr/ird/observe/client/ui/util/ObserveValidationMessageTableRenderer.java
    ... ... @@ -24,6 +24,7 @@ package fr.ird.observe.client.ui.util;
    24 24
     
    
    25 25
     import fr.ird.observe.client.ui.admin.validate.ValidationMessageTableModel;
    
    26 26
     import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
    
    27
    +import fr.ird.observe.dto.decoration.ObserveI18nLabelsBuilder;
    
    27 28
     import fr.ird.observe.services.service.actions.validate.ValidationResultDtoMessage;
    
    28 29
     import java.awt.Color;
    
    29 30
     import java.awt.Component;
    
    ... ... @@ -47,6 +48,8 @@ public class ObserveValidationMessageTableRenderer extends DefaultTableCellRende
    47 48
     
    
    48 49
         private static final long serialVersionUID = 1L;
    
    49 50
     
    
    51
    +    private final ObserveI18nLabelsBuilder labelsBuilder = new ObserveI18nLabelsBuilder(null);
    
    52
    +
    
    50 53
         @Override
    
    51 54
         public Component getTableCellRendererComponent(JTable table,
    
    52 55
                                                        Object value,
    
    ... ... @@ -78,7 +81,7 @@ public class ObserveValidationMessageTableRenderer extends DefaultTableCellRende
    78 81
     
    
    79 82
                 case 1:
    
    80 83
                     // field name
    
    81
    -                text = getFieldName(model.getRow(row),(String) value);
    
    84
    +                text = getFieldName(model.getRow(row), (String) value);
    
    82 85
                     toolTipText = t("observe.validator.field.tip", text);
    
    83 86
                     break;
    
    84 87
     
    
    ... ... @@ -112,8 +115,10 @@ public class ObserveValidationMessageTableRenderer extends DefaultTableCellRende
    112 115
         }
    
    113 116
     
    
    114 117
         private String getFieldName(ValidationResultDtoMessage model, String value) {
    
    115
    -        String fieldName = value.startsWith("observe.") ? value : ObserveI18nDecoratorHelper.getPropertyI18nKey(model.getType(), value);
    
    116
    -        return t(fieldName);
    
    118
    +        if (value.startsWith("observe.")) {
    
    119
    +            return t(value);
    
    120
    +        }
    
    121
    +        return t(labelsBuilder.getI18nKey(model.getType(), ObserveI18nDecoratorHelper.OBSERVE_COMMON_PREFIX, value));
    
    117 122
         }
    
    118 123
     
    
    119 124
     }

  • client/src/main/java/fr/ird/observe/client/ui/util/ObserveValidatorMessageTableRenderer.java
    ... ... @@ -23,6 +23,7 @@ package fr.ird.observe.client.ui.util;
    23 23
      */
    
    24 24
     
    
    25 25
     import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
    
    26
    +import fr.ird.observe.dto.decoration.ObserveI18nLabelsBuilder;
    
    26 27
     import java.awt.Color;
    
    27 28
     import java.awt.Component;
    
    28 29
     import javax.swing.JComponent;
    
    ... ... @@ -51,6 +52,8 @@ public class ObserveValidatorMessageTableRenderer extends SwingValidatorMessageT
    51 52
         /** Logger. */
    
    52 53
         private static final Log log = LogFactory.getLog(ObserveValidatorMessageTableRenderer.class);
    
    53 54
     
    
    55
    +    private final ObserveI18nLabelsBuilder labelsBuilder = new ObserveI18nLabelsBuilder(null);
    
    56
    +
    
    54 57
         @Override
    
    55 58
         public String getFieldName(JTable table, String value, int row) {
    
    56 59
             SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
    
    ... ... @@ -74,8 +77,7 @@ public class ObserveValidatorMessageTableRenderer extends SwingValidatorMessageT
    74 77
             if (value.startsWith("observe.") || model.getValidator() == null) {
    
    75 78
                 return t(value);
    
    76 79
             }
    
    77
    -        String fieldName = ObserveI18nDecoratorHelper.getPropertyI18nKey(model.getValidator().getType(), value);
    
    78
    -        return t(fieldName);
    
    80
    +        return t(labelsBuilder.getI18nKey(model.getValidator().getType(), ObserveI18nDecoratorHelper.OBSERVE_COMMON_PREFIX, value));
    
    79 81
         }
    
    80 82
     
    
    81 83
         @Override
    

  • client/src/main/resources/i18n/client_fr_FR.properties
    ... ... @@ -746,7 +746,7 @@ observe.common.NonTargetCatchDto.table.well.tip=Numéro de cuve
    746 746
     observe.common.NonTargetCatchDto.totalCountComputed.computed.tip=Le nombre estimé a été calculé (%s)
    
    747 747
     observe.common.NonTargetCatchDto.totalCountComputed.observed.tip=Le nombre estimé a été observé
    
    748 748
     observe.common.NonTargetCatchDto.well=Cuve
    
    749
    -observe.common.NonTargetCatchReleaseDto.message.cantAdd=<html><body><strong>Impossible d'ajouter des libération</strong>(pas de faune accessoire sensible)</body></html>
    
    749
    +observe.common.NonTargetCatchReleaseDto.message.cantAdd=<html><body><strong>Impossible d'ajouter des libérations</strong>(pas de faune accessoire sensible)</body></html>
    
    750 750
     observe.common.NonTargetCatchReleaseDto.table.comment=Com
    
    751 751
     observe.common.NonTargetCatchReleaseDto.table.comment.tip=Commentaire
    
    752 752
     observe.common.NonTargetCatchReleaseDto.table.deleteExtraMessage=Blabla
    

  • dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java
    ... ... @@ -321,8 +321,9 @@ public class DecoratorService extends DecoratorProvider {
    321 321
             @Override
    
    322 322
             public void end() {
    
    323 323
                 // Trip commun decorator
    
    324
    -            registerDecorator(TRIP_CONTEXT,
    
    325
    -                              new DataReferenceDecorator<>(TripSeineReference.class, "${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vesselLabel}$s##${observerLabel}$s"));
    
    324
    +            registerDataReferenceDecorator(TRIP_CONTEXT,
    
    325
    +                                           TripSeineReference.class,
    
    326
    +                                           "${startDate}$td/%1$tm/%1$tY##${endDate}$td/%2$tm/%2$tY##${vesselLabel}$s##${observerLabel}$s");
    
    326 327
     
    
    327 328
                 // gps decorators
    
    328 329
                 registerObserveDecorator("activity-gps",
    

  • dto/src/main/java/fr/ird/observe/dto/decoration/ObserveI18nDecoratorHelper.java
    ... ... @@ -40,7 +40,7 @@ import static org.nuiton.i18n.I18n.t;
    40 40
      */
    
    41 41
     public class ObserveI18nDecoratorHelper {
    
    42 42
     
    
    43
    -    private static final String OBSERVE_COMMON_PREFIX = "observe.common.";
    
    43
    +    public static final String OBSERVE_COMMON_PREFIX = "observe.common.";
    
    44 44
     
    
    45 45
         public static <C extends Class<?>> List<C> sortTypes(Collection<C> types, Locale locale) {
    
    46 46
             return ObserveUtil.sortTypes(types, klass -> t(getTypeI18nKey(klass)), locale);
    

  • dto/src/main/java/fr/ird/observe/dto/decoration/ObserveI18nLabelsBuilder.java
    ... ... @@ -65,6 +65,7 @@ public class ObserveI18nLabelsBuilder extends I18nLabelsBuilder {
    65 65
                 .put(ReferentialDto.PROPERTY_URI, ReferentialDto.class.getSimpleName() + ".")
    
    66 66
                 .put(ReferentialDto.PROPERTY_NEED_COMMENT, ReferentialDto.class.getSimpleName() + ".")
    
    67 67
                 .put(ReferentialDto.PROPERTY_CODE, ReferentialDto.class.getSimpleName() + ".")
    
    68
    +            .put(ReferentialDto.PROPERTY_STATUS, ReferentialDto.class.getSimpleName() + ".")
    
    68 69
                 .put("species", "")
    
    69 70
                 .put("country", "")
    
    70 71
                 .build();
    

  • validation/src/main/resources/fr/ird/observe/dto/data/seine/NonTargetLengthDto-update-warning-validation.xml
    ... ... @@ -30,7 +30,7 @@
    30 30
     
    
    31 31
         <!-- pas de speciesFate selectionnee -->
    
    32 32
         <field-validator type="required" short-circuit="true">
    
    33
    -      <message>observe.validation.nonTargetLength.required.speciesFate</message>
    
    33
    +      <message>observe.validation.nonTargetLength.null.speciesFate</message>
    
    34 34
         </field-validator>
    
    35 35
     
    
    36 36
       </field>
    

  • validation/src/main/resources/i18n/validation_en_GB.properties
    ... ... @@ -499,7 +499,7 @@ observe.validation.nonTargetCatchRelease.required.status=Status not filled.
    499 499
     observe.validation.nonTargetLength.desactivated.sizeMeasureType=Selected size measure type is disabled.
    
    500 500
     observe.validation.nonTargetLength.desactivated.speciesFate=Selected species fate is disabled.
    
    501 501
     observe.validation.nonTargetLength.required.sizeMeasureType=Size measure type is mandatory.
    
    502
    -observe.validation.nonTargetLength.required.speciesFate=Species fate must be filled.
    
    502
    +observe.validation.nonTargetLength.null.speciesFate=Species fate should be filled.
    
    503 503
     observe.validation.nonTargetSample.bound.length=Length must be bound between %s and %s.
    
    504 504
     observe.validation.nonTargetSample.bound.weight=Weight must be bound between %s and %s.
    
    505 505
     observe.validation.nonTargetSample.comment.tobig=Comment size can not exceed 1024 characters.
    

  • validation/src/main/resources/i18n/validation_es_ES.properties
    ... ... @@ -499,7 +499,7 @@ observe.validation.nonTargetCatchRelease.required.status=État à la libération
    499 499
     observe.validation.nonTargetLength.desactivated.sizeMeasureType=Selected size mesure type is disabled. \#TODO
    
    500 500
     observe.validation.nonTargetLength.desactivated.speciesFate=El objectFate de fauna seleccionado está desactivado.
    
    501 501
     observe.validation.nonTargetLength.required.sizeMeasureType=Es obligatoria especificar el size measure type \#TODO
    
    502
    -observe.validation.nonTargetLength.required.speciesFate=Es obligatoiro seleccionar un futuro de fauna.
    
    502
    +observe.validation.nonTargetLength.null.speciesFate=Futuro de fauna no establecida.
    
    503 503
     observe.validation.nonTargetSample.bound.length=La talla para esta especie debe estar comprendida entre %1$s y %2$s.
    
    504 504
     observe.validation.nonTargetSample.bound.weight=La peso para esta especie debe estar comprendida entre %1$s y %2$s.
    
    505 505
     observe.validation.nonTargetSample.comment.tobig=La longitud del campo comentarios está limitada a 1024 carácteres.
    

  • validation/src/main/resources/i18n/validation_fr_FR.properties
    ... ... @@ -499,7 +499,7 @@ observe.validation.nonTargetCatchRelease.required.status=État à la libération
    499 499
     observe.validation.nonTargetLength.desactivated.sizeMeasureType=Le type de mesure sélectionné est désactivé.
    
    500 500
     observe.validation.nonTargetLength.desactivated.speciesFate=Le devenir faune sélectionné est désactivé.
    
    501 501
     observe.validation.nonTargetLength.required.sizeMeasureType=Le type de mesure est obligatoire.
    
    502
    -observe.validation.nonTargetLength.required.speciesFate=La sélection d'un devenir faune est obligatoire.
    
    502
    +observe.validation.nonTargetLength.null.speciesFate=La sélection d'un devenir faune est conseillée.
    
    503 503
     observe.validation.nonTargetSample.bound.length=La taille pour cette espèce doit être comprise entre %1$s et %2$s.
    
    504 504
     observe.validation.nonTargetSample.bound.weight=Le poids pour cette espèce doit être compris entre %1$s et %2$s.
    
    505 505
     observe.validation.nonTargetSample.comment.tobig=La taille du commentaire est limitée à 1024 caractères.