Author: kmorin Date: 2013-03-11 12:40:00 +0100 (Mon, 11 Mar 2013) New Revision: 578 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/578 Log: refs #2026 [CAPTURES] Esp?\195?\168ces - Label esp?\195?\168ces Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-03-11 10:53:03 UTC (rev 577) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-03-11 11:40:00 UTC (rev 578) @@ -10,15 +10,15 @@ * %% * 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 + * 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 + * + * 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% @@ -43,6 +43,8 @@ import org.nuiton.util.decorator.DecoratorProvider; import java.io.Serializable; +import org.apache.commons.lang3.StringUtils; +import org.nuiton.util.StringUtil; import static org.nuiton.i18n.I18n._; import static org.nuiton.i18n.I18n.n_; @@ -65,12 +67,6 @@ String getLabel(); } - public static final String SPECIES_BY_CRUISE_CODE = "byCruiseCode"; - - public static final String SPECIES_BY_REF_TAX_CODE = "byRefTaxCode"; - - public static final String SPECIES_BY_GENUS = "byGenus"; - public static final String CARACTERISTIC_WITH_UNIT = "withUnit"; public static final String BY_NAME = "byName"; @@ -96,10 +92,6 @@ return decoratorProvider.getDecoratorByType(type, name); } - public static String getSpeciesContext(boolean protocolFilled) { - return protocolFilled ? SPECIES_BY_CRUISE_CODE : null; - } - @Override public void setServiceContext(TuttiServiceContext context) { super.setServiceContext(context); @@ -119,10 +111,6 @@ registerTuttiDecorator(Caracteristic.class, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s", SEPARATOR, " - "); // registerMultiJXPathDecorator(Caracteristic.class, CARACTERISTIC_WITH_UNIT, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s (${unit}$s)", SEPARATOR, " - "); registerTuttiDecorator(CaracteristicQualitativeValue.class, "${name}$s", SEPARATOR, " - "); -// registerTuttiDecorator(Species.class, "${refTaxCode}$s#${name}$s", SEPARATOR, " - "); -// registerMultiJXPathDecorator(Species.class, SPECIES_BY_CRUISE_CODE, "${surveyCode}$s#${refTaxCode}$s#${name}$s", SEPARATOR, " - "); - registerTuttiDecorator(Species.class, SPECIES_BY_REF_TAX_CODE, "${refTaxCode}$s", SEPARATOR, " - "); - registerTuttiDecorator(Species.class, SPECIES_BY_GENUS, "${name}$s", SEPARATOR, " - "); registerTuttiDecorator(SpeciesProtocol.class, "${speciesReferenceTaxonId}", SEPARATOR, " - "); registerTuttiDecorator(Attachment.class, "${name}$s", SEPARATOR, " - "); registerTuttiDecorator(LabelAware.class, "${label}$s", SEPARATOR, " - "); @@ -137,8 +125,7 @@ registerDecorator(new VesselDecorator()); registerDecorator(new ProgramDecorator()); - registerDecorator(SPECIES_BY_CRUISE_CODE, new SpeciesDecorator()); - registerDecorator(new SimpleSpeciesDecorator()); + registerDecorator(new SpeciesDecorator()); registerTuttiDecorator(Caracteristic.class, CARACTERISTIC_WITH_UNIT, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s (${unit}$s)", SEPARATOR, " - "); } @@ -194,34 +181,26 @@ private static final long serialVersionUID = 1L; public SpeciesDecorator() throws IllegalArgumentException, NullPointerException { - super(Species.class, "${surveyCode}$s#${refTaxCode}$s#${name}$s", DecoratorService.SEPARATOR, " - "); + super(Species.class, "${surveyCode}$s#${name}$s", DecoratorService.SEPARATOR, " - "); } @Override - protected Object onNullValue(Species bean, String token) { - Object result = null; - if ("surveyCode".equals(token)) { - result = _("tutti.propety.no.species.surveyCode"); - } else if ("refTaxCode".equals(token)) { - result = _("tutti.propety.no.species.refTaxCode"); + protected Object getValue(Species bean, String token) { + Object result = super.getValue(bean, token); + if ("surveyCode".equals(token) && result == null) { + result = bean.getRefTaxCode(); } return result; } - } - public static class SimpleSpeciesDecorator extends TuttiDecorator<Species> implements Cloneable { - - private static final long serialVersionUID = 1L; - - public SimpleSpeciesDecorator() throws IllegalArgumentException, NullPointerException { - super(Species.class, "${refTaxCode}$s#${name}$s", DecoratorService.SEPARATOR, " - "); - } - @Override protected Object onNullValue(Species bean, String token) { - Object result = null; - if ("refTaxCode".equals(token)) { - result = _("tutti.propety.no.species.refTaxCode"); + Object result; + if ("surveyCode".equals(token)) { + result = _("tutti.propety.no.species.speciesCode"); + + } else { + result = super.onNullValue(bean, token); } return result; } @@ -254,12 +233,21 @@ } @Override + protected Object getValue(Vessel bean, String token) { + // handle the null internationalRegistrationCode here, + // otherwise this will be considered null during sorting + Object result = super.getValue(bean, token); + if ("internationalRegistrationCode".equals(token) && result == null) { + // use national registration code + result = _("tutti.propety.vessel.nation.registrationCode", bean.getRegistrationCode()); + } + return result; + } + + @Override protected Object onNullValue(Vessel bean, String token) { Object result = null; - if ("internationalRegistrationCode".equals(token)) { - // use national registration code - result = _("tutti.propety.vessel.nation.registrationCode",bean.getRegistrationCode()); - } else if ("name".equals(token)) { + if ("name".equals(token)) { result = _("tutti.propety.no.vessel.name"); } return result; Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties =================================================================== --- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-03-11 10:53:03 UTC (rev 577) +++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-03-11 11:40:00 UTC (rev 578) @@ -39,8 +39,7 @@ tutti.property.vessel=Navire tutti.property.zone=Zone tutti.property.zoneLabel=Zone -tutti.propety.no.species.refTaxCode=\# -tutti.propety.no.species.surveyCode=\# +tutti.propety.no.species.speciesCode=\# tutti.propety.no.vessel.name=Nom inconnu tutti.propety.no.zone=Pas de zone tutti.propety.vessel.nation.registrationCode=%s (nat.)
participants (1)
-
kmorin@users.forge.codelutin.com