Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 346e933e by tchemit at 2019-09-24T13:53:59Z [REFERENTIEL][FOB] Présentation référentiel matériaux - Closes #1344 - - - - - 3 changed files: - dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java - + dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ObjectMaterialReferenceDecorator.java - dto/src/main/java/fr/ird/observe/dto/decoration/decorators/ReferentialReferenceDecorator.java Changes: ===================================== dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java ===================================== @@ -8,12 +8,12 @@ * 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>. @@ -97,6 +97,7 @@ import fr.ird.observe.dto.decoration.decorators.LengthWeightParameterDecorator; import fr.ird.observe.dto.decoration.decorators.NonTargetCatchDecorator; import fr.ird.observe.dto.decoration.decorators.NonTargetCatchReleaseDecorator; import fr.ird.observe.dto.decoration.decorators.NonTargetLengthDecorator; +import fr.ird.observe.dto.decoration.decorators.ObjectMaterialReferenceDecorator; import fr.ird.observe.dto.decoration.decorators.ObjectObservedSpeciesDecorator; import fr.ird.observe.dto.decoration.decorators.ObserveDecorator; import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator; @@ -209,7 +210,6 @@ import fr.ird.observe.dto.referential.seine.NonTargetCatchReleaseStatusReference import fr.ird.observe.dto.referential.seine.NonTargetCatchReleasingTimeDto; import fr.ird.observe.dto.referential.seine.NonTargetCatchReleasingTimeReference; import fr.ird.observe.dto.referential.seine.ObjectMaterialDto; -import fr.ird.observe.dto.referential.seine.ObjectMaterialReference; import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeDto; import fr.ird.observe.dto.referential.seine.ObjectMaterialTypeReference; import fr.ird.observe.dto.referential.seine.ObjectOperationDto; @@ -791,7 +791,9 @@ public class DecoratorService extends DecoratorProvider { @Override public void initObjectMaterialDto() { - registerDefaultReferentialAndReferentialReferenceDecorator(ObjectMaterialDto.class, ObjectMaterialReference.class, libelle); + registerDecorator(new ObjectMaterialReferenceDecorator()); + registerObserveDecorator(ObjectMaterialDto.class, "${code}$s##${" + libelle + "}$s", " "); +// registerDefaultReferentialAndReferentialReferenceDecorator(ObjectMaterialDto.class, ObjectMaterialReference.class, libelle); } @Override ===================================== 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/decorators/ReferentialReferenceDecorator.java ===================================== @@ -55,7 +55,7 @@ public class ReferentialReferenceDecorator<R extends ReferentialDtoReference> ex JXPathContext jxcontext = JXPathContext.newContext(data); Comparable<Comparable<?>> key = getTokenValue(jxcontext, ReferentialDto.PROPERTY_CODE); // on passe en 000000x comme ça si on a des nombres, ils seront bien triés - String value = key == null ? "" : StringUtils.leftPad(key.toString(), 6, "0"); + String value = key == null || key.equals(t("observe.common.nocode")) ? "" : StringUtils.leftPad(key.toString(), 6, "0"); valueCache.put(data, (Comparable) value); } } View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/346e933e7d8ae85d46b376016655... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/346e933e7d8ae85d46b376016655... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT