tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1998 fixing moviefun-rest
Date Wed, 11 Jan 2017 08:25:03 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 1bce28805 -> cd1e39e72


TOMEE-1998 fixing moviefun-rest


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/cd1e39e7
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/cd1e39e7
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/cd1e39e7

Branch: refs/heads/master
Commit: cd1e39e721db73269ab18b540fbe1df110e5cc0a
Parents: 1bce288
Author: rmannibucau <rmannibucau@apache.org>
Authored: Wed Jan 11 09:24:53 2017 +0100
Committer: rmannibucau <rmannibucau@apache.org>
Committed: Wed Jan 11 09:24:53 2017 +0100

----------------------------------------------------------------------
 .../java/org/superbiz/moviefun/rest/MoviesRest.java |  2 ++
 .../src/main/webapp/app/js/model/movie.js           | 16 +++++++++++++---
 .../src/main/webapp/app/js/model/movies.js          |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/cd1e39e7/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
index 335052a..fcbe2f0 100644
--- a/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
+++ b/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
@@ -29,6 +29,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
 import java.util.List;
 
 @Path("movies")
@@ -73,6 +74,7 @@ public class MoviesRest {
 
     @GET
     @Path("count")
+    @Produces(MediaType.TEXT_PLAIN)
     public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String
searchTerm) {
         return service.count(field, searchTerm);
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/cd1e39e7/examples/moviefun-rest/src/main/webapp/app/js/model/movie.js
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/main/webapp/app/js/model/movie.js b/examples/moviefun-rest/src/main/webapp/app/js/model/movie.js
index 15936d0..36be222 100644
--- a/examples/moviefun-rest/src/main/webapp/app/js/model/movie.js
+++ b/examples/moviefun-rest/src/main/webapp/app/js/model/movie.js
@@ -21,13 +21,23 @@
 
     var deps = ['lib/backbone'];
     define(deps, function () {
+        var isString = function (obj) {
+            return Object.prototype.toString.call(obj) === '[object String]';
+        };
         return Backbone.Model.extend({
             urlRoot: window.ux.ROOT_URL + 'rest/movies',
             idAttribute: 'id',
             toJSON: function () {
-                return {
-                    'movie': this.attributes
-                };
+                if (!!this.attributes.rating && isString(this.attributes.rating))
{
+                    this.attributes.rating = parseInt(this.attributes.rating, 10);
+                }
+                if (!!this.attributes.year && isString(this.attributes.year)) {
+                    this.attributes.year = parseInt(this.attributes.year, 10);
+                }
+                if (!!this.attributes.id && isString(this.attributes.id)) {
+                    this.attributes.id = parseInt(this.attributes.id, 10);
+                }
+                return this.attributes;
             },
             defaults: {
                 rating: 5,

http://git-wip-us.apache.org/repos/asf/tomee/blob/cd1e39e7/examples/moviefun-rest/src/main/webapp/app/js/model/movies.js
----------------------------------------------------------------------
diff --git a/examples/moviefun-rest/src/main/webapp/app/js/model/movies.js b/examples/moviefun-rest/src/main/webapp/app/js/model/movies.js
index f03130d..828d2f8 100644
--- a/examples/moviefun-rest/src/main/webapp/app/js/model/movies.js
+++ b/examples/moviefun-rest/src/main/webapp/app/js/model/movies.js
@@ -25,7 +25,7 @@
             model: Movie,
             url: window.ux.ROOT_URL + 'rest/movies',
             parse: function (response) {
-                return response.movie;
+                return response;
             }
         });
         return new Cls();


Mime
View raw message