Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 3196 discussions
Author: tchemit
Date: 2014-04-30 13:26:00 +0200 (Wed, 30 Apr 2014)
New Revision: 3891
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3891
Log:
improve tests
Added:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java
trunk/pollen-services/src/test/resources/pollen-services.properties
Removed:
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenServiceContext.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java
Modified:
trunk/pollen-rest-api/pom.xml
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java
trunk/pollen-rest-api/src/test/resources/log4j.properties
trunk/pollen-services/pom.xml
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
trunk/pollen-services/src/main/resources/fixtures.yaml
trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
trunk/pom.xml
Modified: trunk/pollen-rest-api/pom.xml
===================================================================
--- trunk/pollen-rest-api/pom.xml 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-rest-api/pom.xml 2014-04-30 11:26:00 UTC (rev 3891)
@@ -47,6 +47,20 @@
<dependency>
<groupId>org.debux.webmotion</groupId>
<artifactId>webmotion-unittest</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.jdt.core.compiler</groupId>
+ <artifactId>ecj</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -99,6 +113,21 @@
</dependency>
<dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-log4j</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -23,16 +23,22 @@
* #L%
*/
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
-import org.chorem.pollen.services.PollenFixtures;
+import org.chorem.pollen.persistence.PollenPersistenceContext;
import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.service.FixturesService;
-import org.debux.webmotion.unittest.WebMotionJUnit;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.test.FakePollenServiceContext;
+import org.chorem.pollen.services.test.PollenApplication;
+import org.debux.webmotion.unittest.WebMotionTest;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.nuiton.util.DateUtil;
+import java.io.File;
+import java.io.IOException;
import java.util.Locale;
/**
@@ -41,25 +47,54 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
-public class AbstractPollenRestApiTest extends WebMotionJUnit {
+public class AbstractPollenRestApiTest extends WebMotionTest {
/** Logger. */
private static final Log log = LogFactory.getLog(AbstractPollenRestApiTest.class);
- protected PollenFixtures fixtures;
+ @Rule
+ public final PollenApplication application = new PollenApplication("pollen-rest-api.properties");
+ protected void loadFixtures(String fixturesSetName) {
+
+ PollenRestApiApplicationContext applicationContext = PollenRestApiApplicationContext.getApplicationContext();
+
+ PollenServiceContext serviceContext = applicationContext.newServiceContext(applicationContext.newPersistenceContext(), Locale.FRANCE);
+
+ application.loadFixtures(serviceContext, fixturesSetName);
+ }
+
+ protected <E> E fixture(String id) {
+
+ return application.fixture(id);
+ }
+
@Before
- public void launchServer() throws Exception {
+ public void startServer() throws Exception {
- PollenRestApiApplicationContext applicationContext = FakePollenRestApiApplicationContext.newFakeApplicationContext();
+ PollenRestApiApplicationContext applicationContext =
+ new PollenRestApiApplicationContext(application.getConfiguration(),
+ application.getApplicationContext()) {
+ @Override
+ public PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale) {
+
+ FakePollenServiceContext serviceContext = FakePollenServiceContext.newServiceContext(
+ DateUtil.createDate(1, 1, 2014),
+ Locale.FRANCE,
+ application.getConfiguration(),
+ application.getApplicationContext(),
+ application.newPersistenceContext());
+ return serviceContext;
+ }
+ };
applicationContext.init();
PollenRestApiApplicationContext.setApplicationContext(applicationContext);
- super.launchServer();
+ super.startServer();
}
@After
- public void tearDown() {
+ public void stopServer() throws Exception {
PollenRestApiApplicationContext applicationContext = PollenRestApiApplicationContext.getApplicationContext();
@@ -70,23 +105,20 @@
}
applicationContext.close();
}
+ server.stop();
+ server.destroy();
}
- protected void loadFixtures(String fixturesSetName) {
+ protected void saveTestResult(String content) throws IOException {
+ String testName = application.getMethodName();
- PollenRestApiApplicationContext applicationContext = PollenRestApiApplicationContext.getApplicationContext();
- PollenTopiaPersistenceContext entityManager = applicationContext.newPersistenceContext();
- PollenServiceContext pollenServiceContext = applicationContext.newServiceContext(entityManager, Locale.FRANCE);
-
- FixturesService fixturesService = pollenServiceContext.newService(FixturesService.class);
- fixtures = fixturesService.loadFixtures(fixturesSetName);
-
+ PollenServiceConfig applicationConfig = PollenRestApiApplicationContext.getApplicationContext().getApplicationConfig();
+ File dataDirectory = applicationConfig.getDataDirectory();
+ File resultFile = new File(dataDirectory, testName);
+ FileUtils.write(resultFile, content);
+ if (log.isInfoEnabled()) {
+ log.info("ResultFile: " + resultFile);
+ }
}
- protected <E> E fixture(String id) {
-
- return fixtures.fixture(id);
-
- }
-
}
Deleted: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -1,146 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-/*
- * #%L
- * Pollen :: Rest Api
- * %%
- * Copyright (C) 2009 - 2014 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%
- */
-
-import org.apache.commons.lang3.SystemUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.PollenPersistenceContext;
-import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
-import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.config.PollenServiceConfig;
-import org.hibernate.cfg.Environment;
-import org.nuiton.util.DateUtil;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * Created on 4/27/14.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class FakePollenRestApiApplicationContext extends PollenRestApiApplicationContext {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(FakePollenRestApiApplicationContext.class);
-
- protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
-
- public static PollenRestApiApplicationContext newFakeApplicationContext() {
- PollenServiceConfig applicationConfig = new PollenServiceConfig("pollen-rest-api.properties");
- PollenTopiaApplicationContext pollenTopiaApplicationContext = newTopiaApplicationContext(applicationConfig, UUID.randomUUID().toString());
- PollenRestApiApplicationContext result = new FakePollenRestApiApplicationContext(applicationConfig, pollenTopiaApplicationContext);
- return result;
- }
-
- public FakePollenRestApiApplicationContext(PollenServiceConfig applicationConfig, PollenTopiaApplicationContext pollenTopiaApplicationContext) {
-
- super(applicationConfig, pollenTopiaApplicationContext);
- }
-
- @Override
- public PollenServiceContext newServiceContext(PollenPersistenceContext persistenceContext, Locale locale) {
-
- FakePollenServiceContext serviceContext = new FakePollenServiceContext();
- serviceContext.setPersistenceContext(persistenceContext);
- serviceContext.setPollenServiceConfig(getApplicationConfig());
- serviceContext.setTopiaApplicationContext(getTopiaApplicationContext());
- serviceContext.setLocale(locale);
- serviceContext.setDate(DateUtil.createDate(1, 1, 2014));
-
- return serviceContext;
- }
-
- @Override
- public PollenTopiaPersistenceContext newPersistenceContext() {
- PollenTopiaPersistenceContext pollenTopiaPersistenceContext = super.newPersistenceContext();
- openedTransactions.add(pollenTopiaPersistenceContext);
- return pollenTopiaPersistenceContext;
- }
-
- @Override
- public void close() {
- if (!closed.get()) {
-
- for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
-
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + openedTransaction);
- }
-
- if (!openedTransaction.isClosed()) {
- openedTransaction.closeContext();
- }
- }
- openedTransactions.clear();
- }
- super.close();
- }
-
- protected static PollenTopiaApplicationContext newTopiaApplicationContext(PollenServiceConfig applicationConfig, String dataBase) {
-
- Map<String, String> hibernateH2Config = new HashMap<>();
-
- hibernateH2Config.putAll(applicationConfig.getTopiaProperties());
-
- hibernateH2Config.put(Environment.DRIVER, org.h2.Driver.class.getName());
- hibernateH2Config.put(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
- hibernateH2Config.put(Environment.USER, "sa");
- hibernateH2Config.put(Environment.PASS, "sa");
- hibernateH2Config.put(Environment.HBM2DDL_AUTO, "update");
-
- File tempDirFile = SystemUtils.getJavaIoTmpDir();
-
- File databaseFile = new File(tempDirFile, dataBase);
-
- String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data";
-
- String jdbcUrl = "jdbc:h2:file:" + h2dataPath;
-
- hibernateH2Config.put(Environment.URL, jdbcUrl);
-
- if (log.isTraceEnabled()) {
- log.trace("will store H2 data in " + h2dataPath);
- log.trace("allTopiaParameters = " + hibernateH2Config);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("jdbc url is\n" + jdbcUrl);
- }
-
- PollenTopiaApplicationContext applicationContext = new PollenTopiaApplicationContext(hibernateH2Config);
-
- if (log.isTraceEnabled()) {
- log.trace("created root context " + applicationContext);
- }
-
- return applicationContext;
- }
-}
Deleted: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenServiceContext.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenServiceContext.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenServiceContext.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -1,53 +0,0 @@
-package org.chorem.pollen.rest.api;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 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%
- */
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.services.DefaultPollenServiceContext;
-
-import java.util.Date;
-
-public class FakePollenServiceContext extends DefaultPollenServiceContext {
-
- private static final Log log =
- LogFactory.getLog(FakePollenServiceContext.class);
-
- protected Date date;
-
- @Override
- public Date getNow() {
- Preconditions.checkState(date != null, "you must provide a date before running service test");
- if (log.isTraceEnabled()) {
- log.trace("injecting fake date in service: " + date);
- }
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
-}
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -1,6 +1,7 @@
package org.chorem.pollen.rest.api;
import org.apache.http.client.fluent.Request;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -18,10 +19,17 @@
@Ignore
public class PollServiceTest extends AbstractPollenRestApiTest {
+ @Before
+ public void setUp() throws Exception {
+
+ loadFixtures("fixtures");
+ }
+
@Test
public void getPollsNew() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls/new").Get();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
@@ -29,6 +37,7 @@
public void getPolls() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls").Get();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
@@ -36,6 +45,7 @@
public void getPollsCreated() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls/created").Get();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
@@ -43,6 +53,7 @@
public void getPollsInvited() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls/invited").Get();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
@@ -50,61 +61,75 @@
public void getPollsParticipated() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls/participated").Get();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
@Test
public void getPoll() throws URISyntaxException, IOException {
- String pollId = "";
+ String pollId = "iioi";
Request request = createRequest("/v1/polls/" + pollId).Get();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void postPoll() throws URISyntaxException, IOException {
Request request = createRequest("/v1/polls").Post();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void putPoll() throws URISyntaxException, IOException {
String pollId = "";
Request request = createRequest("/v1/polls/" + pollId).Put();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void deletePoll() throws URISyntaxException, IOException {
String pollId = "";
Request request = createRequest("/v1/polls/" + pollId).Delete();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void clonePoll() throws URISyntaxException, IOException {
String pollId = "";
Request request = createRequest("/v1/polls/" + pollId).Post();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void exportPoll() throws URISyntaxException, IOException {
String pollId = "";
Request request = createRequest("/v1/polls/" + pollId + "/export").Get();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
+ @Ignore
@Test
public void closePoll() throws URISyntaxException, IOException {
String pollId = "";
Request request = createRequest("/v1/polls/" + pollId + "/close").Post();
String content = request.execute().returnContent().asString();
+ saveTestResult(content);
assertNotNull(content);
}
}
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -39,7 +39,6 @@
@Ignore
public class PollenUserServiceTest extends AbstractPollenRestApiTest {
-
@Before
public void setUp() throws Exception {
@@ -50,50 +49,57 @@
public void getUsers() throws Exception {
Request request = createRequest("/v1/users").Get();
- String result = request.execute().returnContent().asString();
-
- assertTrue(result.contains("email"));
+ String content = request.execute().returnContent().asString();
+ saveTestResult(content);
+ assertTrue(content.contains("email"));
}
@Test
public void getUser() throws Exception {
String userId = "";
Request request = createRequest("/v1/users/" + userId).Get();
- String result = request.execute().returnContent().asString();
-
- assertTrue(result.contains("email"));
+ String content = request.execute().returnContent().asString();
+ saveTestResult(content);
+ assertTrue(content.contains("email"));
}
+ @Ignore
@Test
public void postUser() throws Exception {
Request request = createRequest("/v1/users").Post();
- String result = request.execute().returnContent().asString();
-
- assertTrue(result.contains("email2"));
+ String content = request.execute().returnContent().asString();
+ saveTestResult(content);
+ assertTrue(content.contains("email2"));
}
+ @Ignore
@Test
public void putUser() throws Exception {
String userId = "";
Request request = createRequest("/v1/users/" + userId).Get();
- String result = request.execute().returnContent().asString();
- assertTrue(result.contains("email3"));
+ String content = request.execute().returnContent().asString();
+ saveTestResult(content);
+ assertTrue(content.contains("email3"));
}
+ @Ignore
@Test
public void deleteUser() throws Exception {
String userId = "";
Request request = createRequest("/v1/users/" + userId).Delete();
- String result = request.execute().returnContent().asString();
- assertTrue(result.contains("OK!"));
+ String content = request.execute().returnContent().asString();
+ saveTestResult(content);
+ assertTrue(content.contains("OK!"));
}
+ @Ignore
@Test
public void validateUserEmail() throws Exception {
String userId = "";
String token = "";
Request request = createRequest("/v1/users/" + userId + "?token=" + token).Put();
- String result = request.execute().returnContent().asString();
- assertTrue(result.contains("OK!"));
+ String content = request.execute().returnContent().asString();
+ saveTestResult(content);
+ assertTrue(content.contains("OK!"));
}
}
Modified: trunk/pollen-rest-api/src/test/resources/log4j.properties
===================================================================
--- trunk/pollen-rest-api/src/test/resources/log4j.properties 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-rest-api/src/test/resources/log4j.properties 2014-04-30 11:26:00 UTC (rev 3891)
@@ -26,7 +26,7 @@
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{hh:mm:ss} %5p (%F:%L) %m%n
-log4j.logger.org.chorem.pollen=TRACE
+log4j.logger.org.chorem.pollen=INFO
log4j.logger.org.debux=INFO
# log4j.logger.org.hibernate.tool.hbm2ddl.SchemaExport=FATAL
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-services/pom.xml 2014-04-30 11:26:00 UTC (rev 3891)
@@ -26,10 +26,10 @@
<groupId>org.nuiton.topia</groupId>
<artifactId>topia-persistence</artifactId>
</dependency>
- <!--dependency>
+ <dependency>
<groupId>org.nuiton.topia</groupId>
<artifactId>topia-junit</artifactId>
- </dependency-->
+ </dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -88,6 +88,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -53,13 +53,23 @@
protected ApplicationConfig applicationConfig;
public PollenServiceConfig() {
- this("pollen.properties");
+ this("pollen.properties", null);
}
public PollenServiceConfig(String filename) {
+ this(filename, null);
+ }
+
+ public PollenServiceConfig(String filename, Properties defaultValues) {
applicationConfig = new ApplicationConfig();
applicationConfig.loadDefaultOptions(PollenServiceConfigOption.values());
applicationConfig.setConfigFileName(filename);
+ if (defaultValues != null) {
+ for (Map.Entry<Object, Object> entry : defaultValues.entrySet()) {
+
+ applicationConfig.setOption((String) entry.getKey(), (String) entry.getValue());
+ }
+ }
try {
applicationConfig.parse();
} catch (ArgumentsParserException e) {
@@ -74,7 +84,7 @@
option.getKey(),
applicationConfig.getOption(option)));
}
- log.info( builder.toString());
+ log.info(builder.toString());
}
}
Copied: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java (from rev 3890, trunk/pollen-services/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java)
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/FakePollenServiceContext.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -0,0 +1,73 @@
+package org.chorem.pollen.services.test;
+
+/*
+ * #%L
+ * Pollen :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 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%
+ */
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.services.DefaultPollenServiceContext;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+
+import java.util.Date;
+import java.util.Locale;
+
+public class FakePollenServiceContext extends DefaultPollenServiceContext {
+
+ private static final Log log =
+ LogFactory.getLog(FakePollenServiceContext.class);
+
+ protected Date date;
+
+
+ public static FakePollenServiceContext newServiceContext(Date now,
+ Locale locale,
+ PollenServiceConfig serviceConfig,
+ PollenTopiaApplicationContext applicationcontext,
+ PollenTopiaPersistenceContext persistenceContext) {
+ FakePollenServiceContext serviceContext = new FakePollenServiceContext();
+ serviceContext.setPersistenceContext(persistenceContext);
+ serviceContext.setPollenServiceConfig(serviceConfig);
+ serviceContext.setTopiaApplicationContext(applicationcontext);
+ serviceContext.setLocale(locale);
+ serviceContext.setDate(now);
+ return serviceContext;
+ }
+
+ @Override
+ public Date getNow() {
+ Preconditions.checkState(date != null, "you must provide a date before running service test");
+ if (log.isTraceEnabled()) {
+ log.trace("injecting fake date in service: " + date);
+ }
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+
+}
Added: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java (rev 0)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -0,0 +1,170 @@
+package org.chorem.pollen.services.test;
+
+/*
+ * #%L
+ * ToPIA :: JUnit
+ * $Id$
+ * $HeadURL: http://svn.nuiton.org/svn/topia/trunk/topia-junit/src/main/java/org/nuiton/… $
+ * %%
+ * Copyright (C) 2004 - 2014 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
+import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
+import org.chorem.pollen.services.PollenFixtures;
+import org.chorem.pollen.services.PollenServiceContext;
+import org.chorem.pollen.services.config.PollenServiceConfig;
+import org.chorem.pollen.services.config.PollenServiceConfigOption;
+import org.chorem.pollen.services.service.FixturesService;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+import org.nuiton.topia.junit.ConfigurationHelper;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class PollenApplication extends TestWatcher {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(PollenApplication.class);
+
+ private File testBasedir;
+
+ protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
+
+ private PollenTopiaApplicationContext applicationContext;
+
+ private PollenServiceConfig configuration;
+
+ private final String configurationPath;
+
+
+ protected PollenFixtures fixtures;
+
+ protected String methodName;
+
+ public PollenApplication(String configurationPath) {
+ this.configurationPath = configurationPath;
+ }
+
+ @Override
+ protected void starting(Description description) {
+
+ methodName = description.getMethodName();
+
+ // get test directory
+ testBasedir = ConfigurationHelper.getTestSpecificDirectory(
+ description.getTestClass(),
+ description.getMethodName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("testBasedir: " + testBasedir);
+ }
+
+ // create configuration
+
+ Properties defaultvalues = new Properties();
+ defaultvalues.put(PollenServiceConfigOption.DATA_DIRECTORY.getKey(), testBasedir.getAbsolutePath());
+
+ configuration = new PollenServiceConfig(configurationPath, defaultvalues);
+
+ Map<String, String> topiaProperties = configuration.getTopiaProperties();
+ applicationContext = new PollenTopiaApplicationContext(topiaProperties);
+
+ }
+
+ @Override
+ public void finished(Description description) {
+
+ for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + openedTransaction);
+ }
+
+ openedTransaction.closeContext();
+
+ }
+
+ if (applicationContext != null && !applicationContext.isClosed()) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("closing transaction " + applicationContext);
+ }
+
+ applicationContext.closeContext();
+
+ }
+ }
+
+ public File getTestBasedir() {
+ return testBasedir;
+ }
+
+ public PollenTopiaApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+
+ public PollenServiceConfig getConfiguration() {
+ return configuration;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public PollenTopiaPersistenceContext newPersistenceContext() {
+
+ PollenTopiaPersistenceContext persistenceContext;
+
+ persistenceContext = applicationContext.newPersistenceContext();
+
+ if (log.isTraceEnabled()) {
+ log.trace("opened transaction " + persistenceContext);
+ }
+
+ openedTransactions.add(persistenceContext);
+
+ return persistenceContext;
+
+ }
+
+ public void loadFixtures(PollenServiceContext serviceContext, String fixturesSetName) {
+
+ FixturesService fixturesService = serviceContext.newService(FixturesService.class);
+
+ fixtures = fixturesService.loadFixtures(fixturesSetName);
+
+ }
+
+ public <E> E fixture(String id) {
+
+ return fixtures.fixture(id);
+
+ }
+
+}
Property changes on: trunk/pollen-services/src/main/java/org/chorem/pollen/services/test/PollenApplication.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-services/src/main/resources/fixtures.yaml
===================================================================
--- trunk/pollen-services/src/main/resources/fixtures.yaml 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-services/src/main/resources/fixtures.yaml 2014-04-30 11:26:00 UTC (rev 3891)
@@ -1,4 +1,4 @@
-tony:
+user_tony:
&tony !user
login: tony
password: fake
@@ -6,7 +6,7 @@
email: tony(a)pollen.fake
administrator: false
-jean:
+user_jean:
&jean !user
login: jean
password: fake
@@ -14,7 +14,7 @@
email: jean(a)pollen.fake
administrator: true
-julien:
+user_julien:
&julien !user
login: julien
password: fake
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -24,173 +24,49 @@
*/
import com.google.common.collect.Multimap;
-import org.apache.commons.lang3.SystemUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.persistence.PollenTopiaApplicationContext;
-import org.chorem.pollen.persistence.PollenTopiaPersistenceContext;
-import org.chorem.pollen.services.PollenFixtures;
import org.chorem.pollen.services.PollenService;
-import org.chorem.pollen.services.config.PollenServiceConfig;
import org.chorem.pollen.services.exception.AbstractInvalidFormException;
-import org.chorem.pollen.services.service.FixturesService;
-import org.hibernate.cfg.Environment;
-import org.junit.After;
+import org.chorem.pollen.services.test.FakePollenServiceContext;
+import org.chorem.pollen.services.test.PollenApplication;
import org.junit.Assert;
+import org.junit.Rule;
import org.nuiton.util.DateUtil;
-import java.io.File;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import java.util.Locale;
public abstract class AbstractPollenServiceTest {
- private static final Log log = LogFactory.getLog(AbstractPollenServiceTest.class);
-
protected static final double DELTA = 0.0001;
- protected static PollenServiceConfig applicationConfig;
+ @Rule
+ public final PollenApplication application = new PollenApplication("pollen-services.properties");
- protected PollenTopiaApplicationContext applicationContext;
-
- protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
-
protected FakePollenServiceContext serviceContext;
- protected PollenFixtures fixtures;
+ public void loadFixtures(String fixturesSetName) {
- @After
- public void tearDown() {
-
- for (PollenTopiaPersistenceContext openedTransaction : openedTransactions) {
-
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + openedTransaction);
- }
-
- openedTransaction.closeContext();
-
- }
-
- if (applicationContext != null) {
-
- if (log.isTraceEnabled()) {
- log.trace("closing transaction " + applicationContext);
- }
-
- applicationContext.closeContext();
-
- }
-
+ application.loadFixtures(getServiceContext(), fixturesSetName);
}
- protected PollenTopiaApplicationContext newApplicationContext(String dataBase) {
+ public <E> E fixture(String id) {
- Map<String, String> hibernateH2Config = new HashMap<>();
-
- hibernateH2Config.putAll(getApplicationConfig().getTopiaProperties());
-
- hibernateH2Config.put(Environment.DRIVER, org.h2.Driver.class.getName());
- hibernateH2Config.put(Environment.DIALECT, org.hibernate.dialect.H2Dialect.class.getName());
- hibernateH2Config.put(Environment.USER, "sa");
- hibernateH2Config.put(Environment.PASS, "sa");
- hibernateH2Config.put(Environment.HBM2DDL_AUTO, "update");
-
- File tempDirFile = SystemUtils.getJavaIoTmpDir();
-
- File databaseFile = new File(tempDirFile, dataBase);
-
- String h2dataPath = databaseFile.getAbsolutePath() + File.separator + "h2data";
-
- String jdbcUrl = "jdbc:h2:file:" + h2dataPath;
-
- hibernateH2Config.put(Environment.URL, jdbcUrl);
-
- if (log.isTraceEnabled()) {
- log.trace("will store H2 data in " + h2dataPath);
- log.trace("allTopiaParameters = " + hibernateH2Config);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("jdbc url is\n" + jdbcUrl);
- }
-
- PollenTopiaApplicationContext topiaApplicationContext = new PollenTopiaApplicationContext(hibernateH2Config);
-
- if (log.isTraceEnabled()) {
- log.trace("created root context " + topiaApplicationContext);
- }
-
- return topiaApplicationContext;
+ return application.fixture(id);
}
- protected PollenTopiaApplicationContext getApplicationContext() {
-
- String databaseName = UUID.randomUUID().toString();
-
- return newApplicationContext(databaseName);
- }
-
- protected PollenTopiaPersistenceContext newPersistenceContext() {
-
- if (applicationContext == null) {
-
- applicationContext = getApplicationContext();
- }
-
- PollenTopiaPersistenceContext persistenceContext;
-
- persistenceContext = applicationContext.newPersistenceContext();
-
- if (log.isTraceEnabled()) {
- log.trace("opened transaction " + persistenceContext);
- }
-
- openedTransactions.add(persistenceContext);
-
- return persistenceContext;
-
- }
-
- protected static PollenServiceConfig getApplicationConfig() {
-
- if (applicationConfig == null) {
-
- applicationConfig = new PollenServiceConfig("pollen-services.properties");
- }
-
- return applicationConfig;
- }
-
protected FakePollenServiceContext getServiceContext() {
if (serviceContext == null) {
- serviceContext = new FakePollenServiceContext();
- serviceContext.setPollenServiceConfig(getApplicationConfig());
- PollenTopiaPersistenceContext persistenceContext = newPersistenceContext();
- serviceContext.setPersistenceContext(persistenceContext);
- serviceContext.setDate(DateUtil.createDate(2, 11, 2009));
- serviceContext.setTopiaApplicationContext(getApplicationContext());
+ serviceContext = FakePollenServiceContext.newServiceContext(
+ DateUtil.createDate(1, 1, 2014),
+ Locale.FRANCE,
+ application.getConfiguration(),
+ application.getApplicationContext(),
+ application.newPersistenceContext());
}
return serviceContext;
}
- protected void loadFixtures(String fixturesSetName) {
-
- FixturesService fixturesService = getServiceContext().newService(FixturesService.class);
-
- fixtures = fixturesService.loadFixtures(fixturesSetName);
- }
-
- protected <E> E fixture(String id) {
-
- return fixtures.fixture(id);
- }
-
protected <E extends PollenService> E newService(Class<E> serviceClass) {
return getServiceContext().newService(serviceClass);
Deleted: trunk/pollen-services/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/FakePollenServiceContext.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -1,53 +0,0 @@
-package org.chorem.pollen.service;
-
-/*
- * #%L
- * Pollen :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2013 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%
- */
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.pollen.services.DefaultPollenServiceContext;
-
-import java.util.Date;
-
-public class FakePollenServiceContext extends DefaultPollenServiceContext {
-
- private static final Log log =
- LogFactory.getLog(FakePollenServiceContext.class);
-
- protected Date date;
-
- @Override
- public Date getNow() {
- Preconditions.checkState(date != null, "you must provide a date before running service test");
- if (log.isTraceEnabled()) {
- log.trace("injecting fake date in service: " + date);
- }
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
-}
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -61,11 +61,11 @@
loadFixtures("fixtures");
- service = getServiceContext().newService(PollService.class);
+ service = newService(PollService.class);
- serviceContext.setDate(new Date(1363948427576l));
+ getServiceContext().setDate(new Date(1363948427576l));
- serviceContext.setSecurityContext(PollenSecurityContext.newContext(null));
+ getServiceContext().setSecurityContext(PollenSecurityContext.newContext(null));
}
@Test
@@ -127,12 +127,12 @@
Assert.assertNotNull(createdPoll);
Assert.assertNotNull(createdPoll.getTopiaId());
- serviceContext.newService(SecurityService.class).prepareSubject(createdPoll.getCreator().getTopiaId());
+ newService(SecurityService.class).prepareSubject(createdPoll.getCreator().getTopiaId());
Poll reloadedPoll = service.getPoll(createdPoll.getTopiaId());
Assert.assertEquals(createdPoll, reloadedPoll);
- Assert.assertEquals(serviceContext.getNow(), createdPoll.getBeginDate());
+ Assert.assertEquals(getServiceContext().getNow(), createdPoll.getBeginDate());
Assert.assertNotNull(createdPoll.getCreator());
Assert.assertNotNull(createdPoll.getCreator().getTopiaId());
@@ -150,7 +150,7 @@
Assert.assertNotNull(createdChoice1);
Assert.assertNotNull(createdChoice1.getTopiaId());
- ChoiceService choiceService = serviceContext.newService(ChoiceService.class);
+ ChoiceService choiceService = newService(ChoiceService.class);
Choice reloadedChoice1 = choiceService.getChoice(createdPoll.getTopiaId(), createdChoice1.getTopiaId());
Assert.assertEquals(createdChoice1, reloadedChoice1);
@@ -265,7 +265,7 @@
Poll reloadedPoll = service.getPoll(createdPoll.getTopiaId());
Assert.assertEquals(createdPoll, reloadedPoll);
- Assert.assertEquals(serviceContext.getNow(), createdPoll.getBeginDate());
+ Assert.assertEquals(getServiceContext().getNow(), createdPoll.getBeginDate());
Assert.assertNotNull(createdPoll.getCreator());
Assert.assertNotNull(createdPoll.getCreator().getTopiaId());
@@ -281,7 +281,7 @@
Assert.assertNotNull(createdChoice1);
Assert.assertNotNull(createdChoice1.getTopiaId());
- ChoiceService choiceService = serviceContext.newService(ChoiceService.class);
+ ChoiceService choiceService = newService(ChoiceService.class);
Choice reloadedChoice1 = choiceService.getChoice(createdPoll.getTopiaId(), createdChoice1.getTopiaId());
Assert.assertEquals(createdChoice1, reloadedChoice1);
@@ -306,7 +306,7 @@
Assert.assertNotNull(createdVoterList);
Assert.assertNotNull(createdVoterList.getTopiaId());
- VoterListService voterListService = serviceContext.newService(VoterListService.class);
+ VoterListService voterListService = newService(VoterListService.class);
VoterList reloadedVoterList = voterListService.getVoterList(createdPoll.getTopiaId(), createdVoterList.getTopiaId());
Assert.assertEquals(createdVoterList, reloadedVoterList);
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollenUserServiceTest.java 2014-04-30 11:26:00 UTC (rev 3891)
@@ -56,11 +56,11 @@
loadFixtures("fixtures");
- service = getServiceContext().newService(PollenUserService.class);
+ service = newService(PollenUserService.class);
- serviceContext.setDate(new Date(1363948427576l));
+ getServiceContext().setDate(new Date(1363948427576l));
- user = fixture("tony");
+ user = application.fixture("user_tony");
}
@Test
@@ -143,7 +143,7 @@
Assert.assertNotNull(user);
Assert.assertNull(user.getEmailActivationToken());
- serviceContext.getPersistenceContext().getHibernateSupport().getHibernateSession().evict(user);
+ getServiceContext().getPersistenceContext().getHibernateSupport().getHibernateSession().evict(user);
String originalLogin = user.getLogin();
@@ -174,7 +174,7 @@
Assert.assertNotNull(user);
Assert.assertNull(user.getEmailActivationToken());
- serviceContext.getPersistenceContext().getHibernateSupport().getHibernateSession().evict(user);
+ getServiceContext().getPersistenceContext().getHibernateSupport().getHibernateSession().evict(user);
String email = "tony(a)pollen.org";
user.setEmail(email);
Added: trunk/pollen-services/src/test/resources/pollen-services.properties
===================================================================
--- trunk/pollen-services/src/test/resources/pollen-services.properties (rev 0)
+++ trunk/pollen-services/src/test/resources/pollen-services.properties 2014-04-30 11:26:00 UTC (rev 3891)
@@ -0,0 +1,6 @@
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.url=jdbc:h2:file:${pollen.data.directory}/db/pollen-rest-api
+hibernate.connection.username=sa
+hibernate.connection.password=sa
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.hbm2ddl.auto=update
Property changes on: trunk/pollen-services/src/test/resources/pollen-services.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-04-30 10:05:11 UTC (rev 3890)
+++ trunk/pom.xml 2014-04-30 11:26:00 UTC (rev 3891)
@@ -177,6 +177,7 @@
<shiroVersion>1.2.2</shiroVersion>
<slf4jVersion>1.7.6</slf4jVersion>
<jettyVersion>9.0.3.v20130506</jettyVersion>
+ <tomcatEmbedVersion>7.0.47</tomcatEmbedVersion>
<hibernateVersion>4.3.5.Final</hibernateVersion>
<seleniumVersion>2.33.0</seleniumVersion>
<mockitoVersion>1.9.5</mockitoVersion>
@@ -313,12 +314,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.debux.webmotion</groupId>
- <artifactId>webmotion-extra-jpa</artifactId>
- <version>${webmotionVersion}</version>
- </dependency>
-
<!-- Nuiton libs -->
<dependency>
@@ -458,11 +453,32 @@
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
- <version>7.0.41</version>
+ <version>${tomcatEmbedVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ <version>${tomcatEmbedVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-log4j</artifactId>
+ <version>${tomcatEmbedVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ <version>${tomcatEmbedVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
1
0
r3890 - in trunk/pollen-ui-angular/src/main/webapp: css js js/controllers partials
by garandel@users.chorem.org 30 Apr '14
by garandel@users.chorem.org 30 Apr '14
30 Apr '14
Author: garandel
Date: 2014-04-30 12:05:11 +0200 (Wed, 30 Apr 2014)
New Revision: 3890
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3890
Log:
add second interface for create and vote
Added:
trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html
trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Removed:
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Modified:
trunk/pollen-ui-angular/src/main/webapp/css/style.css
trunk/pollen-ui-angular/src/main/webapp/js/app.js
trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
Modified: trunk/pollen-ui-angular/src/main/webapp/css/style.css
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-29 19:10:38 UTC (rev 3889)
+++ trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-30 10:05:11 UTC (rev 3890)
@@ -85,38 +85,24 @@
color: rgb(150, 150, 150);
}
-#voteForm .choice {
- background-position: center;
- background-repeat: no-repeat;
- text-align: center;
-}
-
-#voteForm .selected {
- background-color: #6f6;
-}
-
-#voteForm .notSelected {
- background-color: #f66;
-}
-
-#voteForm .voteBeforeChoice {
- background-color: #ff6;
-}
-
.pollTitle, .pollDesc {
margin-top:15px;
min-height:60px;
- border:1px dashed #AAAAAA;
border-radius:5px;
padding-left:5px;
margin-bottom:30px;
}
+
+.pollTitle input[type="text"] {
+ width:99%;
+}
+
.pollAnim {
- background-color:#F8F8F8;
+ background-color:inherit;
transition-duration:0.8s;
}
.pollAnim:hover {
- background:#CCD8DD;
+ background:#DDDDDD;
transition-duration: 0.8s;
}
.pollTitle input {
@@ -146,11 +132,11 @@
padding-right:5px;
padding-top:10px;
padding-bottom:5px;
- border: 1px dashed #AAAAAA;
text-align:center;
+ border:1px solid #DDD;
}
-.
-pollChoice input[type=text]{
+
+.pollChoice input[type=text]{
height:25px;
width:140px;
}
@@ -170,4 +156,31 @@
.fixe-input .ng-hide {
display:inline-block !important;
visibility:hidden;
+}
+
+.pollBigChoice {
+ border-bottom:1px solid #DDDDDD;
+ text-align:right;
+}
+.pollBigChoice h3 {
+ background-color:rgba(0,0,0,0.1);
+ padding:5px;
+ height:40px;
+}
+.pollBigChoice button {
+ height:30px;
+}
+.pollBigChoice p {
+ text-align:justify;
+}
+.pollBigChoice textarea {
+ width:99%;
+}
+.pollBigChoice h3 input[type=text] {
+ width:99%;
+ text-align:right;
+}
+.pollBigChoice .pollChoiceInput {
+ margin-top:20px;
+ text-align:center;
}
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-29 19:10:38 UTC (rev 3889)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-30 10:05:11 UTC (rev 3890)
@@ -21,11 +21,11 @@
angular.module('pollen', ["ngRoute", "pollControllers", 'ui.bootstrap'])
.config(['$routeProvider', function($routeProvider) {
- $routeProvider.when('/', {templateUrl: 'partials/home.html', controller: "HomeCtrl"})
- .when('/poll/create', {templateUrl: 'partials/poll.html', controller: "PollAdminCtrl"})
- .when('/poll/edit/:pollId', {templateUrl: 'partials/poll.html', controller:"PollAdminCtrl"})
- .when('/poll/vote', {templateUrl: 'partials/poll.html', controller :"PollVoteCtrl"})
- .when('/poll/list', {templateUrl: 'partials/poll-list.html', controller :"PollListCtrl"})
+ $routeProvider.when('/', {templateUrl: './partials/home.html', controller: "HomeCtrl"})
+ .when('/poll/create', {templateUrl: './partials/poll.html', controller: "PollAdminCtrl"})
+ .when('/poll/edit/:pollId', {templateUrl: './partials/poll.html', controller:"PollAdminCtrl"})
+ .when('/poll/vote', {templateUrl: './partials/poll.html', controller :"PollVoteCtrl"})
+ .when('/poll/list', {templateUrl: './partials/poll-list.html', controller :"PollListCtrl"})
.otherwise({redirectTo: '/'});
}])
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-29 19:10:38 UTC (rev 3889)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-30 10:05:11 UTC (rev 3890)
@@ -35,6 +35,32 @@
$scope.toHTML = function (data) {
return $sce.trustAsHtml(data);
}
+
+ $scope.inlineVersion = function () {
+ $scope.poll.template = 'inline';
+ $scope.templateURL = './partials/inline-poll.html';
+ }
+
+ $scope.bigVersion = function () {
+ $scope.poll.template = 'big';
+ $scope.templateURL = './partials/big-poll.html';
+ }
+
+ var initTemplateURL = function () {
+ if (angular.isDefined($scope.poll.template)) {
+ if ($scope.poll.template == "big") {
+ $scope.bigVersion();
+ }
+ else {
+ $scope.inlineVersion();
+ }
+ }
+ else {
+ $scope.inlineVersion();
+ }
+ }
+ initTemplateURL();
+
}])
@@ -57,6 +83,7 @@
}
$scope.globalVariables.editMode = true;
+ $scope.globalVariables.create = true;
$scope.globalVariables.voted = angular.isDefined($scope.poll.votants);
$scope.globalVariables.lastType = 'text';
@@ -154,6 +181,11 @@
$controller('PollCtrl', {$scope:$scope});
$scope.globalVariables.editMode = false;
+ $scope.$watch('voteName', function (newVal) {
+ if (newVal != '') {
+ $scope.globalVariables.errorForm = false;
+ }
+ });
var initVote = function () {
$scope.voteName = "";
@@ -180,6 +212,7 @@
$scope.poll.votants.push(data);
pollStorage.put($scope.poll);
$scope.globalVariables.saved = true;
+ $scope.globalVariables.errorForm = false;
initVote();
}
else {
Added: trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html 2014-04-30 10:05:11 UTC (rev 3890)
@@ -0,0 +1,67 @@
+<!--
+ ~
+ ~ #%L
+ ~ Pollen :: UI (Angular)
+ ~ %%
+ ~ Copyright (C) 2009 - 2014 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%
+ ~
+ -->
+
+<div ng-repeat="choice in poll.choices" class="row pollBigChoice">
+ <div class="col-sm-10">
+
+ <div ng-click="showDesc = !showDesc" >
+ <div ng-if="choice.type == 'text'">
+ <h3 edit-me="showEdit" ng-hide="showEdit" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
+ <button class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)">...</button>
+ {{choice.name}}
+ </h3>
+ <h3 ng-show="showEdit">
+ <input type="text" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false" required/>
+ </h3>
+ </div>
+
+ <div ng-if="choice.type == 'date'">
+ <h3 edit-me="showEdit" ng-hide="showEdit || isOpen" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
+ <button class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)">...</button>
+ {{choice.date | date:'dd/MM/yyyy'}}
+ </h3>
+ <h3 ng-show="showEdit || isOpen">
+ <input type="text" ng-model="choice.date" datepicker-popup="dd/MM/yyyy" is-open="isOpen" focus-me="showEdit" ng-exit="showEdit = false" required/>
+ </h3>
+ </div>
+ </div>
+ <p collapse="!globalVariables.editMode && !showDesc" edit-me="showEditDesc" ng-hide="showEditDesc">{{choice.description}}</p>
+ <p ng-show="globalVariables.editMode && showEditDesc"><textarea ng-model="choice.description" focus-me="showEditDesc" ng-exit="showEditDesc = false" cols="80" rows="8"></textarea></p>
+ </div>
+ <div class="col-sm-2 pollChoiceInput">
+ <input type="checkbox" ng-model="choice.value"/>
+ </div>
+</div>
+<div class="row pollBigChoice" ng-if="globalVariables.editMode">
+ <div class="col-sm-10">
+ <button class="btn btn-info btn-large" ng-click="addChoice()">Ajouter un choix</button>
+ </div>
+ <div class="col-sm-2">
+ <button ng-click="inlineVersion()" class="btn btn-default">inline version</button>
+ </div>
+</div>
+
+<div style="float:right; margin-top:5px;">
+ <input type="text" placeholder="Votre Nom" ng-model="voteName"/>
+ <button class="btn btn-primary" >Voter</button>
+</div>
\ No newline at end of file
Copied: trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html (from rev 3889, trunk/pollen-ui-angular/src/main/webapp/partials/poll.html)
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-04-30 10:05:11 UTC (rev 3890)
@@ -0,0 +1,63 @@
+<!--
+ ~
+ ~ #%L
+ ~ Pollen :: UI (Angular)
+ ~ %%
+ ~ Copyright (C) 2009 - 2014 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%
+ ~
+ -->
+
+ <table>
+ <tr>
+ <td><button ng-if="globalVariables.editMode" ng-click="bigVersion()" class="btn btn-default" >Big version</button></td>
+ <td ng-repeat="choice in poll.choices" class="pollChoice pollAnim" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
+ <div ng-if="choice.type == 'text'" edit-me="showEdit" >
+ <div ng-hide="showEdit && !globalVariables.voted" class="fixe-input" title="{{choice.description}}">{{choice.name}} <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
+ <div ng-show="showEdit && !globalVariables.voted">
+ <input type="text" class="form-control" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false" required/>
+ <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
+ </div>
+ </div>
+ <div ng-if="choice.type == 'date'" edit-me="showEdit" >
+ <div ng-hide="!globalVariables.voted && showEdit || isOpen" class="fixe-input" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}} <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
+ <div ng-show="!globalVariables.voted && showEdit || isOpen" >
+ <input type="text" class="form-control" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" is-open="isOpen" ng-exit="showEdit = false" required/>
+ <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
+ </div>
+ </div>
+ </td>
+ <td ng-if="!globalVariables.voted && globalVariables.editMode"><input type="button" class="btn btn-default btn-large" value="+" ng-click="addChoice()"/></td>
+ </tr>
+
+ <tr>
+ <td class="pollChoice"> <input type="text" class="form-control" placeholder="votre nom" ng-model="voteName" /> </td>
+ <td ng-repeat="choice in voteChoices" class="pollChoice">
+ <input type="checkbox" name="{{choice.name}}" ng-model="choice.value"/>
+ </td>
+ <td>
+ <input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="vote()" />
+ </td>
+ </tr>
+
+ <tr ng-repeat="vote in poll.votants track by $index" class="pollAnim">
+ <td class="pollChoice"> {{vote.name}}</td>
+ <td ng-repeat="choice in vote.choices" class="pollChoice">
+ <input type="checkbox" ng-model="choice.value" disabled/>
+ </td>
+ </tr>
+ </table>
+
Deleted: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-29 19:10:38 UTC (rev 3889)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-30 10:05:11 UTC (rev 3890)
@@ -1,97 +0,0 @@
-<!--
- ~
- ~ #%L
- ~ Pollen :: UI (Angular)
- ~ %%
- ~ Copyright (C) 2009 - 2014 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%
- ~
- -->
-<form class="form-inline" name="pollForm" novalidate>
-
- <alert type="'danger'" ng-if="globalVariables.errorForm"> Champ non remplie </alert>
- <alert type="'success'" ng-if="globalVariables.editMode && globalVariables.saved"> Sondage sauvegardé..</alert>
- <alert type="'success'" ng-if="!globalVariables.editMode && globalVariables.saved"> Vote effectué.. </alert>
-
- <alert type="'warning'" ng-if="globalVariables.voted"> Les votes ont commencé, certaine modification sont inaccessible.. </alert>
-
- <div class="pollTitle pollAnim" edit-me="showEditTitle">
- <h1 ng-hide="showEditTitle"> {{poll.title || 'Click Me for Editing'}} </h1>
-
- <h1 ng-show="showEditTitle"><input type="text" class="form-control" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false" required/></h1>
- </div>
-
- <div ng-hide="showEditDesc" class="pollDesc pollAnim" edit-me="showEditDesc">
- <div> </div>
- <div ng-bind-html="toHTML(poll.description || 'Description (Facultatif). Ce cadre disparait si aucune description n\'est mise')"></div>
- </div>
- <div ng-show="showEditDesc" class="pollDesc " ng-exit="showEditDesc = false;">
- <textarea id="descEditor" data-ck-editor ng-model="poll.description"></textarea>
-
- <input type="button" value="Return" class="btn btn-primary" ng-click="showEditDesc = false;"/>
- </div>
-
- <div id="poll">
- <table>
- <tr>
- <td class="pollChoice"></td>
- <td ng-repeat="choice in poll.choices" class="pollChoice pollAnim" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
- <div ng-if="choice.type == 'text'" edit-me="showEdit" >
- <div ng-hide="showEdit && !globalVariables.voted" class="fixe-input" title="{{choice.description}}">{{choice.name}} <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
- <div ng-show="showEdit && !globalVariables.voted">
- <input type="text" class="form-control" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false" required/>
- <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
- </div>
- </div>
- <div ng-if="choice.type == 'date'" edit-me="showEdit" >
- <div ng-hide="!globalVariables.voted && showEdit || isOpen" class="fixe-input" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}} <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
- <div ng-show="!globalVariables.voted && showEdit || isOpen" >
- <input type="text" class="form-control" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" is-open="isOpen" ng-exit="showEdit = false" required/>
- <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
- </div>
- </div>
- </td>
- <td ng-if="!globalVariables.voted && globalVariables.editMode"><input type="button" class="btn btn-default btn-large" value="+" ng-click="addChoice()"/></td>
- </tr>
-
- <tr>
- <td class="pollChoice"> <input type="text" class="form-control" placeholder="votre nom" ng-model="voteName" /> </td>
- <td ng-repeat="choice in voteChoices" class="pollChoice">
- <input type="checkbox" name="{{choice.name}}" ng-model="choice.value"/>
- </td>
- <td>
- <input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="vote()" />
- </td>
- </tr>
-
- <tr ng-repeat="vote in poll.votants track by $index" class="pollAnim">
- <td class="pollChoice"> {{vote.name}}</td>
- <td ng-repeat="choice in vote.choices" class="pollChoice">
- <input type="checkbox" ng-model="choice.value" disabled/>
- </td>
- </tr>
- </table>
-
- <div ng-if="globalVariables.editMode">
- <button class="btn btn-primary" ng-click="save()">Save</button>
- <button class="btn btn-warning" ng-click="reset();" ng-if="!globalVariables.voted">Reset</button>
- <button class="btn btn-danger" ng-click="delete();">Delete</button>
- </div>
-
-
- </div>
-</form>
-
Added: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-30 10:05:11 UTC (rev 3890)
@@ -0,0 +1,38 @@
+<form class="form-inline" name="pollForm" novalidate>
+
+ <alert type="'danger'" ng-if="globalVariables.errorForm"> Champ non remplie </alert>
+ <alert type="'success'" ng-if="globalVariables.editMode && globalVariables.saved"> Sondage sauvegardé..</alert>
+ <alert type="'success'" ng-if="!globalVariables.editMode && globalVariables.saved"> Vote effectué.. </alert>
+
+ <alert type="'warning'" ng-if="globalVariables.voted"> Les votes ont commencé, certaine modification sont inaccessible.. </alert>
+
+ <div class="pollTitle" edit-me="showEditTitle">
+ <h1 ng-hide="showEditTitle"> {{poll.title || 'Click Me for Editing'}} </h1>
+
+ <h1 ng-show="showEditTitle"><input type="text" class="form-control" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false" required/></h1>
+ </div>
+
+ <div ng-hide="showEditDesc" class="pollDesc" edit-me="showEditDesc">
+ <div ng-bind-html="toHTML(poll.description || 'Description (Facultatif). Ce cadre disparait si aucune description n\'est mise')"></div>
+ </div>
+ <div ng-show="showEditDesc" class="pollDesc " ng-exit="showEditDesc = false;">
+ <textarea id="descEditor" data-ck-editor ng-model="poll.description"></textarea>
+
+ <input type="button" value="Return" class="btn btn-primary" ng-click="showEditDesc = false;"/>
+ </div>
+
+ <div id="poll">
+
+ <div ng-include="templateURL"></div>
+
+ </div>
+
+ <div ng-if="globalVariables.create">
+ <hr/>
+ <button type="button" class="btn btn-default" ng-model="globalVariables.editMode" btn-checkbox>Mode Edition</button>
+ <button class="btn btn-primary" ng-click="save()">Save</button>
+ <button class="btn btn-warning" ng-click="reset();" ng-if="!globalVariables.voted">Reset</button>
+ <button class="btn btn-danger" ng-click="delete();">Delete</button>
+ </div>
+
+</form>
\ No newline at end of file
1
0
r3889 - in trunk: pollen-persistence/src/main/xmi pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1 pollen-rest-api/src/main/resources pollen-rest-api/src/test/java/org/chorem/pollen/rest/api pollen-services/src/main/java/org/chorem/pollen/services/service pollen-services/src/test/java/org/chorem/pollen/service
by tchemit@users.chorem.org 29 Apr '14
by tchemit@users.chorem.org 29 Apr '14
29 Apr '14
Author: tchemit
Date: 2014-04-29 21:10:38 +0200 (Tue, 29 Apr 2014)
New Revision: 3889
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3889
Log:
pass ChoiceType to Choice, no more to Poll + add Rest Doc action + begin to add Rest API tests
Added:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
Modified:
trunk/pollen-persistence/src/main/xmi/pollen.zargo
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java
trunk/pollen-rest-api/src/main/resources/mapping
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
Modified: trunk/pollen-persistence/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Added: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -0,0 +1,29 @@
+package org.chorem.pollen.rest.api.v1;
+
+import org.apache.commons.io.IOUtils;
+import org.debux.webmotion.server.WebMotionController;
+import org.debux.webmotion.server.render.Render;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Created on 4/29/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class DocService extends WebMotionController {
+
+ public Render showMapping() {
+
+ InputStream mappingUrl = getClass().getResourceAsStream("/mapping");
+ try {
+ String content = IOUtils.toString(mappingUrl);
+ return renderContent(content, "text/plain");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+}
Property changes on: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/DocService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollService.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -23,7 +23,6 @@
* #L%
*/
-import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.rest.api.PollenRestApiRequestContext;
import org.chorem.pollen.services.exception.EntityNotFoundException;
@@ -41,8 +40,8 @@
*/
public class PollService extends WebMotionController {
- public Poll getNewPoll(PollenRestApiRequestContext context, String userId, ChoiceType choiceType) throws EntityNotFoundException {
- return context.getPollService().getNewPoll(userId, choiceType);
+ public Poll getNewPoll(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
+ return context.getPollService().getNewPoll(userId);
}
public Set<Poll> getPolls(PollenRestApiRequestContext context, String userId) throws EntityNotFoundException {
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserService.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -62,6 +62,11 @@
return context.getPollenUserService().editUser(user);
}
+ public void deleteUser(PollenRestApiRequestContext context,
+ String userId) throws EntityNotFoundException, InvalidPollenUserFormException {
+ context.getPollenUserService().deleteUser(userId);
+ }
+
public void validateUserEmail(PollenRestApiRequestContext context,
String userId,
String token) throws EntityNotFoundException, UserInvalidEmailActivationTokenException {
Modified: trunk/pollen-rest-api/src/main/resources/mapping
===================================================================
--- trunk/pollen-rest-api/src/main/resources/mapping 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-rest-api/src/main/resources/mapping 2014-04-29 19:10:38 UTC (rev 3889)
@@ -26,6 +26,9 @@
[actions]
+# Doc
+
+GET /v1/doc DocService.showMapping
# AuthService
PUT /v1/login AuthService.login
@@ -84,6 +87,7 @@
GET /v1/users/{userId} PollenUserService.getUser
POST /v1/users PollenUserService.createUser
PUT /v1/users/{userId} PollenUserService.editUser
+DELETE /v1/users/{userId} PollenUserService.deleteUser
PUT /v1/users/{userId}?token={} PollenUserService.validateUserEmail
# VoteCountingService
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -30,6 +30,7 @@
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.config.PollenServiceConfig;
import org.hibernate.cfg.Environment;
+import org.nuiton.util.DateUtil;
import java.io.File;
import java.util.HashMap;
@@ -72,6 +73,7 @@
serviceContext.setPollenServiceConfig(getApplicationConfig());
serviceContext.setTopiaApplicationContext(getTopiaApplicationContext());
serviceContext.setLocale(locale);
+ serviceContext.setDate(DateUtil.createDate(1, 1, 2014));
return serviceContext;
}
Added: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java (rev 0)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -0,0 +1,110 @@
+package org.chorem.pollen.rest.api;
+
+import org.apache.http.client.fluent.Request;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Created on 4/29/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+@Ignore
+public class PollServiceTest extends AbstractPollenRestApiTest {
+
+ @Test
+ public void getPollsNew() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls/new").Get();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void getPolls() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls").Get();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void getPollsCreated() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls/created").Get();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void getPollsInvited() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls/invited").Get();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void getPollsParticipated() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls/participated").Get();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void getPoll() throws URISyntaxException, IOException {
+ String pollId = "";
+ Request request = createRequest("/v1/polls/" + pollId).Get();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void postPoll() throws URISyntaxException, IOException {
+ Request request = createRequest("/v1/polls").Post();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void putPoll() throws URISyntaxException, IOException {
+ String pollId = "";
+ Request request = createRequest("/v1/polls/" + pollId).Put();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void deletePoll() throws URISyntaxException, IOException {
+ String pollId = "";
+ Request request = createRequest("/v1/polls/" + pollId).Delete();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void clonePoll() throws URISyntaxException, IOException {
+ String pollId = "";
+ Request request = createRequest("/v1/polls/" + pollId).Post();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void exportPoll() throws URISyntaxException, IOException {
+ String pollId = "";
+ Request request = createRequest("/v1/polls/" + pollId + "/export").Get();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+
+ @Test
+ public void closePoll() throws URISyntaxException, IOException {
+ String pollId = "";
+ Request request = createRequest("/v1/polls/" + pollId + "/close").Post();
+ String content = request.execute().returnContent().asString();
+ assertNotNull(content);
+ }
+}
Property changes on: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollenUserServiceTest.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -25,6 +25,7 @@
import org.apache.http.client.fluent.Request;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
@@ -35,6 +36,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.0
*/
+@Ignore
public class PollenUserServiceTest extends AbstractPollenRestApiTest {
@@ -45,38 +47,53 @@
}
@Test
- public void testGetUsers() throws Exception {
+ public void getUsers() throws Exception {
Request request = createRequest("/v1/users").Get();
String result = request.execute().returnContent().asString();
assertTrue(result.contains("email"));
+ }
+ @Test
+ public void getUser() throws Exception {
+ String userId = "";
+ Request request = createRequest("/v1/users/" + userId).Get();
+ String result = request.execute().returnContent().asString();
+ assertTrue(result.contains("email"));
}
-// @Test
-// public void testGetUser() throws Exception {
-//
-// }
-//
-// @Test
-// public void testCreateUser() throws Exception {
-//
-// }
-//
-// @Test
-// public void testEditUser() throws Exception {
-//
-// }
-//
-// @Test
-// public void testValidateUserEmail() throws Exception {
-//
-// }
-//
-// @Test
-// public void testChangePassword() throws Exception {
-//
-// }
+ @Test
+ public void postUser() throws Exception {
+ Request request = createRequest("/v1/users").Post();
+ String result = request.execute().returnContent().asString();
+
+ assertTrue(result.contains("email2"));
+ }
+
+ @Test
+ public void putUser() throws Exception {
+ String userId = "";
+ Request request = createRequest("/v1/users/" + userId).Get();
+ String result = request.execute().returnContent().asString();
+ assertTrue(result.contains("email3"));
+ }
+
+ @Test
+ public void deleteUser() throws Exception {
+ String userId = "";
+ Request request = createRequest("/v1/users/" + userId).Delete();
+ String result = request.execute().returnContent().asString();
+ assertTrue(result.contains("OK!"));
+ }
+
+ @Test
+ public void validateUserEmail() throws Exception {
+ String userId = "";
+ String token = "";
+ Request request = createRequest("/v1/users/" + userId + "?token=" + token).Put();
+ String result = request.execute().returnContent().asString();
+ assertTrue(result.contains("OK!"));
+ }
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -120,8 +120,7 @@
return result;
}
- protected Choice saveChoice(Poll poll,
- Choice choice) throws EntityNotFoundException {
+ protected Choice saveChoice(Poll poll, Choice choice) throws EntityNotFoundException {
ChoiceTopiaDao choiceDao = getChoiceDao();
@@ -151,7 +150,7 @@
poll.addChoice(choiceToPersist);
}
- switch (poll.getChoiceType()) {
+ switch (choice.getChoiceType()) {
case TEXT:
choiceToPersist.setName(choice.getName());
@@ -178,21 +177,22 @@
Set<String> choiceNames = Sets.newHashSet();
+ checkNotNull(errors, "choiceType", choice.getChoiceType(), "choiceType can not be null");
if (!poll.isChoiceEmpty()) {
// get all used names
- for (Choice member : poll.getChoice()) {
+ for (Choice choice1 : poll.getChoice()) {
if (choiceExists &&
- member.getTopiaId().equals(choice.getTopiaId())) {
+ choice1.getTopiaId().equals(choice.getTopiaId())) {
continue;
}
- choiceNames.add(member.getName());
+ choiceNames.add(choice1.getName());
}
}
- switch (poll.getChoiceType()) {
+ switch (choice.getChoiceType()) {
case TEXT:
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -30,7 +30,6 @@
import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.persistence.entity.Choice;
-import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.Poll;
import org.chorem.pollen.persistence.entity.PollTopiaDao;
import org.chorem.pollen.persistence.entity.PollenPrincipal;
@@ -88,12 +87,10 @@
return result;
}
- public Poll getNewPoll(String userId, ChoiceType choiceType) throws EntityNotFoundException {
+ public Poll getNewPoll(String userId) throws EntityNotFoundException {
Poll result = getPollDao().newInstance();
- result.setChoiceType(choiceType);
-
// -- default values -- //
result.setVoteCountingType(getPollenServiceConfig().getDefaultVoteCountingType());
@@ -232,7 +229,7 @@
toSave.setVoteCountingType(poll.getVoteCountingType());
toSave.setVoteVisibility(poll.getVoteVisibility());
toSave.setCommentVisibility(poll.getCommentVisibility());
- toSave.setChoiceType(poll.getChoiceType());
+// toSave.setChoiceType(poll.getChoiceType());
toSave.setAnonymousVoteAllowed(poll.isAnonymousVoteAllowed());
toSave.setChoiceAddAllowed(poll.isChoiceAddAllowed());
@@ -273,7 +270,6 @@
Multimap<String, String> errors = ArrayListMultimap.create();
checkNotNull(errors, "pollType", poll.getPollType(), "pollType can not be null");
- checkNotNull(errors, "choiceType", poll.getChoiceType(), "choiceType can not be null");
checkNotNull(errors, "commentVisibility", poll.getCommentVisibility(), "commentVisibility can not be null");
checkNotNull(errors, "voteVisibility", poll.getVoteVisibility(), "voteVisibility can not be null");
checkNotNull(errors, "voteCountingType", poll.getVoteCountingType(), "voteCountingType can not be null");
@@ -299,21 +295,27 @@
String choiceField = "choice[" + (choiceIndex++) + "]";
- switch (poll.getChoiceType()) {
+ checkNotNull(errors,
+ choiceField + ".choiceType",
+ choice.getChoiceType(),
+ "choiceType can not be null");
+ if (choice.getChoiceType()!=null) {
+ switch (choice.getChoiceType()) {
- case TEXT:
+ case TEXT:
- checkNotBlank(errors,
- choiceField + ".name",
- choice.getName(),
- "choice name can not be empty");
+ checkNotBlank(errors,
+ choiceField + ".name",
+ choice.getName(),
+ "choice name can not be empty");
- break;
- case DATE:
- throw new IllegalStateException("Not implemented");
+ break;
+ case DATE:
+ throw new IllegalStateException("Not implemented");
- case IMAGE:
- throw new IllegalStateException("Not implemented");
+ case IMAGE:
+ throw new IllegalStateException("Not implemented");
+ }
}
}
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -97,6 +97,14 @@
return result;
}
+ public void deleteUser(String userId) throws EntityNotFoundException, InvalidPollenUserFormException {
+ Preconditions.checkNotNull(userId);
+
+ PollenUser user = getUser(userId);
+ getPollenUserDao().delete(user);
+ commit();
+ }
+
public void changePassword(String userId,
String oldPassword,
String newPassword) throws EntityNotFoundException, UserInvalidPasswordException {
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-04-29 09:46:36 UTC (rev 3888)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/PollServiceTest.java 2014-04-29 19:10:38 UTC (rev 3889)
@@ -71,7 +71,7 @@
@Test
public void testCreateFreePoll() throws EntityNotFoundException, InvalidPollFormException {
- Poll poll = service.getNewPoll(null, ChoiceType.TEXT);
+ Poll poll = service.getNewPoll(null);
poll.setPollType(PollType.FREE);
@@ -91,6 +91,14 @@
try {
service.createPoll(null, poll);
} catch (InvalidPollFormException e) {
+ // missing choice type
+ assertErrorKeyFound(e, "choice[0].choiceType");
+ }
+
+ choice1.setChoiceType(ChoiceType.TEXT);
+ try {
+ service.createPoll(null, poll);
+ } catch (InvalidPollFormException e) {
// missing choice name
assertErrorKeyFound(e, "choice[0].name");
}
@@ -100,6 +108,7 @@
Choice choice2 = new ChoiceImpl();
+ choice2.setChoiceType(ChoiceType.TEXT);
choice2.setName("A");
choice2.setDescription("Choice B");
poll.addChoice(choice2);
@@ -165,18 +174,20 @@
@Test
public void testCreateRestrictedPoll() throws EntityNotFoundException, InvalidPollFormException {
- Poll poll = service.getNewPoll(null, ChoiceType.TEXT);
+ Poll poll = service.getNewPoll(null);
poll.setPollType(PollType.RESTRICTED);
poll.setTitle("poll1");
Choice choice1 = new ChoiceImpl();
+ choice1.setChoiceType(ChoiceType.TEXT);
choice1.setName("A");
choice1.setDescription("Choice A");
poll.addChoice(choice1);
Choice choice2 = new ChoiceImpl();
+ choice2.setChoiceType(ChoiceType.TEXT);
choice2.setName("B");
choice2.setDescription("Choice B");
1
0
r3888 - in trunk: pollen-rest-api pollen-ui-angular/src/main/webapp/WEB-INF
by tchemit@users.chorem.org 29 Apr '14
by tchemit@users.chorem.org 29 Apr '14
29 Apr '14
Author: tchemit
Date: 2014-04-29 11:46:36 +0200 (Tue, 29 Apr 2014)
New Revision: 3888
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3888
Log:
fix ui-angular war deploy
Modified:
trunk/pollen-rest-api/pom.xml
trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml
Modified: trunk/pollen-rest-api/pom.xml
===================================================================
--- trunk/pollen-rest-api/pom.xml 2014-04-29 09:37:51 UTC (rev 3887)
+++ trunk/pollen-rest-api/pom.xml 2014-04-29 09:46:36 UTC (rev 3888)
@@ -137,7 +137,6 @@
<defaultLogDir>${basedir}/target</defaultLogDir>
<defaultDbDir>${basedir}/target</defaultDbDir>
- <deployFiles>target/${project.build.finalName}.war</deployFiles>
</properties>
<build>
<resources>
Modified: trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml 2014-04-29 09:37:51 UTC (rev 3887)
+++ trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml 2014-04-29 09:46:36 UTC (rev 3888)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-
+
<web-app version="3.0" id="pollen-ui-angular"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1
0
r3887 - in trunk/pollen-ui-angular/src/main/webapp: . WEB-INF
by tchemit@users.chorem.org 29 Apr '14
by tchemit@users.chorem.org 29 Apr '14
29 Apr '14
Author: tchemit
Date: 2014-04-29 11:37:51 +0200 (Tue, 29 Apr 2014)
New Revision: 3887
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3887
Log:
make ui-angular war
Added:
trunk/pollen-ui-angular/src/main/webapp/WEB-INF/
trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml
Added: trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml 2014-04-29 09:37:51 UTC (rev 3887)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="3.0" id="pollen-ui-angular"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+
+ <display-name>Pollen UI (Angular)</display-name>
+</web-app>
\ No newline at end of file
Property changes on: trunk/pollen-ui-angular/src/main/webapp/WEB-INF/web.xml
___________________________________________________________________
Added: svn:mime-type
+ text/xml
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
Author: tchemit
Date: 2014-04-29 11:33:48 +0200 (Tue, 29 Apr 2014)
New Revision: 3886
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3886
Log:
simplify rest-api starting + add some conf
Modified:
trunk/pollen-rest-api/README.txt
Modified: trunk/pollen-rest-api/README.txt
===================================================================
--- trunk/pollen-rest-api/README.txt 2014-04-29 09:33:33 UTC (rev 3885)
+++ trunk/pollen-rest-api/README.txt 2014-04-29 09:33:48 UTC (rev 3886)
@@ -6,7 +6,7 @@
mvn jetty:run
-Une base vierge sera alors créée dans target/dd
+Une base vierge sera alors créée dans target/db
Les services seront appelables sur http://localhost:8080/pollen-rest-api/v1
1
0
r3885 - in trunk: pollen-rest-api pollen-rest-api/src/main/resources pollen-services pollen-services/src/main/java/org/chorem/pollen/services/config pollen-services/src/main/resources pollen-services/src/main/resources/i18n pollen-ui-angular
by tchemit@users.chorem.org 29 Apr '14
by tchemit@users.chorem.org 29 Apr '14
29 Apr '14
Author: tchemit
Date: 2014-04-29 11:33:33 +0200 (Tue, 29 Apr 2014)
New Revision: 3885
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3885
Log:
simplify rest-api starting + add some conf
Added:
trunk/pollen-rest-api/src/main/resources/log4j.properties
trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties
trunk/pollen-services/src/main/resources/i18n/
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
Modified:
trunk/pollen-rest-api/README.txt
trunk/pollen-rest-api/pom.xml
trunk/pollen-services/pom.xml
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java
trunk/pollen-ui-angular/pom.xml
Modified: trunk/pollen-rest-api/README.txt
===================================================================
--- trunk/pollen-rest-api/README.txt 2014-04-29 08:47:41 UTC (rev 3884)
+++ trunk/pollen-rest-api/README.txt 2014-04-29 09:33:33 UTC (rev 3885)
@@ -1,8 +1,15 @@
-Pour tester les services, lancer mvn tomcat7:run -Ptest
+Pour lancer les services, lancer
-Une base vierge sera alors créée dans target/pollen
+mvn tomcat7:run
-Les services seront appelables sur http://localhost:8080/pollen/v1
+ou
-Exemple : http://localhost:8080/pollen/v1/polls retourne la liste des
-sondages.
\ No newline at end of file
+mvn jetty:run
+
+Une base vierge sera alors créée dans target/dd
+
+Les services seront appelables sur http://localhost:8080/pollen-rest-api/v1
+
+Exemple :
+
+http://localhost:8080/pollen-rest-api/v1/users retourne la liste des utilisateurs.
\ No newline at end of file
Modified: trunk/pollen-rest-api/pom.xml
===================================================================
--- trunk/pollen-rest-api/pom.xml 2014-04-29 08:47:41 UTC (rev 3884)
+++ trunk/pollen-rest-api/pom.xml 2014-04-29 09:33:33 UTC (rev 3885)
@@ -133,9 +133,11 @@
<i18n.silent>true</i18n.silent>
<i18n.bundleOutputName>${pollenI18nBundle}</i18n.bundleOutputName>
- <defaultWebContextPath>pollen</defaultWebContextPath>
+ <defaultWebContextPath>pollen-rest-api</defaultWebContextPath>
<defaultLogDir>${basedir}/target</defaultLogDir>
<defaultDbDir>${basedir}/target</defaultDbDir>
+
+ <deployFiles>target/${project.build.finalName}.war</deployFiles>
</properties>
<build>
<resources>
@@ -143,6 +145,7 @@
<directory>src/main/resources</directory>
<includes>
<include>**/mapping</include>
+ <include>**/*.properties</include>
</includes>
<filtering>true</filtering>
</resource>
@@ -166,7 +169,7 @@
<value>${defaultLogDir}</value>
</systemProperty>
<systemProperty>
- <name>testDirectory</name>
+ <name>pollen.data.directory</name>
<value>${defaultDbDir}</value>
</systemProperty>
</systemProperties>
@@ -179,7 +182,7 @@
<configuration>
<path>/${defaultWebContextPath}</path>
<systemProperties>
- <testDirectory>${defaultDbDir}</testDirectory>
+ <pollen.data.directory>${defaultDbDir}</pollen.data.directory>
<pollen.log.dir>${defaultLogDir}</pollen.log.dir>
</systemProperties>
<uriEncoding>UTF-8</uriEncoding>
@@ -204,21 +207,15 @@
</build>
<profiles>
- <profile>
- <id>test</id>
- <build>
- <resources>
- <resource>
- <directory>src/test/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
- </build>
+ <profile>
+ <!--To deploy the rest-api module (for demo instance)-->
+ <id>deploy-rest-api</id>
+ <properties>
+ <deployFiles>target/${project.build.finalName}.war</deployFiles>
+ </properties>
</profile>
+
</profiles>
</project>
Copied: trunk/pollen-rest-api/src/main/resources/log4j.properties (from rev 3879, trunk/pollen-rest-api/src/test/resources/log4j.properties)
===================================================================
--- trunk/pollen-rest-api/src/main/resources/log4j.properties (rev 0)
+++ trunk/pollen-rest-api/src/main/resources/log4j.properties 2014-04-29 09:33:33 UTC (rev 3885)
@@ -0,0 +1,30 @@
+###
+# #%L
+# Pollen :: Rest Api
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2009 - 2013 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%
+###
+log4j.rootCategory=WARN, console
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{hh:mm:ss} %5p (%F:%L) %m%n
+
+log4j.logger.org.chorem.pollen=INFO
+log4j.logger.org.debux=INFO
Added: trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties
===================================================================
--- trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties (rev 0)
+++ trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties 2014-04-29 09:33:33 UTC (rev 3885)
@@ -0,0 +1,6 @@
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.url=jdbc:h2:file:${pollen.data.directory}/db/pollen-rest-api
+hibernate.connection.username=sa
+hibernate.connection.password=sa
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.hbm2ddl.auto=update
Property changes on: trunk/pollen-rest-api/src/main/resources/pollen-rest-api.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-services/pom.xml
===================================================================
--- trunk/pollen-services/pom.xml 2014-04-29 08:47:41 UTC (rev 3884)
+++ trunk/pollen-services/pom.xml 2014-04-29 09:33:33 UTC (rev 3885)
@@ -130,4 +130,21 @@
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>i18n-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-04-29 08:47:41 UTC (rev 3884)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-04-29 09:33:33 UTC (rev 3885)
@@ -66,24 +66,29 @@
throw new PollenTechnicalException(e);
}
if (log.isInfoEnabled()) {
- StringBuilder builder = new StringBuilder("Filename: "+filename);
+ StringBuilder builder = new StringBuilder("Pollen configuration:");
+ builder.append("\nFilename: ").append(filename);
List<PollenServiceConfigOption> options = Lists.newArrayList(PollenServiceConfigOption.values());
for (PollenServiceConfigOption option : options) {
builder.append(String.format("\n%1$-40s = %2$s",
option.getKey(),
applicationConfig.getOption(option)));
}
- log.info("Pollen configuration:" + builder.toString());
+ log.info( builder.toString());
}
}
public Map<String, String> getTopiaProperties() {
- Map<String, String> jpaParameters = Maps.newHashMap();
- Properties hibernateProperties = applicationConfig.getOptionStartsWith("hibernate");
- jpaParameters.putAll((Map) hibernateProperties);
- Properties topiaProperties = applicationConfig.getOptionStartsWith("topia");
- jpaParameters.putAll((Map) topiaProperties);
- return jpaParameters;
+ Map<String, String> topiaParameters = Maps.newHashMap();
+ Properties properties = applicationConfig.getOptionStartsWith("hibernate");
+ properties.putAll(applicationConfig.getOptionStartsWith("topia"));
+
+ for (Object o : properties.keySet()) {
+ String key = String.valueOf(o);
+ String value = applicationConfig.getOption(String.class, key);
+ topiaParameters.put(key, value);
+ }
+ return topiaParameters;
}
public boolean isLogConfigurationProvided() {
@@ -92,6 +97,10 @@
return logConfigurationProvided;
}
+ public File getDataDirectory() {
+ return applicationConfig.getOptionAsFile(PollenServiceConfigOption.DATA_DIRECTORY.key);
+ }
+
public File getLogConfigurationFile() {
return applicationConfig.getOptionAsFile(PollenServiceConfigOption.LOG_CONFIGURATION_FILE.key);
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java 2014-04-29 08:47:41 UTC (rev 3884)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfigOption.java 2014-04-29 09:33:33 UTC (rev 3885)
@@ -28,6 +28,8 @@
import org.chorem.pollen.persistence.entity.VoteVisibility;
import org.nuiton.config.ConfigOptionDef;
+import java.io.File;
+
import static org.nuiton.i18n.I18n.n;
@@ -40,6 +42,16 @@
public enum PollenServiceConfigOption implements ConfigOptionDef {
/**
+ * Where to stroe any data for pollen application.
+ *
+ * @since 2.0
+ */
+ DATA_DIRECTORY(
+ "pollen.data.directory",
+ n("pollen.configuration.data.directory"),
+ "${java.io.tmpdir}/pollen",
+ File.class),
+ /**
* Default poll type to use at a new poll creation.
*
* @since 2.0
Added: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties (rev 0)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2014-04-29 09:33:33 UTC (rev 3885)
@@ -0,0 +1,11 @@
+pollen.configuration.data.directory=
+pollen.configuration.defaultPollCommentVisibility=
+pollen.configuration.defaultPollType=
+pollen.configuration.defaultPollVoteVisibility=
+pollen.configuration.defaultVoteCountingType=
+pollen.error.favoriteList.import.csv.already.used.email=
+pollen.error.favoriteList.import.csv.already.used.name=
+pollen.error.favoriteList.import.csv.invalid.email=
+pollen.error.favoriteList.import.ldap.already.used.email=
+pollen.error.favoriteList.import.ldap.already.used.name=
+pollen.error.favoriteList.import.ldap.invalid.email=
Property changes on: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties (rev 0)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2014-04-29 09:33:33 UTC (rev 3885)
@@ -0,0 +1,11 @@
+pollen.configuration.data.directory=
+pollen.configuration.defaultPollCommentVisibility=
+pollen.configuration.defaultPollType=
+pollen.configuration.defaultPollVoteVisibility=
+pollen.configuration.defaultVoteCountingType=
+pollen.error.favoriteList.import.csv.already.used.email=
+pollen.error.favoriteList.import.csv.already.used.name=
+pollen.error.favoriteList.import.csv.invalid.email=
+pollen.error.favoriteList.import.ldap.already.used.email=
+pollen.error.favoriteList.import.ldap.already.used.name=
+pollen.error.favoriteList.import.ldap.invalid.email=
Property changes on: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-angular/pom.xml
===================================================================
--- trunk/pollen-ui-angular/pom.xml 2014-04-29 08:47:41 UTC (rev 3884)
+++ trunk/pollen-ui-angular/pom.xml 2014-04-29 09:33:33 UTC (rev 3885)
@@ -14,7 +14,7 @@
<groupId>org.chorem.pollen</groupId>
<artifactId>pollen-ui-angular</artifactId>
- <packaging>pom</packaging>
+ <packaging>war</packaging>
<properties>
@@ -86,4 +86,15 @@
</plugins>
</build>
+ <profiles>
+
+ <profile>
+ <!--To deploy the ui-angular module (for demo instance)-->
+ <id>deploy-ui-angular</id>
+ <properties>
+ <deployFiles>target/${project.build.finalName}.war</deployFiles>
+ </properties>
+ </profile>
+
+ </profiles>
</project>
1
0
r3884 - in trunk: pollen-persistence/src/main/resources pollen-rest-api/src/main/java/org/chorem/pollen/rest/api pollen-rest-api/src/test/java/org/chorem/pollen/rest/api pollen-services/src/main/java/org/chorem/pollen/services/config pollen-services/src/test/java/org/chorem/pollen/service
by tchemit@users.chorem.org 29 Apr '14
by tchemit@users.chorem.org 29 Apr '14
29 Apr '14
Author: tchemit
Date: 2014-04-29 10:47:41 +0200 (Tue, 29 Apr 2014)
New Revision: 3884
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3884
Log:
use specific configuration files (pollen-services.properties, pollen-rest-api.properties to avoid any collision with existing config)
Removed:
trunk/pollen-persistence/src/main/resources/META-INF/
Modified:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-04-28 15:39:15 UTC (rev 3883)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationContext.java 2014-04-29 08:47:41 UTC (rev 3884)
@@ -75,7 +75,7 @@
protected PollenServiceConfig applicationConfig;
public static PollenRestApiApplicationContext newApplicationContext() {
- PollenServiceConfig applicationConfig = new PollenServiceConfig();
+ PollenServiceConfig applicationConfig = new PollenServiceConfig("pollen-rest-api.properties");
PollenTopiaApplicationContext pollenTopiaApplicationContext = new PollenTopiaApplicationContext(applicationConfig.getTopiaProperties());
PollenRestApiApplicationContext result = new PollenRestApiApplicationContext(applicationConfig, pollenTopiaApplicationContext);
return result;
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-04-28 15:39:15 UTC (rev 3883)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AbstractPollenRestApiTest.java 2014-04-29 08:47:41 UTC (rev 3884)
@@ -51,7 +51,7 @@
@Before
public void launchServer() throws Exception {
- PollenRestApiApplicationContext applicationContext = FakePollenRestApiApplicationContext.newApplicationContext();
+ PollenRestApiApplicationContext applicationContext = FakePollenRestApiApplicationContext.newFakeApplicationContext();
applicationContext.init();
PollenRestApiApplicationContext.setApplicationContext(applicationContext);
Modified: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-28 15:39:15 UTC (rev 3883)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/FakePollenRestApiApplicationContext.java 2014-04-29 08:47:41 UTC (rev 3884)
@@ -52,8 +52,8 @@
protected List<PollenTopiaPersistenceContext> openedTransactions = new LinkedList<>();
- public static PollenRestApiApplicationContext newApplicationContext() {
- PollenServiceConfig applicationConfig = new PollenServiceConfig();
+ public static PollenRestApiApplicationContext newFakeApplicationContext() {
+ PollenServiceConfig applicationConfig = new PollenServiceConfig("pollen-rest-api.properties");
PollenTopiaApplicationContext pollenTopiaApplicationContext = newTopiaApplicationContext(applicationConfig, UUID.randomUUID().toString());
PollenRestApiApplicationContext result = new FakePollenRestApiApplicationContext(applicationConfig, pollenTopiaApplicationContext);
return result;
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-04-28 15:39:15 UTC (rev 3883)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/config/PollenServiceConfig.java 2014-04-29 08:47:41 UTC (rev 3884)
@@ -53,16 +53,20 @@
protected ApplicationConfig applicationConfig;
public PollenServiceConfig() {
+ this("pollen.properties");
+ }
+
+ public PollenServiceConfig(String filename) {
applicationConfig = new ApplicationConfig();
applicationConfig.loadDefaultOptions(PollenServiceConfigOption.values());
- applicationConfig.setConfigFileName("pollen.properties");
+ applicationConfig.setConfigFileName(filename);
try {
applicationConfig.parse();
} catch (ArgumentsParserException e) {
throw new PollenTechnicalException(e);
}
if (log.isInfoEnabled()) {
- StringBuilder builder = new StringBuilder();
+ StringBuilder builder = new StringBuilder("Filename: "+filename);
List<PollenServiceConfigOption> options = Lists.newArrayList(PollenServiceConfigOption.values());
for (PollenServiceConfigOption option : options) {
builder.append(String.format("\n%1$-40s = %2$s",
Modified: trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java
===================================================================
--- trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-04-28 15:39:15 UTC (rev 3883)
+++ trunk/pollen-services/src/test/java/org/chorem/pollen/service/AbstractPollenServiceTest.java 2014-04-29 08:47:41 UTC (rev 3884)
@@ -118,13 +118,13 @@
log.debug("jdbc url is\n" + jdbcUrl);
}
- PollenTopiaApplicationContext applicationContext = new PollenTopiaApplicationContext(hibernateH2Config);
+ PollenTopiaApplicationContext topiaApplicationContext = new PollenTopiaApplicationContext(hibernateH2Config);
if (log.isTraceEnabled()) {
- log.trace("created root context " + applicationContext);
+ log.trace("created root context " + topiaApplicationContext);
}
- return applicationContext;
+ return topiaApplicationContext;
}
protected PollenTopiaApplicationContext getApplicationContext() {
@@ -159,7 +159,7 @@
if (applicationConfig == null) {
- applicationConfig = new PollenServiceConfig();
+ applicationConfig = new PollenServiceConfig("pollen-services.properties");
}
return applicationConfig;
1
0
r3883 - in trunk/pollen-ui-angular/src/main/webapp: . css js js/controllers partials
by garandel@users.chorem.org 28 Apr '14
by garandel@users.chorem.org 28 Apr '14
28 Apr '14
Author: garandel
Date: 2014-04-28 17:39:15 +0200 (Mon, 28 Apr 2014)
New Revision: 3883
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3883
Log:
d?\195?\169sactivation de certain modification apres le 1er vote
Modified:
trunk/pollen-ui-angular/src/main/webapp/css/style.css
trunk/pollen-ui-angular/src/main/webapp/index.html
trunk/pollen-ui-angular/src/main/webapp/js/app.js
trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Modified: trunk/pollen-ui-angular/src/main/webapp/css/style.css
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-28 09:56:29 UTC (rev 3882)
+++ trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-28 15:39:15 UTC (rev 3883)
@@ -133,12 +133,14 @@
margin:auto;
margin-bottom:8px;
}
-#poll tr, #poll tr td {
- border-collapse: collapse;
+
+#poll tr td > .btn-large {
+ height:60px;
+ width:80px;
}
+
.pollChoice {
- height:60px;
min-width:150px;
padding-left:5px;
padding-right:5px;
@@ -146,10 +148,9 @@
padding-bottom:5px;
border: 1px dashed #AAAAAA;
text-align:center;
- padding-left:5px;
- padding-right:5px;
-}
-.pollChoice input[type=text]{
+ }
+.
+pollChoice input[type=text]{
height:25px;
width:140px;
}
Modified: trunk/pollen-ui-angular/src/main/webapp/index.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/index.html 2014-04-28 09:56:29 UTC (rev 3882)
+++ trunk/pollen-ui-angular/src/main/webapp/index.html 2014-04-28 15:39:15 UTC (rev 3883)
@@ -32,7 +32,6 @@
<script src="js/app.js"></script>
<script src="js/controllers/pollCtrl.js"></script>
- <script src="js/services.js"></script>
</head>
<body>
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-28 09:56:29 UTC (rev 3882)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-04-28 15:39:15 UTC (rev 3883)
@@ -18,19 +18,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-angular.module('pollen', ["ngRoute", "pollenControllers", "pollenServices", 'ui.bootstrap'])
+angular.module('pollen', ["ngRoute", "pollControllers", 'ui.bootstrap'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {templateUrl: 'partials/home.html', controller: "HomeCtrl"})
- .when('/poll/create', {templateUrl: 'partials/poll.html', controller: "PollCreateCtrl"})
+ .when('/poll/create', {templateUrl: 'partials/poll.html', controller: "PollAdminCtrl"})
+ .when('/poll/edit/:pollId', {templateUrl: 'partials/poll.html', controller:"PollAdminCtrl"})
.when('/poll/vote', {templateUrl: 'partials/poll.html', controller :"PollVoteCtrl"})
+ .when('/poll/list', {templateUrl: 'partials/poll-list.html', controller :"PollListCtrl"})
.otherwise({redirectTo: '/'});
-}]).config(['$httpProvider', function($httpProvider) {
-
- $httpProvider.defaults.useXDomain = true;
- delete $httpProvider.defaults.headers.common['X-Requested-With'];
}])
+
.directive('focusMe', function($timeout) {
return {
link: function($scope, element, attrs) {
@@ -51,10 +50,10 @@
restrict:'A',
link: function ($scope, element, attrs) {
element.bind('click', function () {
- if ($scope.gvar.editMode) {
+ if ($scope.globalVariables.editMode) {
$scope.$apply(function () {
$scope[attrs.editMe] = true;
- $scope.gvar.saved = false;
+ $scope.globalVariables.saved = false;
});
}
});
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-28 09:56:29 UTC (rev 3882)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-28 15:39:15 UTC (rev 3883)
@@ -18,15 +18,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-angular.module('pollenControllers', []).controller('HomeCtrl', ['$scope', '$http', function ($scope, $http) {
+angular.module('pollControllers', []).controller('HomeCtrl', ['$scope', '$rootScope', function ($scope, $rootScope) {
}])
.controller('PollCtrl', ['$scope', '$sce', '$timeout', 'pollStorage', function ($scope, $sce, $timeout, pollStorage) {
- $scope.gvar = {saved:false};
- $scope.$watch('gvar.saved', function() {
+ $scope.globalVariables = {saved:false};
+ $scope.$watch('globalVariables.saved', function() {
$timeout(function () {
- $scope.gvar.saved = false;
+ $scope.globalVariables.saved = false;
}, 5000);
});
@@ -35,130 +35,161 @@
$scope.toHTML = function (data) {
return $sce.trustAsHtml(data);
}
-
}])
-.controller('PollCreateCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', 'pollStorage', function ($scope, $controller, $modal, $filter, $timeout, pollStorage) {
+
+.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', 'pollStorage', function ($scope, $controller, $modal, $filter, $timeout, pollStorage) {
$controller('PollCtrl', {$scope:$scope});
- function initPoll() {
- return {
- title :'',
- description : '',
- choices : []
- };
- }
+ var initPoll = function () {
+ return {
+ title :'',
+ description : '',
+ choices : []
+ };
+ }
- function initChoice() {
- return {
- name: '',
- type: 'text'
- };
- }
+ var initChoice = function () {
+ return {
+ name: '',
+ type: $scope.globalVariables.lastType
+ };
+ }
- $scope.gvar.editMode = true;
+ $scope.globalVariables.editMode = true;
+ $scope.globalVariables.voted = angular.isDefined($scope.poll.votants);
+ $scope.globalVariables.lastType = 'text';
- if (JSON.stringify($scope.poll) == "{}") {
- $scope.poll = initPoll();
- }
+ $scope.$watch('pollForm.$valid', function (newVal) {
+ $scope.formValid = newVal;
+ $scope.globalVariables.errorForm = false;
+ });
- $scope.voteChoices = $scope.poll.choices;
+ if (!angular.isDefined($scope.poll.choices)) {
+ $scope.poll = initPoll();
+ }
+ $scope.voteChoices = $scope.poll.choices;
- $scope.addChoice = function () {
- var index = $scope.poll.choices.push(initChoice());
- var choice = $scope.poll.choices[index-1];
- popupChoice(choice, 'Add Choice');
+ $scope.addChoice = function () {
+ var index = $scope.poll.choices.push(initChoice());
+ var choice = $scope.poll.choices[index-1];
+ popupChoice(choice, 'Add Choice');
+ }
- }
+ $scope.editChoice = function (choice) {
+ popupChoice(choice, 'Edit Choice');
+ }
- $scope.editChoice = function (choice) {
- popupChoice(choice, 'Edit Choice');
+ var deleteChoice = function (ch) {
+ var index = $scope.poll.choices.indexOf(ch);
+ if (index > -1) {
+ $scope.poll.choices.splice(index,1);
}
+ }
- var deleteChoice = function (ch) {
- var index = $scope.poll.choices.indexOf(ch);
- if (index > -1) {
- $scope.poll.choices.splice(index,1);
- }
- }
- var popupChoice = function (choice, title) {
- var modalInstance = $modal.open({
- templateUrl : 'partials/poll-popupChoice.html',
- controller : PollPopChoiceCtrl,
- resolve : {
- title : function () { return title;},
- choice : function () { return choice; }
- }
- });
+ var popupChoice = function (choice, title) {
+ var modalInstance = $modal.open({
+ templateUrl : 'partials/poll-popupChoice.html',
+ controller : PollPopChoiceCtrl,
+ resolve : {
+ title : function () { return title;},
+ choice : function () { return choice; }
+ }
+ });
- modalInstance.result.then(function (ch) {
- deleteChoice(ch);
- });
- }
+ modalInstance.result.then(function (ch) {
+ deleteChoice(ch);
+ }, function () {
+ $scope.globalVariables.lastType = choice.type;
+ });
+ }
- $scope.save = function () {
- pollStorage.put($scope.poll);
- $scope.gvar.saved = true;
+ $scope.save = function () {
+ if ($scope.formValid) {
+ pollStorage.put($scope.poll);
+ $scope.globalVariables.saved = true;
}
-
- $scope.reset = function () {
- $scope.poll = initPoll();
- $scope.voteChoices = $scope.poll.choices;
- pollStorage.put({});
+ else {
+ $scope.globalVariables.errorForm = true;
}
- var PollPopChoiceCtrl = function ($scope, $filter, $modalInstance, title, choice) {
- $scope.title = title;
- $scope.choice = choice;
- var oldChoice = angular.copy(choice);
+ }
- $scope.saveChoice = function () {
- $modalInstance.close();
- }
+ $scope.reset = function () {
+ $scope.poll = initPoll();
+ $scope.voteChoices = $scope.poll.choices;
+ pollStorage.put({});
+ }
- $scope.cancelChoice = function () {
- angular.copy(oldChoice, $scope.choice);
- $modalInstance.close();
- }
+ $scope.delete = function () {
+ $scope.poll = initPoll();
+ $scope.voteChoices = $scope.poll.choices;
+ pollStorage.put({});
+ }
- $scope.deleteChoice = function (ch) {
- $modalInstance.close(ch);
- }
+ var PollPopChoiceCtrl = function ($scope, $filter, $modalInstance, title, choice) {
+ $scope.title = title;
+ $scope.choice = choice;
+ var oldChoice = angular.copy(choice);
+
+ $scope.saveChoice = function () {
+ $modalInstance.dismiss();
}
+
+ $scope.cancelChoice = function () {
+ angular.copy(oldChoice, $scope.choice);
+ $modalInstance.dismiss();
+ }
+
+ $scope.deleteChoice = function (ch) {
+ $modalInstance.close(ch);
+ }
+
+ }
}])
.controller('PollVoteCtrl', ['$scope', '$filter', '$controller', 'pollStorage', function ($scope, $filter, $controller, pollStorage) {
$controller('PollCtrl', {$scope:$scope});
- $scope.gvar.editMode = false;
+ $scope.globalVariables.editMode = false;
- var initVote = function () {
- $scope.voteName = "";
- $scope.voteChoices = [];
- for (var i = 0; i < $scope.poll.choices.length; ++i) {
- if ($scope.poll.choices[i].type == 'text') {
- $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
- }
- else if ($scope.poll.choices[i].type == 'date') {
- $scope.voteChoices.push({name: $filter('date')($scope.poll.choices[i].date,'dd/MM/yyyy') , value:false});
- }
+ var initVote = function () {
+ $scope.voteName = "";
+ $scope.voteChoices = [];
+ for (var i = 0; i < $scope.poll.choices.length; ++i) {
+ if ($scope.poll.choices[i].type == 'text') {
+ $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
}
+ else if ($scope.poll.choices[i].type == 'date') {
+ $scope.voteChoices.push({name: $scope.poll.choices[i].date , value:false});
+ }
}
- initVote();
+ }
+ initVote();
- $scope.vote = function () {
- var data = {};
- data.name = $scope.voteName;
- data.choices = angular.copy($scope.voteChoices);
- if (!angular.isDefined($scope.poll.votants)) {
- $scope.poll.votants = [];
- }
- $scope.poll.votants.push(data);
- pollStorage.put($scope.poll);
- $scope.gvar.saved = true;
- initVote();
+ $scope.vote = function () {
+ if ($scope.voteName != '') {
+ var data = {};
+ data.name = $scope.voteName;
+ data.choices = angular.copy($scope.voteChoices);
+ if (!angular.isDefined($scope.poll.votants)) {
+ $scope.poll.votants = [];
+ }
+ $scope.poll.votants.push(data);
+ pollStorage.put($scope.poll);
+ $scope.globalVariables.saved = true;
+ initVote();
}
+ else {
+ $scope.globalVariables.errorForm = true;
+ }
+ }
}])
+
+.controller('PollListCtrl', ['$scope', 'pollStorage', function ($scope, pollStorage) {
+
+}])
+
;
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-04-28 09:56:29 UTC (rev 3882)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-04-28 15:39:15 UTC (rev 3883)
@@ -1,7 +1,6 @@
<form class="form-horizontal">
<div class="modal-header">
<h4 class="modal-title">{{title}}</h4>
- {{oldChoice}}
</div>
<div class="modal-body">
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-28 09:56:29 UTC (rev 3882)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-28 15:39:15 UTC (rev 3883)
@@ -20,14 +20,18 @@
~ #L%
~
-->
-<form class="form-inline">
- <alert type="'success'" ng-if="gvar.editMode && gvar.saved"> Sondage sauvegardé..</alert>
- <alert type="'success'" ng-if="!gvar.editMode && gvar.saved"> Vote effectué.. </alert>
+<form class="form-inline" name="pollForm" novalidate>
+ <alert type="'danger'" ng-if="globalVariables.errorForm"> Champ non remplie </alert>
+ <alert type="'success'" ng-if="globalVariables.editMode && globalVariables.saved"> Sondage sauvegardé..</alert>
+ <alert type="'success'" ng-if="!globalVariables.editMode && globalVariables.saved"> Vote effectué.. </alert>
+
+ <alert type="'warning'" ng-if="globalVariables.voted"> Les votes ont commencé, certaine modification sont inaccessible.. </alert>
+
<div class="pollTitle pollAnim" edit-me="showEditTitle">
<h1 ng-hide="showEditTitle"> {{poll.title || 'Click Me for Editing'}} </h1>
- <h1 ng-show="showEditTitle"><input type="text" class="form-control" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false"/></h1>
+ <h1 ng-show="showEditTitle"><input type="text" class="form-control" focus-me="showEditTitle" ng-model="poll.title" ng-exit="showEditTitle = false" required/></h1>
</div>
<div ng-hide="showEditDesc" class="pollDesc pollAnim" edit-me="showEditDesc">
@@ -44,23 +48,23 @@
<table>
<tr>
<td class="pollChoice"></td>
- <td ng-repeat="choice in poll.choices" class="pollChoice pollAnim" edit-me="showEdit" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
- <div ng-show="choice.type == 'text'">
- <div ng-hide="showEdit" class="fixe-input" title="{{choice.description}}">{{choice.name}} <input type="button" class="btn btn-default" ng-if="gvar.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
- <div ng-show="showEdit">
- <input type="text" class="form-control" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false"/>
+ <td ng-repeat="choice in poll.choices" class="pollChoice pollAnim" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
+ <div ng-if="choice.type == 'text'" edit-me="showEdit" >
+ <div ng-hide="showEdit && !globalVariables.voted" class="fixe-input" title="{{choice.description}}">{{choice.name}} <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
+ <div ng-show="showEdit && !globalVariables.voted">
+ <input type="text" class="form-control" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false" required/>
<input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
</div>
</div>
- <div ng-show="choice.type == 'date'">
- <div ng-hide="showEdit || isOpen" class="fixe-input" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}} <input type="button" class="btn btn-default" ng-if="gvar.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
- <div ng-show="showEdit || isOpen" >
- <input type="text" class="form-control" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" is-open="isOpen" ng-exit="showEdit = false" />
+ <div ng-if="choice.type == 'date'" edit-me="showEdit" >
+ <div ng-hide="!globalVariables.voted && showEdit || isOpen" class="fixe-input" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}} <input type="button" class="btn btn-default" ng-if="!globalVariables.voted && globalVariables.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
+ <div ng-show="!globalVariables.voted && showEdit || isOpen" >
+ <input type="text" class="form-control" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" is-open="isOpen" ng-exit="showEdit = false" required/>
<input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
</div>
</div>
</td>
- <td ng-if="gvar.editMode"><input type="button" class="btn btn-default" value="+" ng-click="addChoice()"/></td>
+ <td ng-if="!globalVariables.voted && globalVariables.editMode"><input type="button" class="btn btn-default btn-large" value="+" ng-click="addChoice()"/></td>
</tr>
<tr>
@@ -68,7 +72,9 @@
<td ng-repeat="choice in voteChoices" class="pollChoice">
<input type="checkbox" name="{{choice.name}}" ng-model="choice.value"/>
</td>
- <td></td>
+ <td>
+ <input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="vote()" />
+ </td>
</tr>
<tr ng-repeat="vote in poll.votants track by $index" class="pollAnim">
@@ -79,15 +85,13 @@
</tr>
</table>
- <div ng-if="gvar.editMode">
- <input class="btn btn-primary" type="button" value="Save" ng-click="save()"/>
- <br/><br/><br/>
- <input type="button" value="reset" ng-click="reset();"/>
+ <div ng-if="globalVariables.editMode">
+ <button class="btn btn-primary" ng-click="save()">Save</button>
+ <button class="btn btn-warning" ng-click="reset();" ng-if="!globalVariables.voted">Reset</button>
+ <button class="btn btn-danger" ng-click="delete();">Delete</button>
</div>
- <div ng-if="!gvar.editMode">
- <input class="btn btn-primary" type="button" value="Vote" ng-click="vote()" />
- </div>
+
</div>
</form>
1
0
r3882 - in trunk/pollen-ui-angular/src/main/webapp: css js/controllers partials
by garandel@users.chorem.org 28 Apr '14
by garandel@users.chorem.org 28 Apr '14
28 Apr '14
Author: garandel
Date: 2014-04-28 11:56:29 +0200 (Mon, 28 Apr 2014)
New Revision: 3882
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3882
Log:
add gobal poll controller.
Added:
trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html
Modified:
trunk/pollen-ui-angular/src/main/webapp/css/style.css
trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Modified: trunk/pollen-ui-angular/src/main/webapp/css/style.css
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-27 17:12:24 UTC (rev 3881)
+++ trunk/pollen-ui-angular/src/main/webapp/css/style.css 2014-04-28 09:56:29 UTC (rev 3882)
@@ -164,4 +164,9 @@
right: 30px;
top:10px;
pointer-events: none;
+}
+
+.fixe-input .ng-hide {
+ display:inline-block !important;
+ visibility:hidden;
}
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-27 17:12:24 UTC (rev 3881)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-04-28 09:56:29 UTC (rev 3882)
@@ -21,7 +21,26 @@
angular.module('pollenControllers', []).controller('HomeCtrl', ['$scope', '$http', function ($scope, $http) {
}])
-.controller('PollCreateCtrl', ['$scope', '$http', '$sce', '$modal', '$filter', '$timeout', 'pollStorage', function ($scope, $http, $sce, $modal, $filter, $timeout, pollStorage) {
+
+.controller('PollCtrl', ['$scope', '$sce', '$timeout', 'pollStorage', function ($scope, $sce, $timeout, pollStorage) {
+ $scope.gvar = {saved:false};
+ $scope.$watch('gvar.saved', function() {
+ $timeout(function () {
+ $scope.gvar.saved = false;
+ }, 5000);
+ });
+
+ $scope.poll = pollStorage.get();
+
+ $scope.toHTML = function (data) {
+ return $sce.trustAsHtml(data);
+ }
+
+}])
+
+.controller('PollCreateCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', 'pollStorage', function ($scope, $controller, $modal, $filter, $timeout, pollStorage) {
+ $controller('PollCtrl', {$scope:$scope});
+
function initPoll() {
return {
title :'',
@@ -37,14 +56,8 @@
};
}
- $scope.gvar = {saved:false, editMode:true};
- $scope.$watch('gvar.saved', function() {
- $timeout(function () {
- $scope.gvar.saved = false;
- }, 5000);
- })
+ $scope.gvar.editMode = true;
- $scope.poll = pollStorage.get();
if (JSON.stringify($scope.poll) == "{}") {
$scope.poll = initPoll();
}
@@ -54,33 +67,12 @@
$scope.addChoice = function () {
var index = $scope.poll.choices.push(initChoice());
var choice = $scope.poll.choices[index-1];
- var modalInstance = $modal.open({
- templateUrl : 'popupChoice.html',
- controller : PollPopChoiceCtrl,
- resolve : {
- title : function () { return 'Add Choice';},
- choice : function () { return choice; }
- }
- });
- modalInstance.result.then(function (ch) {
- deleteChoice(ch);
- });
+ popupChoice(choice, 'Add Choice');
}
$scope.editChoice = function (choice) {
- var modalInstance = $modal.open({
- templateUrl : 'popupChoice.html',
- controller : PollPopChoiceCtrl,
- resolve : {
- title : function () { return 'Edit Choice';},
- choice : function () { return choice; }
- }
- });
-
- modalInstance.result.then(function (ch) {
- deleteChoice(ch);
- });
+ popupChoice(choice, 'Edit Choice');
}
var deleteChoice = function (ch) {
@@ -90,6 +82,21 @@
}
}
+ var popupChoice = function (choice, title) {
+ var modalInstance = $modal.open({
+ templateUrl : 'partials/poll-popupChoice.html',
+ controller : PollPopChoiceCtrl,
+ resolve : {
+ title : function () { return title;},
+ choice : function () { return choice; }
+ }
+ });
+
+ modalInstance.result.then(function (ch) {
+ deleteChoice(ch);
+ });
+ }
+
$scope.save = function () {
pollStorage.put($scope.poll);
$scope.gvar.saved = true;
@@ -97,21 +104,24 @@
$scope.reset = function () {
$scope.poll = initPoll();
+ $scope.voteChoices = $scope.poll.choices;
pollStorage.put({});
}
- $scope.toHTML = function (data) {
- return $sce.trustAsHtml(data);
- }
-
var PollPopChoiceCtrl = function ($scope, $filter, $modalInstance, title, choice) {
$scope.title = title;
$scope.choice = choice;
+ var oldChoice = angular.copy(choice);
$scope.saveChoice = function () {
$modalInstance.close();
}
+ $scope.cancelChoice = function () {
+ angular.copy(oldChoice, $scope.choice);
+ $modalInstance.close();
+ }
+
$scope.deleteChoice = function (ch) {
$modalInstance.close(ch);
}
@@ -119,24 +129,24 @@
}
}])
-.controller('PollVoteCtrl', ['$scope', '$filter', '$sce', '$timeout', 'pollStorage', function ($scope, $filter, $sce, $timeout, pollStorage) {
- $scope.gvar = {saved:false, editMode:false};
- $scope.$watch('gvar.saved', function() {
- $timeout(function () {
- $scope.gvar.saved = false;
- }, 5000);
- })
- $scope.poll = pollStorage.get();
- $scope.voteName = "";
- $scope.voteChoices = [];
- for (var i = 0; i < $scope.poll.choices.length; ++i) {
- if ($scope.poll.choices[i].type == 'text') {
- $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
- }
- else if ($scope.poll.choices[i].type == 'date') {
- $scope.voteChoices.push({name: $filter('date')($scope.poll.choices[i].date,'dd/MM/yyyy') , value:false});
- }
+.controller('PollVoteCtrl', ['$scope', '$filter', '$controller', 'pollStorage', function ($scope, $filter, $controller, pollStorage) {
+ $controller('PollCtrl', {$scope:$scope});
+
+ $scope.gvar.editMode = false;
+
+ var initVote = function () {
+ $scope.voteName = "";
+ $scope.voteChoices = [];
+ for (var i = 0; i < $scope.poll.choices.length; ++i) {
+ if ($scope.poll.choices[i].type == 'text') {
+ $scope.voteChoices.push({name:$scope.poll.choices[i].name, value:false});
+ }
+ else if ($scope.poll.choices[i].type == 'date') {
+ $scope.voteChoices.push({name: $filter('date')($scope.poll.choices[i].date,'dd/MM/yyyy') , value:false});
+ }
+ }
}
+ initVote();
$scope.vote = function () {
var data = {};
@@ -148,10 +158,7 @@
$scope.poll.votants.push(data);
pollStorage.put($scope.poll);
$scope.gvar.saved = true;
+ initVote();
}
-
- $scope.toHTML = function (data) {
- return $sce.trustAsHtml(data);
- }
}])
;
\ No newline at end of file
Added: trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-04-28 09:56:29 UTC (rev 3882)
@@ -0,0 +1,49 @@
+<form class="form-horizontal">
+ <div class="modal-header">
+ <h4 class="modal-title">{{title}}</h4>
+ {{oldChoice}}
+ </div>
+ <div class="modal-body">
+
+ <div class="form-group">
+ <label class="col-sm-4 control-label">Type de choix :</label>
+
+ <div class="col-sm-8 btn-group">
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'text'">Text</button>
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'date'">Date</button>
+ <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'picture'" disabled>Image</button>
+ </div>
+ </div>
+
+ <div class="form-group" ng-if="choice.type == 'text'">
+ <label for="popNameChoiceCheck" class="col-sm-4 control-label">Nom du Choix : </label>
+
+ <div class="col-sm-6">
+ <input id="popNameChoiceCheck" type="text" ng-model="choice.name" class="form-control" />
+ </div>
+ </div>
+
+ <div class="form-group" ng-if="choice.type == 'date'">
+ <label for="popNameChoiceDate" class="col-sm-4 control-label">Date : </label>
+
+ <div class="col-sm-6">
+ <div class="right-inner-addon ">
+ <i class="glyphicon glyphicon-calendar glyphicon-input"></i>
+ <input id="popNameChoiceDate" class="form-control" datepicker-popup="dd/MM/yyyy" type="text" ng-model="choice.date" is-open="opened"/>
+ </div>
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="popDescChoice" class="col-sm-4 control-label">Description : </label>
+
+ <div class="col-sm-6">
+ <textarea id="popDescChoice" type="text" ng-model="choice.description" class="form-control"></textarea>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-danger" ng-click="deleteChoice(choice)">Delete</button>
+ <button type="button" class="btn btn-default" ng-click="cancelChoice()">Cancel</button>
+ <button type="button" class="btn btn-primary" ng-click="saveChoice()">Save</button>
+ </div>
+</form>
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-27 17:12:24 UTC (rev 3881)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-04-28 09:56:29 UTC (rev 3882)
@@ -46,15 +46,15 @@
<td class="pollChoice"></td>
<td ng-repeat="choice in poll.choices" class="pollChoice pollAnim" edit-me="showEdit" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
<div ng-show="choice.type == 'text'">
- <div ng-hide="showEdit" title="{{choice.description}}">{{choice.name}} <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-show="gvar.editMode && showEditHover" ng-click="editChoice(choice)" value="..."/></div>
+ <div ng-hide="showEdit" class="fixe-input" title="{{choice.description}}">{{choice.name}} <input type="button" class="btn btn-default" ng-if="gvar.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
<div ng-show="showEdit">
<input type="text" class="form-control" ng-model="choice.name" focus-me="showEdit" ng-exit="showEdit = false"/>
<input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
</div>
</div>
<div ng-show="choice.type == 'date'">
- <div ng-hide="showEdit || isOpen" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}} <input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
- <div ng-show="showEdit || isOpen">
+ <div ng-hide="showEdit || isOpen" class="fixe-input" title="{{choice.description}}">{{choice.date | date:'dd/MM/yyyy'}} <input type="button" class="btn btn-default" ng-if="gvar.editMode" ng-show="showEditHover" ng-click="editChoice(choice)" value="..."/></div>
+ <div ng-show="showEdit || isOpen" >
<input type="text" class="form-control" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" is-open="isOpen" ng-exit="showEdit = false" />
<input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
</div>
@@ -91,52 +91,3 @@
</div>
</form>
-<script type="text/ng-template" id="popupChoice.html">
- <form class="form-horizontal">
- <div class="modal-header">
- <h4 class="modal-title">{{title}}</h4>
- </div>
- <div class="modal-body">
-
- <div class="form-group">
- <label class="col-sm-4 control-label">Type de choix :</label>
-
- <div class="col-sm-8 btn-group">
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'text'">Text</button>
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'date'">Date</button>
- <button type="button" class="btn btn-default" ng-model="choice.type" btn-radio="'picture'" disabled>Image</button>
- </div>
- </div>
-
- <div class="form-group" ng-if="choice.type == 'text'">
- <label for="popNameChoiceCheck" class="col-sm-4 control-label">Nom du Choix : </label>
-
- <div class="col-sm-6">
- <input id="popNameChoiceCheck" type="text" ng-model="choice.name" class="form-control" />
- </div>
- </div>
-
- <div class="form-group" ng-if="choice.type == 'date'">
- <label for="popNameChoiceDate" class="col-sm-4 control-label">Date : </label>
-
- <div class="col-sm-6">
- <div class="right-inner-addon ">
- <i class="glyphicon glyphicon-calendar glyphicon-input"></i>
- <input id="popNameChoiceDate" class="form-control" datepicker-popup="dd/MM/yyyy" type="text" ng-model="choice.date" is-open="opened"/>
- </div>
- </div>
- </div>
- <div class="form-group">
- <label for="popDescChoice" class="col-sm-4 control-label">Description : </label>
-
- <div class="col-sm-6">
- <textarea id="popDescChoice" type="text" ng-model="choice.description" class="form-control"></textarea>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="deleteChoice(choice)">delete</button>
- <button type="button" class="btn btn-primary" ng-click="saveChoice()">Save</button>
- </div>
- </form>
-</script>
1
0