r3411 - in trunk: pollen-persistence/src/main/java/org/chorem/pollen/entities/migration pollen-persistence/src/main/resources/META-INF/services pollen-ui-struts2 pollen-ui-struts2/src pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters pollen-ui-struts2/src/test pollen-ui-struts2/src/test/java pollen-ui-struts2/src/test/java/org pollen-ui-struts2/src/test/java/org/chorem pollen-ui-struts2/src/test/java/org/chorem/
Author: tchemit Date: 2012-06-03 10:42:32 +0200 (Sun, 03 Jun 2012) New Revision: 3411 Url: http://chorem.org/repositories/revision/pollen/3411 Log: fixes #574: Mauvais d?\195?\169pouillement Vote Condorcet fixes #576: Impossible de modifier un vote condorcet pour revenir ?\195?\160 "null" Added: trunk/pollen-ui-struts2/src/test/ trunk/pollen-ui-struts2/src/test/java/ trunk/pollen-ui-struts2/src/test/java/org/ trunk/pollen-ui-struts2/src/test/java/org/chorem/ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion trunk/pollen-ui-struts2/pom.xml trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java =================================================================== --- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-01 10:04:08 UTC (rev 3410) +++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-06-03 08:42:32 UTC (rev 3411) @@ -1,9 +1,9 @@ /* * #%L * Pollen :: Persistence - * - * $Id: PollenMigrationCallbackV1_3_1.java 3407 2012-05-28 17:06:39Z tchemit $ - * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-persistence/src/main/java/org/... $ + * * + * $Id$ + * $HeadURL$ * %% * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit * %% @@ -11,12 +11,12 @@ * it under the terms of the GNU Affero 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 Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% @@ -72,7 +72,7 @@ @Override protected PreparedStatement prepareQuery(Connection connection) throws SQLException { - PreparedStatement ps = connection.prepareStatement("select topiaid from vote where topiaid in (select topiaid from poll where votecountingtype=2);"); + PreparedStatement ps = connection.prepareStatement("select topiaid from vote where poll in (select topiaid from poll where votecountingtype=2);"); return ps; } Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/pollen-persistence/src/main/resources/META-INF/services/org.nuiton.topia.migration.TopiaMigrationCallbackByClassNG$MigrationCallBackForVersion ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/pollen-ui-struts2/pom.xml =================================================================== --- trunk/pollen-ui-struts2/pom.xml 2012-06-01 10:04:08 UTC (rev 3410) +++ trunk/pollen-ui-struts2/pom.xml 2012-06-03 08:42:32 UTC (rev 3411) @@ -179,6 +179,11 @@ <scope>runtime</scope> </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + </dependencies> <!-- ************************************************************* --> Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-01 10:04:08 UTC (rev 3410) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-06-03 08:42:32 UTC (rev 3411) @@ -34,7 +34,6 @@ import org.chorem.pollen.business.persistence.Vote; import org.chorem.pollen.business.persistence.VoteToChoice; import org.chorem.pollen.common.PollType; -import org.chorem.pollen.common.VoteCountingType; /** * Votes to a poll. @@ -100,6 +99,10 @@ // see http://chorem.org/issues/576 nbVotes++; totalValues += value; + } else { + + // otherwise does not take account of this choice + voteToChoice.setVoteValue(null); } // for other vote type, value must be > 0 } else if (value != 0) { Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java 2012-06-01 10:04:08 UTC (rev 3410) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/converters/BooleanIntegerConverter.java 2012-06-03 08:42:32 UTC (rev 3411) @@ -23,6 +23,7 @@ */ package org.chorem.pollen.ui.converters; +import org.apache.commons.lang3.StringUtils; import org.apache.struts2.util.StrutsTypeConverter; import java.util.Map; @@ -48,7 +49,9 @@ protected Integer parseValue(String value) { Integer result; - if ("true".equals(value)) { + if (StringUtils.isEmpty(value)) { + result = null; + } else if ("true".equals(value)) { result = 1; } else if ("false".equals(value)) { Added: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java =================================================================== --- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java (rev 0) +++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java 2012-06-03 08:42:32 UTC (rev 3411) @@ -0,0 +1,57 @@ +/* + * #%L + * Pollen :: UI (struts2) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.pollen.ui.converters; + +import junit.framework.Assert; +import org.junit.Test; + +/** + * Tests the {@link BooleanIntegerConverter}. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class BooleanIntegerConverterTest { + + @Test + public void testConvertFromString() throws Exception { + + BooleanIntegerConverter converter = new BooleanIntegerConverter(); + + convertFromString(null, null, converter); + convertFromString("", null, converter); + convertFromString("0", 0, converter); + convertFromString("1", 1, converter); + convertFromString("-1", -1, converter); + convertFromString("false", 0, converter); + convertFromString("true", 1, converter); + } + + protected void convertFromString(String valueToConvert, + Integer expected, + BooleanIntegerConverter converter) { + Integer actual = converter.convertFromString( + null, new String[]{valueToConvert}, Integer.class); + Assert.assertEquals(expected, actual); + } +} Property changes on: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/converters/BooleanIntegerConverterTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native
participants (1)
-
tchemit@users.chorem.org