Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
787fee60
by tchemit at 2019-09-28T10:44:08Z
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:
| 1 |
+package fr.ird.observe.dto.decoration.decorators;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Dto
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2019 IRD, Code Lutin, 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.referential.ReferentialDto;
|
|
| 26 |
+import fr.ird.observe.dto.referential.seine.ObjectMaterialReference;
|
|
| 27 |
+import org.apache.commons.jxpath.JXPathContext;
|
|
| 28 |
+ |
|
| 29 |
+import static io.ultreia.java4all.i18n.I18n.t;
|
|
| 30 |
+ |
|
| 31 |
+public class ObjectMaterialReferenceDecorator extends ReferentialReferenceDecorator<ObjectMaterialReference> {
|
|
| 32 |
+ |
|
| 33 |
+ public ObjectMaterialReferenceDecorator() {
|
|
| 34 |
+ super(ObjectMaterialReference.class, "${code}$s##${label}$s");
|
|
| 35 |
+ }
|
|
| 36 |
+ |
|
| 37 |
+ @Override
|
|
| 38 |
+ protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
|
|
| 39 |
+ Comparable<Comparable<?>> result = super.getTokenValue(jxcontext, token);
|
|
| 40 |
+ if (ReferentialDto.PROPERTY_CODE.equals(token) && (result == null || (result + "").isEmpty())) {
|
|
| 41 |
+ result = (Comparable) t("observe.common.nocode");
|
|
| 42 |
+ }
|
|
| 43 |
+ return result;
|
|
| 44 |
+ }
|
|
| 45 |
+}
|
| ... | ... | @@ -23,6 +23,7 @@ package fr.ird.observe.dto.decoration.init; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.dto.decoration.DecoratorService;
|
| 26 |
+import fr.ird.observe.dto.decoration.decorators.ObjectMaterialReferenceDecorator;
|
|
| 26 | 27 |
import fr.ird.observe.dto.referential.ps.observation.DetectionModeDto;
|
| 27 | 28 |
import fr.ird.observe.dto.referential.ps.observation.DetectionModeReference;
|
| 28 | 29 |
import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleaseConformityDto;
|
| ... | ... | @@ -32,7 +33,6 @@ import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleaseStatus |
| 32 | 33 |
import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleasingTimeDto;
|
| 33 | 34 |
import fr.ird.observe.dto.referential.ps.observation.NonTargetCatchReleasingTimeReference;
|
| 34 | 35 |
import fr.ird.observe.dto.referential.ps.observation.ObjectMaterialDto;
|
| 35 |
-import fr.ird.observe.dto.referential.ps.observation.ObjectMaterialReference;
|
|
| 36 | 36 |
import fr.ird.observe.dto.referential.ps.observation.ObservedSystemDto;
|
| 37 | 37 |
import fr.ird.observe.dto.referential.ps.observation.ObservedSystemReference;
|
| 38 | 38 |
import fr.ird.observe.dto.referential.ps.observation.ReasonForDiscardDto;
|
| ... | ... | @@ -76,7 +76,8 @@ public class ReferentialPsObservationModelDecoratorInitializer extends ModelDeco |
| 76 | 76 |
|
| 77 | 77 |
@Override
|
| 78 | 78 |
public void initPsObservationObjectMaterialDto() {
|
| 79 |
- registerDefaultReferentialAndReferentialReferenceDecorator(ObjectMaterialDto.class, ObjectMaterialReference.class, libelle);
|
|
| 79 |
+ registerDecorator(new ObjectMaterialReferenceDecorator());
|
|
| 80 |
+ registerObserveDecorator(ObjectMaterialDto.class, "${code}$s##${" + libelle + "}$s", " ");
|
|
| 80 | 81 |
}
|
| 81 | 82 |
|
| 82 | 83 |
@Override
|