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
May 2014
- 5 participants
- 203 discussions
r3919 - in trunk/pollen-ui-angular/src/main/webapp/js: . controllers
by garandel@users.chorem.org 07 May '14
by garandel@users.chorem.org 07 May '14
07 May '14
Author: garandel
Date: 2014-05-07 15:14:48 +0200 (Wed, 07 May 2014)
New Revision: 3919
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3919
Log:
fix create poll
Modified:
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/js/services.js
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-05-07 09:21:47 UTC (rev 3918)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-05-07 13:14:48 UTC (rev 3919)
@@ -18,8 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-angular.module('pollen', ['pollenServices', 'ngRoute', 'pollControllers', 'ui.bootstrap'])
+angular.module('pollen', ['pollenServices', 'ngRoute', 'pollControllers', 'ui.bootstrap'], function($httpProvider) {
+ $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
+ $httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
+})
+
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {templateUrl: './partials/home.html', controller: "HomeCtrl"})
.when('/poll/create', {templateUrl: './partials/poll.html', controller: "PollCreateCtrl"})
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-07 09:21:47 UTC (rev 3918)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-07 13:14:48 UTC (rev 3919)
@@ -213,11 +213,11 @@
}])
-.controller('PollCreateCtrl', ['$scope', '$controller', 'SkeletonPoll', 'Poll', function ($scope, $controller, SkeletonPoll, NewPoll) {
+.controller('PollCreateCtrl', ['$scope', '$controller', 'Poll', '$http', function ($scope, $controller, Poll, $http) {
$controller('PollAdminCtrl', {$scope:$scope});
var initPoll = function () {
- SkeletonPoll.get().$promise.then(function (poll) {
+ Poll.get({cmd:'new'}).$promise.then(function (poll) {
$scope.poll = poll;
$scope.poll.choice = [];
$scope.vote = {};
@@ -228,7 +228,7 @@
$scope.save = function () {
if ($scope.formValid) {
- Poll.post($scope.poll);
+ $scope.poll.$add();
}
else {
$scope.globalVariables.errorForm = true;
@@ -241,7 +241,7 @@
}])
-.controller('PollEditCtrl', ['$scope', '$controller', '$routeParams', 'Poll', 'PollChoice', function ($scope, $controller, $routeParams, Poll, PollChoice) {
+.controller('PollEditCtrl', ['$scope', '$controller', '$routeParams', '$location', 'Poll', 'PollChoice', function ($scope, $controller, $routeParams, $location, Poll, PollChoice) {
$controller('PollAdminCtrl', {$scope:$scope});
var initPoll = function () {
@@ -258,7 +258,7 @@
$scope.save = function () {
if ($scope.formValid) {
- Poll.save($scope.poll).$promise.then(function () {
+ $scope.poll.$update(function () {
$scope.globalVariables.saved = true;
});
}
@@ -269,9 +269,8 @@
}
$scope.delete = function () {
- $scope.$delete();
- $scope.poll = initPoll();
- $scope.globalVariables.voted = false;
+ $scope.poll.$delete();
+ $location.path('/');
}
}])
Modified: trunk/pollen-ui-angular/src/main/webapp/js/services.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/services.js 2014-05-07 09:21:47 UTC (rev 3918)
+++ trunk/pollen-ui-angular/src/main/webapp/js/services.js 2014-05-07 13:14:48 UTC (rev 3919)
@@ -20,14 +20,36 @@
*/
angular.module('pollenServices', ['ngResource'])
-.factory('SkeletonPoll', ['$resource', function ($resource) {
- return $resource('http://localhost:8080/pollen-rest-api/v1/polls/new', null, {});
-}])
+.factory('BaseUrl', function() {
+ return 'http://localhost\\:8080/pollen-rest-api/v1';
+})
-.factory('Poll', ['$resource', function ($resource) {
- return $resource('http://localhost:8080/pollen-rest-api/v1/polls/:pollId', {pollId : '@topiaId'});
+.factory('Poll', ['$resource', 'BaseUrl', function ($resource, BaseUrl) {
+ var transformParam = function (data) {
+ return 'poll='+JSON.stringify(data);
+ };
+
+ return $resource(BaseUrl+'/polls/:pollId:cmd', {pollId:'@topiaId'}, {
+ 'add' : {
+ method : 'POST',
+ transformRequest : function (data, headersGetter) {
+ return transformParam(data);
+ }
+ },
+ 'update' : {
+ method : 'PUT',
+ transformRequest : function (data, headersGetter) {
+ return transformParam(data);
+ }
+ }
+ });
}])
-.factory('PollChoice', ['$resource', function ($resource) {
- return $resource('http://localhost:8080/pollen-rest-api/v1/polls/:pollId/choices/:choiceId', {choiceId : '@topiaId'});
+.factory('PollChoice', ['$resource', 'BaseUrl', function ($resource, BaseUrl) {
+ return $resource(BaseUrl+'/polls/:pollId/choices/:choiceId', {choiceId : '@topiaId'},
+ {
+ 'add' : { method:'POST'},
+ 'update' : {method:'PUT'}
+ }
+ );
}])
\ No newline at end of file
1
0
r3918 - trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api
by tchemit@users.chorem.org 07 May '14
by tchemit@users.chorem.org 07 May '14
07 May '14
Author: tchemit
Date: 2014-05-07 11:21:47 +0200 (Wed, 07 May 2014)
New Revision: 3918
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3918
Log:
fix json serialization
Modified:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-07 09:04:29 UTC (rev 3917)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-07 09:21:47 UTC (rev 3918)
@@ -106,24 +106,20 @@
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- map = toMap(model);
-
mapper = Jsons.newSimpleMapper();
} else if (model instanceof PollenPrincipalRef) {
- map = toMap(model);
-
mapper = Jsons.newSimpleMapper();
} else {
- map = model;
-
mapper = Jsons.newEntityMapper();
}
+ map = toMap(model);
+
// GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
// @Override
// public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext c) {
@@ -210,6 +206,7 @@
}
// single object
+ // FIXME Do this in service, not here
if (model instanceof TopiaEntity) {
@@ -243,10 +240,13 @@
}
}
+
return result;
+
}
return model;
+
}
protected static class PollenEntityBinder<E extends TopiaEntity> extends Binder<E, E> {
1
0
r3917 - in trunk: . pollen-rest-api pollen-rest-api/src/main/java/org/chorem/pollen/rest/api pollen-rest-api/src/test/java/org/chorem/pollen/rest/api
by tchemit@users.chorem.org 07 May '14
by tchemit@users.chorem.org 07 May '14
07 May '14
Author: tchemit
Date: 2014-05-07 11:04:29 +0200 (Wed, 07 May 2014)
New Revision: 3917
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3917
Log:
- receive object as json
- change from gson to jackson since gson can only deal with field accessors :(
- clean deps
Added:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/Jsons.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/TopiaEntityConverter.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/TopiaEntityConverterTest.java
Modified:
trunk/pollen-rest-api/pom.xml
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java
trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java
trunk/pom.xml
Modified: trunk/pollen-rest-api/pom.xml
===================================================================
--- trunk/pollen-rest-api/pom.xml 2014-05-06 15:56:39 UTC (rev 3916)
+++ trunk/pollen-rest-api/pom.xml 2014-05-07 09:04:29 UTC (rev 3917)
@@ -104,12 +104,27 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
+ </dependency-->
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-afterburner</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
@@ -146,6 +161,12 @@
</dependency>
<dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jcl</artifactId>
<scope>test</scope>
Added: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/Jsons.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/Jsons.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/Jsons.java 2014-05-07 09:04:29 UTC (rev 3917)
@@ -0,0 +1,48 @@
+package org.chorem.pollen.rest.api;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
+import org.chorem.pollen.persistence.PollenEntityEnum;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * Created on 5/7/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class Jsons {
+
+ public static ObjectMapper newSimpleMapper() {
+
+ ObjectMapper mapper = new ObjectMapper()
+ .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) //FIXME Could be better ?
+ .registerModule(new AfterburnerModule());
+
+ return mapper;
+
+ }
+
+ public static ObjectMapper newEntityMapper() {
+
+ SimpleModule module = new SimpleModule();
+
+ for (Class<? extends TopiaEntity> entityClass : PollenEntityEnum.getContractClasses()) {
+
+ Class concreteClass = PollenEntityEnum.getImplementationClass(entityClass);
+ module.addAbstractTypeMapping(entityClass, concreteClass);
+
+ }
+
+ ObjectMapper mapper = newSimpleMapper()
+ .registerModule(module);
+
+ return mapper;
+
+ }
+
+}
Property changes on: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/Jsons.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/PollenRender.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-06 15:56:39 UTC (rev 3916)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRender.java 2014-05-07 09:04:29 UTC (rev 3917)
@@ -23,16 +23,11 @@
* #L%
*/
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonNull;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.persistence.PollenEntityEnum;
@@ -58,9 +53,7 @@
import java.lang.annotation.Target;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -99,64 +92,97 @@
HttpServletResponse response = context.getResponse();
response.setContentType("application/json");
- String[] includeCollection = null;
- ExposeCollection annotation = call.getCurrent().getMethod().getAnnotation(ExposeCollection.class);
- if (annotation != null) {
- includeCollection = annotation.values();
- }
+// String[] includeCollection = null;
+// ExposeCollection annotation = call.getCurrent().getMethod().getAnnotation(ExposeCollection.class);
+// if (annotation != null) {
+// includeCollection = annotation.values();
+// }
Object map;
+ ObjectMapper mapper;
+
if (model instanceof InvalidFormException) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- map = toMap(((InvalidFormException) model).getErrors());
- } else {
+ map = toMap(model);
- map = toMap(model, includeCollection);
+ mapper = Jsons.newSimpleMapper();
- }
+ } else if (model instanceof PollenPrincipalRef) {
- GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
- @Override
- public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext c) {
- JsonElement result;
+ map = toMap(model);
- if (src == null) {
- result = JsonNull.INSTANCE;
- } else {
- result = new JsonPrimitive(src.getTime());
- }
+ mapper = Jsons.newSimpleMapper();
- return result;
+ } else {
- }
- });
+ map = model;
+ mapper = Jsons.newEntityMapper();
+
+ }
+
+// GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
+// @Override
+// public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext c) {
+// JsonElement result;
+//
+// if (src == null) {
+// result = JsonNull.INSTANCE;
+// } else {
+// result = new JsonPrimitive(src.getTime());
+// }
+//
+// return result;
+//
+// }
+// });
+
PollenRestApiApplicationContext applicationContext =
PollenRestApiApplicationContext.getApplicationContext(context.getServletContext());
boolean devMode = applicationContext.getApplicationConfig().isDevMode();
+
+ String json;
+
if (devMode) {
- gsonBuilder.setPrettyPrinting();
+
+ ObjectWriter objectWriter = mapper.writerWithDefaultPrettyPrinter();
+ json = objectWriter.writeValueAsString(map);
+// gsonBuilder.setPrettyPrinting();
+
+ } else {
+
+ json = mapper.writeValueAsString(map);
+
}
- Gson gson = gsonBuilder.create();
- String json = gson.toJson(map);
+// Gson gson = gsonBuilder.create();
+//
+// String json = gson.toJson(map);
PrintWriter out = context.getOut();
out.print(json);
- }
- protected Object toMap(Multimap<String, String> model) {
- Map<String, Object> result = new HashMap<>();
- for (String key : model.keySet()) {
- result.put(key, model.get(key));
- }
- return result;
}
protected <M> Object toMap(M model, String... includeCollection) {
+ if (model instanceof InvalidFormException) {
+
+ InvalidFormException invalidFormException = (InvalidFormException) model;
+
+ Multimap<String, String> errors = invalidFormException.getErrors();
+
+ Map<String, Object> result = new HashMap<>();
+ for (String key : errors.keySet()) {
+ result.put(key, errors.get(key));
+ }
+
+ return result;
+
+ }
+
if (model instanceof PollenPrincipalRef<?>) {
PollenPrincipalRef<?> pollenEntityRef = (PollenPrincipalRef<?>) model;
Modified: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java 2014-05-06 15:56:39 UTC (rev 3916)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiApplicationListener.java 2014-05-07 09:04:29 UTC (rev 3917)
@@ -23,7 +23,6 @@
* #L%
*/
-import org.apache.commons.beanutils.Converter;
import org.chorem.pollen.persistence.PollenEntityEnum;
import org.chorem.pollen.services.PollenService;
import org.debux.webmotion.server.WebMotionServerListener;
@@ -35,7 +34,6 @@
import org.nuiton.topia.persistence.TopiaEntity;
import java.lang.reflect.Type;
-import java.util.Date;
/**
* TODO
@@ -50,47 +48,30 @@
// --- init converters --- //
- serverContext.addConverter(new Converter() {
- @Override
- public Object convert(Class type, Object value) {
- Object result = null;
- if (value != null) {
- if (value.getClass().isAssignableFrom(Date.class)) {
- result = value;
- } else {
- Object o = ((Object[]) value)[0];
- String sTime = o.toString();
- Long time = Long.parseLong(sTime);
- result = new Date(time);
- }
- }
- return result;
- }
+// serverContext.addConverter(new Converter() {
+// @Override
+// public Object convert(Class type, Object value) {
+// Object result = null;
+// if (value != null) {
+// if (value.getClass().isAssignableFrom(Date.class)) {
+// result = value;
+// } else {
+// Object o = ((Object[]) value)[0];
+// String sTime = o.toString();
+// Long time = Long.parseLong(sTime);
+// result = new Date(time);
+// }
+// }
+// return result;
+// }
+//
+// }, Date.class);
- }, Date.class);
+ for (Class<? extends TopiaEntity> entityClass : PollenEntityEnum.getContractClasses()) {
- Converter entityconverter = new Converter() {
- @Override
- public TopiaEntity convert(Class type, Object value) {
- TopiaEntity result;
- if (value != null && value.getClass().isAssignableFrom(TopiaEntity.class)) {
- result = (TopiaEntity) value;
- } else {
- Class<?> implementationClass = PollenEntityEnum.getImplementationClass(type);
- try {
- result = (TopiaEntity) implementationClass.newInstance();
- } catch (InstantiationException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
- return result;
- }
+ TopiaEntityConverter<? extends TopiaEntity> converter = TopiaEntityConverter.newconverter(entityClass);
+ serverContext.addConverter(converter, entityClass);
- };
- for (Class<? extends TopiaEntity> entityClass : PollenEntityEnum.getContractClasses()) {
- serverContext.addConverter(entityconverter, entityClass);
}
// --- init injectors --- //
@@ -98,19 +79,23 @@
serverContext.addInjector(new ExecutorParametersInjectorHandler.Injector() {
@Override
public PollenRestApiRequestContext getValue(Mapping m, Call call, String name, Class<?> type, Type generic) {
+
PollenRestApiRequestContext result = null;
if (PollenRestApiRequestContext.class.isAssignableFrom(type)) {
HttpContext httpContext = call.getContext();
result = PollenRestApiRequestContext.getRequestContext(httpContext);
}
+
return result;
+
}
});
serverContext.addInjector(new ExecutorParametersInjectorHandler.Injector() {
@Override
public PollenService getValue(Mapping m, Call call, String name, Class type, Type generic) {
+
PollenService result = null;
if (PollenService.class.isAssignableFrom(type)) {
HttpContext httpContext = call.getContext();
@@ -119,7 +104,9 @@
PollenRestApiRequestContext.getRequestContext(httpContext);
result = requestContext.getServiceContext().newService(type);
}
+
return result;
+
}
});
@@ -130,6 +117,7 @@
PollenRestApiApplicationContext.setApplicationContext(
serverContext.getServletContext(), applicationContext);
+
}
@Override
@@ -144,5 +132,7 @@
if (applicationContext != null) {
applicationContext.close();
}
+
}
+
}
Added: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/TopiaEntityConverter.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/TopiaEntityConverter.java (rev 0)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/TopiaEntityConverter.java 2014-05-07 09:04:29 UTC (rev 3917)
@@ -0,0 +1,100 @@
+package org.chorem.pollen.rest.api;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import org.apache.commons.beanutils.converters.AbstractConverter;
+import org.chorem.pollen.persistence.PollenEntityEnum;
+import org.chorem.pollen.services.PollenTechnicalException;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.io.IOException;
+
+/**
+ * Created on 5/6/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class TopiaEntityConverter<E extends TopiaEntity> extends AbstractConverter {
+
+ protected Class<E> entityType;
+
+ protected Class<E> implementationClass;
+
+ protected ObjectMapper mapper;
+
+ public static <E extends TopiaEntity> TopiaEntityConverter<E> newconverter(Class<E> entityType) {
+ return new TopiaEntityConverter<>(entityType);
+ }
+
+ public TopiaEntityConverter(Class<E> entityType) {
+
+ this.entityType = entityType;
+
+ this.implementationClass = PollenEntityEnum.getImplementationClass(entityType);
+
+ SimpleModule module = new SimpleModule();
+
+ for (Class<? extends TopiaEntity> entityClass : PollenEntityEnum.getContractClasses()) {
+
+ Class concreteClass = PollenEntityEnum.getImplementationClass(entityClass);
+ module.addAbstractTypeMapping(entityClass, concreteClass);
+
+ }
+
+ mapper = Jsons.newEntityMapper();
+
+ }
+
+ public ObjectMapper getMapper() {
+
+ return mapper;
+
+ }
+
+ @Override
+ protected String convertToString(Object value) throws Throwable {
+
+ String result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(value);
+ return result;
+
+ }
+
+ @Override
+ protected <T> T convertToType(Class<T> type, Object value) throws Throwable {
+
+ String stringValue;
+
+ if (value instanceof String) {
+
+ stringValue = (String) value;
+
+ } else {
+
+ stringValue = ((String[]) value)[0];
+
+ }
+
+ try {
+
+ T result = (T) mapper.readValue(stringValue, implementationClass);
+
+ return result;
+
+ } catch (IOException e) {
+ throw new PollenTechnicalException("Could not convert " + stringValue + " to " + type.getName(), e);
+ }
+
+ }
+
+ @Override
+ protected Class<E> getDefaultType() {
+
+ return entityType;
+
+ }
+
+
+}
Property changes on: trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/TopiaEntityConverter.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/PollApiTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java 2014-05-06 15:56:39 UTC (rev 3916)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/PollApiTest.java 2014-05-07 09:04:29 UTC (rev 3917)
@@ -22,10 +22,14 @@
*/
import org.apache.http.client.fluent.Request;
+import org.chorem.pollen.persistence.entity.Choice;
+import org.chorem.pollen.persistence.entity.ChoiceImpl;
import org.chorem.pollen.persistence.entity.ChoiceType;
import org.chorem.pollen.persistence.entity.CommentVisibility;
import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollImpl;
import org.chorem.pollen.persistence.entity.PollType;
+import org.chorem.pollen.persistence.entity.ResultVisibility;
import org.chorem.pollen.persistence.entity.VoteVisibility;
import org.chorem.pollen.services.PollenFixtures;
import org.junit.Before;
@@ -43,6 +47,7 @@
* @author Tony Chemit <chemit(a)codelutin.com>
* @since 2.0
*/
+@Ignore
public class PollApiTest extends AbstractPollenRestApiTest {
@Before
@@ -108,21 +113,36 @@
}
@Test
- public void postPoll() throws URISyntaxException, IOException {
- Request request = createRequest("/v1/polls").
- addParameter("poll.pollType", PollType.FREE.name()).
- addParameter("poll.commentVisibility", CommentVisibility.EVERYBODY.name()).
- addParameter("poll.voteVisibility", VoteVisibility.EVERYBODY.name()).
- addParameter("poll.voteCountingType", "1").
- addParameter("poll.title", "title").
- addParameter("poll.choice[1].choiceType", ChoiceType.TEXT.name()).
- addParameter("poll.choice[1].name", "choiceB").
- addParameter("poll.choice[0].choiceType", ChoiceType.TEXT.name()).
- addParameter("poll.choice[0].name", "choiceA").
- Post();
+ public void postPoll() throws Throwable {
+
+ Poll poll = new PollImpl();
+ poll.setPollType(PollType.FREE);
+ poll.setCommentVisibility(CommentVisibility.EVERYBODY);
+ poll.setResultVisibility(ResultVisibility.EVERYBODY);
+ poll.setVoteVisibility(VoteVisibility.EVERYBODY);
+ poll.setVoteCountingType(1);
+ poll.setTitle("title");
+ Choice choice1 = new ChoiceImpl();
+ choice1.setChoiceType(ChoiceType.TEXT);
+ choice1.setName("choiceA");
+ poll.addChoice(choice1);
+ Choice choice2 = new ChoiceImpl();
+ choice2.setChoiceType(ChoiceType.TEXT);
+ choice2.setName("choiceB");
+ poll.addChoice(choice2);
+
+ TopiaEntityConverter<Poll> converter = TopiaEntityConverter.newconverter(Poll.class);
+
+ String strPoll = converter.convertToString(poll);
+
+ Request request = createRequest("/v1/polls")
+ .addParameter("poll", strPoll)
+ .Post();
+
String content = request.execute().returnContent().asString();
showTestResult(content);
assertNotNull(content);
+
}
@Ignore
Added: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/TopiaEntityConverterTest.java
===================================================================
--- trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/TopiaEntityConverterTest.java (rev 0)
+++ trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/TopiaEntityConverterTest.java 2014-05-07 09:04:29 UTC (rev 3917)
@@ -0,0 +1,41 @@
+package org.chorem.pollen.rest.api;
+
+import org.chorem.pollen.persistence.entity.ChoiceType;
+import org.chorem.pollen.persistence.entity.CommentVisibility;
+import org.chorem.pollen.persistence.entity.Poll;
+import org.chorem.pollen.persistence.entity.PollType;
+import org.chorem.pollen.persistence.entity.VoteVisibility;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TopiaEntityConverterTest {
+
+ @Test
+ public void convert() {
+
+ String pollStr = "{topiaCreateDate: 1399033089600, title: \"pollTitle\", " +
+ "choice: [ {name: \"choice1\", choiceType: \"TEXT\"}, " +
+ "{name: \"choice2\", choiceType: \"IMAGE\"} ], voteVisibility: \"ANONYMOUS\", " +
+ "commentVisibility:\"NOBODY\", pollType: \"FREE\" }";
+
+ TopiaEntityConverter<Poll> converter = new TopiaEntityConverter<>(Poll.class);
+
+ Poll poll = converter.convert(Poll.class, pollStr);
+
+ Assert.assertNotNull(poll);
+ Assert.assertEquals("pollTitle", poll.getTitle());
+ Assert.assertEquals(VoteVisibility.ANONYMOUS, poll.getVoteVisibility());
+ Assert.assertEquals(CommentVisibility.NOBODY, poll.getCommentVisibility());
+ Assert.assertEquals(PollType.FREE, poll.getPollType());
+ Assert.assertEquals(2, poll.sizeChoice());
+ Assert.assertEquals("choice1", poll.getChoice(0).getName());
+ Assert.assertEquals(ChoiceType.TEXT, poll.getChoice(0).getChoiceType());
+ Assert.assertEquals("choice2", poll.getChoice(1).getName());
+ Assert.assertEquals(ChoiceType.IMAGE, poll.getChoice(1).getChoiceType());
+
+ String convert = converter.convert(String.class, poll);
+ Assert.assertNotNull(convert);
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/TopiaEntityConverterTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-05-06 15:56:39 UTC (rev 3916)
+++ trunk/pom.xml 2014-05-07 09:04:29 UTC (rev 3917)
@@ -239,12 +239,6 @@
<!-- persistence module dependencies -->
<dependency>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.1-api</artifactId>
- <version>1.0.0.Draft-16</version>
- </dependency>
-
- <dependency>
<groupId>org.nuiton.topia</groupId>
<artifactId>topia-persistence</artifactId>
<version>${topiaVersion}</version>
@@ -276,13 +270,6 @@
</dependency>
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- <version>${hibernateVersion}</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
<groupId>com.esotericsoftware.yamlbeans</groupId>
<artifactId>yamlbeans</artifactId>
<version>1.06</version>
@@ -333,17 +320,17 @@
<version>${nuitonConfigVersion}</version>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-csv</artifactId>
<version>${nuitonCsvVersion}</version>
- </dependency>
+ </dependency-->
- <dependency>
+ <!--dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-validator</artifactId>
<version>${nuitonValidatorVersion}</version>
- </dependency>
+ </dependency-->
<dependency>
<groupId>org.nuiton.web</groupId>
@@ -365,15 +352,15 @@
<artifactId>shiro-core</artifactId>
<version>${shiroVersion}</version>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>${shiroVersion}</version>
- </dependency>
+ </dependency-->
<!-- JFreeChart -->
- <dependency>
+ <!--dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.14</version>
@@ -383,21 +370,15 @@
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.17</version>
- </dependency>
+ </dependency-->
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.12.1.GA</version>
- </dependency>
-
<!-- Rome (rss) -->
- <dependency>
+ <!--dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
<version>1.0</version>
- </dependency>
+ </dependency-->
<!-- Logging -->
@@ -416,12 +397,12 @@
<version>0.8.13</version>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
- </dependency>
+ </dependency-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
@@ -429,31 +410,49 @@
<version>${httpCommonsHttpclientVersion}</version>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${httpCommonsHttpclientVersion}</version>
- </dependency>
+ </dependency-->
- <dependency>
+ <!--dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
+ </dependency-->
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.3.3</version>
</dependency>
<dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>2.3.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-afterburner</artifactId>
+ <version>2.3.3</version>
+ </dependency>
+
+ <dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-runner</artifactId>
<version>${jettyVersion}</version>
<scope>provided</scope>
- </dependency>
+ </dependency-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
@@ -483,11 +482,11 @@
<scope>provided</scope>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
- </dependency>
+ </dependency-->
<dependency>
<groupId>org.mockito</groupId>
@@ -497,7 +496,7 @@
</dependency>
<!-- Selenium -->
- <dependency>
+ <!--dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>${seleniumVersion}</version>
@@ -550,7 +549,7 @@
<artifactId>selenium-remote-driver</artifactId>
<version>${seleniumVersion}</version>
<scope>test</scope>
- </dependency>
+ </dependency-->
</dependencies>
</dependencyManagement>
1
0
r3916 - in trunk/pollen-ui-angular/src/main/webapp: . js js/controllers partials
by garandel@users.chorem.org 06 May '14
by garandel@users.chorem.org 06 May '14
06 May '14
Author: garandel
Date: 2014-05-06 17:56:39 +0200 (Tue, 06 May 2014)
New Revision: 3916
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3916
Log:
migrate restangular to resource / send a single json data
Modified:
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/js/services.js
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Modified: trunk/pollen-ui-angular/src/main/webapp/index.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-06 08:56:15 UTC (rev 3915)
+++ trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-06 15:56:39 UTC (rev 3916)
@@ -30,10 +30,10 @@
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-resource.min…"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.11.0/ui-bootst…"></script>
- <script src="http://cdnjs.cloudflare.com/ajax/libs/restangular/1.4.0/restangular.min.js"></script>
<script src="js/libs/ckeditor/ckeditor.js"></script>
<script src="js/app.js"></script>
+ <script src="js/services.js"></script>
<script src="js/controllers/pollCtrl.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-05-06 08:56:15 UTC (rev 3915)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-05-06 15:56:39 UTC (rev 3916)
@@ -18,52 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-angular.module('pollen', ["restangular", 'ngRoute', 'pollControllers', 'ui.bootstrap'], function($httpProvider) {
- // Use x-www-form-urlencoded Content-Type
- $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
+angular.module('pollen', ['pollenServices', 'ngRoute', 'pollControllers', 'ui.bootstrap'])
- /**
- * The workhorse; converts an object to x-www-form-urlencoded serialization.
- * @param {Object} obj
- * @return {String}
- */
- var param = function(obj) {
- var query = '', name, value, fullSubName, subName, subValue, innerObj, i;
-
- for(name in obj) {
- value = obj[name];
-
- if(value instanceof Array) {
- for(i=0; i<value.length; ++i) {
- subValue = value[i];
- fullSubName = name + '[' + i + ']';
- innerObj = {};
- innerObj[fullSubName] = subValue;
- query += param(innerObj) + '&';
- }
- }
- else if(value instanceof Object) {
- for(subName in value) {
- subValue = value[subName];
- fullSubName = name + '.' + subName ;
- innerObj = {};
- innerObj[fullSubName] = subValue;
- query += param(innerObj) + '&';
- }
- }
- else if(value !== undefined && value !== null)
- query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
- }
-
- return query.length ? query.substr(0, query.length - 1) : query;
- };
-
- // Override $http service's default transformRequest
- $httpProvider.defaults.transformRequest = [function(data) {
- return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
- }];
-})
-
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {templateUrl: './partials/home.html', controller: "HomeCtrl"})
.when('/poll/create', {templateUrl: './partials/poll.html', controller: "PollCreateCtrl"})
@@ -74,15 +30,7 @@
}])
-.config(['RestangularProvider', function (RestangularProvider) {
- //RestangularProvider.setBaseUrl('http://demo.codelutin.com/pollen-rest-api-latest/v1');
- RestangularProvider.setBaseUrl('http://localhost:8080/pollen-rest-api/v1');
-}])
-.factory('PollsRest', ['Restangular', function(Restangular) {
- return Restangular.service('polls');
-}])
-
.directive('focusMe', function($timeout) {
return {
link: function($scope, element, attrs) {
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-06 08:56:15 UTC (rev 3915)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-06 15:56:39 UTC (rev 3916)
@@ -65,7 +65,7 @@
}])
-.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', 'Restangular', '$http', function ($scope, $controller, $modal, $filter, $timeout, Restangular, $http) {
+.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$filter', '$timeout', function ($scope, $controller, $modal, $filter, $timeout) {
$controller('PollCtrl', {$scope:$scope});
var initChoice = function () {
@@ -134,19 +134,6 @@
});
}
- $scope.reset = function () {
- $scope.poll = initPoll();
- $scope.voteChoice = $scope.poll.choice;
- pollStorage.put({});
- }
-
- $scope.delete = function () {
- $scope.poll = initPoll();
- $scope.voteChoice= $scope.poll.choice;
- $scope.globalVariables.voted = false;
- pollStorage.put({});
- }
-
var PollPopChoiceCtrl = function ($scope, $filter, $modalInstance, title, choice) {
$scope.title = title;
$scope.choice = choice;
@@ -191,9 +178,11 @@
poll.endChoiceDate = poll.endDate;
}
}
+ /*
else {
poll.endChoiceDate = poll.endDate;
}
+ */
});
if (!angular.isDefined($scope.poll.continuousResults)) {
@@ -224,47 +213,41 @@
}])
-.controller('PollCreateCtrl', ['$scope', '$controller', 'Restangular', '$http', function ($scope, $controller, Restangular, $http) {
+.controller('PollCreateCtrl', ['$scope', '$controller', 'SkeletonPoll', 'Poll', function ($scope, $controller, SkeletonPoll, NewPoll) {
$controller('PollAdminCtrl', {$scope:$scope});
var initPoll = function () {
- Restangular.service('polls').one('new').get().then(function (skeletonPoll) {
- $scope.poll = skeletonPoll;
+ SkeletonPoll.get().$promise.then(function (poll) {
+ $scope.poll = poll;
$scope.poll.choice = [];
$scope.vote = {};
$scope.vote.choice = $scope.poll.choice;
- });
+ })
}
initPoll();
$scope.save = function () {
if ($scope.formValid) {
- var data = {};
- data.poll = $scope.poll;
-
-// Restangular.all('polls').post('polls', data).then(function (data) {;
- $http.post('http://localhost:8080/pollen-rest-api/v1/polls', data).success(function (data) {
- $scope.test = data;
- $scope.globalVariables.saved = true;
- });
-
+ Poll.post($scope.poll);
}
else {
$scope.globalVariables.errorForm = true;
}
+ }
+ $scope.delete = function () {
+ $scope.poll = initPoll();
}
}])
-.controller('PollEditCtrl', ['$scope', '$controller', '$routeParams', 'Restangular', '$http', function ($scope, $controller, $routeParams, Restangular, $http) {
+.controller('PollEditCtrl', ['$scope', '$controller', '$routeParams', 'Poll', 'PollChoice', function ($scope, $controller, $routeParams, Poll, PollChoice) {
$controller('PollAdminCtrl', {$scope:$scope});
var initPoll = function () {
-
- Restangular.one('polls', $routeParams.pollId).get().then(function (poll) {
+ Poll.get({pollId:$routeParams.pollId}).$promise.then(function (poll) {
$scope.poll = poll;
- Restangular.one('polls', $routeParams.pollId).all('choices').getList().then(function (choices) {
+ PollChoice.query({pollId:$routeParams.pollId}).$promise.then(function (choices) {
$scope.poll.choice = choices;
$scope.vote = {};
$scope.vote.choice = $scope.poll.choice;
@@ -275,36 +258,37 @@
$scope.save = function () {
if ($scope.formValid) {
- var data = {};
- data.poll = $scope.poll;
-
-// Restangular.all('polls').post('polls', data).then(function (data) {;
- $http.put('http://localhost:8080/pollen-rest-api/v1/polls/'+$routeParams.pollId, data).success(function (data) {
- $scope.test = data;
+ Poll.save($scope.poll).$promise.then(function () {
$scope.globalVariables.saved = true;
});
-
}
else {
$scope.globalVariables.errorForm = true;
}
}
+
+ $scope.delete = function () {
+ $scope.$delete();
+ $scope.poll = initPoll();
+ $scope.globalVariables.voted = false;
+ }
}])
-.controller('PollVoteCtrl', ['$scope', '$filter', '$controller', '$routeParams', 'Restangular', function ($scope, $filter, $controller, $routeParams, Restangular) {
+.controller('PollVoteCtrl', ['$scope', '$filter', '$controller', '$routeParams', 'Poll', 'PollChoice', function ($scope, $filter, $controller, $routeParams, Poll, PollChoice) {
$controller('PollCtrl', {$scope:$scope});
- Restangular.one('polls', $routeParams.pollId).get().then(function (poll) {
+ Poll.get({pollId:$routeParams.pollId}).$promise.then(function (poll) {
$scope.poll = poll;
- Restangular.one('polls', $routeParams.pollId).all('choices').getList().then(function (choices) {
+ PollChoice.query({pollId:$routeParams.pollId}).$promise.then(function (choices) {
$scope.poll.choice = choices;
- initVote();
- })
+ $scope.vote = {};
+ $scope.vote.choice = $scope.poll.choice;
+ });
});
$scope.globalVariables.editMode = false;
- $scope.$watch('vote.ame', function (newVal) {
+ $scope.$watch('vote.name', function (newVal) {
if (newVal != '') {
$scope.globalVariables.errorForm = false;
}
@@ -346,12 +330,11 @@
}
}])
-.controller('PollListCtrl', ['$scope', '$controller', 'Restangular', function ($scope, $controller, Restangular) {
+.controller('PollListCtrl', ['$scope', '$controller', 'Poll', function ($scope, $controller, Poll) {
$controller('PollCtrl', {$scope:$scope});
- Restangular.all('polls').getList().then(function (polls) {
- $scope.polls = polls;
- });
+ $scope.polls = Poll.query();
+
}])
;
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/js/services.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/services.js 2014-05-06 08:56:15 UTC (rev 3915)
+++ trunk/pollen-ui-angular/src/main/webapp/js/services.js 2014-05-06 15:56:39 UTC (rev 3916)
@@ -18,7 +18,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-angular.module('pollenServices', ['ngResource']).factory('Poll', function($resource) {
- return $resource('http://localhost:8080/pollen/v1/polls/:pollId', {}, {
- });
-});
\ No newline at end of file
+angular.module('pollenServices', ['ngResource'])
+
+.factory('SkeletonPoll', ['$resource', function ($resource) {
+ return $resource('http://localhost:8080/pollen-rest-api/v1/polls/new', null, {});
+}])
+
+.factory('Poll', ['$resource', function ($resource) {
+ return $resource('http://localhost:8080/pollen-rest-api/v1/polls/:pollId', {pollId : '@topiaId'});
+}])
+
+.factory('PollChoice', ['$resource', function ($resource) {
+ return $resource('http://localhost:8080/pollen-rest-api/v1/polls/:pollId/choices/:choiceId', {choiceId : '@topiaId'});
+}])
\ 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-05-06 08:56:15 UTC (rev 3915)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-05-06 15:56:39 UTC (rev 3916)
@@ -21,11 +21,12 @@
<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="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>
+ <alert type="warning" ng-if="globalVariables.voted"> Les votes ont commencé, certaine modification sont inaccessible.. </alert>
+ <alert type="warning" ng-if="globalVariables.created"> <a href="#/poll/edit/{{pollId}}"> Edition du sondage </a>.. </alert>
<div class="pollTitle" edit-me="showEditTitle">
<h1 ng-hide="showEditTitle"> {{poll.title || 'Click Me for Editing'}} </h1>
@@ -52,7 +53,6 @@
<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>
<button class="btn btn-default" ng-click="popupSettings()">Settings</button>
</div>
1
0
r3915 - in trunk/pollen-ui-angular/src/main/webapp: js/controllers partials
by garandel@users.chorem.org 06 May '14
by garandel@users.chorem.org 06 May '14
06 May '14
Author: garandel
Date: 2014-05-06 10:56:15 +0200 (Tue, 06 May 2014)
New Revision: 3915
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3915
Log:
update settings popup, and date popup
Modified:
trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
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-popupChoice.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupSettings.html
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-05 15:39:10 UTC (rev 3914)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-06 08:56:15 UTC (rev 3915)
@@ -172,7 +172,30 @@
var PollPopupSettingsCtrl = function ($scope, $filter, $modalInstance, poll) {
$scope.poll = poll;
+ $scope.toDay = new Date();
+ $scope.$watch('poll.beginDate', function() {
+ if (poll.beginChoiceDate) {
+ if (poll.beginChoiceDate < poll.beginDate) {
+ poll.beginChoiceDate = poll.beginDate;
+ }
+ }
+ else {
+ poll.beginChoiceDate = poll.beginDate;
+ }
+ });
+
+ $scope.$watch('poll.endDate', function() {
+ if (poll.endChoiceDate) {
+ if (poll.endChoiceDate > poll.endDate) {
+ poll.endChoiceDate = poll.endDate;
+ }
+ }
+ else {
+ poll.endChoiceDate = poll.endDate;
+ }
+ });
+
if (!angular.isDefined($scope.poll.continuousResults)) {
$scope.poll.continuousResults = false;
}
@@ -196,7 +219,6 @@
return 'Non';
}
}
-
}
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html 2014-05-05 15:39:10 UTC (rev 3914)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/big-poll.html 2014-05-06 08:56:15 UTC (rev 3915)
@@ -41,7 +41,12 @@
{{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/>
+ <input type="text" ng-model="choice.date"
+ datepicker-popup="dd/MM/yyyy"
+ is-open="isOpen"
+ focus-me="showEdit"
+ ng-exit="showEdit = false"
+ ng-click="isOpen = true" required/>
</h3>
</div>
</div>
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-05-05 15:39:10 UTC (rev 3914)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-05-06 08:56:15 UTC (rev 3915)
@@ -36,7 +36,7 @@
<div ng-if="choice.choiceType == '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="text" class="form-control" ng-model="choice.date" focus-me="showEdit" datepicker-popup="dd/MM/yyyy" is-open="isOpen" ng-exit="showEdit = false" ng-click="isOpen = true" required/>
<input type="button" class="btn btn-default" data-toggle="modal" data-target="#popupAddChoice" ng-click="editChoice(choice)" value="..."/>
</div>
</div>
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-05-05 15:39:10 UTC (rev 3914)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupChoice.html 2014-05-06 08:56:15 UTC (rev 3915)
@@ -49,7 +49,7 @@
<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"/>
+ <input id="popNameChoiceDate" class="form-control" datepicker-popup="dd/MM/yyyy" type="text" ng-model="choice.date" is-open="opened" ng-click="opened = true"/>
</div>
</div>
</div>
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupSettings.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupSettings.html 2014-05-05 15:39:10 UTC (rev 3914)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupSettings.html 2014-05-06 08:56:15 UTC (rev 3915)
@@ -35,8 +35,11 @@
<div class="col-lg-8">
<input id="popBeginDate" class="form-control" type="text"
datepicker-popup="dd/MM/yyyy"
+ min-date="toDay"
+ max-date="poll.endDate"
ng-model="poll.beginDate"
- is-open="beginDateOpened"/>
+ is-open="beginDateOpened"
+ ng-click="beginDateOpened = true" />
</div>
</div>
@@ -45,8 +48,10 @@
<div class="col-lg-8">
<input id="popEndDate" class="form-control" type="text"
datepicker-popup="dd/MM/yyyy"
+ min-date="poll.beginDate"
ng-model="poll.endDate"
- is-open="endDateOpened"/>
+ is-open="endDateOpened"
+ ng-click="endDateOpened = true" />
</div>
</div>
@@ -80,20 +85,23 @@
<input class="form-control" type="text" id="popBeginChoiceDate"
datepicker-popup="dd/MM/yyyy"
min-date="poll.beginDate"
- max-date="poll.endDate"
+ max-date="poll.endChoiceDate"
ng-model="poll.beginChoiceDate"
- is-open="beginChoiceDateOpened"/>
+ is-open="beginChoiceDateOpened"
+ ng-click="beginChoiceDateOpened = true" />
</div>
</div>
- <div class="form-group" ng-show="poll.choiceAddAllowed" for="popEndChoiceDate">
+ <div class="form-group" ng-if="poll.choiceAddAllowed" for="popEndChoiceDate">
<label class="col-lg-4 control-label">Date de fin : </label>
<div class="col-lg-8">
<input class="form-control" type="text" id="popEndChoiceDate"
datepicker-popup="dd/MM/yyyy"
- min-date="poll.beginDate"
+ min-date="poll.beginChoiceDate"
max-date="poll.endDate"
+
ng-model="poll.endChoiceDate"
- is-open="endChoiceDateOpened"/>
+ is-open="endChoiceDateOpened"
+ ng-click="endChoiceDateOpened = true" />
</div>
</div>
@@ -126,7 +134,7 @@
<button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="6">Vote alternatif</button>
<button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="7">Coombs</button>
</div>
- <p>description type...</p>
+ <p>Description du types de vote</p>
</div>
</div>
</div>
@@ -140,7 +148,6 @@
<button type="button" class="btn btn-success" ng-model="poll.voteVisibility" btn-radio="'ANONYMOUS'">Anonyme</button>
</div>
</div>
- </div>
<div class="form-group">
<label class="col-lg-4 control-label">Autoriser les votes anonymes :</label>
1
0
r3914 - in trunk/pollen-ui-angular/src/main/webapp: . js/controllers partials
by garandel@users.chorem.org 05 May '14
by garandel@users.chorem.org 05 May '14
05 May '14
Author: garandel
Date: 2014-05-05 17:39:10 +0200 (Mon, 05 May 2014)
New Revision: 3914
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3914
Log:
Add popup setting
Added:
trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupSettings.html
Modified:
trunk/pollen-ui-angular/src/main/webapp/index.html
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/index.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-05 12:36:59 UTC (rev 3913)
+++ trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-05 15:39:10 UTC (rev 3914)
@@ -29,7 +29,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-resource.min…"></script>
- <script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.10.0/ui-bootst…"></script>
+ <script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.11.0/ui-bootst…"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/restangular/1.4.0/restangular.min.js"></script>
<script src="js/libs/ckeditor/ckeditor.js"></script>
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-05 12:36:59 UTC (rev 3913)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-05 15:39:10 UTC (rev 3914)
@@ -122,6 +122,18 @@
});
}
+ $scope.popupSettings = function () {
+ var modalInstance = $modal.open({
+ templateUrl : 'partials/poll-popupSettings.html',
+ controller : PollPopupSettingsCtrl,
+ size : 'lg',
+ resolve : { poll: function () {
+ return $scope.poll;
+ }
+ }
+ });
+ }
+
$scope.reset = function () {
$scope.poll = initPoll();
$scope.voteChoice = $scope.poll.choice;
@@ -158,8 +170,36 @@
}
+ var PollPopupSettingsCtrl = function ($scope, $filter, $modalInstance, poll) {
+ $scope.poll = poll;
+ if (!angular.isDefined($scope.poll.continuousResults)) {
+ $scope.poll.continuousResults = false;
+ }
+ if (!angular.isDefined($scope.poll.resultVisibility)) {
+ $scope.poll.resultVisibility = 'EVERYBODY';
+ }
+
+ if (!angular.isDefined($scope.poll.choiceAddAllowed)) {
+ $scope.poll.choiceAddAllowed = false;
+ }
+
+ $scope.close = function () {
+ $modalInstance.dismiss();
+ }
+
+ $scope.printCheckbox= function (value) {
+ if (value) {
+ return 'Oui';
+ } else {
+ return 'Non';
+ }
+ }
+
+ }
+
+
}])
.controller('PollCreateCtrl', ['$scope', '$controller', 'Restangular', '$http', function ($scope, $controller, Restangular, $http) {
Added: trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupSettings.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupSettings.html (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-popupSettings.html 2014-05-05 15:39:10 UTC (rev 3914)
@@ -0,0 +1,156 @@
+<!--
+ #%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-horizontal">
+ <div class="modal-header">
+ <h3 class="modal-title">Configuration</h3>
+ </div>
+
+ <div class="modal-body">
+
+ <h4>Confiuration global</h4>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label" for="popBeginDate">Date de début : </label>
+ <div class="col-lg-8">
+ <input id="popBeginDate" class="form-control" type="text"
+ datepicker-popup="dd/MM/yyyy"
+ ng-model="poll.beginDate"
+ is-open="beginDateOpened"/>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label" for="popEndDate">Date de fin : </label>
+ <div class="col-lg-8">
+ <input id="popEndDate" class="form-control" type="text"
+ datepicker-popup="dd/MM/yyyy"
+ ng-model="poll.endDate"
+ is-open="endDateOpened"/>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label">Résultat : </label>
+ <div class="col-lg-8 btn-group">
+ <button type="button" class="btn btn-success" ng-model="poll.resultVisibility" btn-radio="'EVERYBODY'">Public</button>
+ <button type="button" class="btn btn-success" ng-model="poll.resultVisibility" btn-radio="'VOTER'">Participants</button>
+ <button type="button" class="btn btn-success" ng-model="poll.resultVisibility" btn-radio="'CREATOR'">Créateur</button>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label" for="popContinuousResults">Résultat continue : </label>
+ <div class="col-lg-8">
+ <button class="btn btn-default" id="popContinuousResults" ng-model="poll.continuousResults" btn-checkbox>{{printCheckbox(poll.continuousResults)}}</button>
+ </div>
+ </div>
+
+ <h4>Configuration des Choix</h4>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label" for="popChoiceAddAllowed">Ajout de choix par les votants :</label>
+ <div class="col-lg-8">
+ <button class="btn btn-default" id="popChoiceAddAllowed" ng-model="poll.choiceAddAllowed" btn-checkbox >{{printCheckbox(poll.choiceAddAllowed)}}</button>
+ </div>
+ </div>
+ <div class="form-group" ng-show="poll.choiceAddAllowed">
+ <label class="col-lg-4 control-label" for="popBeginChoiceDate">Date de début : </label>
+ <div class="col-lg-8">
+ <input class="form-control" type="text" id="popBeginChoiceDate"
+ datepicker-popup="dd/MM/yyyy"
+ min-date="poll.beginDate"
+ max-date="poll.endDate"
+ ng-model="poll.beginChoiceDate"
+ is-open="beginChoiceDateOpened"/>
+ </div>
+ </div>
+ <div class="form-group" ng-show="poll.choiceAddAllowed" for="popEndChoiceDate">
+ <label class="col-lg-4 control-label">Date de fin : </label>
+ <div class="col-lg-8">
+ <input class="form-control" type="text" id="popEndChoiceDate"
+ datepicker-popup="dd/MM/yyyy"
+ min-date="poll.beginDate"
+ max-date="poll.endDate"
+ ng-model="poll.endChoiceDate"
+ is-open="endChoiceDateOpened"/>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label" for="popLimitedVote">Limiter les votes :</label>
+ <div class="col-lg-8">
+ <button class="btn btn-default" id="popLimitedVote" ng-model="poll.limitedVote" btn-checkbox >{{printCheckbox(poll.limitedVote)}}</button>
+ </div>
+ </div>
+ <div class="form-group" ng-show="poll.limitedVote">
+ <label class="col-lg-4 control-label" for="popMaxChoiceNumber">Nombre de vote :</label>
+ <div class="col-lg-6">
+ <input type="text" class="form-control" id="popMaxChoiceNumber" ng-model="poll.maxChoiceNumber"/>
+ </div>
+ </div>
+
+ <h4> Configuration des Réponses </h4>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label">Type : </label>
+ <div class="col-lg-8">
+ <div class="btn-group">
+ <button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="1">Normal</button>
+ <button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="2">Pourcentage</button>
+ <button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="3">Condorcet</button>
+ <button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="4">Nombre</button>
+ </div>
+ <div class="btn-group">
+ <button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="5">Borda</button>
+ <button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="6">Vote alternatif</button>
+ <button type="button" class="btn btn-success" ng-model="poll.voteCountingType" btn-radio="7">Coombs</button>
+ </div>
+ <p>description type...</p>
+ </div>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label">Visibilité : </label>
+ <div class="col-lg-8 btn-group">
+ <button type="button" class="btn btn-success" ng-model="poll.voteVisibility" btn-radio="'EVERYBODY'">Public</button>
+ <button type="button" class="btn btn-success" ng-model="poll.voteVisibility" btn-radio="'VOTER'">Participants</button>
+ <button type="button" class="btn btn-success" ng-model="poll.voteVisibility" btn-radio="'CREATOR'">Créateur</button>
+ <button type="button" class="btn btn-success" ng-model="poll.voteVisibility" btn-radio="'ANONYMOUS'">Anonyme</button>
+ </div>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-lg-4 control-label">Autoriser les votes anonymes :</label>
+ <div class="col-lg-8">
+ <button class="btn btn-default" ng-model="poll.anonymousVoteAllowed" btn-checkbox >{{printCheckbox(poll.anonymousVoteAllowed)}}</button>
+ </div>
+ </div>
+
+
+ <div class="modal-footer">
+ <button type="button" class="btn btn-primary" ng-click="close()">close</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-05-05 12:36:59 UTC (rev 3913)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-05-05 15:39:10 UTC (rev 3914)
@@ -54,6 +54,7 @@
<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>
+ <button class="btn btn-default" ng-click="popupSettings()">Settings</button>
</div>
</form>
\ No newline at end of file
1
0
r3913 - in trunk/pollen-ui-angular/src/main/webapp: . js js/controllers partials
by garandel@users.chorem.org 05 May '14
by garandel@users.chorem.org 05 May '14
05 May '14
Author: garandel
Date: 2014-05-05 14:36:59 +0200 (Mon, 05 May 2014)
New Revision: 3913
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3913
Log:
Add list of polls for edit and vote (no security)
Added:
trunk/pollen-ui-angular/src/main/webapp/partials/poll-list.html
Modified:
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/inline-poll.html
trunk/pollen-ui-angular/src/main/webapp/partials/poll.html
Modified: trunk/pollen-ui-angular/src/main/webapp/index.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-05 09:43:49 UTC (rev 3912)
+++ trunk/pollen-ui-angular/src/main/webapp/index.html 2014-05-05 12:36:59 UTC (rev 3913)
@@ -46,7 +46,7 @@
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#/poll/create">Creer</a></li>
- <li><a href="#/poll/vote">Voter</a></li>
+ <li><a href="#/poll/list">Liste</a></li>
</ul>
</div>
</div>
Modified: trunk/pollen-ui-angular/src/main/webapp/js/app.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-05-05 09:43:49 UTC (rev 3912)
+++ trunk/pollen-ui-angular/src/main/webapp/js/app.js 2014-05-05 12:36:59 UTC (rev 3913)
@@ -68,7 +68,7 @@
$routeProvider.when('/', {templateUrl: './partials/home.html', controller: "HomeCtrl"})
.when('/poll/create', {templateUrl: './partials/poll.html', controller: "PollCreateCtrl"})
.when('/poll/edit/:pollId', {templateUrl: './partials/poll.html', controller:"PollEditCtrl"})
- .when('/poll/vote', {templateUrl: './partials/poll.html', controller :"PollVoteCtrl"})
+ .when('/poll/vote/:pollId', {templateUrl: './partials/poll.html', controller :"PollVoteCtrl"})
.when('/poll/list', {templateUrl: './partials/poll-list.html', controller :"PollListCtrl"})
.otherwise({redirectTo: '/'});
@@ -103,11 +103,11 @@
restrict:'A',
link: function ($scope, element, attrs) {
element.bind('click', function () {
- if ($scope.globalVariables.editMode) {
- $scope.$apply(function () {
- $scope[attrs.editMe] = true;
- $scope.globalVariables.saved = false;
- });
+ if ($scope.globalVariables.editMode) {
+ $scope.$apply(function () {
+ $scope[attrs.editMe] = true;
+ $scope.globalVariables.saved = false;
+ });
}
});
}
@@ -152,18 +152,3 @@
};
})
-.factory('pollStorage', function () {
- var storageId='poll-storage';
- return {
- get: function () {
- return JSON.parse(localStorage.getItem(storageId) || '{}');
- },
- put: function (data) {
- localStorage.setItem(storageId, JSON.stringify(data));
- },
- remove: function () {
- localStorage.setItem(storageId, '{}');
- }
- }
-});
-
Modified: trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-05 09:43:49 UTC (rev 3912)
+++ trunk/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js 2014-05-05 12:36:59 UTC (rev 3913)
@@ -18,7 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-angular.module('pollControllers', []).controller('HomeCtrl', ['$scope', '$rootScope', function ($scope, $rootScope) {
+angular.module('pollControllers', [])
+.controller('HomeCtrl', ['$scope', function ($scope) {
}])
@@ -70,6 +71,7 @@
var initChoice = function () {
return {
name: '',
+ date: $scope.globalVariables.lastDate,
choiceType: $scope.globalVariables.lastType
};
}
@@ -78,6 +80,7 @@
$scope.globalVariables.create = true;
$scope.globalVariables.voted = angular.isDefined($scope.poll.votants);
$scope.globalVariables.lastType = 'TEXT';
+ $scope.globalVariables.lastDate = new Date();
$scope.$watch('pollForm.$valid', function (newVal) {
$scope.formValid = newVal;
@@ -101,7 +104,6 @@
}
}
-
var popupChoice = function (choice, title) {
var modalInstance = $modal.open({
templateUrl : 'partials/poll-popupChoice.html',
@@ -116,27 +118,10 @@
deleteChoice(ch);
}, function () {
$scope.globalVariables.lastType = choice.choiceType;
+ $scope.globalVariables.lastDate = choice.date;
});
}
- $scope.save = function () {
- if ($scope.formValid) {
- var data = {};
- data.poll = $scope.poll;
-
-// Restangular.all('polls').post('polls', data).then(function (data) {;
- $http.post('http://localhost:8080/pollen-rest-api/v1/polls', data).success(function (data) {
- $scope.test = data;
- $scope.globalVariables.saved = true;
- });
-
- }
- else {
- $scope.globalVariables.errorForm = true;
- }
-
- }
-
$scope.reset = function () {
$scope.poll = initPoll();
$scope.voteChoice = $scope.poll.choice;
@@ -172,24 +157,45 @@
}
}
+
+
+
}])
-.controller('PollCreateCtrl', ['$scope', '$controller', 'Restangular', function ($scope, $controller, Restangular) {
+.controller('PollCreateCtrl', ['$scope', '$controller', 'Restangular', '$http', function ($scope, $controller, Restangular, $http) {
$controller('PollAdminCtrl', {$scope:$scope});
- var initPoll = function () {
- Restangular.service('polls').one('new').get().then(function (skeletonPoll) {
- $scope.poll = skeletonPoll;
- $scope.poll.choice = [];
- $scope.vote = {};
- $scope.vote.choice = $scope.poll.choice;
+ var initPoll = function () {
+ Restangular.service('polls').one('new').get().then(function (skeletonPoll) {
+ $scope.poll = skeletonPoll;
+ $scope.poll.choice = [];
+ $scope.vote = {};
+ $scope.vote.choice = $scope.poll.choice;
+ });
+ }
+ initPoll();
+
+ $scope.save = function () {
+ if ($scope.formValid) {
+ var data = {};
+ data.poll = $scope.poll;
+
+// Restangular.all('polls').post('polls', data).then(function (data) {;
+ $http.post('http://localhost:8080/pollen-rest-api/v1/polls', data).success(function (data) {
+ $scope.test = data;
+ $scope.globalVariables.saved = true;
});
+
}
- initPoll();
+ else {
+ $scope.globalVariables.errorForm = true;
+ }
+ }
+
}])
-.controller('PollEditCtrl', ['$scope', '$controller', '$routeParams', 'Restangular', function ($scope, $controller, $routeParams, Restangular) {
+.controller('PollEditCtrl', ['$scope', '$controller', '$routeParams', 'Restangular', '$http', function ($scope, $controller, $routeParams, Restangular, $http) {
$controller('PollAdminCtrl', {$scope:$scope});
var initPoll = function () {
@@ -204,17 +210,37 @@
});
}
initPoll();
+
+ $scope.save = function () {
+ if ($scope.formValid) {
+ var data = {};
+ data.poll = $scope.poll;
+
+// Restangular.all('polls').post('polls', data).then(function (data) {;
+ $http.put('http://localhost:8080/pollen-rest-api/v1/polls/'+$routeParams.pollId, data).success(function (data) {
+ $scope.test = data;
+ $scope.globalVariables.saved = true;
+ });
+
+ }
+ else {
+ $scope.globalVariables.errorForm = true;
+ }
+
+ }
}])
-.controller('PollVoteCtrl', ['$scope', '$filter', '$controller', 'Restangular', 'pollStorage', function ($scope, $filter, $controller, Restangular, pollStorage) {
+.controller('PollVoteCtrl', ['$scope', '$filter', '$controller', '$routeParams', 'Restangular', function ($scope, $filter, $controller, $routeParams, Restangular) {
$controller('PollCtrl', {$scope:$scope});
- Restangular.one('polls').get().then(function (poll) {
- $scope.poll = poll[0];
+ Restangular.one('polls', $routeParams.pollId).get().then(function (poll) {
+ $scope.poll = poll;
+ Restangular.one('polls', $routeParams.pollId).all('choices').getList().then(function (choices) {
+ $scope.poll.choice = choices;
+ initVote();
+ })
+ });
- initVote();
- })
-
$scope.globalVariables.editMode = false;
$scope.$watch('vote.ame', function (newVal) {
if (newVal != '') {
@@ -226,12 +252,12 @@
$scope.vote = {};
$scope.vote.name = "";
$scope.vote.choice = [];
- for (var i = 0; i < $scope.poll.choices.length; ++i) {
- if ($scope.poll.choices[i].choiceType == 'text') {
- $scope.vote.choices.push({name:$scope.poll.choice[i].name, value:false});
+ for (var i = 0; i < $scope.poll.choice.length; ++i) {
+ if ($scope.poll.choice[i].choiceType == 'TEXT') {
+ $scope.vote.choice.push({name:$scope.poll.choice[i].name, value:false});
}
- else if ($scope.poll.choices[i].choiceType == 'date') {
- $scope.vote.choices.push({name: $scope.poll.choice[i].date , value:false});
+ else if ($scope.poll.choice[i].choiceType == 'DATE') {
+ $scope.vote.choice.push({name: $scope.poll.choice[i].date , value:false});
}
}
}
@@ -245,7 +271,9 @@
$scope.poll.votants = [];
}
$scope.poll.votants.push(data);
- pollStorage.put($scope.poll);
+
+ // save vote
+
$scope.globalVariables.saved = true;
$scope.globalVariables.errorForm = false;
initVote();
@@ -256,8 +284,12 @@
}
}])
-.controller('PollListCtrl', ['$scope', 'pollStorage', function ($scope, pollStorage) {
+.controller('PollListCtrl', ['$scope', '$controller', 'Restangular', function ($scope, $controller, Restangular) {
+ $controller('PollCtrl', {$scope:$scope});
+ Restangular.all('polls').getList().then(function (polls) {
+ $scope.polls = polls;
+ });
}])
;
\ No newline at end of file
Modified: trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-05-05 09:43:49 UTC (rev 3912)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/inline-poll.html 2014-05-05 12:36:59 UTC (rev 3913)
@@ -22,6 +22,7 @@
-->
<table>
+<!-- begin print choices -->
<tr>
<td><button ng-if="globalVariables.editMode" ng-click="bigVersion()" class="btn btn-default" >Big version</button></td>
<td ng-repeat="choice in poll.choice" class="pollChoice pollAnim" ng-mouseenter="showEditHover = true" ng-mouseleave="showEditHover = false">
@@ -42,7 +43,9 @@
</td>
<td ng-if="!globalVariables.voted && globalVariables.editMode"><input type="button" class="btn btn-default btn-large" value="+" ng-click="addChoice()"/></td>
</tr>
+<!-- end print choice -->
+<!-- begin input vote -->
<tr>
<td class="pollChoice"> <input type="text" class="form-control" placeholder="votre nom" ng-model="vote.name" /> </td>
<td ng-repeat="choice in vote.choice" class="pollChoice">
@@ -52,12 +55,15 @@
<input class="btn btn-primary btn-large" type="button" value="Vote" ng-click="voter()" />
</td>
</tr>
+<!-- end input vote -->
+<!-- begin print vote -->
<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">
+ <td ng-repeat="choice in vote.choice" class="pollChoice">
<input type="checkbox" ng-model="choice.value" disabled/>
</td>
</tr>
+<!-- end print vote -->
</table>
Added: trunk/pollen-ui-angular/src/main/webapp/partials/poll-list.html
===================================================================
--- trunk/pollen-ui-angular/src/main/webapp/partials/poll-list.html (rev 0)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll-list.html 2014-05-05 12:36:59 UTC (rev 3913)
@@ -0,0 +1,6 @@
+
+<div ng-repeat="poll in polls">
+ <h2><a href="#/poll/vote/{{poll.topiaId}}">{{poll.title}}</a> <a href="#/poll/edit/{{poll.topiaId}}"><i class="glyphicon glyphicon-pencil"></i></a></h2>
+ <p ng-bind-html="toHTML(poll.description)"></p>
+ <hr/>
+</div>
\ 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-05-05 09:43:49 UTC (rev 3912)
+++ trunk/pollen-ui-angular/src/main/webapp/partials/poll.html 2014-05-05 12:36:59 UTC (rev 3913)
@@ -23,7 +23,7 @@
<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é.. <pre>{{rest}}</pre></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>
1
0
See <http://ci.chorem.org/jenkins/job/pollen-ci/33/changes>
Changes:
[Tony CHEMIT] reformat rest api + use PollenPrincipalRef for create operations
------------------------------------------
[...truncated 1006 lines...]
11:23:05 INFO (SecurityService.java:213) Check permission: :readPoll:org.chorem.pollen.persistence.entity.Poll_90e8bddf-d6c8-4ebf-9506-353c3001254d
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.888 sec - in org.chorem.pollen.service.PollServiceTest
Running org.chorem.pollen.service.PollenUserServiceTest
11:23:05 DEBUG (FakePollenApplicationContext.java:99) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
11:23:05 INFO (PollenServiceConfig.java:88) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
11:23:06 INFO (FixturesService.java:75) will restore database with fixture set
11:23:06 DEBUG (FakePollenApplicationContext.java:99) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
11:23:06 INFO (PollenServiceConfig.java:88) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
11:23:06 INFO (FixturesService.java:75) will restore database with fixture set
11:23:06 DEBUG (FakePollenApplicationContext.java:99) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
11:23:06 INFO (PollenServiceConfig.java:88) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
11:23:07 INFO (FixturesService.java:75) will restore database with fixture set
11:23:07 DEBUG (FakePollenApplicationContext.java:99) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
11:23:07 INFO (PollenServiceConfig.java:88) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
11:23:07 INFO (FixturesService.java:75) will restore database with fixture set
11:23:07 DEBUG (FakePollenApplicationContext.java:99) testBasedir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
11:23:07 INFO (PollenServiceConfig.java:88) Pollen configuration:
Filename: pollen-services.properties
pollen.data.directory = <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
pollen.default.pollType = FREE
pollen.default.voteCountingType = 1
pollen.default.pollVoteVisibility = EVERYBODY
pollen.default.pollCommentVisibility = EVERYBODY
pollen.smtp.host =
pollen.smtp.port = 25
pollen.smtp.from =
pollen.devMode = true
logConfigurationFile = null
11:23:07 INFO (FixturesService.java:75) will restore database with fixture set
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.94 sec - in org.chorem.pollen.service.PollenUserServiceTest
Results :
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ pollen-services ---
[INFO] Building jar: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-services/target/…>
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ pollen-services ---
[JENKINS] Archiving disabled
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Pollen :: Rest Api 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti… (2 KB at 1.2 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti… (613 B at 1.7 KB/sec)
[WARNING] The POM for org.antlr:stringtemplate:jar:3.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti… (2 KB at 3.0 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ pollen-rest-api ---
[INFO] Deleting <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/target>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ pollen-rest-api ---
[INFO]
[INFO] >>> i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.0:collect-i18n-artifacts (collect-i18n-artifacts) @ pollen-rest-api ---
[WARNING] Invalid POM for org.antlr:stringtemplate:jar:3.2.1, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/debux/webmotion…
[INFO] Downloaded: https://oss.sonatype.org/content/repositories/snapshots/org/debux/webmotion… (2 KB at 1.3 KB/sec)
[INFO] Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/debux/webmotion…
[INFO] Downloaded: https://oss.sonatype.org/content/repositories/snapshots/org/debux/webmotion… (613 B at 2.1 KB/sec)
[INFO] collected 2 i18n artifacts for locale fr_FR stored in <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/target/…>
[INFO] collected 2 i18n artifacts for locale en_GB stored in <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/target/…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api ---
[WARNING] bundle fr_FR contains 6/70 empty entries! (use -Di18n.showEmpty to see these entries)
[WARNING] bundle en_GB contains 6/70 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ pollen-rest-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pollen-rest-api ---
[INFO] Compiling 17 source files to <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/target/…>
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/src/mai…>:[278,35] getNullValue(java.lang.Class<?>) in org.nuiton.util.ObjectUtil has been deprecated
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/src/mai…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/src/mai…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ pollen-rest-api ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/target/…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ pollen-rest-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ pollen-rest-api ---
[INFO] Compiling 3 source files to <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/target/…>
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/src/tes…>:[120,5] method does not override or implement a method from a supertype
[INFO] 1 error
[INFO] -------------------------------------------------------------
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Pollen ............................................ SUCCESS [ 1.607 s]
[INFO] Pollen :: VoteCounting (Api) ...................... SUCCESS [ 5.612 s]
[INFO] Pollen :: VoteCounting :: Normal .................. SUCCESS [ 1.396 s]
[INFO] Pollen :: VoteCounting :: Percentage .............. SUCCESS [ 1.248 s]
[INFO] Pollen :: VoteCounting :: Condorcet ............... SUCCESS [ 1.259 s]
[INFO] Pollen :: VoteCounting :: Number .................. SUCCESS [ 1.148 s]
[INFO] Pollen :: VoteCounting :: Borda ................... SUCCESS [ 1.198 s]
[INFO] Pollen :: VoteCounting :: Instant Runoff .......... SUCCESS [ 1.158 s]
[INFO] Pollen :: VoteCounting :: Coombs .................. SUCCESS [ 1.128 s]
[INFO] Pollen :: VoteCounting (Aggregator) ............... SUCCESS [ 0.219 s]
[INFO] Pollen :: Persistence ............................. SUCCESS [ 6.114 s]
[INFO] Pollen :: Service ................................. SUCCESS [ 6.868 s]
[INFO] Pollen :: Rest Api ................................ FAILURE [ 4.273 s]
[INFO] Pollen :: UI (CanJS) .............................. SKIPPED
[INFO] Pollen :: UI (Angular) ............................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.757 s
[INFO] Finished at: 2014-05-05T11:23:13+01:00
[INFO] Final Memory: 61M/397M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project pollen-rest-api: Compilation failure
[ERROR] <http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/src/tes…>:[120,5] method does not override or implement a method from a supertype
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project pollen-rest-api: Compilation failure
<http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/src/tes…>:[120,5] method does not override or implement a method from a supertype
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
<http://ci.chorem.org/jenkins/job/pollen-ci/ws/trunk/pollen-rest-api/src/tes…>:[120,5] method does not override or implement a method from a supertype
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:152)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 30 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :pollen-rest-api
Sending e-mails to: pollen-commits(a)list.chorem.org chemit+chorem-ci(a)codelutin.com
channel stopped
1
1
Build failed in Jenkins: pollen-ci » Pollen :: Rest Api #33
by admin+ci-chorem.org@codelutin.com 05 May '14
by admin+ci-chorem.org@codelutin.com 05 May '14
05 May '14
See <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>
Changes:
[Tony CHEMIT] reformat rest api + use PollenPrincipalRef for create operations
------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Pollen :: Rest Api 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti… (2 KB at 1.2 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti… (613 B at 1.7 KB/sec)
[WARNING] The POM for org.antlr:stringtemplate:jar:3.2.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/snapshots/org/debux/webm…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/pollen-group/org/debux/webmoti… (2 KB at 3.0 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ pollen-rest-api ---
[INFO] Deleting <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ pollen-rest-api ---
[INFO]
[INFO] >>> i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api >>>
[INFO]
[INFO] --- i18n-maven-plugin:3.0:collect-i18n-artifacts (collect-i18n-artifacts) @ pollen-rest-api ---
[WARNING] Invalid POM for org.antlr:stringtemplate:jar:3.2.1, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/debux/webmotion…
[INFO] Downloaded: https://oss.sonatype.org/content/repositories/snapshots/org/debux/webmotion… (2 KB at 1.3 KB/sec)
[INFO] Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/debux/webmotion…
[INFO] Downloaded: https://oss.sonatype.org/content/repositories/snapshots/org/debux/webmotion… (613 B at 2.1 KB/sec)
[INFO] collected 2 i18n artifacts for locale fr_FR stored in <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>
[INFO] collected 2 i18n artifacts for locale en_GB stored in <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>
[INFO]
[INFO] <<< i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api <<<
[INFO]
[INFO] --- i18n-maven-plugin:3.0:bundle (default) @ pollen-rest-api ---
[WARNING] bundle fr_FR contains 6/70 empty entries! (use -Di18n.showEmpty to see these entries)
[WARNING] bundle en_GB contains 6/70 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ pollen-rest-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pollen-rest-api ---
[INFO] Compiling 17 source files to <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>:[278,35] getNullValue(java.lang.Class<?>) in org.nuiton.util.ObjectUtil has been deprecated
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ pollen-rest-api ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ pollen-rest-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ pollen-rest-api ---
[INFO] Compiling 3 source files to <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.chorem.org/jenkins/job/pollen-ci/org.chorem.pollen$pollen-rest-ap…>:[120,5] method does not override or implement a method from a supertype
[INFO] 1 error
[INFO] -------------------------------------------------------------
[JENKINS] Archiving disabled
1
1
r3912 - in trunk: pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity pollen-rest-api/src/main/java/org/chorem/pollen/rest/api pollen-services/src/main/java/org/chorem/pollen/services/service/security
by tchemit@users.chorem.org 05 May '14
by tchemit@users.chorem.org 05 May '14
05 May '14
Author: tchemit
Date: 2014-05-05 11:43:49 +0200 (Mon, 05 May 2014)
New Revision: 3912
Url: http://forge.chorem.org/projects/pollen/repository/revisions/3912
Log:
fix security permission
Added:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipalTopiaDao.java
Modified:
trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipalTopiaDao.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipalTopiaDao.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipalTopiaDao.java 2014-05-05 09:43:49 UTC (rev 3912)
@@ -0,0 +1,11 @@
+package org.chorem.pollen.persistence.entity;
+
+public class PollenPrincipalTopiaDao extends AbstractPollenPrincipalTopiaDao<PollenPrincipal> {
+
+ public PollenPrincipal findByPermissionToken(String permissionToken) {
+
+ PollenPrincipal principal = forEquals(PollenPrincipal.PROPERTY_PERMISSION + "." + PollenToken.PROPERTY_TOKEN, permissionToken).findUnique();
+ return principal;
+
+ }
+}
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/persistence/entity/PollenPrincipalTopiaDao.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/PollenRestApiRequestFilter.java
===================================================================
--- trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java 2014-05-05 09:38:12 UTC (rev 3911)
+++ trunk/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/PollenRestApiRequestFilter.java 2014-05-05 09:43:49 UTC (rev 3912)
@@ -124,7 +124,7 @@
Map<String, String[]> parameters = httpContext.getParameters();
String[] strings = parameters.get(REQUEST_PERMISSION_PARAMETER);
String credentialParam = strings == null || strings.length < 1 ? null : strings[0];
- PollenPrincipal mainPrincipal = securityService.getPollenPrincipalById(credentialParam);
+ PollenPrincipal mainPrincipal = securityService.getPollenPrincipalByPermissionToken(credentialParam);
// --- create security context --- //
PollenSecurityContext securityContext =
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java 2014-05-05 09:38:12 UTC (rev 3911)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java 2014-05-05 09:43:49 UTC (rev 3912)
@@ -26,6 +26,7 @@
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authc.AuthenticationException;
@@ -141,11 +142,11 @@
}
- public PollenPrincipal getPollenPrincipalById(String principalId) {
+ public PollenPrincipal getPollenPrincipalByPermissionToken(String principalId) {
PollenPrincipal principal = null;
if (principalId != null) {
- principal = getPollenPrincipalDao().findByTopiaId(principalId);
+ principal = getPollenPrincipalDao().findByPermissionToken(principalId);
}
return principal;
@@ -239,7 +240,11 @@
// Create Subject
SimplePrincipalCollection principalCollection = new SimplePrincipalCollection();
- principalCollection.addAll(permissions, PollenSecurityRealm.REALM_NAME);
+
+ if (CollectionUtils.isNotEmpty(permissions)) {
+ principalCollection.addAll(permissions, PollenSecurityRealm.REALM_NAME);
+ }
+
subject = new Subject.
Builder().
authenticated(securityContext.isConnected()).
1
0