Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
d39cba11
by Tony Chemit at 2022-09-02T19:04:58+02:00
-
048de6cf
by Tony Chemit at 2022-09-02T19:04:58+02:00
-
7bdf5cac
by Tony Chemit at 2022-09-02T19:07:12+02:00
19 changed files:
- client/datasource/editor/common/src/main/java/fr/ird/observe/client/datasource/editor/common/referential/common/OceanUI.jaxx
- + client/datasource/editor/common/src/main/java/fr/ird/observe/client/datasource/editor/common/referential/common/OceanUI.jcss
- core/api/dto/src/main/resources/META-INF/dto/Observe/DifferentialMetaModel.json
- core/api/services/src/main/resources/META-INF/i18n/Observe-labels.properties
- core/api/validation/src/main/i18n/getters/eugene.getter
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripBatchSpi.java
- + core/persistence/java/src/main/java/fr/ird/observe/entities/referential/common/OceanSpi.java
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/referential/common/Ocean/validation-create.json
- core/persistence/resources/src/main/resources/fr/ird/observe/entities/referential/common/Ocean/validation-update.json
- core/persistence/test/src/test/java/fr/ird/observe/persistence/test/DecoratorServiceTest.java
- core/services/i18n/src/main/i18n/translations/services_en_GB.properties
- core/services/i18n/src/main/i18n/translations/services_es_ES.properties
- core/services/i18n/src/main/i18n/translations/services_fr_FR.properties
- model/src/main/models/Observe/dto/01-referential-common.model
- model/src/main/models/Observe/dto/attribute/ordered.properties
- model/src/main/models/Observe/dto/class/i18nLabels.properties
- toolkit/persistence/src/main/java/fr/ird/observe/spi/context/DtoEntityContext.java
- toolkit/persistence/src/main/java/fr/ird/observe/spi/context/DtoEntityContextSupport.java
- toolkit/persistence/src/main/java/fr/ird/observe/spi/context/ReferentialDtoEntityContext.java
Changes:
| ... | ... | @@ -24,24 +24,61 @@ |
| 24 | 24 | <import>
|
| 25 | 25 | fr.ird.observe.dto.referential.common.OceanDto
|
| 26 | 26 | fr.ird.observe.dto.referential.common.OceanReference
|
| 27 | + fr.ird.observe.dto.referential.common.SpeciesReference
|
|
| 27 | 28 | io.ultreia.java4all.jaxx.widgets.choice.BeanCheckBox
|
| 29 | + io.ultreia.java4all.jaxx.widgets.list.DoubleList
|
|
| 28 | 30 | </import>
|
| 29 | 31 | <BeanValidator id='validator' autoField='true' beanClass='fr.ird.observe.dto.referential.common.OceanDto'
|
| 30 | 32 | context='create' errorTableModel='{getErrorTableModel()}'/>
|
| 31 | 33 | <OceanUIModel id='model' constructorParams='@override:getNavigationSource(this)'/>
|
| 32 | 34 | <OceanDto id='bean'/>
|
| 33 | - <Table id='editTable' forceOverride="3">
|
|
| 35 | + <Table id="editView" insets="0" fill="both">
|
|
| 34 | 36 | <row>
|
| 35 | - <cell anchor='west'>
|
|
| 36 | - <JLabel id='atLeastOneSelectedLabel'/>
|
|
| 37 | - </cell>
|
|
| 38 | - <cell weightx="1" fill="both">
|
|
| 39 | - <JPanel id="atLeastOneSelected" layout="{new GridLayout(2, 2)}" border='{BorderFactory.createLoweredBevelBorder()}'>
|
|
| 40 | - <BeanCheckBox id='northWestAllowed'/>
|
|
| 41 | - <BeanCheckBox id='northEastAllowed' />
|
|
| 42 | - <BeanCheckBox id='southWestAllowed'/>
|
|
| 43 | - <BeanCheckBox id='southEastAllowed'/>
|
|
| 44 | - </JPanel>
|
|
| 37 | + <cell anchor="north" weightx="1" weighty="1">
|
|
| 38 | + <JTabbedPane id='mainTabbedPane'>
|
|
| 39 | + <tab id='generalTab' i18nProperty="">
|
|
| 40 | + <Table fill="both" weightx="1">
|
|
| 41 | + <row>
|
|
| 42 | + <cell>
|
|
| 43 | + <Table id='editTable' styleClass="caracteristic" addToContainer="true" forceOverride="3">
|
|
| 44 | + <row>
|
|
| 45 | + <cell anchor='west'>
|
|
| 46 | + <JLabel id='atLeastOneSelectedLabel'/>
|
|
| 47 | + </cell>
|
|
| 48 | + <cell weightx="1" fill="both">
|
|
| 49 | + <JPanel id="atLeastOneSelected" layout="{new GridLayout(2, 2)}" border='{BorderFactory.createLoweredBevelBorder()}'>
|
|
| 50 | + <BeanCheckBox id='northWestAllowed'/>
|
|
| 51 | + <BeanCheckBox id='northEastAllowed' />
|
|
| 52 | + <BeanCheckBox id='southWestAllowed'/>
|
|
| 53 | + <BeanCheckBox id='southEastAllowed'/>
|
|
| 54 | + </JPanel>
|
|
| 55 | + </cell>
|
|
| 56 | + </row>
|
|
| 57 | + </Table>
|
|
| 58 | + </cell>
|
|
| 59 | + </row>
|
|
| 60 | + <row>
|
|
| 61 | + <cell>
|
|
| 62 | + <Table id='editI18nTable' addToContainer="true"/>
|
|
| 63 | + </cell>
|
|
| 64 | + </row>
|
|
| 65 | + <row>
|
|
| 66 | + <cell weighty="1">
|
|
| 67 | + <JLabel styleClass="skipI18n"/>
|
|
| 68 | + </cell>
|
|
| 69 | + </row>
|
|
| 70 | + </Table>
|
|
| 71 | + </tab>
|
|
| 72 | + <tab id='speciesTab' i18nProperty="species">
|
|
| 73 | + <Table fill="both">
|
|
| 74 | + <row>
|
|
| 75 | + <cell weightx="1" weighty="1">
|
|
| 76 | + <DoubleList id='species' genericType='SpeciesReference'/>
|
|
| 77 | + </cell>
|
|
| 78 | + </row>
|
|
| 79 | + </Table>
|
|
| 80 | + </tab>
|
|
| 81 | + </JTabbedPane>
|
|
| 45 | 82 | </cell>
|
| 46 | 83 | </row>
|
| 47 | 84 | </Table>
|
| 1 | +/*-
|
|
| 2 | + * #%L
|
|
| 3 | + * ObServe Client :: DataSource :: Editor :: Common
|
|
| 4 | + * %%
|
|
| 5 | + * Copyright (C) 2008 - 2022 IRD, Ultreia.io
|
|
| 6 | + * %%
|
|
| 7 | + * This program is free software: you can redistribute it and/or modify
|
|
| 8 | + * it under the terms of the GNU General Public License as
|
|
| 9 | + * published by the Free Software Foundation, either version 3 of the
|
|
| 10 | + * License, or (at your option) any later version.
|
|
| 11 | + *
|
|
| 12 | + * This program is distributed in the hope that it will be useful,
|
|
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 15 | + * GNU General Public License for more details.
|
|
| 16 | + *
|
|
| 17 | + * You should have received a copy of the GNU General Public
|
|
| 18 | + * License along with this program. If not, see
|
|
| 19 | + * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 20 | + * #L%
|
|
| 21 | + */
|
|
| 22 | + |
|
| 23 | +#mainTabbedPane {
|
|
| 24 | + _focusComponent:{newComponentArray(uri,species)};
|
|
| 25 | +}
|
|
| 26 | + |
|
| 27 | +/*#species {
|
|
| 28 | + border:{new TitledBorder(t("observe.referential.common.SpeciesList.speciesTab") + " ")};
|
|
| 29 | +}*/ |
| ... | ... | @@ -96,6 +96,7 @@ |
| 96 | 96 | "northWestAllowed",
|
| 97 | 97 | "southEastAllowed",
|
| 98 | 98 | "southWestAllowed",
|
| 99 | + "species",
|
|
| 99 | 100 | "uri"
|
| 100 | 101 | ],
|
| 101 | 102 | "fr.ird.observe.dto.referential.common.SexDto": [
|
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | # #L%
|
| 21 | 21 | ###
|
| 22 | 22 | #Generated by org.nuiton.i18n.plugin.GenerateI18nLabelsMojo
|
| 23 | -#Wed Jul 27 12:29:59 CEST 2022
|
|
| 23 | +#Fri Sep 02 18:35:55 CEST 2022
|
|
| 24 | 24 | observe.Business.createDate=observe.Common.createDate
|
| 25 | 25 | observe.Business.homeId=observe.Common.homeId
|
| 26 | 26 | observe.Business.id=observe.Common.id
|
| ... | ... | @@ -1826,6 +1826,7 @@ observe.referential.common.Ocean.code=observe.referential.Referential.code |
| 1826 | 1826 | observe.referential.common.Ocean.codeAndHomeId=observe.referential.Referential.codeAndHomeId
|
| 1827 | 1827 | observe.referential.common.Ocean.createDate=observe.Common.createDate
|
| 1828 | 1828 | observe.referential.common.Ocean.enabled=observe.Common.enabled
|
| 1829 | +observe.referential.common.Ocean.generalTab=observe.Common.generalTab
|
|
| 1829 | 1830 | observe.referential.common.Ocean.homeId=observe.Common.homeId
|
| 1830 | 1831 | observe.referential.common.Ocean.id=observe.Common.id
|
| 1831 | 1832 | observe.referential.common.Ocean.label=observe.Common.label
|
| ... | ... | @@ -1839,6 +1840,9 @@ observe.referential.common.Ocean.label7=observe.Common.label7 |
| 1839 | 1840 | observe.referential.common.Ocean.label8=observe.Common.label8
|
| 1840 | 1841 | observe.referential.common.Ocean.lastUpdateDate=observe.Common.lastUpdateDate
|
| 1841 | 1842 | observe.referential.common.Ocean.needComment=observe.Common.needComment
|
| 1843 | +observe.referential.common.Ocean.species=observe.Common.species
|
|
| 1844 | +observe.referential.common.Ocean.species.available=observe.Common.species.available
|
|
| 1845 | +observe.referential.common.Ocean.species.selected=observe.Common.species.selected
|
|
| 1842 | 1846 | observe.referential.common.Ocean.status=observe.Common.status
|
| 1843 | 1847 | observe.referential.common.Ocean.uri=observe.Common.uri
|
| 1844 | 1848 | observe.referential.common.Ocean.version=observe.Common.version
|
| ... | ... | @@ -355,6 +355,7 @@ observe.referential.common.Ocean.northEastAllowed |
| 355 | 355 | observe.referential.common.Ocean.northWestAllowed
|
| 356 | 356 | observe.referential.common.Ocean.southEastAllowed
|
| 357 | 357 | observe.referential.common.Ocean.southWestAllowed
|
| 358 | +observe.referential.common.Ocean.species
|
|
| 358 | 359 | observe.referential.common.Person.atLeastOneSelected
|
| 359 | 360 | observe.referential.common.Person.dataEntryOperator
|
| 360 | 361 | observe.referential.common.Person.dataSource
|
| ... | ... | @@ -32,6 +32,7 @@ import fr.ird.observe.spi.service.ServiceContext; |
| 32 | 32 | import java.util.Date;
|
| 33 | 33 | import java.util.LinkedHashSet;
|
| 34 | 34 | import java.util.stream.Collectors;
|
| 35 | +import java.util.stream.Stream;
|
|
| 35 | 36 | |
| 36 | 37 | public class TripBatchSpi extends GeneratedTripBatchSpi {
|
| 37 | 38 | |
| ... | ... | @@ -44,9 +45,12 @@ public class TripBatchSpi extends GeneratedTripBatchSpi { |
| 44 | 45 | protected LinkedHashSet<PackagingReference> getPackaging(ServiceContext context, Trip trip) {
|
| 45 | 46 | Harbour landingHarbour = trip.getLandingHarbour();
|
| 46 | 47 | Date date = trip.getEndDate();
|
| 47 | - return Packaging.toReferenceSet(context.getReferentialLocale(), Packaging.getDao(context)
|
|
| 48 | - .streamAll()
|
|
| 49 | - .filter(p -> p.acceptHarbour(landingHarbour) && p.acceptDate(date)), null, null).stream().collect(Collectors.toCollection(LinkedHashSet::new));
|
|
| 48 | + try (Stream<Packaging> stream = Packaging.getDao(context).streamAll()) {
|
|
| 49 | + return Packaging.toReferenceSet(context.getReferentialLocale(),
|
|
| 50 | + stream.filter(p -> p.acceptHarbour(landingHarbour) && p.acceptDate(date)),
|
|
| 51 | + null,
|
|
| 52 | + null).stream().collect(Collectors.toCollection(LinkedHashSet::new));
|
|
| 53 | + }
|
|
| 50 | 54 | }
|
| 51 | 55 | |
| 52 | 56 | } |
| 1 | +package fr.ird.observe.entities.referential.common;
|
|
| 2 | + |
|
| 3 | +/*-
|
|
| 4 | + * #%L
|
|
| 5 | + * ObServe Core :: Persistence :: Java
|
|
| 6 | + * %%
|
|
| 7 | + * Copyright (C) 2008 - 2022 IRD, 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.form.Form;
|
|
| 26 | +import fr.ird.observe.dto.referential.common.OceanDto;
|
|
| 27 | +import fr.ird.observe.dto.referential.common.SpeciesReference;
|
|
| 28 | +import fr.ird.observe.dto.result.SaveResultDto;
|
|
| 29 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 30 | +import fr.ird.observe.spi.service.ServiceContext;
|
|
| 31 | + |
|
| 32 | +import java.util.LinkedHashSet;
|
|
| 33 | +import java.util.List;
|
|
| 34 | +import java.util.Set;
|
|
| 35 | +import java.util.stream.Collectors;
|
|
| 36 | +import java.util.stream.Stream;
|
|
| 37 | + |
|
| 38 | +/**
|
|
| 39 | + * @author Tony Chemit - dev@tchemit.fr
|
|
| 40 | + * @since 9.0.7
|
|
| 41 | + */
|
|
| 42 | +public class OceanSpi extends GeneratedOceanSpi {
|
|
| 43 | + |
|
| 44 | + @Override
|
|
| 45 | + public Form<OceanDto> loadForm(ServiceContext context, String id) {
|
|
| 46 | + Form<OceanDto> form = super.loadForm(context, id);
|
|
| 47 | + // add species that use this ocean, to be able to edit species list from Ocean form
|
|
| 48 | + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2366
|
|
| 49 | + try (Stream<Species> speciesStream = Species.loadEntities(context, s -> s.getOceanTopiaIds().contains(id))) {
|
|
| 50 | + List<SpeciesReference> speciesReferences = Species.toReferenceSet(context.getReferentialLocale(), speciesStream, null, null, null).toList();
|
|
| 51 | + form.getObject().setSpecies(speciesReferences);
|
|
| 52 | + }
|
|
| 53 | + return form;
|
|
| 54 | + }
|
|
| 55 | + |
|
| 56 | + @Override
|
|
| 57 | + public SaveResultDto saveEntity(ServiceContext context, Ocean entity, OceanDto dto) {
|
|
| 58 | + Set<Species> speciesToUpdate = new LinkedHashSet<>();
|
|
| 59 | + Set<String> newSpeciesWithThisOceanIds = dto.getSpecies().stream().map(SpeciesReference::getId).collect(Collectors.toSet());
|
|
| 60 | + if (dto.isPersisted()) {
|
|
| 61 | + // In that case, we could have some species to update by removing some ocean associations
|
|
| 62 | + try (Stream<Species> speciesStream = Species.loadEntities(context, s -> s.getOceanTopiaIds().contains(entity.getId()))) {
|
|
| 63 | + speciesStream.forEach(oldSpeciesWithThisOcean -> {
|
|
| 64 | + String oldSpeciesWithThisOceanId = oldSpeciesWithThisOcean.getTopiaId();
|
|
| 65 | + if (!newSpeciesWithThisOceanIds.contains(oldSpeciesWithThisOceanId)) {
|
|
| 66 | + // this species was removed from the ocean
|
|
| 67 | + oldSpeciesWithThisOcean.removeOcean(entity);
|
|
| 68 | + speciesToUpdate.add(oldSpeciesWithThisOcean);
|
|
| 69 | + } else {
|
|
| 70 | + // this species still have this ocean, no need to keep it
|
|
| 71 | + newSpeciesWithThisOceanIds.remove(oldSpeciesWithThisOceanId);
|
|
| 72 | + }
|
|
| 73 | + });
|
|
| 74 | + }
|
|
| 75 | + }
|
|
| 76 | + if (!newSpeciesWithThisOceanIds.isEmpty()) {
|
|
| 77 | + // need to add this ocean to those species
|
|
| 78 | + try (Stream<Species> speciesStream = Species.loadEntities(context, s -> newSpeciesWithThisOceanIds.contains(s.getTopiaId()))) {
|
|
| 79 | + speciesStream.forEach(s -> {
|
|
| 80 | + s.addOcean(entity);
|
|
| 81 | + speciesToUpdate.add(s);
|
|
| 82 | + });
|
|
| 83 | + }
|
|
| 84 | + }
|
|
| 85 | + AddEntityToUpdateStep update = newSaveHelper(context).update(this, entity);
|
|
| 86 | + for (Species species : speciesToUpdate) {
|
|
| 87 | + update.update(Species.SPI, species);
|
|
| 88 | + }
|
|
| 89 | + return update.build(entity);
|
|
| 90 | + }
|
|
| 91 | +} //OceanSpi |
| ... | ... | @@ -54,6 +54,14 @@ |
| 54 | 54 | "southWestAllowed is mandatory"
|
| 55 | 55 | ]
|
| 56 | 56 | },
|
| 57 | + "species": {
|
|
| 58 | + "errors": [
|
|
| 59 | + "check if referential species is disabled (only if validation is strong)"
|
|
| 60 | + ],
|
|
| 61 | + "warnings": [
|
|
| 62 | + "check if referential species is disabled (only if validation is not strong)"
|
|
| 63 | + ]
|
|
| 64 | + },
|
|
| 57 | 65 | "status": {
|
| 58 | 66 | "warnings": [
|
| 59 | 67 | "referential is enabled"
|
| ... | ... | @@ -54,6 +54,14 @@ |
| 54 | 54 | "southWestAllowed is mandatory"
|
| 55 | 55 | ]
|
| 56 | 56 | },
|
| 57 | + "species": {
|
|
| 58 | + "errors": [
|
|
| 59 | + "check if referential species is disabled (only if validation is strong)"
|
|
| 60 | + ],
|
|
| 61 | + "warnings": [
|
|
| 62 | + "check if referential species is disabled (only if validation is not strong)"
|
|
| 63 | + ]
|
|
| 64 | + },
|
|
| 57 | 65 | "status": {
|
| 58 | 66 | "warnings": [
|
| 59 | 67 | "referential is enabled"
|
| ... | ... | @@ -52,6 +52,7 @@ import org.junit.Test; |
| 52 | 52 | |
| 53 | 53 | import java.util.NoSuchElementException;
|
| 54 | 54 | import java.util.Objects;
|
| 55 | +import java.util.stream.Stream;
|
|
| 55 | 56 | |
| 56 | 57 | /**
|
| 57 | 58 | * Created by tchemit on 31/08/17.
|
| ... | ... | @@ -120,22 +121,24 @@ public class DecoratorServiceTest extends PersistenceTestSupportRead { |
| 120 | 121 | R reference1 = spi.toReference(ReferentialLocale.FR, newDto);
|
| 121 | 122 | decoratorService.installDecorator(reference1);
|
| 122 | 123 | decorate(referenceDecorator, reference1);
|
| 123 | - spi.getDao(persistenceContext).streamAll().limit(ObservePersistenceFixtures.ENTITIES_LIMIT_SIZE).forEach(entity -> {
|
|
| 124 | - D dto = spi.toDto(ReferentialLocale.FR, entity);
|
|
| 125 | - entity.registerDecorator(entityDecorator);
|
|
| 126 | - String entityToString = entityDecorator.decorate(entity);
|
|
| 127 | - Assert.assertNotNull(entityToString);
|
|
| 128 | - decoratorService.installDecorator(dto);
|
|
| 129 | - String dtoToString = decorate(decorator, dto);
|
|
| 130 | - if (!(dto instanceof LayoutAware)) {
|
|
| 131 | - Assert.assertEquals(entityToString, dtoToString);
|
|
| 132 | - }
|
|
| 133 | - |
|
| 134 | - R reference = spi.toReference(ReferentialLocale.FR, dto);
|
|
| 135 | - decoratorService.installDecorator(reference);
|
|
| 136 | - String referenceToString = decorate(referenceDecorator, reference);
|
|
| 137 | - Assert.assertEquals(referenceToString, dtoToString);
|
|
| 138 | - });
|
|
| 124 | + try (Stream<E> stream = spi.getDao(persistenceContext).streamAll().limit(ObservePersistenceFixtures.ENTITIES_LIMIT_SIZE)) {
|
|
| 125 | + stream.forEach(entity -> {
|
|
| 126 | + D dto = spi.toDto(ReferentialLocale.FR, entity);
|
|
| 127 | + entity.registerDecorator(entityDecorator);
|
|
| 128 | + String entityToString = entityDecorator.decorate(entity);
|
|
| 129 | + Assert.assertNotNull(entityToString);
|
|
| 130 | + decoratorService.installDecorator(dto);
|
|
| 131 | + String dtoToString = decorate(decorator, dto);
|
|
| 132 | + if (!(dto instanceof LayoutAware)) {
|
|
| 133 | + Assert.assertEquals(entityToString, dtoToString);
|
|
| 134 | + }
|
|
| 135 | + |
|
| 136 | + R reference = spi.toReference(ReferentialLocale.FR, dto);
|
|
| 137 | + decoratorService.installDecorator(reference);
|
|
| 138 | + String referenceToString = decorate(referenceDecorator, reference);
|
|
| 139 | + Assert.assertEquals(referenceToString, dtoToString);
|
|
| 140 | + });
|
|
| 141 | + }
|
|
| 139 | 142 | }
|
| 140 | 143 | }
|
| 141 | 144 |
| ... | ... | @@ -1478,6 +1478,7 @@ observe.referential.common.Ocean.northEastAllowed=Quadrant 1 (NE) |
| 1478 | 1478 | observe.referential.common.Ocean.northWestAllowed=Quadrant 4 (NW)
|
| 1479 | 1479 | observe.referential.common.Ocean.southEastAllowed=Quadrant 2 (SE)
|
| 1480 | 1480 | observe.referential.common.Ocean.southWestAllowed=Quadrant 3 (SW)
|
| 1481 | +observe.referential.common.Ocean.species=Species
|
|
| 1481 | 1482 | observe.referential.common.Ocean.type=Ocean
|
| 1482 | 1483 | observe.referential.common.Ocean.validation.atLeastOneSelected=At least one quadrant must be selected.
|
| 1483 | 1484 | observe.referential.common.Organism.type=Organism
|
| ... | ... | @@ -1478,6 +1478,7 @@ observe.referential.common.Ocean.northEastAllowed=Quadrant 1 (NE) |
| 1478 | 1478 | observe.referential.common.Ocean.northWestAllowed=Quadrant 4 (NW)
|
| 1479 | 1479 | observe.referential.common.Ocean.southEastAllowed=Quadrant 2 (SE)
|
| 1480 | 1480 | observe.referential.common.Ocean.southWestAllowed=Quadrant 3 (SW)
|
| 1481 | +observe.referential.common.Ocean.species=Especies
|
|
| 1481 | 1482 | observe.referential.common.Ocean.type=Océano
|
| 1482 | 1483 | observe.referential.common.Ocean.validation.atLeastOneSelected=At least one quadrant must be selected.
|
| 1483 | 1484 | observe.referential.common.Organism.type=Organismo
|
| ... | ... | @@ -1478,6 +1478,7 @@ observe.referential.common.Ocean.northEastAllowed=Quadrant 1 (NE) |
| 1478 | 1478 | observe.referential.common.Ocean.northWestAllowed=Quadrant 4 (NW)
|
| 1479 | 1479 | observe.referential.common.Ocean.southEastAllowed=Quadrant 2 (SE)
|
| 1480 | 1480 | observe.referential.common.Ocean.southWestAllowed=Quadrant 3 (SW)
|
| 1481 | +observe.referential.common.Ocean.species=Espèces
|
|
| 1481 | 1482 | observe.referential.common.Ocean.type=Océan
|
| 1482 | 1483 | observe.referential.common.Ocean.validation.atLeastOneSelected=Veuillez sélectionner au moins un quadrant.
|
| 1483 | 1484 | observe.referential.common.Organism.type=Organisme
|
| ... | ... | @@ -81,6 +81,7 @@ northEastAllowed boolean |
| 81 | 81 | southEastAllowed boolean
|
| 82 | 82 | southWestAllowed boolean
|
| 83 | 83 | northWestAllowed boolean
|
| 84 | +species {*:*} referential.common.SpeciesReference
|
|
| 84 | 85 | |
| 85 | 86 | referential.common.LengthMeasureMethod > referential.I18nReferential
|
| 86 | 87 |
| ... | ... | @@ -57,6 +57,7 @@ data.ps.observation.Sample.attribute.sampleMeasure=true |
| 57 | 57 | data.ps.observation.SetCatch.attribute.catches=true
|
| 58 | 58 | data.ps.observation.SetNonTargetCatchRelease.attribute.nonTargetCatchRelease=true
|
| 59 | 59 | referential.common.Gear.attribute.gearCharacteristic=true
|
| 60 | +referential.common.Ocean.attribute.species=true
|
|
| 60 | 61 | referential.common.Species.attribute.ocean=true
|
| 61 | 62 | referential.common.SpeciesGroup.attribute.speciesGroupReleaseMode=true
|
| 62 | 63 | referential.common.SpeciesList.attribute.species=true |
| ... | ... | @@ -103,7 +103,7 @@ referential.common.Harbour=coordinate,country,latitude,locode,longitude,quadrant |
| 103 | 103 | referential.common.LengthFormulaSupport=ocean,species,sex,coefficients,source,coefficientsInformation,generalTab,otherTab
|
| 104 | 104 | referential.common.LengthLengthParameter=inputOutputFormula,inputSizeMeasureType,outputInputFormula,outputSizeMeasureType,inputOutputFormulaInformation,outputInputFormulaInformation
|
| 105 | 105 | referential.common.LengthWeightParameter=lengthWeightFormula,meanLength,meanWeight,sizeMeasureType,weightLengthFormula,lengthWeightFormulaInformation,meanValues,weightLengthFormulaInformation
|
| 106 | -referential.common.Ocean=northEastAllowed,southEastAllowed,southWestAllowed,northWestAllowed,atLeastOneSelected,validation.atLeastOneSelected
|
|
| 106 | +referential.common.Ocean=northEastAllowed,southEastAllowed,southWestAllowed,northWestAllowed,atLeastOneSelected,validation.atLeastOneSelected,generalTab,species,species.available,species.selected
|
|
| 107 | 107 | referential.common.Organism=country,description
|
| 108 | 108 | referential.common.Person=captain,country,dataEntryOperator,dataSource,firstName,lastName,observer,psSampler,atLeastOneSelected,validation.atLeastOneSelected
|
| 109 | 109 | referential.common.ShipOwner=country,endDate,label,startDate
|
| ... | ... | @@ -308,7 +308,9 @@ public interface DtoEntityContext< |
| 308 | 308 | }
|
| 309 | 309 | |
| 310 | 310 | default Set<D> loadEntitiesToDto(ServiceContext context) {
|
| 311 | - return toDtoSet(context.getReferentialLocale(), getDao(context).streamAll());
|
|
| 311 | + try (Stream<E> stream = getDao(context).streamAll()) {
|
|
| 312 | + return toDtoSet(context.getReferentialLocale(), stream);
|
|
| 313 | + }
|
|
| 312 | 314 | }
|
| 313 | 315 | |
| 314 | 316 | default Stream<E> loadEntities(ServiceContext context, Predicate<E> predicate) {
|
| ... | ... | @@ -131,10 +131,12 @@ public abstract class DtoEntityContextSupport< |
| 131 | 131 | public DtoReferenceCollection<R> toReferenceSet(ServiceContext context, Date now) {
|
| 132 | 132 | ReferentialLocale referentialLocale = context.getReferentialLocale();
|
| 133 | 133 | Set<R> references = new LinkedHashSet<>();
|
| 134 | - getDao(context).streamAll().forEach(entity -> {
|
|
| 135 | - R reference = toReference(referentialLocale, entity);
|
|
| 136 | - references.add(reference);
|
|
| 137 | - });
|
|
| 134 | + try (Stream<E> stream = getDao(context).streamAll()) {
|
|
| 135 | + stream.forEach(entity -> {
|
|
| 136 | + R reference = toReference(referentialLocale, entity);
|
|
| 137 | + references.add(reference);
|
|
| 138 | + });
|
|
| 139 | + }
|
|
| 138 | 140 | return createReferenceSet(referentialLocale, references, now);
|
| 139 | 141 | }
|
| 140 | 142 | |
| ... | ... | @@ -230,10 +232,12 @@ public abstract class DtoEntityContextSupport< |
| 230 | 232 | public final Map<String, R> uniqueIndex(ServiceContext context) {
|
| 231 | 233 | Map<String, R> references = new LinkedHashMap<>();
|
| 232 | 234 | ReferentialLocale referentialLocale = context.getReferentialLocale();
|
| 233 | - getDao(context).streamAll().forEach(entity -> {
|
|
| 234 | - R reference = toReference(referentialLocale, entity);
|
|
| 235 | - references.put(reference.getId(), reference);
|
|
| 236 | - });
|
|
| 235 | + try (Stream<E> stream = getDao(context).streamAll()) {
|
|
| 236 | + stream.forEach(entity -> {
|
|
| 237 | + R reference = toReference(referentialLocale, entity);
|
|
| 238 | + references.put(reference.getId(), reference);
|
|
| 239 | + });
|
|
| 240 | + }
|
|
| 237 | 241 | return references;
|
| 238 | 242 | }
|
| 239 | 243 |
| ... | ... | @@ -89,6 +89,16 @@ public abstract class ReferentialDtoEntityContext< |
| 89 | 89 | this.extraScripts = SingletonSupplier.of(this::loadExtraScripts);
|
| 90 | 90 | }
|
| 91 | 91 | |
| 92 | + @Override
|
|
| 93 | + public Form<D> loadForm(ServiceContext context, String id) {
|
|
| 94 | + E entity = loadEntity(context, id);
|
|
| 95 | + return referentialEntityToForm(context.getReferentialLocale(), entity);
|
|
| 96 | + }
|
|
| 97 | + |
|
| 98 | + public SaveResultDto saveEntity(ServiceContext context, E entity, D dto) {
|
|
| 99 | + return saveEntity(context, entity);
|
|
| 100 | + }
|
|
| 101 | + |
|
| 92 | 102 | public Optional<ReplaceReferentialScript> getReplaceScript() {
|
| 93 | 103 | return getSqlScript().getReplaceReferentialScript();
|
| 94 | 104 | }
|
| ... | ... | @@ -182,12 +192,6 @@ public abstract class ReferentialDtoEntityContext< |
| 182 | 192 | return ReferentialDtoReferenceSet.of(toReferenceType(), references, now);
|
| 183 | 193 | }
|
| 184 | 194 | |
| 185 | - @Override
|
|
| 186 | - public final Form<D> loadForm(ServiceContext context, String id) {
|
|
| 187 | - E entity = loadEntity(context, id);
|
|
| 188 | - return referentialEntityToForm(context.getReferentialLocale(), entity);
|
|
| 189 | - }
|
|
| 190 | - |
|
| 191 | 195 | public final LinkedHashSet<E> toReferentialEntitySet(Collection<R> references) {
|
| 192 | 196 | LinkedHashSet<E> entityList = null;
|
| 193 | 197 | if (references != null && !references.isEmpty()) {
|
| ... | ... | @@ -274,7 +278,7 @@ public abstract class ReferentialDtoEntityContext< |
| 274 | 278 | E entity = loadOrCreateEntityFromReferentialDto(context, dto);
|
| 275 | 279 | checkLastUpdateDate(context, entity, dto);
|
| 276 | 280 | fromDto(context.getReferentialLocale(), entity, dto);
|
| 277 | - return saveEntity(context, entity);
|
|
| 281 | + return saveEntity(context, entity, dto);
|
|
| 278 | 282 | }
|
| 279 | 283 | |
| 280 | 284 | private SqlScript generateDuplicateScript(ServiceContext context, String id, String newId) {
|