Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 787fee60 by tchemit at 2019-09-28T10:44:08Z [REFERENTIEL][FOB] Présentation référentiel matériaux - Closes #1344 - - - - - 2 changed files: - + dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ObjectMaterialReferenceDecorator.java - dto/src/main/java/fr/ird/observe/dto/decoration/init/ReferentialPsObservationModelDecoratorInitializer.java Changes: ===================================== dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ObjectMaterialReferenceDecorator.java ===================================== @@ -0,0 +1,45 @@ +package fr.ird.observe.dto.decoration.decorators; + +/*- + * #%L + * ObServe :: Dto + * %% + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * 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>. + * #L% + */ + +import fr.ird.observe.dto.referential.ReferentialDto; +import fr.ird.observe.dto.referential.seine.ObjectMaterialReference; +import org.apache.commons.jxpath.JXPathContext; + +import static io.ultreia.java4all.i18n.I18n.t; + +public class ObjectMaterialReferenceDecorator extends ReferentialReferenceDecorator<ObjectMaterialReference> { + + public ObjectMaterialReferenceDecorator() { + super(ObjectMaterialReference.class, "${code}$s##${label}$s"); + } + + @Override + protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) { + Comparable<Comparable<?>> result = super.getTokenValue(jxcontext, token); + if (ReferentialDto.PROPERTY_CODE.equals(token) && (result == null || (result + "").isEmpty())) { + result = (Comparable) t("observe.common.nocode"); + } + return result; + } +} ===================================== dto/src/main/java/fr/ird/observe/dto/decoration/init/ReferentialPsObservationModelDecoratorInitializer.java ===================================== @@ -23,6 +23,7 @@ package fr.ird.observe.dto.decoration.init; */ import fr.ird.observe.dto.decoration.DecoratorService; +import fr.ird.observe.dto.decoration.decorators.ObjectMaterialReferenceDecorator; import fr.ird.observe.dto.referential.ps.observation.DetectionModeDto; import fr.ird.observe.dto.referential.ps.observation.DetectionModeReference; import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleaseConformityDto; @@ -32,7 +33,6 @@ import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleaseStatus import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleasingTimeDto; import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleasingTimeReference; import fr.ird.observe.dto.referential.ps.observation.ObjectMaterialDto; -import fr.ird.observe.dto.referential.ps.observation.ObjectMaterialReference; import fr.ird.observe.dto.referential.ps.observation.ObservedSystemDto; import fr.ird.observe.dto.referential.ps.observation.ObservedSystemReference; import fr.ird.observe.dto.referential.ps.observation.ReasonForDiscardDto; @@ -76,7 +76,8 @@ public class ReferentialPsObservationModelDecoratorInitializer extends ModelDeco @Override public void initPsObservationObjectMaterialDto() { - registerDefaultReferentialAndReferentialReferenceDecorator(ObjectMaterialDto.class, ObjectMaterialReference.class, libelle); + registerDecorator(new ObjectMaterialReferenceDecorator()); + registerObserveDecorator(ObjectMaterialDto.class, "${code}$s##${" + libelle + "}$s", " "); } @Override View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/787fee60903ad914cf7dadb899d3... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/787fee60903ad914cf7dadb899d3... You're receiving this email because of your account on gitlab.com.