branch feature/7608 updated (992b656 -> 5f6f1c9)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7608 in repository observe. See http://git.codelutin.com/observe.git from 992b656 migration des écrans d'échantillons de la faune accessoire (refs #7608) new 4a0dcae conserver dans le referenceDto toutes les propriétées mêmes celles null new 5f6f1c9 ajout des validateurs (refs #7608) The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 5f6f1c9feaf96a9b3acee3c2e257117adec8de4c Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Oct 21 15:24:14 2015 +0200 ajout des validateurs (refs #7608) commit 4a0dcae04a59f1a96405c839273f204dbf2ca485 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Oct 21 15:23:51 2015 +0200 conserver dans le referenceDto toutes les propriétées mêmes celles null Summary of changes: ...nTargetLengthDto-n1-update-error-validation.xml | 0 ...argetLengthDto-n1-update-warning-validation.xml | 0 ...nTargetSampleDto-n1-update-error-validation.xml | 0 .../builder/EntityToReferenceDtoBuilder.java | 25 ++++++++-------- .../EntityToReferentialReferenceDtoBuilder.java | 28 ++++++++++-------- ...EntityToReferentialReferenceDtoBuilderTest.java | 33 ++++++++++++++++++++++ 6 files changed, 63 insertions(+), 23 deletions(-) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/NonTargetLength-n1-update-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetLengthDto-n1-update-error-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/NonTargetLength-n1-update-warning-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetLengthDto-n1-update-warning-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/NonTargetSample-n1-update-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetSampleDto-n1-update-error-validation.xml (100%) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7608 in repository observe. See http://git.codelutin.com/observe.git commit 4a0dcae04a59f1a96405c839273f204dbf2ca485 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Oct 21 15:23:51 2015 +0200 conserver dans le referenceDto toutes les propriétées mêmes celles null --- .../builder/EntityToReferenceDtoBuilder.java | 25 ++++++++-------- .../EntityToReferentialReferenceDtoBuilder.java | 28 ++++++++++-------- ...EntityToReferentialReferenceDtoBuilderTest.java | 33 ++++++++++++++++++++++ 3 files changed, 63 insertions(+), 23 deletions(-) diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/builder/EntityToReferenceDtoBuilder.java b/observe-services-topia/src/main/java/fr/ird/observe/services/builder/EntityToReferenceDtoBuilder.java index bc97a46..518f155 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/builder/EntityToReferenceDtoBuilder.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/builder/EntityToReferenceDtoBuilder.java @@ -58,7 +58,7 @@ public class EntityToReferenceDtoBuilder<E extends TopiaEntity, D extends IdDto> Preconditions.checkNotNull(binder, "EntityToReferenceBinder<" + entityType.getName() + ", " + dtoType.getName() + "> not found."); - Map<String, Object> entityProperties = binder.obtainProperties(entity); + Map<String, Object> entityProperties = binder.obtainProperties(entity, true); Set<String> propertyNames = entityProperties.keySet(); ReferenceDto<D> result = ReferenceDtos.newReferenceDto(dtoType, propertyNames); @@ -67,21 +67,24 @@ public class EntityToReferenceDtoBuilder<E extends TopiaEntity, D extends IdDto> String propertyName = entry.getKey(); Object propertyValue = entry.getValue(); - if (propertyValue instanceof ReferenceEntity) { + if (propertyValue != null) { - ReferenceEntity referentialEntity = (ReferenceEntity) propertyValue; - Class referenceDtoType = ObserveServiceTopia.getDtoType(referentialEntity.getClass()); - propertyValue = EntityToReferentialReferenceDtoBuilder.build(referenceDtoType, referentialLocale, referentialEntity); + if (propertyValue instanceof ReferenceEntity) { - } else if (propertyValue instanceof TopiaEntity) { + ReferenceEntity referentialEntity = (ReferenceEntity) propertyValue; + Class referenceDtoType = ObserveServiceTopia.getDtoType(referentialEntity.getClass()); + propertyValue = EntityToReferentialReferenceDtoBuilder.build(referenceDtoType, referentialLocale, referentialEntity); - TopiaEntity topiaEntity = (TopiaEntity) propertyValue; - Class referenceDtoType = ObserveServiceTopia.getDtoType(topiaEntity.getClass()); - propertyValue = EntityToReferenceDtoBuilder.build(referenceDtoType, referentialLocale, topiaEntity); + } else if (propertyValue instanceof TopiaEntity) { - } + TopiaEntity topiaEntity = (TopiaEntity) propertyValue; + Class referenceDtoType = ObserveServiceTopia.getDtoType(topiaEntity.getClass()); + propertyValue = EntityToReferenceDtoBuilder.build(referenceDtoType, referentialLocale, topiaEntity); + + } - result.setPropertyValue(propertyName, (Serializable) propertyValue); + result.setPropertyValue(propertyName, (Serializable) propertyValue); + } } result.setId(entity.getTopiaId()); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilder.java b/observe-services-topia/src/main/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilder.java index d1fd630..5747a04 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilder.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilder.java @@ -66,7 +66,7 @@ public class EntityToReferentialReferenceDtoBuilder<E extends TopiaEntity, D ext Binder<E, D> binder = ObserveDtoBinders.newEntityToReferenceBinder(entityType, dtoType); Preconditions.checkNotNull(binder, "EntityToReferenceBinder<" + entityType.getName() + ", " + dtoType.getName() + "> not found."); - Map<String, Object> entityProperties = binder.obtainProperties(entity); + Map<String, Object> entityProperties = binder.obtainProperties(entity, true); Set<String> propertyNames = entityProperties.keySet(); ReferentialReferenceDto<D> result = ReferentialReferenceDtos.newReferentialReferenceDto(dtoType, referentialLocale, propertyNames); @@ -75,23 +75,27 @@ public class EntityToReferentialReferenceDtoBuilder<E extends TopiaEntity, D ext String propertyName = entry.getKey(); Object propertyValue = entry.getValue(); - if (propertyValue instanceof ReferenceEntity) { + if (propertyValue != null) { - ReferenceEntity referentialEntity = (ReferenceEntity) propertyValue; - Class referenceDtoType = ObserveServiceTopia.getDtoType(referentialEntity.getClass()); - propertyValue = EntityToReferentialReferenceDtoBuilder.build(referenceDtoType, referentialLocale, referentialEntity); + if (propertyValue instanceof ReferenceEntity) { - } else if (propertyValue instanceof TopiaEntity) { + ReferenceEntity referentialEntity = (ReferenceEntity) propertyValue; + Class referenceDtoType = ObserveServiceTopia.getDtoType(referentialEntity.getClass()); + propertyValue = EntityToReferentialReferenceDtoBuilder.build(referenceDtoType, referentialLocale, referentialEntity); - TopiaEntity topiaEntity = (TopiaEntity) propertyValue; - Class referenceDtoType = ObserveServiceTopia.getDtoType(topiaEntity.getClass()); - propertyValue = EntityToReferenceDtoBuilder.build(referenceDtoType, referentialLocale, topiaEntity); + } else if (propertyValue instanceof TopiaEntity) { - } else { - propertyValue = transform(propertyValue); + TopiaEntity topiaEntity = (TopiaEntity) propertyValue; + Class referenceDtoType = ObserveServiceTopia.getDtoType(topiaEntity.getClass()); + propertyValue = EntityToReferenceDtoBuilder.build(referenceDtoType, referentialLocale, topiaEntity); + + } else { + propertyValue = transform(propertyValue); + } + + result.setPropertyValue(referentialLocale, propertyName, (Serializable) propertyValue); } - result.setPropertyValue(referentialLocale, propertyName, (Serializable) propertyValue); } result.setId(entity.getTopiaId()); //FIXME diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilderTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilderTest.java index c64795b..2f01251 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilderTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/builder/EntityToReferentialReferenceDtoBuilderTest.java @@ -54,4 +54,37 @@ public class EntityToReferentialReferenceDtoBuilderTest { } + @Test + public void testCopyWithNullProperty() { + + Program program = new ProgramImpl(); + program.setCode("code"); + program.setNeedComment(true); + program.setStatus(ReferenceStatus.enabled); + program.setLabel1("label1"); + program.setLabel2("label2"); + program.setLabel3("label3"); + program.setLabel4("label4"); + program.setLabel5("label5"); + program.setLabel6("label6"); + program.setLabel7("label7"); + program.setLabel8("label8"); + program.setTopiaId("Program1"); + program.setStartDate(DateUtil.createDate(1, 1, 1)); + program.setEndDate(DateUtil.createDate(1, 1, 2)); + program.setGearType(null); + program.setTargetDiscardsObservation(1); + + ReferentialReferenceDto<ProgramDto> referenceProgramDto = EntityToReferentialReferenceDtoBuilder.build(ProgramDto.class, ReferentialLocale.FR, program); + + // On vérife que le program a bien été copié et que la propriété a null est toujour presente + + Assert.assertEquals(program.getTopiaId(), referenceProgramDto.getId()); + Assert.assertEquals(program.getCode(), referenceProgramDto.getPropertyValue(ProgramDto.PROPERTY_CODE)); + Assert.assertEquals(program.getLabel2(), referenceProgramDto.getPropertyValue("label")); + Assert.assertNull(referenceProgramDto.getPropertyValue(ProgramDto.PROPERTY_GEAR_TYPE)); + + + } + } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7608 in repository observe. See http://git.codelutin.com/observe.git commit 5f6f1c9feaf96a9b3acee3c2e257117adec8de4c Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Oct 21 15:24:14 2015 +0200 ajout des validateurs (refs #7608) --- ...nTargetLengthDto-n1-update-error-validation.xml | 117 +++++++++++++++++++++ ...argetLengthDto-n1-update-warning-validation.xml | 53 ++++++++++ ...nTargetSampleDto-n1-update-error-validation.xml | 49 +++++++++ 3 files changed, 219 insertions(+) diff --git a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetLengthDto-n1-update-error-validation.xml b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetLengthDto-n1-update-error-validation.xml new file mode 100644 index 0000000..6a4dc4e --- /dev/null +++ b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetLengthDto-n1-update-error-validation.xml @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + ObServe :: Validation + %% + Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + %% + 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% + --> + +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="species"> + + <!-- pas de species selectionnee --> + <field-validator type="required" short-circuit="true"> + <message>validator.nonTargetSample.required.species</message> + </field-validator> + + <!-- species desactive --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ species.enabled ]]> + </param> + <message>validator.nonTargetSample.desactivated.species</message> + </field-validator> + + </field> + + <field name="length"> + + <!-- taille obligatoire en mode par count --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ acquisitionMode == 1 || length != null ]]> + </param> + <message>validator.nonTargetSample.required.taille</message> + </field-validator> + + <!-- au moins un des 2 valeurs taille / weight doit etre renseignee (en mode par individu) --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ acquisitionMode == 0 || length != null || weight != null ]]> + </param> + <message>validator.nonTargetSample.required.weight.or.taille</message> + </field-validator> + + <!-- pas de length selectionnee --> + <!--field-validator type="required" short-circuit="true"> + <message>validator.nonTargetSample.required.length</message> + </field-validator--> + + <!-- length non renseigné ou > 0 --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ length == null || length > 0 ]]> + </param> + <message>validator.nonTargetSample.positive.length</message> + </field-validator> + + </field> + + <field name="weight"> + + <!-- au moins un des 2 valeurs taille / weight doit etre renseignee (en mode par individu) --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ acquisitionMode == 0 || length != null || weight != null ]]> + </param> + <message>validator.nonTargetSample.required.weight.or.taille</message> + </field-validator> + + <!-- weight non renseigné ou > 0 --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ weight == null || weight > 0 ]]> + </param> + <message>validator.nonTargetSample.positive.weight</message> + </field-validator> + + </field> + + <field name="count"> + + <!-- pas d'individu selectionnee --> + <field-validator type="required" short-circuit="true"> + <message>validator.nonTargetSample.required.count</message> + </field-validator> + + </field> + + <field name="sex"> + + <!-- pas de sex selectionne --> + <field-validator type="required" short-circuit="true"> + <message>validator.nonTargetSample.required.gender</message> + </field-validator> + + </field> + +</validators> diff --git a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetLengthDto-n1-update-warning-validation.xml b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetLengthDto-n1-update-warning-validation.xml new file mode 100644 index 0000000..e38c3f0 --- /dev/null +++ b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetLengthDto-n1-update-warning-validation.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + ObServe :: Validation + %% + Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + %% + 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% + --> + +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="length"> + + <!-- validation de la taille par borne --> + <field-validator type="species_length"> + <!--<param name="fieldName">length</param>--> + <param name="ratio">1.0</param> + <message>validator.nonTargetSample.bound.length##${min}##${max}</message> + </field-validator> + + </field> + + <field name="weight"> + + <!-- validation du weight par borne (uniquement pour mode saisie par individus) --> + <field-validator type="species_weight"> + <param name="ratio">1.0</param> + <param name="expression"> + <![CDATA[ acquisitionMode == 1 ]]> + </param> + <message>validator.nonTargetSample.bound.weight##${min}##${max}</message> + </field-validator> + + </field> + +</validators> diff --git a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetSampleDto-n1-update-error-validation.xml b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetSampleDto-n1-update-error-validation.xml new file mode 100644 index 0000000..41cda81 --- /dev/null +++ b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/NonTargetSampleDto-n1-update-error-validation.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + ObServe :: Validation + %% + Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + %% + 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% + --> + +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="comment"> + + <!-- comentaire de moins de 1024 caractères --> + <field-validator type="stringlength"> + <param name="maxLength">1024</param> + <message>validator.nonTargetSample.comment.tobig</message> + </field-validator> + + <!-- comment requis selone le type d'species indiquee dans les tailles thons choisi --> + + <field-validator type="collectionFieldExpression"> + <param name="mode">ALL</param> + <param name="useSensitiveContext">true</param> + <param name="collectionFieldName">nonTargetSample</param> + <param name="expression"> + <![CDATA[ (comment != null && !comment.empty) || current.species == null || !current.species.needComment ]]></param> + <message>validator.nonTargetSample.required.comment.for.species##${index}</message> + </field-validator> + + </field> +</validators> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm