Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: e8ee529f by Tony Chemit at 2021-01-21T18:19:47+01:00 Suppression en cade des libérations de capture accessoire - Closes #1768 - - - - - 7 changed files: - client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetNonTargetCatchReleaseUI.jcss - client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetNonTargetCatchReleaseUIModelStates.java - client/i18n/src/main/i18n/translations/observe_en_GB.properties - client/i18n/src/main/i18n/translations/observe_es_ES.properties - client/i18n/src/main/i18n/translations/observe_fr_FR.properties - models/persistence/src/main/java/fr/ird/observe/entities/data/ps/observation/SetImpl.java Changes: ===================================== client/datasource/editor/ps/src/main/i18n/getters/jaxx.getter ===================================== @@ -89,7 +89,6 @@ observe.data.ps.observation.NonTargetCatchRelease.length observe.data.ps.observation.NonTargetCatchRelease.message.cantAdd observe.data.ps.observation.NonTargetCatchRelease.releasingTime observe.data.ps.observation.NonTargetCatchRelease.speciesGroupReleaseMode -observe.data.ps.observation.NonTargetCatchRelease.table.deleteExtraMessage observe.data.ps.observation.NonTargetLength.count observe.data.ps.observation.NonTargetLength.length 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 @@ * #L% */ -#tableModel { - deleteExtraMessage:{t("observe.data.ps.observation.NonTargetCatchRelease.table.deleteExtraMessage")}; -} - #editorPanel { _focusComponent:{species}; } ===================================== client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SetNonTargetCatchReleaseUIModelStates.java ===================================== @@ -27,7 +27,9 @@ import fr.ird.observe.client.constants.AcquisitionMode; import fr.ird.observe.client.datasource.api.cache.ReferencesCache; import fr.ird.observe.client.datasource.api.cache.ReferencesFilterHelper; import fr.ird.observe.dto.data.ps.observation.NonTargetCatchReleaseDto; +import fr.ird.observe.dto.data.ps.observation.SetNonTargetCatchReleaseDto; import fr.ird.observe.dto.referential.common.SpeciesGroupDto; +import fr.ird.observe.dto.referential.common.SpeciesReference; import fr.ird.observe.navigation.select.ProjectSelectModel; import fr.ird.observe.services.ObserveServicesProvider; import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition; @@ -47,7 +49,7 @@ public class SetNonTargetCatchReleaseUIModelStates extends GeneratedSetNonTarget @Override public void onAfterInitAddReferentialFilters(ClientConfig clientConfig, ProjectSelectModel observeSelectModel, ObserveServicesProvider servicesProvider, ReferencesCache referenceCache) { - referenceCache.addReferentialFilter(NonTargetCatchReleaseDto.PROPERTY_SPECIES, ReferencesFilterHelper.newSubList(getBean().getAvailableSpeciesIds())); + referenceCache.addReferentialFilter(NonTargetCatchReleaseDto.PROPERTY_SPECIES, ReferencesFilterHelper.<SetNonTargetCatchReleaseDto, SpeciesReference>newSubList(SetNonTargetCatchReleaseDto::getAvailableSpeciesIds)); } public Map<String, SpeciesGroupDto> getSpeciesGroupDtoMap() { @@ -58,5 +60,4 @@ public class SetNonTargetCatchReleaseUIModelStates extends GeneratedSetNonTarget public void initDefault(NonTargetCatchReleaseDto newTableBean) { newTableBean.setAcquisitionMode(AcquisitionMode.individual.ordinal()); } - } ===================================== client/i18n/src/main/i18n/translations/observe_en_GB.properties ===================================== @@ -943,7 +943,6 @@ observe.data.ps.observation.NonTargetCatchRelease.releasingTime.short=Releasing observe.data.ps.observation.NonTargetCatchRelease.sex.short=Sex observe.data.ps.observation.NonTargetCatchRelease.species.short=Species observe.data.ps.observation.NonTargetCatchRelease.speciesGroupReleaseMode.short=Mode -observe.data.ps.observation.NonTargetCatchRelease.table.deleteExtraMessage=\nIf you delete this catches released, samples using this species will also be deleted. observe.data.ps.observation.NonTargetLength.count.short=Count observe.data.ps.observation.NonTargetLength.length.short=Length observe.data.ps.observation.NonTargetLength.picturesReferences=Pictures references ===================================== client/i18n/src/main/i18n/translations/observe_es_ES.properties ===================================== @@ -943,7 +943,6 @@ observe.data.ps.observation.NonTargetCatchRelease.releasingTime.short=Tiempo de observe.data.ps.observation.NonTargetCatchRelease.sex.short=Sexo observe.data.ps.observation.NonTargetCatchRelease.species.short=Especie observe.data.ps.observation.NonTargetCatchRelease.speciesGroupReleaseMode.short=Modo -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 observe.data.ps.observation.NonTargetLength.count.short=Grupo de tallas observe.data.ps.observation.NonTargetLength.length.short=Talla 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 observe.data.ps.observation.NonTargetCatch.meanWeight.short=Poids moy observe.data.ps.observation.NonTargetCatch.meanWeightComputed.computed.tip=Le poids moyen a été calculé (%s) observe.data.ps.observation.NonTargetCatch.meanWeightComputed.observed.tip=Le poids moyen a été observé -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 +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 +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. observe.data.ps.observation.NonTargetCatch.reasonForDiscard.short=Raison rejet observe.data.ps.observation.NonTargetCatch.species.short=Espèce de faune observe.data.ps.observation.NonTargetCatch.speciesFate.short=Devenir -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. observe.data.ps.observation.NonTargetCatch.totalCount.short=Nombre observe.data.ps.observation.NonTargetCatch.totalCountComputed.computed.tip=Le nombre estimé a été calculé (%s) observe.data.ps.observation.NonTargetCatch.totalCountComputed.observed.tip=Le nombre estimé a été observé @@ -943,7 +943,6 @@ observe.data.ps.observation.NonTargetCatchRelease.releasingTime.short=Moment observe.data.ps.observation.NonTargetCatchRelease.sex.short=Sexe observe.data.ps.observation.NonTargetCatchRelease.species.short=Espèce observe.data.ps.observation.NonTargetCatchRelease.speciesGroupReleaseMode.short=Mode -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 observe.data.ps.observation.NonTargetLength.count.short=Effectif observe.data.ps.observation.NonTargetLength.length.short=Longueur observe.data.ps.observation.NonTargetLength.picturesReferences=référence photo ===================================== models/persistence/src/main/java/fr/ird/observe/entities/data/ps/observation/SetImpl.java ===================================== @@ -100,7 +100,7 @@ public class SetImpl extends SetAbstract { @Override public boolean canUseNonTargetCatchRelease() { - return isNonTargetCatchReleaseNotEmpty() && getNonTargetCatch().stream().anyMatch(t -> isSpeciesGroupRelease(t.getSpecies())); + return isNonTargetCatchNotEmpty() && getNonTargetCatch().stream().anyMatch(t -> isSpeciesGroupRelease(t.getSpecies())); } public boolean isSpeciesGroupRelease(Species species) { @@ -136,6 +136,10 @@ public class SetImpl extends SetAbstract { toSetNonTargetCatchDto(referentialLocale, (SetNonTargetCatchDto) dto); return; } + if (dto instanceof SetNonTargetCatchReleaseDto) { + toSetNonTargetCatchReleaseDto(referentialLocale, (SetNonTargetCatchReleaseDto) dto); + return; + } super.toDto(referentialLocale, dto); if (dto instanceof SetDto) { ((SetDto) dto).setDiscardedTargetSampleEnabled(canUseDiscardedTargetSample()); @@ -143,9 +147,6 @@ public class SetImpl extends SetAbstract { ((SetDto) dto).setNonTargetSampleEnabled(canUseNonTargetSample()); ((SetDto) dto).setSetNonTargetCatchReleaseEnabled(canUseNonTargetCatchRelease()); } - if (dto instanceof SetNonTargetCatchReleaseDto) { - ((SetNonTargetCatchReleaseDto) dto).setAvailableSpeciesIds(getNonTargetCatch().stream().map(NonTargetCatch::getSpecies).filter(this::isSpeciesGroupRelease).map(Species::getTopiaId).distinct().collect(ImmutableSet.toImmutableSet())); - } if (dto instanceof NonTargetSampleDto) { ((NonTargetSampleDto) dto).setAvailableSpeciesIds(getNonTargetCatch().stream().map(NonTargetCatch::getSpecies).map(Species::getTopiaId).distinct().collect(ImmutableSet.toImmutableSet())); ((NonTargetSampleDto) dto).setAvailableSpeciesFateIds(getNonTargetCatch().stream().map(NonTargetCatch::getSpeciesFate).map(SpeciesFate::getTopiaId).distinct().collect(ImmutableSet.toImmutableSet())); @@ -160,10 +161,6 @@ public class SetImpl extends SetAbstract { @Override public <D extends DataDto> void fromDto(ReferentialLocale referentialLocale, D dto) { - if (dto instanceof SetDiscardedTargetCatchDto) { - fromSetDiscardedTargetCatchDto(referentialLocale, (SetDiscardedTargetCatchDto) dto); - return; - } if (dto instanceof SetKeptTargetCatchDto) { fromSetKeptTargetCatchDto(referentialLocale, (SetKeptTargetCatchDto) dto); return; @@ -206,7 +203,7 @@ public class SetImpl extends SetAbstract { dtoList.forEach(catchDto -> { SpeciesReference species = catchDto.getSpecies(); boolean hasSample = speciesId.contains(species.getId()); - catchDto.set(KeptTargetCatchDto.PROPERTY_HAS_SAMPLE, hasSample); + catchDto.setHasSample(hasSample); }); } } @@ -224,7 +221,7 @@ public class SetImpl extends SetAbstract { dtoList.forEach(catchDto -> { SpeciesReference species = catchDto.getSpecies(); boolean hasSample = speciesId.contains(species.getId()); - catchDto.set(KeptTargetCatchDto.PROPERTY_HAS_SAMPLE, hasSample); + catchDto.setHasSample(hasSample); }); } } @@ -255,6 +252,12 @@ public class SetImpl extends SetAbstract { } } + private void toSetNonTargetCatchReleaseDto(ReferentialLocale referentialLocale, SetNonTargetCatchReleaseDto dto) { + // do normal copy + super.toDto(referentialLocale, dto); + dto.setAvailableSpeciesIds(getNonTargetCatch().stream().map(NonTargetCatch::getSpecies).filter(this::isSpeciesGroupRelease).map(Species::getTopiaId).distinct().collect(ImmutableSet.toImmutableSet())); + } + private void fromSetKeptTargetCatchDto(ReferentialLocale referentialLocale, SetKeptTargetCatchDto dto) { // keep other catches List<TargetCatch> otherTargetCatches = getTargetCatch(true); @@ -272,23 +275,6 @@ public class SetImpl extends SetAbstract { otherTargetCatches.forEach(this::addTargetCatch); } - private void fromSetDiscardedTargetCatchDto(ReferentialLocale referentialLocale, SetDiscardedTargetCatchDto dto) { - // keep other catches - List<TargetCatch> otherTargetCatches = getTargetCatch(false); - // do normal copy - super.fromDto(referentialLocale, dto); - // delete any sample which not using the given species ids - TargetSample targetSample = getTargetSample(true); - if (targetSample != null) { - List<DiscardedTargetCatchDto> targetCatch = dto.getTargetCatch(); - Set<String> speciesIds = DtoReferenceAware.ids(targetCatch.stream().map(DiscardedTargetCatchDto::getSpecies)); - // remove sample from species ids - targetSample.getTargetLength().removeIf(targetLength -> !speciesIds.contains(targetLength.getSpecies().getTopiaId())); - } - // push back other catches - otherTargetCatches.forEach(this::addTargetCatch); - } - private List<TargetCatch> getTargetCatch(boolean discarded) { return super.getTargetCatch().stream().filter(c -> c != null && Objects.equals(discarded, c.isDiscarded())).collect(Collectors.toList()); } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/e8ee529f6b83ed2a9f0b6a4797... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/e8ee529f6b83ed2a9f0b6a4797... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT