Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* fixed tests

* followed change in header panel

* nicer to_xml

* moved dhammapada to restful-gwt
  • Loading branch information...
commit eb5cc03718a87d37042d066a4f48c72fc707196f 1 parent 22de0ff
Christian Meier authored
1  .gitignore
... ... @@ -1,3 +1,4 @@
1 1 target
2 2 root_*
3 3 tomcat
  4 +www-test
10 app/models/board.rb
@@ -20,10 +20,16 @@ class Board
20 20 alias :to_x :to_xml_document
21 21 def to_xml_document(opts = {}, doc = nil)
22 22 unless(opts[:methods])
23   - opts.merge!({:methods => [:updated_by, :listings], :updated_by => {:methods => [], :exclude => [:created_at, :updated_at, :hashed_password, :language]}, :listings =>{ :exclude => [:created_at, :updated_at, :password, :board_id], :methods => []}})
  23 + opts.merge!({
  24 + :methods => [:created_by, :updated_by, :listings],
  25 + :listings =>{
  26 + :exclude => [:created_at, :updated_at, :password, :board_id],
  27 + :methods => []
  28 + }
  29 + })
24 30 end
25 31 unless(opts[:exclude])
26   - opts.merge!({:exclude => [:updated_by_id]})
  32 + opts.merge!({:exclude => [:created_by_id, :updated_by_id]})
27 33 end
28 34 to_x(opts, doc)
29 35 end
14 app/models/listing.rb
@@ -24,8 +24,20 @@ class Listing
24 24 require 'dm-serializer'
25 25 alias :to_x :to_xml_document
26 26 def to_xml_document(opts = {}, doc = nil)
  27 + opts.merge!({ :skip_types => true,
  28 + :skip_empty_tags => true
  29 + })
27 30 unless(opts[:methods])
28   - opts.merge!({:methods => [:board], :board => {:methods => [], :exclude => [:created_at, :updated_at]}})
  31 + opts.merge!({ :methods => [:board],
  32 + :board => {
  33 + :methods => [:listings],
  34 + :listings => {
  35 + :methods => [],
  36 + :exclude => [:password, :board_id, :created_at, :updated_at, :driver, :ridedate, :name, :email, :location]
  37 + },
  38 + :exclude => [:created_at, :updated_at]
  39 + }
  40 + })
29 41 end
30 42 unless(opts[:exclude])
31 43 opts.merge!({:exclude => [:password, :board_id]})
5 pom.xml
@@ -139,11 +139,6 @@
139 139 <type>gem</type>
140 140 <scope>test</scope>
141 141 </dependency>
142   - <dependency>
143   - <groupId>de.saumya.webfortune</groupId>
144   - <artifactId>dhammapada</artifactId>
145   - <version>0.3-SNAPSHOT</version>
146   - </dependency>
147 142 </dependencies>
148 143 <properties>
149 144 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2  src/main/java/com/example/client/Application.java
@@ -90,5 +90,7 @@ public void onModuleLoad() {
90 90 container.listeners,
91 91 container.hyperlinkFactory);
92 92 screenController.addScreen(venueScreen, "venues");
  93 +
  94 + screenController.dispatchDefault();
93 95 }
94 96 }
22 src/main/java/com/example/client/models/Listing.java
@@ -44,14 +44,20 @@ protected void appendXml(final StringBuilder buf) {
44 44
45 45 @Override
46 46 protected void fromElement(final Element root) {
47   - this.location = getString(root, "location");
48   - this.email = getString(root, "email");
49   - this.name = getString(root, "name");
50   - this.ridedate = getDate(root, "ridedate");
51   - this.driver = getBoolean(root, "driver");
52   - this.board = this.boardFactory.getChildResource(root, "board");
53   - this.createdAt = getTimestamp(root, "created_at");
54   - this.updatedAt = getTimestamp(root, "updated_at");
  47 + // allow empty listings which do NOT override existing data
  48 + // location is a required field so if not present just do not
  49 + // override anything - i.e. assume id only content
  50 + final String location = getString(root, "location");
  51 + if (location != null) {
  52 + this.location = location;
  53 + this.email = getString(root, "email");
  54 + this.name = getString(root, "name");
  55 + this.ridedate = getDate(root, "ridedate");
  56 + this.driver = getBoolean(root, "driver");
  57 + this.board = this.boardFactory.getChildResource(root, "board");
  58 + this.createdAt = getTimestamp(root, "created_at");
  59 + this.updatedAt = getTimestamp(root, "updated_at");
  60 + }
55 61 }
56 62
57 63 @Override
12 src/main/java/com/example/client/views/board_configs/BoardConfigScreen.java
@@ -22,14 +22,18 @@
22 22
23 23 public class BoardConfigScreen extends ResourceScreen<BoardConfig> {
24 24
25   - private static class BoardConfigHeaders extends ResourceHeaderPanel<BoardConfig> {
  25 + private static class BoardConfigHeaders extends
  26 + ResourceHeaderPanel<BoardConfig> {
26 27
27 28 public BoardConfigHeaders(final GetTextController getTextController) {
28 29 super(getTextController);
29 30 }
30 31
31 32 public void reset(final BoardConfig resource) {
32   - reset(resource, resource.updatedAt, resource.updatedBy);
  33 + reset(resource.createdAt,
  34 + resource.createdBy,
  35 + resource.updatedAt,
  36 + resource.updatedBy);
33 37 }
34 38 }
35 39
@@ -42,8 +46,8 @@ public BoardConfigScreen(final LoadingNotice loadingNotice,
42 46 super(loadingNotice,
43 47 factory,
44 48 session,
45   - new ResourcePanel<BoardConfig>(new BoardConfigHeaders(getTextController),
46   - new BoardConfigFields(getTextController, bindings)),
  49 + new ResourcePanel<BoardConfig>(new BoardConfigHeaders(getTextController),
  50 + new BoardConfigFields(getTextController, bindings)),
47 51 new ResourceCollectionPanel<BoardConfig>(loadingNotice,
48 52 new ResourceCollectionNavigation<BoardConfig>(loadingNotice,
49 53 factory,
5 src/main/java/com/example/client/views/boards/BoardScreen.java
@@ -30,7 +30,10 @@ public BoardHeaders(final GetTextController getTextController) {
30 30 }
31 31
32 32 public void reset(final Board resource) {
33   - reset(resource, resource.updatedAt, resource.updatedBy);
  33 + reset(resource.createdAt,
  34 + resource.createdBy,
  35 + resource.updatedAt,
  36 + resource.updatedBy);
34 37 }
35 38 }
36 39
2  src/main/java/com/example/client/views/listings/ListingScreen.java
@@ -30,7 +30,7 @@ public ListingHeaders(final GetTextController getTextController) {
30 30 }
31 31
32 32 public void reset(final Listing resource) {
33   - reset(resource, resource.updatedAt, null);
  33 + reset(resource.updatedAt, null);
34 34 }
35 35 }
36 36
12 src/main/java/com/example/client/views/venue_configs/VenueConfigScreen.java
@@ -22,14 +22,18 @@
22 22
23 23 public class VenueConfigScreen extends ResourceScreen<VenueConfig> {
24 24
25   - private static class VenueConfigHeaders extends ResourceHeaderPanel<VenueConfig> {
  25 + private static class VenueConfigHeaders extends
  26 + ResourceHeaderPanel<VenueConfig> {
26 27
27 28 public VenueConfigHeaders(final GetTextController getTextController) {
28 29 super(getTextController);
29 30 }
30 31
31 32 public void reset(final VenueConfig resource) {
32   - reset(resource, resource.updatedAt, resource.updatedBy);
  33 + reset(resource.createdAt,
  34 + resource.createdBy,
  35 + resource.updatedAt,
  36 + resource.updatedBy);
33 37 }
34 38 }
35 39
@@ -42,8 +46,8 @@ public VenueConfigScreen(final LoadingNotice loadingNotice,
42 46 super(loadingNotice,
43 47 factory,
44 48 session,
45   - new ResourcePanel<VenueConfig>(new VenueConfigHeaders(getTextController),
46   - new VenueConfigFields(getTextController, bindings)),
  49 + new ResourcePanel<VenueConfig>(new VenueConfigHeaders(getTextController),
  50 + new VenueConfigFields(getTextController, bindings)),
47 51 new ResourceCollectionPanel<VenueConfig>(loadingNotice,
48 52 new ResourceCollectionNavigation<VenueConfig>(loadingNotice,
49 53 factory,
9 src/main/java/com/example/client/views/venues/VenueScreen.java
@@ -29,7 +29,10 @@ public VenueHeaders(final GetTextController getTextController) {
29 29 }
30 30
31 31 public void reset(final Venue resource) {
32   - reset(resource, resource.updatedAt, resource.updatedBy);
  32 + reset(resource.createdAt,
  33 + resource.createdBy,
  34 + resource.updatedAt,
  35 + resource.updatedBy);
33 36 }
34 37 }
35 38
@@ -42,8 +45,8 @@ public VenueScreen(final LoadingNotice loadingNotice,
42 45 super(loadingNotice,
43 46 factory,
44 47 session,
45   - new ResourcePanel<Venue>(new VenueHeaders(getTextController),
46   - new VenueFields(getTextController, bindings)),
  48 + new ResourcePanel<Venue>(new VenueHeaders(getTextController),
  49 + new VenueFields(getTextController, bindings)),
47 50 new ResourceCollectionPanel<Venue>(loadingNotice,
48 51 new ResourceCollectionNavigation<Venue>(loadingNotice,
49 52 factory,
2  src/main/resources/com/example/public/Application.html
@@ -12,7 +12,7 @@
12 12 <!-- -->
13 13 <!-- Any title is fine -->
14 14 <!-- -->
15   - <title>Ixtlan Application</title>
  15 + <title>Dhamma.org Ridesboard Admin Console</title>
16 16
17 17 <!-- -->
18 18 <!-- This script loads your compiled module. -->
21 src/test/java/com/example/client/models/BoardTestGwt.java
@@ -11,7 +11,7 @@
11 11 */
12 12 public class BoardTestGwt extends AbstractApplicationResourceTestGwt<Board> {
13 13
14   - private Board resource;
  14 + private Board resource;
15 15
16 16 private static final String RESOURCE_XML = "<board>"
17 17 + "<id>1</id>"
@@ -19,13 +19,17 @@
19 19 + "<fullname>first valule of fullname</fullname>"
20 20 + "<position>1</position>"
21 21 + "<enabled>false</enabled>"
  22 + + "<listings></listings>"
22 23 + "<created_at>2009-07-09 17:14:48.0</created_at>"
23 24 + "<updated_at>2009-07-09 17:14:48.0</updated_at>"
24 25 + "</board>";
25 26
26 27 @Override
27 28 protected String resourceNewXml() {
28   - return RESOURCE_XML.replaceFirst("<created_at>[0-9-:. ]*</created_at>", "").replaceFirst("<updated_at>[0-9-:. ]*</updated_at>", "").replace("<id>1</id>", "");
  29 + return RESOURCE_XML.replaceFirst("<created_at>[0-9-:. ]*</created_at>",
  30 + "")
  31 + .replaceFirst("<updated_at>[0-9-:. ]*</updated_at>", "")
  32 + .replace("<id>1</id>", "");
29 33 }
30 34
31 35 @Override
@@ -46,7 +50,9 @@ protected String resourcesXml() {
46 50 @Override
47 51 protected ResourceFactory<Board> factorySetUp() {
48 52 return new BoardFactory(this.repository,
49   - this.notifications, this.userFactory);
  53 + this.notifications,
  54 + this.userFactory,
  55 + new ListingFactory(this.repository, this.notifications));
50 56 }
51 57
52 58 @Override
@@ -54,10 +60,10 @@ protected String resourcesXml() {
54 60 this.resource = this.factory.newResource(idValue());
55 61
56 62 this.resource.id = 1;
57   - this.resource.name = "first valule of name";
58   - this.resource.fullname = "first valule of fullname";
59   - this.resource.position = 1;
60   - this.resource.enabled = false;
  63 + this.resource.name = "first valule of name";
  64 + this.resource.fullname = "first valule of fullname";
  65 + this.resource.position = 1;
  66 + this.resource.enabled = false;
61 67
62 68 this.repository.addXmlResponse(RESOURCE_XML);
63 69
@@ -84,6 +90,7 @@ public void doTestUpdate() {
84 90 + "<fullname>first valule of fullname</fullname>"
85 91 + "<position>1</position>"
86 92 + "<enabled>false</enabled>"
  93 + + "<listings></listings>"
87 94 + "<created_at>2009-07-09 17:14:48.0</created_at>"
88 95 + "<updated_at>2007-07-09 17:14:48.0</updated_at>"
89 96 + "</board>";

0 comments on commit eb5cc03

Please sign in to comment.
Something went wrong with that request. Please try again.