Changes for page Your First Rest Project

Last modified by Steve Peery on 2013/09/06 11:02

From version 43.1
edited by Pascal Robert
on 2012/12/12 08:00
Change comment: There is no comment for this version
To version 44.1
edited by skcodes
on 2013/05/13 12:53
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.probert
1 +XWiki.skcodes
Content
... ... @@ -75,6 +75,7 @@
75 75  |= Attribute name |= Column |= Prototype
76 76  | content | content | longtext
77 77  | creationDate | creationDate | dateTime
78 +| lastModified | lastModified | dateTime
78 78  
79 79  If you did everything well, the list of attributes should look like this:
80 80  
... ... @@ -93,7 +93,7 @@
93 93  
94 94  If you check in the **Outline** tab, you should see that **Author** now have a **blogEntries** relationship, and **BlogEntry** have a **author** relationship.
95 95  
96 -You are now ready to save the model. Save it (File > Save) and close the **Entity Modeler** window. If you open the **Sources** in the main Eclipse window, you will notice that the **Sources** folder contains a package named **your.app.model**.
97 +You are now ready to save the model. Save it (File > Save) and close the **Entity Modeler** window. If you open the **Sources** in the main Eclipse window, you will notice that the **Sources** folder contains a package named **your.app.model**. (If this folder doesn't appear, you may need to set your preferences to automatically generate these source files; see the second suggestion on http:~/~/wiki.wocommunity.org/display/documentation/Useful+Eclipse+or+WOLips+Preferences.)
97 97  
98 98  That package have four Java classes: **Author**, **Author**, **BlogEntry** and **BlogEntry**. Those classes were generated by Veogen, a templating engine build on Velocity. The two classes that starts with a underscore are recreated every time you change the EOModel, so if you want to change something in those classes, you need to change the template (no need for that right now). But you can change freely the two classes that don't have the underscore, and this is what we will be doing.
99 99  
... ... @@ -111,15 +111,17 @@
111 111  
112 112  {{code}}
113 113  
114 -@Override
115 + @Override
115 115   public void awakeFromInsertion(EOEditingContext editingContext) {
116 - super.awakeFromInsertion(editingContext);
117 - this.setCreationDate(new NSTimestamp());
117 + super.awakeFromInsertion(editingContext);
118 + NSTimestamp now = new NSTimestamp();
119 + setCreationDate(now);
120 + setLastModified(now);
118 118   }
119 119  
120 120  {{/code}}
121 121  
122 -Why are we adding this? **awakeFromInsertion** is a very good way of setting default values when creating a new instance of a Enterprise Object (EO). In this case, we want to set automatically the creation date without having the user to add that value.
125 +Why are we adding this? **awakeFromInsertion** is a very good way of setting default values when creating a new instance of a Enterprise Object (EO). In this case, we want to set automatically the creation and last modification dates without having the user to add those values.
123 123  
124 124  Now, let's use migrations to actually create the database.
125 125