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

Commits:

11 changed files:

Changes:

  • client/datasource/editor/ps/src/main/i18n/getters/java.getter
    ... ... @@ -32,6 +32,8 @@ observe.data.ps.observation.NonTargetCatch.message.will.delete.sub.data
    32 32
     observe.data.ps.observation.NonTargetCatch.message.will.delete.sub.data.for.species
    
    33 33
     observe.data.ps.observation.NonTargetCatch.totalCountComputed.computed.tip
    
    34 34
     observe.data.ps.observation.NonTargetCatch.totalCountComputed.observed.tip
    
    35
    +observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data
    
    36
    +observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data.for.species
    
    35 37
     observe.data.ps.observation.Route.choice.create.fin.veille.activity
    
    36 38
     observe.data.ps.observation.Route.choice.not.create.fin.veille.activity.and.continue
    
    37 39
     observe.data.ps.observation.Route.message.need.fin.veille.activity
    

  • client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter
    ... ... @@ -89,7 +89,6 @@ observe.data.ps.observation.NonTargetCatchRelease.length
    89 89
     observe.data.ps.observation.NonTargetCatchRelease.message.cantAdd
    
    90 90
     observe.data.ps.observation.NonTargetCatchRelease.releasingTime
    
    91 91
     observe.data.ps.observation.NonTargetCatchRelease.speciesGroupReleaseMode
    
    92
    -observe.data.ps.observation.NonTargetCatchRelease.table.deleteExtraMessage
    
    93 92
     observe.data.ps.observation.NonTargetLength.count
    
    94 93
     observe.data.ps.observation.NonTargetLength.length
    
    95 94
     observe.data.ps.observation.NonTargetLength.picturesReferences
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetNonTargetCatchReleaseUI.jcss
    ... ... @@ -20,10 +20,6 @@
    20 20
      * #L%
    
    21 21
      */
    
    22 22
     
    
    23
    -#tableModel {
    
    24
    -  deleteExtraMessage:{t("observe.data.ps.observation.NonTargetCatchRelease.table.deleteExtraMessage")};
    
    25
    -}
    
    26
    -
    
    27 23
     #editorPanel {
    
    28 24
       _focusComponent:{species};
    
    29 25
     }
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetNonTargetCatchReleaseUIModelStates.java
    ... ... @@ -26,12 +26,17 @@ import fr.ird.observe.client.configuration.ClientConfig;
    26 26
     import fr.ird.observe.client.constants.AcquisitionMode;
    
    27 27
     import fr.ird.observe.client.datasource.api.cache.ReferencesCache;
    
    28 28
     import fr.ird.observe.client.datasource.api.cache.ReferencesFilterHelper;
    
    29
    +import fr.ird.observe.client.datasource.editor.api.content.data.table.AskToDelete;
    
    29 30
     import fr.ird.observe.dto.data.ps.observation.NonTargetCatchReleaseDto;
    
    31
    +import fr.ird.observe.dto.data.ps.observation.SetNonTargetCatchReleaseDto;
    
    30 32
     import fr.ird.observe.dto.referential.common.SpeciesGroupDto;
    
    33
    +import fr.ird.observe.dto.referential.common.SpeciesReference;
    
    31 34
     import fr.ird.observe.navigation.select.ProjectSelectModel;
    
    32 35
     import fr.ird.observe.services.ObserveServicesProvider;
    
    33 36
     import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
    
    37
    +import io.ultreia.java4all.i18n.I18n;
    
    34 38
     
    
    39
    +import java.util.List;
    
    35 40
     import java.util.Map;
    
    36 41
     import java.util.TreeMap;
    
    37 42
     
    
    ... ... @@ -47,7 +52,7 @@ public class SetNonTargetCatchReleaseUIModelStates extends GeneratedSetNonTarget
    47 52
     
    
    48 53
         @Override
    
    49 54
         public void onAfterInitAddReferentialFilters(ClientConfig clientConfig, ProjectSelectModel observeSelectModel, ObserveServicesProvider servicesProvider, ReferencesCache referenceCache) {
    
    50
    -        referenceCache.addReferentialFilter(NonTargetCatchReleaseDto.PROPERTY_SPECIES, ReferencesFilterHelper.newSubList(getBean().getAvailableSpeciesIds()));
    
    55
    +        referenceCache.addReferentialFilter(NonTargetCatchReleaseDto.PROPERTY_SPECIES, ReferencesFilterHelper.<SetNonTargetCatchReleaseDto, SpeciesReference>newSubList(SetNonTargetCatchReleaseDto::getAvailableSpeciesIds));
    
    51 56
         }
    
    52 57
     
    
    53 58
         public Map<String, SpeciesGroupDto> getSpeciesGroupDtoMap() {
    
    ... ... @@ -59,4 +64,11 @@ public class SetNonTargetCatchReleaseUIModelStates extends GeneratedSetNonTarget
    59 64
             newTableBean.setAcquisitionMode(AcquisitionMode.individual.ordinal());
    
    60 65
         }
    
    61 66
     
    
    67
    +    @Override
    
    68
    +    public boolean canSave(SetNonTargetCatchReleaseDto originalBean, SetNonTargetCatchReleaseDto bean, List<NonTargetCatchReleaseDto> data) {
    
    69
    +        AskToDelete<SetNonTargetCatchReleaseDto> ask = new AskToDelete<>(
    
    70
    +                SetNonTargetCatchReleaseDto::getRemovedUnsafeSpecies,
    
    71
    +                I18n.n("observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data"));
    
    72
    +        return ask.needDelete(this.getClientUIContext().getDecoratorService(), originalBean, bean);
    
    73
    +    }
    
    62 74
     }

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetNonTargetCatchReleaseUITableModel.java
    ... ... @@ -31,6 +31,8 @@ import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleaseStatus
    31 31
     import javax.swing.JTable;
    
    32 32
     import java.util.List;
    
    33 33
     
    
    34
    +import static io.ultreia.java4all.i18n.I18n.t;
    
    35
    +
    
    34 36
     /**
    
    35 37
      * Created on 12/4/14.
    
    36 38
      *
    
    ... ... @@ -78,4 +80,17 @@ public class SetNonTargetCatchReleaseUITableModel extends GeneratedSetNonTargetC
    78 80
     
    
    79 81
             super.onSelectedRowChanged(ui, editingRow, tableEditBean, previousRowBean, notPersisted, newRow);
    
    80 82
         }
    
    83
    +
    
    84
    +    @Override
    
    85
    +    protected String getDeleteExtraMessage(NonTargetCatchReleaseDto bean) {
    
    86
    +        if (bean.isHasSample()) {
    
    87
    +            int count = getBean().getUnsafeSpeciesUsageCount(bean.getSpecies());
    
    88
    +            if (count == 1) {
    
    89
    +                // while deleting this one, this species won't be available on sample
    
    90
    +                return t("observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data.for.species", bean.getSpecies());
    
    91
    +            }
    
    92
    +        }
    
    93
    +        // No specific message
    
    94
    +        return null;
    
    95
    +    }
    
    81 96
     }

  • client/i18n/src/main/i18n/translations/observe_en_GB.properties
    ... ... @@ -939,11 +939,12 @@ observe.data.ps.observation.NonTargetCatchRelease.comment.short=Com
    939 939
     observe.data.ps.observation.NonTargetCatchRelease.conformity.short=Conformity
    
    940 940
     observe.data.ps.observation.NonTargetCatchRelease.length.short=Length
    
    941 941
     observe.data.ps.observation.NonTargetCatchRelease.message.cantAdd=<html><body><strong>Can not add non target catch release</strong>(no sensible non target catch)</body></html>
    
    942
    +observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data=If you confirm save, some data could be deleted\!\n\nFollowing species won't be useable in samples \:\n%1$s\nAll samples of those species will be deleted.
    
    943
    +observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data.for.species=\nIf you delete this non target catch release, the species (%s) will not be available for samples.\nSamples using this species (%s) will also be deleted.
    
    942 944
     observe.data.ps.observation.NonTargetCatchRelease.releasingTime.short=Releasing time
    
    943 945
     observe.data.ps.observation.NonTargetCatchRelease.sex.short=Sex
    
    944 946
     observe.data.ps.observation.NonTargetCatchRelease.species.short=Species
    
    945 947
     observe.data.ps.observation.NonTargetCatchRelease.speciesGroupReleaseMode.short=Mode
    
    946
    -observe.data.ps.observation.NonTargetCatchRelease.table.deleteExtraMessage=\nIf you delete this catches released, samples using this species will also be deleted.
    
    947 948
     observe.data.ps.observation.NonTargetLength.count.short=Count
    
    948 949
     observe.data.ps.observation.NonTargetLength.length.short=Length
    
    949 950
     observe.data.ps.observation.NonTargetLength.picturesReferences=Pictures references
    

  • client/i18n/src/main/i18n/translations/observe_es_ES.properties
    ... ... @@ -939,11 +939,12 @@ observe.data.ps.observation.NonTargetCatchRelease.comment.short=Observaciones
    939 939
     observe.data.ps.observation.NonTargetCatchRelease.conformity.short=Conformidad
    
    940 940
     observe.data.ps.observation.NonTargetCatchRelease.length.short=Talla
    
    941 941
     observe.data.ps.observation.NonTargetCatchRelease.message.cantAdd=<html><body><strong>Impossible d'ajouter des libération</strong>(pas de faune accessoire sensible)</body></html> \#TODO
    
    942
    +observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data=If you confirm save, some data could be deleted\!\n\nFollowing species won't be useable in samples \:\n%1$s\nAll samples of those species will be deleted. \#TODO
    
    943
    +observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data.for.species=\nIf you delete this non target catch release, the species (%s) will not be available for samples.\nSamples using this species (%s) will also be deleted. \#TODO
    
    942 944
     observe.data.ps.observation.NonTargetCatchRelease.releasingTime.short=Tiempo de liberación
    
    943 945
     observe.data.ps.observation.NonTargetCatchRelease.sex.short=Sexo
    
    944 946
     observe.data.ps.observation.NonTargetCatchRelease.species.short=Especie
    
    945 947
     observe.data.ps.observation.NonTargetCatchRelease.speciesGroupReleaseMode.short=Modo
    
    946
    -observe.data.ps.observation.NonTargetCatchRelease.table.deleteExtraMessage=\nLa eliminación de una captura de fauna puede tener como consecuencia la eliminación de muestreo(s) de la especie. \#TODO
    
    947 948
     observe.data.ps.observation.NonTargetLength.count.short=Grupo de tallas
    
    948 949
     observe.data.ps.observation.NonTargetLength.length.short=Talla
    
    949 950
     observe.data.ps.observation.NonTargetLength.picturesReferences=Referencia foto
    

  • client/i18n/src/main/i18n/translations/observe_fr_FR.properties
    ... ... @@ -925,11 +925,11 @@ observe.data.ps.observation.NonTargetCatch.meanLengthComputed.observed.tip=La ta
    925 925
     observe.data.ps.observation.NonTargetCatch.meanWeight.short=Poids moy
    
    926 926
     observe.data.ps.observation.NonTargetCatch.meanWeightComputed.computed.tip=Le poids moyen a été calculé (%s)
    
    927 927
     observe.data.ps.observation.NonTargetCatch.meanWeightComputed.observed.tip=Le poids moyen a été observé
    
    928
    -observe.data.ps.observation.NonTargetCatch.message.table.will.delete.nonTargetSample=En confirmant la sauvegarde des objets vont être supprimés\!\n\nLes espèces suivantes ne seront plus utilisables dans des échantillonages ou les espèces libérées \:\n%1$s\nCela entrainera la suppression des données saisies liées à ces espèces
    
    928
    +observe.data.ps.observation.NonTargetCatch.message.will.delete.sub.data=En confirmant la sauvegarde des objets vont être supprimés\!\n\nLes espèces suivantes ne seront plus utilisables dans des échantillonnages ou les espèces libérées \:\n%1$s\nCela entrainera la suppression des données saisies liées à ces espèces
    
    929
    +observe.data.ps.observation.NonTargetCatch.message.will.delete.sub.data.for.species=\nLe fait de supprimer cette capture rend indisponible l'espèce (%s) sur les libérations ou les échantillons.\nLes libérations ou échantillons utilisant cette espèce seront alors supprimer.
    
    929 930
     observe.data.ps.observation.NonTargetCatch.reasonForDiscard.short=Raison rejet
    
    930 931
     observe.data.ps.observation.NonTargetCatch.species.short=Espèce de faune
    
    931 932
     observe.data.ps.observation.NonTargetCatch.speciesFate.short=Devenir
    
    932
    -observe.data.ps.observation.NonTargetCatch.table.deleteExtraMessage=\nLe fait de supprimer une capture de faune peut entrainer la suppression d'échantillonnage(s) sur l'espèce.
    
    933 933
     observe.data.ps.observation.NonTargetCatch.totalCount.short=Nombre
    
    934 934
     observe.data.ps.observation.NonTargetCatch.totalCountComputed.computed.tip=Le nombre estimé a été calculé (%s)
    
    935 935
     observe.data.ps.observation.NonTargetCatch.totalCountComputed.observed.tip=Le nombre estimé a été observé
    
    ... ... @@ -939,11 +939,12 @@ observe.data.ps.observation.NonTargetCatchRelease.comment.short=Com
    939 939
     observe.data.ps.observation.NonTargetCatchRelease.conformity.short=Conformité
    
    940 940
     observe.data.ps.observation.NonTargetCatchRelease.length.short=Longueur
    
    941 941
     observe.data.ps.observation.NonTargetCatchRelease.message.cantAdd=<html><body><strong>Impossible d'ajouter des libérations</strong>(pas de faune accessoire sensible)</body></html>
    
    942
    +observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data=En confirmant la sauvegarde des objets vont être supprimés\!\n\nLes espèces suivantes ne seront plus utilisables dans des échantillonages \:\n%1$s\nCela entrainera la suppression des données saisies liées à ces espèces
    
    943
    +observe.data.ps.observation.NonTargetCatchRelease.message.will.delete.sub.data.for.species=\nLe fait de supprimer cette libération rend indisponible l'espèce (%s) sur les échantillons.\nLes échantillons utilisant cette espèce seront alors supprimer.
    
    942 944
     observe.data.ps.observation.NonTargetCatchRelease.releasingTime.short=Moment
    
    943 945
     observe.data.ps.observation.NonTargetCatchRelease.sex.short=Sexe
    
    944 946
     observe.data.ps.observation.NonTargetCatchRelease.species.short=Espèce
    
    945 947
     observe.data.ps.observation.NonTargetCatchRelease.speciesGroupReleaseMode.short=Mode
    
    946
    -observe.data.ps.observation.NonTargetCatchRelease.table.deleteExtraMessage=\nLe fait de supprimer une capture de faune peut entrainer la suppression d'échantillonnage(s) sur l'espèce. \#TODO
    
    947 948
     observe.data.ps.observation.NonTargetLength.count.short=Effectif
    
    948 949
     observe.data.ps.observation.NonTargetLength.length.short=Longueur
    
    949 950
     observe.data.ps.observation.NonTargetLength.picturesReferences=référence photo
    

  • models/dto-definition/src/main/models/Observe-20-data-ps-observation.model
    ... ... @@ -81,6 +81,7 @@ comment + {*:1} String
    81 81
     length + {*:1} Float | positiveNumber
    
    82 82
     count + {*:1} Integer | notNull strictlyPositiveNumber
    
    83 83
     acquisitionMode + {*:1} int
    
    84
    +hasSample + {*:1} boolean
    
    84 85
     status {*:1} !fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleaseStatusReference | notNull
    
    85 86
     species {*:1} fr.ird.observe.dto.referential.common.SpeciesReference | notNull
    
    86 87
     sex {*:1} fr.ird.observe.dto.referential.common.SexReference | notNull
    

  • models/dto/src/main/java/fr/ird/observe/dto/data/ps/observation/SetNonTargetCatchReleaseDto.java
    1
    +package fr.ird.observe.dto.data.ps.observation;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe Models :: Dto
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2021 IRD, Code Lutin, Ultreia.io
    
    8
    + * %%
    
    9
    + * This program is free software: you can redistribute it and/or modify
    
    10
    + * it under the terms of the GNU General Public License as
    
    11
    + * published by the Free Software Foundation, either version 3 of the
    
    12
    + * License, or (at your option) any later version.
    
    13
    + *
    
    14
    + * This program is distributed in the hope that it will be useful,
    
    15
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    + * GNU General Public License for more details.
    
    18
    + *
    
    19
    + * You should have received a copy of the GNU General Public
    
    20
    + * License along with this program.  If not, see
    
    21
    + * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    + * #L%
    
    23
    + */
    
    24
    +
    
    25
    +import fr.ird.observe.dto.referential.common.SpeciesReference;
    
    26
    +import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
    
    27
    +
    
    28
    +import java.util.Objects;
    
    29
    +import java.util.Set;
    
    30
    +import java.util.stream.Collectors;
    
    31
    +
    
    32
    +@GenerateJavaBeanDefinition
    
    33
    +public class SetNonTargetCatchReleaseDto extends GeneratedSetNonTargetCatchReleaseDto {
    
    34
    +
    
    35
    +    private static final long serialVersionUID = 1L;
    
    36
    +
    
    37
    +    /**
    
    38
    +     * Get the set of unsafe species no more used in the {@code incoming} dto.
    
    39
    +     *
    
    40
    +     * @param incoming the dto to compare this
    
    41
    +     * @return the set of unsafe species no more used in incoming dto
    
    42
    +     */
    
    43
    +    public Set<SpeciesReference> getRemovedUnsafeSpecies(SetNonTargetCatchReleaseDto incoming) {
    
    44
    +        // Get all unsafe species
    
    45
    +        Set<SpeciesReference> allUnsafeSpecies = getUnsafeSpecies();
    
    46
    +        // Get incoming used unsafe species
    
    47
    +        Set<SpeciesReference> incomingUsedUnsafeSpecies = incoming.getUnsafeSpecies();
    
    48
    +        // Remove for all the used
    
    49
    +        allUnsafeSpecies.removeAll(incomingUsedUnsafeSpecies);
    
    50
    +        // This will return the set of no more used unsafe species
    
    51
    +        return allUnsafeSpecies;
    
    52
    +    }
    
    53
    +
    
    54
    +    /**
    
    55
    +     * @return set of unsafe species used in catches
    
    56
    +     */
    
    57
    +    public Set<SpeciesReference> getUnsafeSpecies() {
    
    58
    +        return getNonTargetCatchRelease().stream().filter(NonTargetCatchReleaseDto::isHasSample).map(NonTargetCatchReleaseDto::getSpecies).collect(Collectors.toSet());
    
    59
    +    }
    
    60
    +
    
    61
    +    /**
    
    62
    +     * @param species species to test
    
    63
    +     * @return count of usage of this species in catches
    
    64
    +     */
    
    65
    +    public int getUnsafeSpeciesUsageCount(SpeciesReference species) {
    
    66
    +        return (int) getNonTargetCatchRelease().stream().filter(d -> Objects.equals(species, d.getSpecies())).count();
    
    67
    +    }
    
    68
    +}

  • models/persistence/src/main/java/fr/ird/observe/entities/data/ps/observation/SetImpl.java
    ... ... @@ -28,6 +28,7 @@ import fr.ird.observe.dto.data.ps.observation.DiscardedTargetCatchDto;
    28 28
     import fr.ird.observe.dto.data.ps.observation.DiscardedTargetSampleDto;
    
    29 29
     import fr.ird.observe.dto.data.ps.observation.KeptTargetCatchDto;
    
    30 30
     import fr.ird.observe.dto.data.ps.observation.KeptTargetSampleDto;
    
    31
    +import fr.ird.observe.dto.data.ps.observation.NonTargetCatchReleaseDto;
    
    31 32
     import fr.ird.observe.dto.data.ps.observation.NonTargetSampleDto;
    
    32 33
     import fr.ird.observe.dto.data.ps.observation.SetDiscardedTargetCatchDto;
    
    33 34
     import fr.ird.observe.dto.data.ps.observation.SetDto;
    
    ... ... @@ -100,7 +101,7 @@ public class SetImpl extends SetAbstract {
    100 101
     
    
    101 102
         @Override
    
    102 103
         public boolean canUseNonTargetCatchRelease() {
    
    103
    -        return isNonTargetCatchReleaseNotEmpty() && getNonTargetCatch().stream().anyMatch(t -> isSpeciesGroupRelease(t.getSpecies()));
    
    104
    +        return isNonTargetCatchNotEmpty() && getNonTargetCatch().stream().anyMatch(t -> isSpeciesGroupRelease(t.getSpecies()));
    
    104 105
         }
    
    105 106
     
    
    106 107
         public boolean isSpeciesGroupRelease(Species species) {
    
    ... ... @@ -136,6 +137,10 @@ public class SetImpl extends SetAbstract {
    136 137
                 toSetNonTargetCatchDto(referentialLocale, (SetNonTargetCatchDto) dto);
    
    137 138
                 return;
    
    138 139
             }
    
    140
    +        if (dto instanceof SetNonTargetCatchReleaseDto) {
    
    141
    +            toSetNonTargetCatchReleaseDto(referentialLocale, (SetNonTargetCatchReleaseDto) dto);
    
    142
    +            return;
    
    143
    +        }
    
    139 144
             super.toDto(referentialLocale, dto);
    
    140 145
             if (dto instanceof SetDto) {
    
    141 146
                 ((SetDto) dto).setDiscardedTargetSampleEnabled(canUseDiscardedTargetSample());
    
    ... ... @@ -143,9 +148,6 @@ public class SetImpl extends SetAbstract {
    143 148
                 ((SetDto) dto).setNonTargetSampleEnabled(canUseNonTargetSample());
    
    144 149
                 ((SetDto) dto).setSetNonTargetCatchReleaseEnabled(canUseNonTargetCatchRelease());
    
    145 150
             }
    
    146
    -        if (dto instanceof SetNonTargetCatchReleaseDto) {
    
    147
    -            ((SetNonTargetCatchReleaseDto) dto).setAvailableSpeciesIds(getNonTargetCatch().stream().map(NonTargetCatch::getSpecies).filter(this::isSpeciesGroupRelease).map(Species::getTopiaId).distinct().collect(ImmutableSet.toImmutableSet()));
    
    148
    -        }
    
    149 151
             if (dto instanceof NonTargetSampleDto) {
    
    150 152
                 ((NonTargetSampleDto) dto).setAvailableSpeciesIds(getNonTargetCatch().stream().map(NonTargetCatch::getSpecies).map(Species::getTopiaId).distinct().collect(ImmutableSet.toImmutableSet()));
    
    151 153
                 ((NonTargetSampleDto) dto).setAvailableSpeciesFateIds(getNonTargetCatch().stream().map(NonTargetCatch::getSpeciesFate).map(SpeciesFate::getTopiaId).distinct().collect(ImmutableSet.toImmutableSet()));
    
    ... ... @@ -172,6 +174,10 @@ public class SetImpl extends SetAbstract {
    172 174
                 fromSetNonTargetCatchDto(referentialLocale, (SetNonTargetCatchDto) dto);
    
    173 175
                 return;
    
    174 176
             }
    
    177
    +        if (dto instanceof SetNonTargetCatchReleaseDto) {
    
    178
    +            fromSetNonTargetCatchReleaseDto(referentialLocale, (SetNonTargetCatchReleaseDto) dto);
    
    179
    +            return;
    
    180
    +        }
    
    175 181
             super.fromDto(referentialLocale, dto);
    
    176 182
         }
    
    177 183
     
    
    ... ... @@ -206,7 +212,7 @@ public class SetImpl extends SetAbstract {
    206 212
                 dtoList.forEach(catchDto -> {
    
    207 213
                     SpeciesReference species = catchDto.getSpecies();
    
    208 214
                     boolean hasSample = speciesId.contains(species.getId());
    
    209
    -                catchDto.set(KeptTargetCatchDto.PROPERTY_HAS_SAMPLE, hasSample);
    
    215
    +                catchDto.setHasSample(hasSample);
    
    210 216
                 });
    
    211 217
             }
    
    212 218
         }
    
    ... ... @@ -224,7 +230,7 @@ public class SetImpl extends SetAbstract {
    224 230
                 dtoList.forEach(catchDto -> {
    
    225 231
                     SpeciesReference species = catchDto.getSpecies();
    
    226 232
                     boolean hasSample = speciesId.contains(species.getId());
    
    227
    -                catchDto.set(KeptTargetCatchDto.PROPERTY_HAS_SAMPLE, hasSample);
    
    233
    +                catchDto.setHasSample(hasSample);
    
    228 234
                 });
    
    229 235
             }
    
    230 236
         }
    
    ... ... @@ -255,6 +261,23 @@ public class SetImpl extends SetAbstract {
    255 261
             }
    
    256 262
         }
    
    257 263
     
    
    264
    +    private void toSetNonTargetCatchReleaseDto(ReferentialLocale referentialLocale, SetNonTargetCatchReleaseDto dto) {
    
    265
    +        // do normal copy
    
    266
    +        super.toDto(referentialLocale, dto);
    
    267
    +        // is there some sample?
    
    268
    +        if (isNonTargetSampleNotEmpty()) {
    
    269
    +            NonTargetSample targetSample = getNonTargetSample().iterator().next();
    
    270
    +            // get usable species ids
    
    271
    +            java.util.Set<String> speciesId = DtoReferenceAware.ids(targetSample.getNonTargetLength().stream().map(NonTargetLength::getSpecies));
    
    272
    +            // mark catch if there is associated samples to it
    
    273
    +            dto.getNonTargetCatchRelease().forEach(childDto -> {
    
    274
    +                boolean hasSample = speciesId.contains(childDto.getSpecies().getId());
    
    275
    +                childDto.setHasSample(hasSample);
    
    276
    +            });
    
    277
    +        }
    
    278
    +        dto.setAvailableSpeciesIds(getNonTargetCatch().stream().map(NonTargetCatch::getSpecies).filter(this::isSpeciesGroupRelease).map(Species::getTopiaId).distinct().collect(ImmutableSet.toImmutableSet()));
    
    279
    +    }
    
    280
    +
    
    258 281
         private void fromSetKeptTargetCatchDto(ReferentialLocale referentialLocale, SetKeptTargetCatchDto dto) {
    
    259 282
             // keep other catches
    
    260 283
             List<TargetCatch> otherTargetCatches = getTargetCatch(true);
    
    ... ... @@ -289,6 +312,20 @@ public class SetImpl extends SetAbstract {
    289 312
             otherTargetCatches.forEach(this::addTargetCatch);
    
    290 313
         }
    
    291 314
     
    
    315
    +    private void fromSetNonTargetCatchReleaseDto(ReferentialLocale referentialLocale, SetNonTargetCatchReleaseDto dto) {
    
    316
    +        // do normal copy
    
    317
    +        super.fromDto(referentialLocale, dto);
    
    318
    +        // delete any discarded sample which not using the given species ids
    
    319
    +        //FIXME should we also check in non target catches ???
    
    320
    +//        TargetSample targetSample = getTargetSample(true);
    
    321
    +//        if (targetSample != null) {
    
    322
    +//            List<NonTargetCatchReleaseDto> targetCatch = dto.getNonTargetCatchRelease();
    
    323
    +//            Set<String> speciesIds = DtoReferenceAware.ids(targetCatch.stream().map(NonTargetCatchReleaseDto::getSpecies));
    
    324
    +//            // remove sample from species ids
    
    325
    +//            targetSample.getTargetLength().removeIf(targetLength -> !speciesIds.contains(targetLength.getSpecies().getTopiaId()));
    
    326
    +//        }
    
    327
    +    }
    
    328
    +
    
    292 329
         private List<TargetCatch> getTargetCatch(boolean discarded) {
    
    293 330
             return super.getTargetCatch().stream().filter(c -> c != null && Objects.equals(discarded, c.isDiscarded())).collect(Collectors.toList());
    
    294 331
         }