Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 74f5c64d by Tony CHEMIT at 2018-06-13T12:54:08Z [GEAR] Page des caractéristiques d'équipements -> afficher l'unité attendue - Closes #955 - - - - - 9 changed files: - dto/src/main/java/fr/ird/observe/binder/referential/common/GearCaracteristicDtoReferenceBinder.java - dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java - + dto/src/main/java/fr/ird/observe/dto/decoration/decorators/GearCaracteristicDtoDecorator.java - + dto/src/main/java/fr/ird/observe/dto/decoration/decorators/GeatCaracteristicReferenceDecorator.java - dto/src/main/models/Observe.model - dto/src/main/resources/i18n/dto_en_GB.properties - dto/src/main/resources/i18n/dto_es_ES.properties - dto/src/main/resources/i18n/dto_fr_FR.properties - persistence/src/main/java/fr/ird/observe/binder/referential/common/GearCaracteristicEntityReferenceBinder.java Changes: ===================================== dto/src/main/java/fr/ird/observe/binder/referential/common/GearCaracteristicDtoReferenceBinder.java ===================================== --- a/dto/src/main/java/fr/ird/observe/binder/referential/common/GearCaracteristicDtoReferenceBinder.java +++ b/dto/src/main/java/fr/ird/observe/binder/referential/common/GearCaracteristicDtoReferenceBinder.java @@ -10,12 +10,12 @@ package fr.ird.observe.binder.referential.common; * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. @@ -43,7 +43,8 @@ public class GearCaracteristicDtoReferenceBinder extends ReferentialDtoReference return new GearCaracteristicReference(dto, dto.getCode(), dto.getLabel(referentialLocale), - dto.getGearCaracteristicType().getId()); + dto.getGearCaracteristicType().getId(), + dto.getUnit()); } } ===================================== dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java ===================================== --- a/dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java +++ b/dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java @@ -89,6 +89,8 @@ import fr.ird.observe.dto.data.seine.TransmittingBuoyDto; import fr.ird.observe.dto.data.seine.TransmittingBuoyReference; import fr.ird.observe.dto.data.seine.TripSeineReference; import fr.ird.observe.dto.decoration.decorators.DataReferenceDecorator; +import fr.ird.observe.dto.decoration.decorators.GearCaracteristicDtoDecorator; +import fr.ird.observe.dto.decoration.decorators.GeatCaracteristicReferenceDecorator; import fr.ird.observe.dto.decoration.decorators.LengthLengthParameterDecorator; import fr.ird.observe.dto.decoration.decorators.LengthWeightParameterDecorator; import fr.ird.observe.dto.decoration.decorators.NonTargetCatchDecorator; @@ -541,7 +543,8 @@ public class DecoratorService extends DecoratorProvider { @Override public void initGearCaracteristicDto() { - registerDefaultReferentialAndReferentialReferenceDecorator(GearCaracteristicDto.class, GearCaracteristicReference.class, libelle); + registerDecorator(new GearCaracteristicDtoDecorator(libelle)); + registerDecorator(null, new GeatCaracteristicReferenceDecorator()); } @Override ===================================== dto/src/main/java/fr/ird/observe/dto/decoration/decorators/GearCaracteristicDtoDecorator.java ===================================== --- /dev/null +++ b/dto/src/main/java/fr/ird/observe/dto/decoration/decorators/GearCaracteristicDtoDecorator.java @@ -0,0 +1,26 @@ +package fr.ird.observe.dto.decoration.decorators; + +import fr.ird.observe.dto.referential.GearCaracteristicDto; + +import static org.nuiton.i18n.I18n.t; + +/** + * Created by tchemit on 13/06/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class GearCaracteristicDtoDecorator extends ObserveDecorator<GearCaracteristicDto> { + + public GearCaracteristicDtoDecorator(String libelle) { + super(GearCaracteristicDto.class, "${code}$s##${" + libelle + "}$s##${unit}$s", " "); + } + + @Override + protected Comparable<?> getDefaultNullValue(String token) { + Comparable<?> defaultNullValue = super.getDefaultNullValue(token); + if (defaultNullValue == null && token.equals(GearCaracteristicDto.PROPERTY_UNIT)) { + return t("observe.common.no.unit"); + } + return defaultNullValue; + } +} ===================================== dto/src/main/java/fr/ird/observe/dto/decoration/decorators/GeatCaracteristicReferenceDecorator.java ===================================== --- /dev/null +++ b/dto/src/main/java/fr/ird/observe/dto/decoration/decorators/GeatCaracteristicReferenceDecorator.java @@ -0,0 +1,26 @@ +package fr.ird.observe.dto.decoration.decorators; + +import fr.ird.observe.dto.referential.GearCaracteristicDto; +import fr.ird.observe.dto.referential.GearCaracteristicReference; + +import static org.nuiton.i18n.I18n.t; + +/** + * Created by tchemit on 13/06/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class GeatCaracteristicReferenceDecorator extends ReferentialReferenceDecorator<GearCaracteristicReference> { + public GeatCaracteristicReferenceDecorator( ) { + super(GearCaracteristicReference.class, "${code}$s##${label}$s##${unit}$s"); + } + + @Override + protected Comparable<?> getDefaultNullValue(String token) { + Comparable<?> defaultNullValue = super.getDefaultNullValue(token); + if (defaultNullValue == null && token.equals(GearCaracteristicDto.PROPERTY_UNIT)) { + return t("observe.common.no.unit"); + } + return defaultNullValue; + } +} ===================================== dto/src/main/models/Observe.model ===================================== --- a/dto/src/main/models/Observe.model +++ b/dto/src/main/models/Observe.model @@ -368,7 +368,7 @@ endDate + {*:1} Date referential.Gear > referential.I18nReferential gearCaracteristic {*:*} fr.ird.observe.dto.referential.GearCaracteristicReference | ordered -referential.GearCaracteristic > referential.I18nReferential | references=code,label,gearCaracteristicTypeId +referential.GearCaracteristic > referential.I18nReferential | references=code,label,gearCaracteristicTypeId,unit unit + {*:1} String gearCaracteristicType {*:1} fr.ird.observe.dto.referential.GearCaracteristicTypeReference ===================================== dto/src/main/resources/i18n/dto_en_GB.properties ===================================== --- a/dto/src/main/resources/i18n/dto_en_GB.properties +++ b/dto/src/main/resources/i18n/dto_en_GB.properties @@ -243,6 +243,7 @@ observe.common.haulingIdentifier=Hauling identifier observe.common.homeId=Home id observe.common.inconnu=Unknown observe.common.lengthWeightFormula=Length weight formula +observe.common.no.unit=No unit observe.common.nocode=Nocode observe.common.none=None observe.common.program=Program ===================================== dto/src/main/resources/i18n/dto_es_ES.properties ===================================== --- a/dto/src/main/resources/i18n/dto_es_ES.properties +++ b/dto/src/main/resources/i18n/dto_es_ES.properties @@ -241,6 +241,7 @@ observe.common.haulingIdentifier=Arrastre observe.common.homeId=Identificador observe.common.inconnu=desconocido observe.common.lengthWeightFormula=Relación de peso +observe.common.no.unit=No unit \#TODO observe.common.nocode=codigo ausente observe.common.none=Ninguno observe.common.program=Programa ===================================== dto/src/main/resources/i18n/dto_fr_FR.properties ===================================== --- a/dto/src/main/resources/i18n/dto_fr_FR.properties +++ b/dto/src/main/resources/i18n/dto_fr_FR.properties @@ -243,6 +243,7 @@ observe.common.haulingIdentifier=Virage observe.common.homeId=Identifiant observe.common.inconnu=inconnu observe.common.lengthWeightFormula=Relation Poids +observe.common.no.unit=Pas d'unité observe.common.nocode=code absent observe.common.none=Aucun observe.common.program=Programme ===================================== persistence/src/main/java/fr/ird/observe/binder/referential/common/GearCaracteristicEntityReferenceBinder.java ===================================== --- a/persistence/src/main/java/fr/ird/observe/binder/referential/common/GearCaracteristicEntityReferenceBinder.java +++ b/persistence/src/main/java/fr/ird/observe/binder/referential/common/GearCaracteristicEntityReferenceBinder.java @@ -10,12 +10,12 @@ package fr.ird.observe.binder.referential.common; * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. @@ -44,7 +44,8 @@ public class GearCaracteristicEntityReferenceBinder extends ReferentialEntityRef return new GearCaracteristicReference(dto, dto.getCode(), dto.getLabel(referentialLocale), - dto.getGearCaracteristicType().getTopiaId()); + dto.getGearCaracteristicType().getTopiaId(), + dto.getUnit()); } } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/74f5c64dd7579f56e4d19a645bcf... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/74f5c64dd7579f56e4d19a645bcf... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT