You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by bu...@apache.org on 2015/01/03 11:35:40 UTC

svn commit: r934888 - in /websites/staging/isis/trunk: cgi-bin/ content/ content/intro/tutorials/step-by-step-petclinic.html

Author: buildbot
Date: Sat Jan  3 10:35:40 2015
New Revision: 934888

Log:
Staging update by buildbot for isis

Modified:
    websites/staging/isis/trunk/cgi-bin/   (props changed)
    websites/staging/isis/trunk/content/   (props changed)
    websites/staging/isis/trunk/content/intro/tutorials/step-by-step-petclinic.html

Propchange: websites/staging/isis/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat Jan  3 10:35:40 2015
@@ -1 +1 @@
-1649009
+1649184

Propchange: websites/staging/isis/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat Jan  3 10:35:40 2015
@@ -1 +1 @@
-1649009
+1649184

Modified: websites/staging/isis/trunk/content/intro/tutorials/step-by-step-petclinic.html
==============================================================================
--- websites/staging/isis/trunk/content/intro/tutorials/step-by-step-petclinic.html (original)
+++ websites/staging/isis/trunk/content/intro/tutorials/step-by-step-petclinic.html Sat Jan  3 10:35:40 2015
@@ -693,6 +693,49 @@ git checkout <a href="https://github.com
 </ul></li>
 </ul>
 
+<p>Note that <code>Pet</code> has both both Isis and JDO annotations:</p>
+
+<pre><code>@javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.DATASTORE)
+@javax.jdo.annotations.DatastoreIdentity(
+        strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
+         column="id")
+@javax.jdo.annotations.Version(
+        strategy=VersionStrategy.VERSION_NUMBER, 
+        column="version")
+@javax.jdo.annotations.Unique(name="Pet_name_UNQ", members = {"name"})
+@ObjectType("PET")
+@Bookmarkable
+public class Pet implements Comparable&lt;Pet&gt; {
+    ...
+}
+</code></pre>
+
+<p>where:</p>
+
+<ul>
+<li><code>PersistenceCapable</code> and <code>DatastoreIdentity</code> specify a surrogate <code>Id</code> column to be used as the primary key</li>
+<li><code>Version</code> provides support for optimistic locking</li>
+<li><code>Unique</code> enforces a uniqueness constraint so that no two <code>Pet</code>s can have the same name (unrealistic, but can refactor later)</li>
+<li><code>ObjectType</code> is used by Isis for its own internal "OID" identifier; this also appears in the URL in Isis' Wicket viewer and REST API</li>
+<li><code>Bookmarkable</code> indicates that the object can be automatically bookmarked in Isis' Wicket viewer</li>
+</ul>
+
+<p>The <code>Pets</code> domain service also has Isis annotations:</p>
+
+<pre><code>@DomainService(repositoryFor = Pet.class)
+@DomainServiceLayout(menuOrder = "10")
+public class Pets {
+    ...
+}
+</code></pre>
+
+<p>where:</p>
+
+<ul>
+<li><code>DomainService</code> indicates that the service should be instantiated automatically (as a singleton)</li>
+<li><code>DomainServiceLayout</code> provides UI hints, in this case the positioning of the menu for the actions provided by the service</li>
+</ul>
+
 <p>To run the application will require an update to the IDE configuration, for the changed name of the fixture class:</p>
 
 <p><a href="resources/petclinic/030-01-idea-configuration-updated.png"><img src="resources/petclinic/030-01-idea-configuration-updated.png" width="600"></img></a></p>
@@ -777,28 +820,80 @@ git checkout <a href="https://github.com
 
 <p><a href="resources/petclinic/050-02-view-pet.png"><img src="resources/petclinic/050-02-view-pet.png" width="600"></img></a></p>
 
-<!--
+<h2>Add Pet Owner</h2>
 
+<p><div class="note">
+git checkout <a href="https://github.com/danhaywood/isis-app-petclinic/commit/6f92a8ee8e76696d005da2a8b7a746444d017546">6f92a8ee8e76696d005da2a8b7a746444d017546</a>
+</div></p>
 
+<p>Add the <code>Owner</code> entity and corresponding <code>Owners</code> domain service (repository).  Add a query to find <code>Order</code>s by name:</p>
 
-1bc1bfc0e8ede52078d5fc0c22e1a3af
+<pre><code>...
+@javax.jdo.annotations.Queries( {
+        @javax.jdo.annotations.Query(
+                name = "findByName", language = "JDOQL",
+                value = "SELECT "
+                        + "FROM dom.owners.Owner "
+                        + "WHERE name.matches(:name)")
+})
+public class Owner ... {
+    ...
+}
+</code></pre>
 
+<p>and <code>findByName(...)</code> in <code>Owners</code>:</p>
+
+<pre><code>public class Owners {
+    ...
+    public List&lt;Owner&gt; findByName(
+            @ParameterLayout(named = "Name")
+            final String name) {
+        final String nameArg = String.format(".*%s.*", name);
+        final List&lt;Owner&gt; owners = container.allMatches(
+                new QueryDefault&lt;&gt;(
+                        Owner.class,
+                        "findByName",
+                        "name", nameArg));
+        return owners;
+    }
+    ...
+}
+</code></pre>
 
+<p>Add Pet#owner property, with supporting <code>autoCompleteXxx()</code> method (so that available owners are shown in a drop-down list box):</p>
 
-<div class="note">
-git checkout [6f92a8ee8e76696d005da2a8b7a746444d017546](https://github.com/danhaywood/isis-app-petclinic/commit/6f92a8ee8e76696d005da2a8b7a746444d017546)
-</div>
+<pre><code>public class Pet ... {
+    ...
+    private Owner owner;
+    @javax.jdo.annotations.Column(allowsNull = "false")
+    public Owner getOwner() { return owner; }
+    public void setOwner(final Owner owner) { this.owner = owner; }
+    public Collection&lt;Owner&gt; autoCompleteOwner(final @MinLength(1) String name) {
+        return owners.findByName(name);
+    }
+    ...
+}
+</code></pre>
+
+<p>Also updated fixture data to set up a number of <code>Owner</code>s, and associate each <code>Pet</code> with an <code>Owner</code>.  Also dded unit tests and integration tests for <code>Owner</code>/<code>Owners</code> and updated for <code>Pet</code>/<code>Pets</code>.</p>
+
+<p>When running the app, notice the new <code>Owners</code> menu:</p>
 
+<p><a href="resources/petclinic/060-01-owners-menu.png"><img src="resources/petclinic/060-01-owners-menu.png" width="600"></img></a></p>
 
-<a href="resources/petclinic/060-01-owners-menu.png"><img src="resources/petclinic/060-01-owners-menu.png" width="600"></img></a>
+<p>which when invoked returns all <code>Owner</code> objects:</p>
 
-<a href="resources/petclinic/060-02-owners-list.png"><img src="resources/petclinic/060-02-owners-list.png" width="600"></img></a>
+<p><a href="resources/petclinic/060-02-owners-list.png"><img src="resources/petclinic/060-02-owners-list.png" width="600"></img></a></p>
 
-<a href="resources/petclinic/060-03-pets-list.png"><img src="resources/petclinic/060-03-pets-list.png" width="600"></img></a>
+<p>Each <code>Pet</code> also indicates its corresponding <code>Owner</code>:</p>
 
-<a href="resources/petclinic/060-04-pet-owner-autoComplete.png"><img src="resources/petclinic/060-04-pet-owner-autoComplete.png" width="600"></img></a>
+<p><a href="resources/petclinic/060-03-pets-list.png"><img src="resources/petclinic/060-03-pets-list.png" width="600"></img></a></p>
 
+<p>And, on editing a <code>Pet</code>, a new <code>Owner</code> can be specified using the autoComplete:</p>
 
+<p><a href="resources/petclinic/060-04-pet-owner-autoComplete.png"><img src="resources/petclinic/060-04-pet-owner-autoComplete.png" width="600"></img></a></p>
+
+<!--
 
 
 <div class="note">