You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/19 09:15:03 UTC
[5/12] git commit: ISIS-188: updating quickstart archetype for
wicket/restful/jdo
ISIS-188: updating quickstart archetype for wicket/restful/jdo
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/1c328cf2
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/1c328cf2
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/1c328cf2
Branch: refs/heads/master
Commit: 1c328cf21e7604f0b89135fbc81970713844b604
Parents: f067a9c
Author: Dan Haywood <da...@apache.org>
Authored: Wed Dec 19 00:22:03 2012 +0000
Committer: Dan Haywood <da...@apache.org>
Committed: Wed Dec 19 08:03:28 2012 +0000
----------------------------------------------------------------------
.../application/onlinedemo/dom/items/ToDoItem.java | 7 +-
.../dom/src/main/java/dom/todo/ToDoItems.java | 1 -
.../dom/src/main/java/dom/todo/ToDoItem.java | 261 +-
.../dom/src/main/java/dom/todo/ToDoItems.java | 56 +-
.../main/java/fixture/todo/ToDoItemsFixture.java | 56 +-
.../main/java/objstore/jdo/todo/ToDoItemsJdo.java | 12 +-
.../quickstart_wicket_restful_jdo/pom.xml | 8 +-
.../viewer-restfulobjects/pom.xml | 1 -
.../src/main/resources/app/welcome.html | 4 +-
.../quickstart_wicket_restful_jdo/pom.xml | 44 +
.../META-INF/maven/archetype-metadata.xml | 177 +
.../archetype-resources/dom/log4j.properties | 27 +
.../main/resources/archetype-resources/dom/pom.xml | 161 +
.../dom/src/main/java/META-INF/persistence.xml | 11 +
.../dom/src/main/java/dom/audit/AuditEntry.java | 118 +
.../src/main/java/dom/audit/AuditServiceDemo.java | 30 +
.../dom/src/main/java/dom/todo/ToDoItem.java | 438 +
.../dom/src/main/java/dom/todo/ToDoItems.java | 162 +
.../dom/src/main/resources/images/AuditEntry.png | Bin 0 -> 2215 bytes
.../dom/src/main/resources/images/ToDoItem.gif | Bin 0 -> 1592 bytes
.../resources/archetype-resources/fixture/pom.xml | 38 +
.../src/main/java/fixture/LogonAsSvenFixture.java | 33 +
.../main/java/fixture/todo/ToDoItemsFixture.java | 79 +
.../fixture/todo/ToDoItemsFixturesService.java | 50 +
.../objstore-jdo/lib/.gitignore | 5 +
.../archetype-resources/objstore-jdo/pom.xml | 56 +
.../main/java/objstore/jdo/todo/ToDoItemsJdo.java | 91 +
.../src/main/resources/archetype-resources/pom.xml | 227 +
...wicket_restful_jdo-viewer-restfulobjects.launch | 23 +
.../viewer-restfulobjects/lib/.gitignore | 5 +
.../viewer-restfulobjects/pom.xml | 190 +
.../src/main/jettyconsole/isis-banner.pdn | Bin 0 -> 64679 bytes
.../src/main/jettyconsole/isis-banner.png | Bin 0 -> 24486 bytes
.../src/main/resources/images/Default.png | Bin 0 -> 3016 bytes
.../webapp/WEB-INF/authentication_file.passwords | 28 +
.../webapp/WEB-INF/authentication_file.properties | 28 +
.../main/webapp/WEB-INF/authorization_file.allow | 28 +
.../webapp/WEB-INF/authorization_file.properties | 50 +
.../src/main/webapp/WEB-INF/isis.properties | 176 +
.../src/main/webapp/WEB-INF/logging.properties | 92 +
.../WEB-INF/persistor_datanucleus.properties | 114 +
.../WEB-INF/viewer_restfulobjects.properties | 28 +
.../src/main/webapp/WEB-INF/web.xml | 204 +
.../webapp/jquery.mobile/images/ajax-loader.png | Bin 0 -> 366 bytes
.../webapp/jquery.mobile/images/icons-18-black.png | Bin 0 -> 2152 bytes
.../webapp/jquery.mobile/images/icons-18-white.png | Bin 0 -> 1958 bytes
.../webapp/jquery.mobile/images/icons-36-black.png | Bin 0 -> 4260 bytes
.../webapp/jquery.mobile/images/icons-36-white.png | Bin 0 -> 3746 bytes
.../webapp/jquery.mobile/jquery.mobile-1.0.css | 1847 +++
.../main/webapp/jquery.mobile/jquery.mobile-1.0.js | 6951 +++++++++++
.../jquery.mobile/jquery.mobile.structure-1.0.css | 714 ++
.../webapp/jquery.tmpl/jquery.tmpl-vBeta1.0.0.js | 484 +
.../jquery.tmpl/jquery.tmpl-vBeta1.0.0.min.js | 10 +
.../src/main/webapp/jquery/jquery-1.6.4.js | 9046 +++++++++++++++
.../src/main/webapp/mobile/app.css | 18 +
.../src/main/webapp/mobile/app.js | 24 +
.../src/main/webapp/mobile/generic.js | 226 +
.../src/main/webapp/mobile/index.html | 205 +
.../src/main/webapp/mobile/namespace.js | 13 +
.../src/main/webapp/mobile/util.js | 94 +
...ckstart_wicket_restful_jdo-viewer-wicket.launch | 23 +
.../viewer-wicket/lib/.gitignore | 5 +
.../archetype-resources/viewer-wicket/pom.xml | 187 +
.../ComponentFactoryRegistrarForQuickStart.java | 18 +
.../src/main/java/app/QuickStartApplication.java | 74 +
.../src/main/jettyconsole/isis-banner.pdn | Bin 0 -> 64679 bytes
.../src/main/jettyconsole/isis-banner.png | Bin 0 -> 24486 bytes
.../src/main/resources/app/welcome.html | 12 +
.../src/main/resources/images/Default.png | Bin 0 -> 3016 bytes
.../webapp/WEB-INF/authentication_file.passwords | 28 +
.../webapp/WEB-INF/authentication_file.properties | 28 +
.../main/webapp/WEB-INF/authorization_file.allow | 28 +
.../webapp/WEB-INF/authorization_file.properties | 50 +
.../src/main/webapp/WEB-INF/isis.properties | 183 +
.../src/main/webapp/WEB-INF/logging.properties | 93 +
.../WEB-INF/persistor_datanucleus.properties | 114 +
.../viewer-wicket/src/main/webapp/WEB-INF/web.xml | 136 +
.../src/main/webapp/css/application.css | 32 +
.../src/main/webapp/scripts/application.js | 3 +
.../resources/projects/basic/archetype.properties | 5 +
scripts/updateGeneratedArchetypeSources.groovy | 88 +-
81 files changed, 23725 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/onlinedemo/dom/src/main/java/org/apache/isis/example/application/onlinedemo/dom/items/ToDoItem.java
----------------------------------------------------------------------
diff --git a/example/application/onlinedemo/dom/src/main/java/org/apache/isis/example/application/onlinedemo/dom/items/ToDoItem.java b/example/application/onlinedemo/dom/src/main/java/org/apache/isis/example/application/onlinedemo/dom/items/ToDoItem.java
index d1924a7..d8bf3a8 100644
--- a/example/application/onlinedemo/dom/src/main/java/org/apache/isis/example/application/onlinedemo/dom/items/ToDoItem.java
+++ b/example/application/onlinedemo/dom/src/main/java/org/apache/isis/example/application/onlinedemo/dom/items/ToDoItem.java
@@ -29,6 +29,7 @@ import org.apache.isis.applib.annotation.Ignore;
import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.applib.annotation.Named;
import org.apache.isis.applib.annotation.Optional;
+import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.annotation.RegEx;
import org.apache.isis.applib.clock.Clock;
import org.apache.isis.applib.filter.Filter;
@@ -187,7 +188,7 @@ public class ToDoItem implements Comparable<ToDoItem> {
// }}
// {{ isDue (programmatic)
- @Ignore
+ @Programmatic
// excluded from the framework's metamodel
public boolean isDue() {
if (getDueBy() == null) {
@@ -210,7 +211,7 @@ public class ToDoItem implements Comparable<ToDoItem> {
/**
* by complete flag, then due by date, then description
*/
- @Ignore
+ @Programmatic
// exclude from the framework's metamodel
@Override
public int compareTo(final ToDoItem other) {
@@ -226,7 +227,7 @@ public class ToDoItem implements Comparable<ToDoItem> {
if (getDueBy() != null && other.getDueBy() == null) {
return -1;
}
- if (getDueBy() == null && other.getDueBy() == null || getDueBy().equals(this.getDescription())) {
+ if (getDueBy() == null && other.getDueBy() == null || getDueBy().equals(this.getDueBy())) {
return getDescription().compareTo(other.getDescription());
}
return (int) (getDueBy().getMillisSinceEpoch() - other.getDueBy().getMillisSinceEpoch());
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/quickstart_dnd_junit_bdd/dom/src/main/java/dom/todo/ToDoItems.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_dnd_junit_bdd/dom/src/main/java/dom/todo/ToDoItems.java b/example/application/quickstart_dnd_junit_bdd/dom/src/main/java/dom/todo/ToDoItems.java
index 6d4c12d..d13e71e 100644
--- a/example/application/quickstart_dnd_junit_bdd/dom/src/main/java/dom/todo/ToDoItems.java
+++ b/example/application/quickstart_dnd_junit_bdd/dom/src/main/java/dom/todo/ToDoItems.java
@@ -115,7 +115,6 @@ public class ToDoItems extends AbstractFactoryAndRepository {
// {{ autoComplete (hidden)
@Hidden
- @MemberOrder(sequence = "1")
public List<ToDoItem> autoComplete(final String description) {
return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
index 1edc704..7b639f3 100644
--- a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
+++ b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
@@ -27,8 +27,6 @@ import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.VersionStrategy;
import javax.jdo.spi.PersistenceCapable;
-import org.joda.time.LocalDate;
-
import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.annotation.AutoComplete;
import org.apache.isis.applib.annotation.Disabled;
@@ -37,23 +35,36 @@ import org.apache.isis.applib.annotation.MemberGroups;
import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.applib.annotation.MultiLine;
import org.apache.isis.applib.annotation.Named;
+import org.apache.isis.applib.annotation.NotPersisted;
import org.apache.isis.applib.annotation.ObjectType;
import org.apache.isis.applib.annotation.Optional;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.annotation.RegEx;
import org.apache.isis.applib.annotation.Resolve;
import org.apache.isis.applib.annotation.Resolve.Type;
import org.apache.isis.applib.annotation.Title;
import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.applib.filter.Filters;
+import org.apache.isis.applib.util.TitleBuffer;
import org.apache.isis.core.objectstore.jdo.applib.annotations.Auditable;
+import org.joda.time.LocalDate;
+
+import com.google.common.base.Objects;
@javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.DATASTORE)
@javax.jdo.annotations.DatastoreIdentity(strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY)
@javax.jdo.annotations.Queries( {
@javax.jdo.annotations.Query(
- name="todo_notYetDone", language="JDOQL",
- value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && done == false"),
+ name="todo_all", language="JDOQL",
+ value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy"),
@javax.jdo.annotations.Query(
- name="todo_done", language="JDOQL",
- value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && done == true"),
+ name="todo_notYetComplete", language="JDOQL",
+ value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && complete == false"),
+ @javax.jdo.annotations.Query(
+ name="todo_complete", language="JDOQL",
+ value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && complete == true"),
@javax.jdo.annotations.Query(
name="todo_similarTo", language="JDOQL",
value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && category == :category"),
@@ -66,16 +77,35 @@ import org.apache.isis.core.objectstore.jdo.applib.annotations.Auditable;
@Auditable
@AutoComplete(repository=ToDoItems.class, action="autoComplete")
@MemberGroups({"General", "Detail"})
-public class ToDoItem {
-
+public class ToDoItem implements Comparable<ToDoItem> {
+
+ private static final long ONE_WEEK_IN_MILLIS = 7 * 24 * 60 * 60 * 1000L;
+
public static enum Category {
Professional, Domestic, Other;
}
+ // {{ Identification on the UI
+ public String title() {
+ final TitleBuffer buf = new TitleBuffer();
+ buf.append(getDescription());
+ if (isComplete()) {
+ buf.append(" - Completed!");
+ } else {
+ if (getDueBy() != null) {
+ buf.append(" due by ", getDueBy());
+ }
+ }
+ return buf.toString();
+ }
+
+ // }}
+
// {{ Description
private String description;
- @Title
+ @RegEx(validation = "\\w[@&:\\-\\,\\.\\+ \\w]*")
+ // words, spaces and selected punctuation
@MemberOrder(sequence = "1")
public String getDescription() {
return description;
@@ -86,6 +116,28 @@ public class ToDoItem {
}
// }}
+ // {{ DueBy (property)
+ private LocalDate dueBy;
+
+ @javax.jdo.annotations.Persistent
+ @MemberOrder(name="Detail", sequence = "3")
+ @Optional
+ public LocalDate getDueBy() {
+ return dueBy;
+ }
+
+ public void setDueBy(final LocalDate dueBy) {
+ this.dueBy = dueBy;
+ }
+ // proposed new value is validated before setting
+ public String validateDueBy(final LocalDate dueBy) {
+ if (dueBy == null) {
+ return null;
+ }
+ return isMoreThanOneWeekInPast(dueBy) ? "Due by date cannot be more than one week old" : null;
+ }
+ // }}
+
// {{ Category
private Category category;
@@ -99,34 +151,34 @@ public class ToDoItem {
}
// }}
- // {{ DueBy (property)
- private LocalDate dueBy;
+ // {{ OwnedBy (property)
+ private String ownedBy;
- @javax.jdo.annotations.Persistent
- @MemberOrder(name="Detail", sequence = "3")
- @Optional
- public LocalDate getDueBy() {
- return dueBy;
+ @Hidden
+ // not shown in the UI
+ public String getOwnedBy() {
+ return ownedBy;
}
- public void setDueBy(final LocalDate dueBy) {
- this.dueBy = dueBy;
+ public void setOwnedBy(final String ownedBy) {
+ this.ownedBy = ownedBy;
}
+
// }}
- // {{ Done
- private boolean done;
+ // {{ Complete (property)
+ private boolean complete;
@Disabled
+ // cannot be edited as a property
@MemberOrder(sequence = "4")
- public boolean getDone() {
- return done;
+ public boolean isComplete() {
+ return complete;
}
- public void setDone(final boolean done) {
- this.done = done;
+ public void setComplete(final boolean complete) {
+ this.complete = complete;
}
- // }}
// {{ Notes (property)
private String notes;
@@ -144,18 +196,6 @@ public class ToDoItem {
}
// }}
- // {{ OwnedBy (property, hidden)
- private String ownedBy;
-
- @Hidden
- public String getOwnedBy() {
- return ownedBy;
- }
-
- public void setOwnedBy(final String ownedBy) {
- this.ownedBy = ownedBy;
- }
- // }}
// {{ Version (derived property)
@Hidden(where=Where.ALL_TABLES)
@@ -175,27 +215,31 @@ public class ToDoItem {
}
// }}
- // {{ markAsDone (action)
+ // {{ completed (action)
@MemberOrder(sequence = "1")
- public ToDoItem markAsDone() {
- setDone(true);
+ public ToDoItem completed() {
+ setComplete(true);
return this;
}
- public String disableMarkAsDone() {
- return done ? "Already done" : null;
+ // disable action dependent on state of object
+ public String disableCompleted() {
+ return complete ? "Already completed" : null;
}
+
// }}
- // {{ markAsNotDone (action)
+ // {{ notYetCompleted (action)
@MemberOrder(sequence = "2")
- public ToDoItem markAsNotDone() {
- setDone(false);
+ public ToDoItem notYetCompleted() {
+ setComplete(false);
return this;
}
- public String disableMarkAsNotDone() {
- return !done ? "Not yet done" : null;
+
+ // disable action dependent on state of object
+ public String disableNotYetCompleted() {
+ return !complete ? "Not yet completed" : null;
}
// }}
@@ -251,6 +295,124 @@ public class ToDoItem {
}
// }}
+
+ // {{ clone (action)
+ @Named("Clone")
+ // the name of the action in the UI
+ @MemberOrder(sequence = "3")
+ // nb: method is not called "clone()" is inherited by java.lang.Object and
+ // (a) has different semantics and (b) is in any case automatically ignored
+ // by the framework
+ public ToDoItem duplicate() {
+ return toDoItems.newToDo(getDescription() + " - Copy", getCategory(), getDueBy());
+ }
+ // }}
+
+ // {{ isDue (programmatic)
+ @Programmatic
+ // excluded from the framework's metamodel
+ public boolean isDue() {
+ if (getDueBy() == null) {
+ return false;
+ }
+ return !isMoreThanOneWeekInPast(getDueBy());
+ }
+
+ // }}
+
+
+ // {{ SimilarItems (derived collection)
+ @MemberOrder(sequence = "5")
+ @NotPersisted
+ @Resolve(Type.EAGERLY)
+ public List<ToDoItem> getSimilarItems() {
+ return toDoItems.similarTo(this);
+ }
+
+ // }}
+
+
+
+ // {{ compareTo (programmatic)
+ /**
+ * by complete flag, then due by date, then description
+ */
+ @Programmatic
+ // exclude from the framework's metamodel
+ @Override
+ public int compareTo(final ToDoItem other) {
+ if (isComplete() && !other.isComplete()) {
+ return +1;
+ }
+ if (!isComplete() && other.isComplete()) {
+ return -1;
+ }
+ if (getDueBy() == null && other.getDueBy() != null) {
+ return +1;
+ }
+ if (getDueBy() != null && other.getDueBy() == null) {
+ return -1;
+ }
+ if (getDueBy() == null && other.getDueBy() == null || getDueBy().equals(this.getDueBy())) {
+ return getDescription().compareTo(other.getDescription());
+ }
+ return getDueBy().compareTo(getDueBy());
+ }
+
+ // }}
+
+ // {{ helpers
+ private static boolean isMoreThanOneWeekInPast(final LocalDate dueBy) {
+ return dueBy.toDateTimeAtStartOfDay().getMillis() < Clock.getTime() - ONE_WEEK_IN_MILLIS;
+ }
+
+ // }}
+
+ // {{ filters (programmatic)
+ @SuppressWarnings("unchecked")
+ public static Filter<ToDoItem> thoseDue() {
+ return Filters.and(Filters.not(thoseComplete()), new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem t) {
+ return t.isDue();
+ }
+ });
+ }
+
+ public static Filter<ToDoItem> thoseComplete() {
+ return new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem t) {
+ return t.isComplete();
+ }
+ };
+ }
+
+ public static Filter<ToDoItem> thoseOwnedBy(final String currentUser) {
+ return new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem toDoItem) {
+ return Objects.equal(toDoItem.getOwnedBy(), currentUser);
+ }
+
+ };
+ }
+
+ public static Filter<ToDoItem> thoseSimilarTo(final ToDoItem toDoItem) {
+ return new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem eachToDoItem) {
+ return Objects.equal(toDoItem.getCategory(), eachToDoItem.getCategory()) &&
+ Objects.equal(toDoItem.getOwnedBy(), eachToDoItem.getOwnedBy()) &&
+ eachToDoItem != toDoItem;
+ }
+
+ };
+ }
+
+
+ // }}
+
// {{ injected: DomainObjectContainer
@SuppressWarnings("unused")
private DomainObjectContainer container;
@@ -261,12 +423,13 @@ public class ToDoItem {
// }}
// {{ injected: ToDoItems
- @SuppressWarnings("unused")
private ToDoItems toDoItems;
public void setToDoItems(final ToDoItems toDoItems) {
this.toDoItems = toDoItems;
}
// }}
-
+
+
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItems.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItems.java b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItems.java
index 6d4c12d..c363339 100644
--- a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItems.java
+++ b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItems.java
@@ -19,12 +19,9 @@
package dom.todo;
+import java.util.Collections;
import java.util.List;
-import com.google.common.base.Objects;
-
-import dom.todo.ToDoItem.Category;
-
import org.apache.isis.applib.AbstractFactoryAndRepository;
import org.apache.isis.applib.annotation.ActionSemantics;
import org.apache.isis.applib.annotation.ActionSemantics.Of;
@@ -33,6 +30,11 @@ import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.applib.annotation.Named;
import org.apache.isis.applib.annotation.NotInServiceMenu;
import org.apache.isis.applib.filter.Filter;
+import org.joda.time.LocalDate;
+
+import com.google.common.base.Objects;
+
+import dom.todo.ToDoItem.Category;
@Named("ToDos")
public class ToDoItems extends AbstractFactoryAndRepository {
@@ -48,61 +50,78 @@ public class ToDoItems extends AbstractFactoryAndRepository {
}
// }}
- // {{ notYetDone (action)
+ // {{ notYetComplete (action)
@ActionSemantics(Of.SAFE)
@MemberOrder(sequence = "1")
- public List<ToDoItem> notYetDone() {
+ public List<ToDoItem> notYetComplete() {
return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
@Override
public boolean accept(final ToDoItem t) {
- return ownedByCurrentUser(t) && !t.getDone();
+ return ownedByCurrentUser(t) && !t.isComplete();
}
});
}
// }}
- // {{ done (action)
+ // {{ complete (action)
@ActionSemantics(Of.SAFE)
@MemberOrder(sequence = "2")
- public List<ToDoItem> done() {
+ public List<ToDoItem> complete() {
return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
@Override
public boolean accept(final ToDoItem t) {
- return ownedByCurrentUser(t) && t.getDone();
+ return ownedByCurrentUser(t) && t.isComplete();
}
});
}
// }}
// {{ newToDo (action)
- @MemberOrder(sequence = "2")
+ @MemberOrder(sequence = "3")
public ToDoItem newToDo(
@Named("Description") String description,
- @Named("Category") Category category) {
- final String ownedBy = getContainer().getUser().getName();
- return newToDo(description, category, ownedBy);
+ @Named("Category") Category category,
+ @Named("Due by") LocalDate dueBy) {
+ final String ownedBy = currentUserName();
+ return newToDo(description, category, ownedBy, dueBy);
}
// }}
+
+ // {{ AllToDos (action)
+ @ActionSemantics(Of.SAFE)
+ @MemberOrder(sequence = "4")
+ public List<ToDoItem> allToDos() {
+ final String currentUser = currentUserName();
+ final List<ToDoItem> items = allMatches(ToDoItem.class, ToDoItem.thoseOwnedBy(currentUser));
+ Collections.sort(items);
+ return items;
+ }
+ // }}
+
+
// {{ newToDo (hidden)
@Hidden // for use by fixtures
public ToDoItem newToDo(
String description,
Category category,
- String ownedBy) {
+ String userName,
+ LocalDate dueBy) {
final ToDoItem toDoItem = newTransientInstance(ToDoItem.class);
toDoItem.setDescription(description);
toDoItem.setCategory(category);
- toDoItem.setOwnedBy(ownedBy);
+ toDoItem.setOwnedBy(userName);
+ toDoItem.setDueBy(dueBy);
persist(toDoItem);
return toDoItem;
}
// }}
+
// {{ similarTo (action)
@NotInServiceMenu
@ActionSemantics(Of.SAFE)
- @MemberOrder(sequence = "3")
+ @MemberOrder(sequence = "5")
public List<ToDoItem> similarTo(final ToDoItem toDoItem) {
return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
@Override
@@ -113,9 +132,10 @@ public class ToDoItems extends AbstractFactoryAndRepository {
}
// }}
+
+
// {{ autoComplete (hidden)
@Hidden
- @MemberOrder(sequence = "1")
public List<ToDoItem> autoComplete(final String description) {
return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
index b0c7b61..cfa0e1d 100644
--- a/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
+++ b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
@@ -19,56 +19,58 @@
package fixture.todo;
+import java.util.List;
+
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.fixtures.AbstractFixture;
+import org.joda.time.LocalDate;
+
import dom.todo.ToDoItem;
import dom.todo.ToDoItem.Category;
import dom.todo.ToDoItems;
-import org.apache.isis.applib.fixtures.AbstractFixture;
-
public class ToDoItemsFixture extends AbstractFixture {
@Override
public void install() {
- createFiveFor("sven");
- createThreeFor("dick");
- createTwoFor("bob");
- createOneFor("joe");
- // for exploration user
- createFiveFor("exploration");
- }
+ removeAllToDosForCurrentUser();
- private void createFiveFor(String ownedBy) {
- createToDoItem("Buy milk", Category.Domestic, ownedBy);
- createToDoItem("Pick up laundry", Category.Domestic, ownedBy);
- createToDoItem("Buy stamps", Category.Domestic, ownedBy);
- createToDoItem("Write blog post", Category.Professional, ownedBy);
- createToDoItem("Organize brown bag", Category.Professional, ownedBy);
- }
+ createToDoItemForCurrentUser("Buy milk", Category.Domestic, daysFromToday(0));
+ createToDoItemForCurrentUser("Buy stamps", Category.Domestic, daysFromToday(0));
+ createToDoItemForCurrentUser("Pick up laundry", Category.Other, daysFromToday(6));
+ createToDoItemForCurrentUser("Write blog post", Category.Professional, null);
+ createToDoItemForCurrentUser("Organize brown bag", Category.Professional, daysFromToday(14));
- private void createThreeFor(String ownedBy) {
- createToDoItem("Book car in for service", Category.Domestic, ownedBy);
- createToDoItem("Buy birthday present for sven", Category.Domestic, ownedBy);
- createToDoItem("Write presentation for conference", Category.Professional, ownedBy);
+ getContainer().flush();
}
- private void createTwoFor(String ownedBy) {
- createToDoItem("Write thank you notes", Category.Domestic, ownedBy);
- createToDoItem("Look into solar panels", Category.Domestic, ownedBy);
+ // {{ helpers
+ private void removeAllToDosForCurrentUser() {
+ final List<ToDoItem> allToDos = toDoItems.allToDos();
+ for (final ToDoItem toDoItem : allToDos) {
+ getContainer().remove(toDoItem);
+ }
}
- private void createOneFor(String ownedBy) {
- createToDoItem("Pitch book idea to publisher", Category.Professional, ownedBy);
+ private ToDoItem createToDoItemForCurrentUser(final String description, final Category category, final LocalDate dueBy) {
+ return toDoItems.newToDo(description, category, dueBy);
}
- private ToDoItem createToDoItem(final String description, Category category, String ownedBy) {
- return toDoItems.newToDo(description, category, ownedBy);
+ private static LocalDate daysFromToday(final int i) {
+ final LocalDate date = new LocalDate(Clock.getTimeAsDateTime());
+ return date.plusDays(i);
}
+ // }}
+
+ // {{ injected: ToDoItems
private ToDoItems toDoItems;
public void setToDoItems(final ToDoItems toDoItems) {
this.toDoItems = toDoItems;
}
+ // }}
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/quickstart_wicket_restful_jdo/objstore-jdo/src/main/java/objstore/jdo/todo/ToDoItemsJdo.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/objstore-jdo/src/main/java/objstore/jdo/todo/ToDoItemsJdo.java b/example/application/quickstart_wicket_restful_jdo/objstore-jdo/src/main/java/objstore/jdo/todo/ToDoItemsJdo.java
index 27cf716..1d4112a 100644
--- a/example/application/quickstart_wicket_restful_jdo/objstore-jdo/src/main/java/objstore/jdo/todo/ToDoItemsJdo.java
+++ b/example/application/quickstart_wicket_restful_jdo/objstore-jdo/src/main/java/objstore/jdo/todo/ToDoItemsJdo.java
@@ -32,22 +32,22 @@ import org.apache.isis.applib.query.QueryDefault;
public class ToDoItemsJdo extends ToDoItems {
- // {{ notYetDone (action)
+ // {{ notYetComplete (action)
@Override
- public List<ToDoItem> notYetDone() {
+ public List<ToDoItem> notYetComplete() {
return allMatches(
new QueryDefault<ToDoItem>(ToDoItem.class,
- "todo_notYetDone",
+ "todo_notYetComplete",
"ownedBy", currentUserName()));
}
// }}
// {{ done (action)
@Override
- public List<ToDoItem> done() {
+ public List<ToDoItem> complete() {
return allMatches(
new QueryDefault<ToDoItem>(ToDoItem.class,
- "todo_done",
+ "todo_complete",
"ownedBy", currentUserName()));
}
// }}
@@ -58,7 +58,7 @@ public class ToDoItemsJdo extends ToDoItems {
final List<ToDoItem> similarToDoItems = allMatches(
new QueryDefault<ToDoItem>(ToDoItem.class,
"todo_similarTo",
- "ownedBy", thisToDoItem.getOwnedBy(),
+ "ownedBy", currentUserName(),
"category", thisToDoItem.getCategory()));
return Lists.newArrayList(Iterables.filter(similarToDoItems, excluding(thisToDoItem)));
}
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/quickstart_wicket_restful_jdo/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/pom.xml b/example/application/quickstart_wicket_restful_jdo/pom.xml
index a331706..ada3696 100644
--- a/example/application/quickstart_wicket_restful_jdo/pom.xml
+++ b/example/application/quickstart_wicket_restful_jdo/pom.xml
@@ -30,10 +30,10 @@
<packaging>pom</packaging>
<properties>
- <isis.version>1.0.0-SNAPSHOT</isis.version>
- <isis-objectstore-jdo.version>1.0.0-SNAPSHOT</isis-objectstore-jdo.version>
- <isis-viewer-wicket.version>1.0.0-SNAPSHOT</isis-viewer-wicket.version>
- <isis-viewer-restfulobjects.version>1.0.0-SNAPSHOT</isis-viewer-restfulobjects.version>
+ <isis.version>1.0.0</isis.version>
+ <isis-objectstore-jdo.version>1.0.0</isis-objectstore-jdo.version>
+ <isis-viewer-wicket.version>1.0.0</isis-viewer-wicket.version>
+ <isis-viewer-restfulobjects.version>1.0.0</isis-viewer-restfulobjects.version>
</properties>
<repositories>
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/quickstart_wicket_restful_jdo/viewer-restfulobjects/pom.xml
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/viewer-restfulobjects/pom.xml b/example/application/quickstart_wicket_restful_jdo/viewer-restfulobjects/pom.xml
index 3f3289c..1421bf2 100644
--- a/example/application/quickstart_wicket_restful_jdo/viewer-restfulobjects/pom.xml
+++ b/example/application/quickstart_wicket_restful_jdo/viewer-restfulobjects/pom.xml
@@ -184,7 +184,6 @@
<dependency>
<groupId>org.lazyluke</groupId>
<artifactId>log4jdbc-remix</artifactId>
- <version>0.2.7</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/application/quickstart_wicket_restful_jdo/viewer-wicket/src/main/resources/app/welcome.html
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/viewer-wicket/src/main/resources/app/welcome.html b/example/application/quickstart_wicket_restful_jdo/viewer-wicket/src/main/resources/app/welcome.html
index 8975fa8..6188923 100644
--- a/example/application/quickstart_wicket_restful_jdo/viewer-wicket/src/main/resources/app/welcome.html
+++ b/example/application/quickstart_wicket_restful_jdo/viewer-wicket/src/main/resources/app/welcome.html
@@ -1,9 +1,9 @@
<p class="intro">
-This is a one-domain application, configured to run with Isis' wicket viewer and the JDO/DataNucleus objectstore.
+This is a <a href="https://github.com/apache/isis/blob/master/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java" target="_blank">single-class</a> domain application, configured to run with Isis' wicket viewer and the JDO/DataNucleus objectstore.
</p>
<br/>
<br/>
<p>
-For more details, see <a href="http://isis.apache.org/documentation.html">Isis website</a>.
+For more details, see the <a href="http://isis.apache.org/documentation.html" target="_blank">Isis website</a>.
</p>
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/pom.xml
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/pom.xml b/example/archetype/quickstart_wicket_restful_jdo/pom.xml
new file mode 100644
index 0000000..2ee4af2
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.isis.archetype</groupId>
+ <artifactId>quickstart_wicket_restful_jdo-archetype</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+ <name>quickstart_wicket_restful_jdo-archetype</name>
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.2</version>
+ </extension>
+ </extensions>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/META-INF/maven/archetype-metadata.xml b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..39b7f5d
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" name="quickstart_wicket_restful_jdo" xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modules>
+ <module id="${rootArtifactId}-dom" dir="dom" name="${rootArtifactId}-dom">
+ <fileSets>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.png</include>
+ <include>**/*.gif</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory/>
+ <includes>
+ <include>log4j.properties</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ </module>
+ <module id="${rootArtifactId}-fixture" dir="fixture" name="${rootArtifactId}-fixture">
+ <fileSets>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ </module>
+ <module id="${rootArtifactId}-objstore-jdo" dir="objstore-jdo" name="${rootArtifactId}-objstore-jdo">
+ <fileSets>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>lib</directory>
+ <includes>
+ <include>**/*.gitignore</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ </module>
+ <module id="${rootArtifactId}-viewer-restfulobjects" dir="viewer-restfulobjects" name="${rootArtifactId}-viewer-restfulobjects">
+ <fileSets>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.html</include>
+ <include>**/*.properties</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>src/main/jettyconsole</directory>
+ <includes>
+ <include>**/*.png</include>
+ <include>**/*.pdn</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.passwords</include>
+ <include>**/*.allow</include>
+ <include>**/*.png</include>
+ <include>**/*.js</include>
+ <include>**/*.css</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.png</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>lib</directory>
+ <includes>
+ <include>**/*.gitignore</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>ide/eclipse</directory>
+ <includes>
+ <include>**/*.launch</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ </module>
+ <module id="${rootArtifactId}-viewer-wicket" dir="viewer-wicket" name="${rootArtifactId}-viewer-wicket">
+ <fileSets>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.html</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>src/main/jettyconsole</directory>
+ <includes>
+ <include>**/*.png</include>
+ <include>**/*.pdn</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>src/main/webapp</directory>
+ <includes>
+ <include>**/*.passwords</include>
+ <include>**/*.allow</include>
+ <include>**/*.js</include>
+ <include>**/*.css</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.png</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>lib</directory>
+ <includes>
+ <include>**/*.gitignore</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>ide/eclipse</directory>
+ <includes>
+ <include>**/*.launch</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ </module>
+ </modules>
+</archetype-descriptor>
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/log4j.properties
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/log4j.properties b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/log4j.properties
new file mode 100644
index 0000000..43ee48c
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/log4j.properties
@@ -0,0 +1,27 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+${symbol_pound} LOG4J Configuration
+${symbol_pound} ===================
+
+${symbol_pound} Basic logging goes to "datanucleus.log"
+log4j.appender.A1=org.apache.log4j.FileAppender
+log4j.appender.A1.File=datanucleus.log
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n
+${symbol_pound}log4j.appender.A1.Threshold=INFO
+
+${symbol_pound} Categories
+${symbol_pound} Each category can be set to a "level", and to direct to an appender
+
+${symbol_pound} Default to DEBUG level for all DataNucleus categories
+log4j.logger.DataNucleus = DEBUG, A1
+
+log4j.category.com.mchange.v2.c3p0=INFO, A1
+log4j.category.com.mchange.v2.resourcepool=INFO, A1
+log4j.category.org.logicalcobwebs.proxool=INFO,A1
+
+
+${symbol_pound} Hbase libs logging
+log4j.category.org.apache.hadoop=INFO,A1
+log4j.category.org.apache.zookeeper=INFO,A1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/pom.xml
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/pom.xml b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/pom.xml
new file mode 100644
index 0000000..dc9a823
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/pom.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>${groupId}</groupId>
+ <artifactId>${rootArtifactId}</artifactId>
+ <version>${version}</version>
+ </parent>
+
+ <artifactId>${artifactId}</artifactId>
+ <name>Quickstart Wicket/Restful/JDO DOM</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>maven-datanucleus-plugin</artifactId>
+ <version>3.1.1</version>
+ <configuration>
+ <fork>false</fork>
+ <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
+ <verbose>true</verbose>
+ <props>${basedir}/datanucleus.properties</props>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>maven-datanucleus-plugin</artifactId>
+ <versionRange>[3.0.2,)</versionRange>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- for DataNucleus, see below -->
+ <dependency>
+ <groupId>org.apache.isis.objectstore</groupId>
+ <artifactId>isis-objectstore-jdo</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-applib</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.objectstore</groupId>
+ <artifactId>isis-objectstore-jdo-applib</artifactId>
+ </dependency>
+
+
+ <!-- DataNucleus (horrid, but needed to run the enhancer)-->
+ <dependency>
+ <groupId>javax.jdo</groupId>
+ <artifactId>jdo-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-enhancer</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-api-jdo</artifactId>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>not-m2e</id>
+ <activation>
+ <property>
+ <name>!m2e.version</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-core</artifactId>
+ <version>(3.0.99, 3.1.99)</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-enhancer</artifactId>
+ <version>(3.0.99, 3.1.99)</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/META-INF/persistence.xml b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/META-INF/persistence.xml
new file mode 100644
index 0000000..b7b8f6f
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/META-INF/persistence.xml
@@ -0,0 +1,11 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?xml version="1.0" encoding="UTF-8" ?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
+
+ <persistence-unit name="quickstart">
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/audit/AuditEntry.java
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/audit/AuditEntry.java b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/audit/AuditEntry.java
new file mode 100644
index 0000000..5d1e43b
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/audit/AuditEntry.java
@@ -0,0 +1,118 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package dom.audit;
+
+import javax.jdo.annotations.IdGeneratorStrategy;
+import javax.jdo.annotations.IdentityType;
+
+import org.apache.isis.applib.annotation.Hidden;
+import org.apache.isis.applib.annotation.Immutable;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.annotation.Title;
+import org.apache.isis.applib.bookmarks.Bookmark;
+import org.apache.isis.applib.bookmarks.BookmarkHolder;
+import org.apache.isis.applib.value.DateTime;
+
+@javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.DATASTORE)
+@javax.jdo.annotations.DatastoreIdentity(strategy=IdGeneratorStrategy.UUIDHEX)
+@Immutable
+public class AuditEntry implements BookmarkHolder {
+
+ // {{ TimestampUtc (property)
+ private Long timestampEpoch;
+
+ @Hidden
+ public Long getTimestampEpoch() {
+ return timestampEpoch;
+ }
+
+ public void setTimestampEpoch(final Long timestampEpoch) {
+ this.timestampEpoch = timestampEpoch;
+ }
+ // }}
+
+ // {{ Timestamp (property)
+ @Title(sequence="1")
+ @MemberOrder(sequence = "1")
+ public DateTime getTimestamp() {
+ return timestampEpoch != null? new DateTime(timestampEpoch): null;
+ }
+
+ // }}
+
+ // {{ User (property)
+ private String user;
+
+ @MemberOrder(sequence = "2")
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(final String user) {
+ this.user = user;
+ }
+ // }}
+
+ // {{ ObjectType (property)
+ private String objectType;
+
+ @Title(sequence="3", prepend=":")
+ @MemberOrder(sequence = "3")
+ public String getObjectType() {
+ return objectType;
+ }
+
+ public void setObjectType(final String objectType) {
+ this.objectType = objectType;
+ }
+ // }}
+
+ // {{ Identifier (property)
+ private String identifier;
+
+ @MemberOrder(sequence = "4")
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public void setIdentifier(final String identifier) {
+ this.identifier = identifier;
+ }
+ // }}
+
+ // {{ PreValue (property)
+ private String preValue;
+
+ @MemberOrder(sequence = "5")
+ public String getPreValue() {
+ return preValue;
+ }
+
+ public void setPreValue(final String preValue) {
+ this.preValue = preValue;
+ }
+ // }}
+
+ // {{ PostValue (property)
+ private String postValue;
+
+ @MemberOrder(sequence = "6")
+ public String getPostValue() {
+ return postValue;
+ }
+
+ public void setPostValue(final String postValue) {
+ this.postValue = postValue;
+ }
+ // }}
+
+ // {{ bookmark (action)
+ @Override
+ @Programmatic
+ public Bookmark bookmark() {
+ return new Bookmark(getObjectType(), getIdentifier());
+ }
+ // }}
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/audit/AuditServiceDemo.java
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/audit/AuditServiceDemo.java b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/audit/AuditServiceDemo.java
new file mode 100644
index 0000000..a33a9e9
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/audit/AuditServiceDemo.java
@@ -0,0 +1,30 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package dom.audit;
+
+import java.util.List;
+
+import org.apache.isis.applib.AbstractFactoryAndRepository;
+import org.apache.isis.applib.annotation.Hidden;
+import org.apache.isis.objectstore.jdo.applib.AuditService;
+
+public class AuditServiceDemo extends AbstractFactoryAndRepository implements AuditService {
+
+ public List<AuditEntry> list() {
+ return allInstances(AuditEntry.class);
+ }
+
+ @Hidden
+ public void audit(String user, long currentTimestampEpoch, String objectType, String identifier, String preValue, String postValue) {
+ AuditEntry auditEntry = newTransientInstance(AuditEntry.class);
+ auditEntry.setTimestampEpoch(currentTimestampEpoch);
+ auditEntry.setUser(user);
+ auditEntry.setObjectType(objectType);
+ auditEntry.setIdentifier(identifier);
+ auditEntry.setPreValue(preValue);
+ auditEntry.setPostValue(postValue);
+ persist(auditEntry);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/todo/ToDoItem.java
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/todo/ToDoItem.java b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/todo/ToDoItem.java
new file mode 100644
index 0000000..0adbd9b
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/todo/ToDoItem.java
@@ -0,0 +1,438 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package dom.todo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.annotations.IdentityType;
+import javax.jdo.annotations.VersionStrategy;
+import javax.jdo.spi.PersistenceCapable;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.annotation.AutoComplete;
+import org.apache.isis.applib.annotation.Disabled;
+import org.apache.isis.applib.annotation.Hidden;
+import org.apache.isis.applib.annotation.MemberGroups;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.MultiLine;
+import org.apache.isis.applib.annotation.Named;
+import org.apache.isis.applib.annotation.NotPersisted;
+import org.apache.isis.applib.annotation.ObjectType;
+import org.apache.isis.applib.annotation.Optional;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.annotation.RegEx;
+import org.apache.isis.applib.annotation.Resolve;
+import org.apache.isis.applib.annotation.Resolve.Type;
+import org.apache.isis.applib.annotation.Title;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.applib.filter.Filters;
+import org.apache.isis.applib.util.TitleBuffer;
+import org.apache.isis.core.objectstore.jdo.applib.annotations.Auditable;
+import org.joda.time.LocalDate;
+
+import com.google.common.base.Objects;
+
+@javax.jdo.annotations.PersistenceCapable(identityType=IdentityType.DATASTORE)
+@javax.jdo.annotations.DatastoreIdentity(strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY)
+@javax.jdo.annotations.Queries( {
+ @javax.jdo.annotations.Query(
+ name="todo_all", language="JDOQL",
+ value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy"),
+ @javax.jdo.annotations.Query(
+ name="todo_notYetComplete", language="JDOQL",
+ value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && complete == false"),
+ @javax.jdo.annotations.Query(
+ name="todo_complete", language="JDOQL",
+ value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && complete == true"),
+ @javax.jdo.annotations.Query(
+ name="todo_similarTo", language="JDOQL",
+ value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && category == :category"),
+ @javax.jdo.annotations.Query(
+ name="todo_autoComplete", language="JDOQL",
+ value="SELECT FROM dom.todo.ToDoItem WHERE ownedBy == :ownedBy && description.startsWith(:description)")
+})
+@javax.jdo.annotations.Version(strategy=VersionStrategy.VERSION_NUMBER, column="VERSION")
+@ObjectType("TODO")
+@Auditable
+@AutoComplete(repository=ToDoItems.class, action="autoComplete")
+@MemberGroups({"General", "Detail"})
+public class ToDoItem implements Comparable<ToDoItem> {
+
+ private static final long ONE_WEEK_IN_MILLIS = 7 * 24 * 60 * 60 * 1000L;
+
+ public static enum Category {
+ Professional, Domestic, Other;
+ }
+
+ // {{ Identification on the UI
+ public String title() {
+ final TitleBuffer buf = new TitleBuffer();
+ buf.append(getDescription());
+ if (isComplete()) {
+ buf.append(" - Completed!");
+ } else {
+ if (getDueBy() != null) {
+ buf.append(" due by ", getDueBy());
+ }
+ }
+ return buf.toString();
+ }
+
+ // }}
+
+ // {{ Description
+ private String description;
+
+ @RegEx(validation = "${symbol_escape}${symbol_escape}w[@&:${symbol_escape}${symbol_escape}-${symbol_escape}${symbol_escape},${symbol_escape}${symbol_escape}.${symbol_escape}${symbol_escape}+ ${symbol_escape}${symbol_escape}w]*")
+ // words, spaces and selected punctuation
+ @MemberOrder(sequence = "1")
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(final String description) {
+ this.description = description;
+ }
+ // }}
+
+ // {{ DueBy (property)
+ private LocalDate dueBy;
+
+ @javax.jdo.annotations.Persistent
+ @MemberOrder(name="Detail", sequence = "3")
+ @Optional
+ public LocalDate getDueBy() {
+ return dueBy;
+ }
+
+ public void setDueBy(final LocalDate dueBy) {
+ this.dueBy = dueBy;
+ }
+ // proposed new value is validated before setting
+ public String validateDueBy(final LocalDate dueBy) {
+ if (dueBy == null) {
+ return null;
+ }
+ return isMoreThanOneWeekInPast(dueBy) ? "Due by date cannot be more than one week old" : null;
+ }
+ // }}
+
+ // {{ Category
+ private Category category;
+
+ @MemberOrder(sequence = "2")
+ public Category getCategory() {
+ return category;
+ }
+
+ public void setCategory(final Category category) {
+ this.category = category;
+ }
+ // }}
+
+ // {{ OwnedBy (property)
+ private String ownedBy;
+
+ @Hidden
+ // not shown in the UI
+ public String getOwnedBy() {
+ return ownedBy;
+ }
+
+ public void setOwnedBy(final String ownedBy) {
+ this.ownedBy = ownedBy;
+ }
+
+ // }}
+
+ // {{ Complete (property)
+ private boolean complete;
+
+ @Disabled
+ // cannot be edited as a property
+ @MemberOrder(sequence = "4")
+ public boolean isComplete() {
+ return complete;
+ }
+
+ public void setComplete(final boolean complete) {
+ this.complete = complete;
+ }
+
+ // {{ Notes (property)
+ private String notes;
+
+ @Hidden(where=Where.ALL_TABLES)
+ @Optional
+ @MultiLine(numberOfLines=5)
+ @MemberOrder(name="Detail", sequence = "6")
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(final String notes) {
+ this.notes = notes;
+ }
+ // }}
+
+
+ // {{ Version (derived property)
+ @Hidden(where=Where.ALL_TABLES)
+ @Disabled
+ @MemberOrder(name="Detail", sequence = "99")
+ @Named("Version")
+ public Long getVersionSequence() {
+ if(!(this instanceof PersistenceCapable)) {
+ return null;
+ }
+ PersistenceCapable persistenceCapable = (PersistenceCapable) this;
+ final Long version = (Long) JDOHelper.getVersion(persistenceCapable);
+ return version;
+ }
+ public boolean hideVersionSequence() {
+ return !(this instanceof PersistenceCapable);
+ }
+ // }}
+
+ // {{ completed (action)
+ @MemberOrder(sequence = "1")
+ public ToDoItem completed() {
+ setComplete(true);
+ return this;
+ }
+
+ // disable action dependent on state of object
+ public String disableCompleted() {
+ return complete ? "Already completed" : null;
+ }
+
+ // }}
+
+ // {{ notYetCompleted (action)
+ @MemberOrder(sequence = "2")
+ public ToDoItem notYetCompleted() {
+ setComplete(false);
+ return this;
+ }
+
+
+ // disable action dependent on state of object
+ public String disableNotYetCompleted() {
+ return !complete ? "Not yet completed" : null;
+ }
+ // }}
+
+ // {{ dependencies (Collection)
+ private List<ToDoItem> dependencies = new ArrayList<ToDoItem>();
+
+ @Disabled
+ @MemberOrder(sequence = "1")
+ @Resolve(Type.EAGERLY)
+ public List<ToDoItem> getDependencies() {
+ return dependencies;
+ }
+
+ public void setDependencies(final List<ToDoItem> dependencies) {
+ this.dependencies = dependencies;
+ }
+ // }}
+
+ // {{ add (action)
+ @MemberOrder(name="dependencies", sequence = "3")
+ public ToDoItem add(final ToDoItem toDoItem) {
+ getDependencies().add(toDoItem);
+ return this;
+ }
+ public String validateAdd(final ToDoItem toDoItem) {
+ if(getDependencies().contains(toDoItem)) {
+ return "Already a dependency";
+ }
+ if(toDoItem == this) {
+ return "Can't set up a dependency to self";
+ }
+ return null;
+ }
+ // }}
+
+ // {{ remove (action)
+ @MemberOrder(name="dependencies", sequence = "4")
+ public ToDoItem remove(final ToDoItem toDoItem) {
+ getDependencies().remove(toDoItem);
+ return this;
+ }
+ public String disableRemove() {
+ return getDependencies().isEmpty()? "No dependencies to remove": null;
+ }
+ public String validateRemove(final ToDoItem toDoItem) {
+ if(!getDependencies().contains(toDoItem)) {
+ return "Not a dependency";
+ }
+ return null;
+ }
+ public List<ToDoItem> choices0Remove() {
+ return getDependencies();
+ }
+ // }}
+
+
+ // {{ clone (action)
+ @Named("Clone")
+ // the name of the action in the UI
+ @MemberOrder(sequence = "3")
+ // nb: method is not called "clone()" is inherited by java.lang.Object and
+ // (a) has different semantics and (b) is in any case automatically ignored
+ // by the framework
+ public ToDoItem duplicate() {
+ return toDoItems.newToDo(getDescription() + " - Copy", getCategory(), getDueBy());
+ }
+ // }}
+
+ // {{ isDue (programmatic)
+ @Programmatic
+ // excluded from the framework's metamodel
+ public boolean isDue() {
+ if (getDueBy() == null) {
+ return false;
+ }
+ return !isMoreThanOneWeekInPast(getDueBy());
+ }
+
+ // }}
+
+
+ // {{ SimilarItems (derived collection)
+ @MemberOrder(sequence = "5")
+ @NotPersisted
+ @Resolve(Type.EAGERLY)
+ public List<ToDoItem> getSimilarItems() {
+ return toDoItems.similarTo(this);
+ }
+
+ // }}
+
+
+
+ // {{ compareTo (programmatic)
+ /**
+ * by complete flag, then due by date, then description
+ */
+ @Programmatic
+ // exclude from the framework's metamodel
+ @Override
+ public int compareTo(final ToDoItem other) {
+ if (isComplete() && !other.isComplete()) {
+ return +1;
+ }
+ if (!isComplete() && other.isComplete()) {
+ return -1;
+ }
+ if (getDueBy() == null && other.getDueBy() != null) {
+ return +1;
+ }
+ if (getDueBy() != null && other.getDueBy() == null) {
+ return -1;
+ }
+ if (getDueBy() == null && other.getDueBy() == null || getDueBy().equals(this.getDueBy())) {
+ return getDescription().compareTo(other.getDescription());
+ }
+ return getDueBy().compareTo(getDueBy());
+ }
+
+ // }}
+
+ // {{ helpers
+ private static boolean isMoreThanOneWeekInPast(final LocalDate dueBy) {
+ return dueBy.toDateTimeAtStartOfDay().getMillis() < Clock.getTime() - ONE_WEEK_IN_MILLIS;
+ }
+
+ // }}
+
+ // {{ filters (programmatic)
+ @SuppressWarnings("unchecked")
+ public static Filter<ToDoItem> thoseDue() {
+ return Filters.and(Filters.not(thoseComplete()), new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem t) {
+ return t.isDue();
+ }
+ });
+ }
+
+ public static Filter<ToDoItem> thoseComplete() {
+ return new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem t) {
+ return t.isComplete();
+ }
+ };
+ }
+
+ public static Filter<ToDoItem> thoseOwnedBy(final String currentUser) {
+ return new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem toDoItem) {
+ return Objects.equal(toDoItem.getOwnedBy(), currentUser);
+ }
+
+ };
+ }
+
+ public static Filter<ToDoItem> thoseSimilarTo(final ToDoItem toDoItem) {
+ return new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem eachToDoItem) {
+ return Objects.equal(toDoItem.getCategory(), eachToDoItem.getCategory()) &&
+ Objects.equal(toDoItem.getOwnedBy(), eachToDoItem.getOwnedBy()) &&
+ eachToDoItem != toDoItem;
+ }
+
+ };
+ }
+
+
+ // }}
+
+ // {{ injected: DomainObjectContainer
+ @SuppressWarnings("unused")
+ private DomainObjectContainer container;
+
+ public void setDomainObjectContainer(final DomainObjectContainer container) {
+ this.container = container;
+ }
+ // }}
+
+ // {{ injected: ToDoItems
+ private ToDoItems toDoItems;
+
+ public void setToDoItems(final ToDoItems toDoItems) {
+ this.toDoItems = toDoItems;
+ }
+ // }}
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/todo/ToDoItems.java
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/todo/ToDoItems.java b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/todo/ToDoItems.java
new file mode 100644
index 0000000..152ff3f
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/java/dom/todo/ToDoItems.java
@@ -0,0 +1,162 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package dom.todo;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.applib.AbstractFactoryAndRepository;
+import org.apache.isis.applib.annotation.ActionSemantics;
+import org.apache.isis.applib.annotation.ActionSemantics.Of;
+import org.apache.isis.applib.annotation.Hidden;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Named;
+import org.apache.isis.applib.annotation.NotInServiceMenu;
+import org.apache.isis.applib.filter.Filter;
+import org.joda.time.LocalDate;
+
+import com.google.common.base.Objects;
+
+import dom.todo.ToDoItem.Category;
+
+@Named("ToDos")
+public class ToDoItems extends AbstractFactoryAndRepository {
+
+ // {{ Id, iconName
+ @Override
+ public String getId() {
+ return "toDoItems";
+ }
+
+ public String iconName() {
+ return "ToDoItem";
+ }
+ // }}
+
+ // {{ notYetComplete (action)
+ @ActionSemantics(Of.SAFE)
+ @MemberOrder(sequence = "1")
+ public List<ToDoItem> notYetComplete() {
+ return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem t) {
+ return ownedByCurrentUser(t) && !t.isComplete();
+ }
+ });
+ }
+ // }}
+
+ // {{ complete (action)
+ @ActionSemantics(Of.SAFE)
+ @MemberOrder(sequence = "2")
+ public List<ToDoItem> complete() {
+ return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem t) {
+ return ownedByCurrentUser(t) && t.isComplete();
+ }
+ });
+ }
+ // }}
+
+ // {{ newToDo (action)
+ @MemberOrder(sequence = "3")
+ public ToDoItem newToDo(
+ @Named("Description") String description,
+ @Named("Category") Category category,
+ @Named("Due by") LocalDate dueBy) {
+ final String ownedBy = currentUserName();
+ return newToDo(description, category, ownedBy, dueBy);
+ }
+ // }}
+
+
+ // {{ AllToDos (action)
+ @ActionSemantics(Of.SAFE)
+ @MemberOrder(sequence = "4")
+ public List<ToDoItem> allToDos() {
+ final String currentUser = currentUserName();
+ final List<ToDoItem> items = allMatches(ToDoItem.class, ToDoItem.thoseOwnedBy(currentUser));
+ Collections.sort(items);
+ return items;
+ }
+ // }}
+
+
+ // {{ newToDo (hidden)
+ @Hidden // for use by fixtures
+ public ToDoItem newToDo(
+ String description,
+ Category category,
+ String userName,
+ LocalDate dueBy) {
+ final ToDoItem toDoItem = newTransientInstance(ToDoItem.class);
+ toDoItem.setDescription(description);
+ toDoItem.setCategory(category);
+ toDoItem.setOwnedBy(userName);
+ toDoItem.setDueBy(dueBy);
+ persist(toDoItem);
+ return toDoItem;
+ }
+ // }}
+
+
+ // {{ similarTo (action)
+ @NotInServiceMenu
+ @ActionSemantics(Of.SAFE)
+ @MemberOrder(sequence = "5")
+ public List<ToDoItem> similarTo(final ToDoItem toDoItem) {
+ return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(ToDoItem t) {
+ return t != toDoItem && Objects.equal(toDoItem.getCategory(), t.getCategory()) && Objects.equal(toDoItem.getOwnedBy(), t.getOwnedBy());
+ }
+ });
+ }
+ // }}
+
+
+
+ // {{ autoComplete (hidden)
+ @Hidden
+ public List<ToDoItem> autoComplete(final String description) {
+ return allMatches(ToDoItem.class, new Filter<ToDoItem>() {
+ @Override
+ public boolean accept(final ToDoItem t) {
+ return ownedByCurrentUser(t) && t.getDescription().contains(description);
+ }
+
+ });
+ }
+ // }}
+
+ // {{ helpers
+ protected boolean ownedByCurrentUser(final ToDoItem t) {
+ return Objects.equal(t.getOwnedBy(), currentUserName());
+ }
+ protected String currentUserName() {
+ return getContainer().getUser().getName();
+ }
+ // }}
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/resources/images/AuditEntry.png
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/resources/images/AuditEntry.png b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/resources/images/AuditEntry.png
new file mode 100644
index 0000000..950d792
Binary files /dev/null and b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/resources/images/AuditEntry.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/resources/images/ToDoItem.gif
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/resources/images/ToDoItem.gif b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/resources/images/ToDoItem.gif
new file mode 100644
index 0000000..cc536e1
Binary files /dev/null and b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/dom/src/main/resources/images/ToDoItem.gif differ
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/pom.xml
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/pom.xml b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/pom.xml
new file mode 100644
index 0000000..1872775
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>${groupId}</groupId>
+ <artifactId>${rootArtifactId}</artifactId>
+ <version>${version}</version>
+ </parent>
+
+ <artifactId>${artifactId}</artifactId>
+ <name>Quickstart Wicket/Restful/JDO Fixtures</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${rootArtifactId}-dom</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/src/main/java/fixture/LogonAsSvenFixture.java
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/src/main/java/fixture/LogonAsSvenFixture.java b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/src/main/java/fixture/LogonAsSvenFixture.java
new file mode 100644
index 0000000..86f60ee
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/src/main/java/fixture/LogonAsSvenFixture.java
@@ -0,0 +1,33 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package fixture;
+
+import org.apache.isis.applib.fixtures.LogonFixture;
+
+public class LogonAsSvenFixture extends LogonFixture {
+
+ public LogonAsSvenFixture() {
+ super("sven");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/1c328cf2/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
----------------------------------------------------------------------
diff --git a/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
new file mode 100644
index 0000000..d954ef9
--- /dev/null
+++ b/example/archetype/quickstart_wicket_restful_jdo/src/main/resources/archetype-resources/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
@@ -0,0 +1,79 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package fixture.todo;
+
+import java.util.List;
+
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.fixtures.AbstractFixture;
+import org.joda.time.LocalDate;
+
+import dom.todo.ToDoItem;
+import dom.todo.ToDoItem.Category;
+import dom.todo.ToDoItems;
+
+public class ToDoItemsFixture extends AbstractFixture {
+
+ @Override
+ public void install() {
+
+ removeAllToDosForCurrentUser();
+
+ createToDoItemForCurrentUser("Buy milk", Category.Domestic, daysFromToday(0));
+ createToDoItemForCurrentUser("Buy stamps", Category.Domestic, daysFromToday(0));
+ createToDoItemForCurrentUser("Pick up laundry", Category.Other, daysFromToday(6));
+ createToDoItemForCurrentUser("Write blog post", Category.Professional, null);
+ createToDoItemForCurrentUser("Organize brown bag", Category.Professional, daysFromToday(14));
+
+ getContainer().flush();
+ }
+
+ // {{ helpers
+ private void removeAllToDosForCurrentUser() {
+ final List<ToDoItem> allToDos = toDoItems.allToDos();
+ for (final ToDoItem toDoItem : allToDos) {
+ getContainer().remove(toDoItem);
+ }
+ }
+
+ private ToDoItem createToDoItemForCurrentUser(final String description, final Category category, final LocalDate dueBy) {
+ return toDoItems.newToDo(description, category, dueBy);
+ }
+
+ private static LocalDate daysFromToday(final int i) {
+ final LocalDate date = new LocalDate(Clock.getTimeAsDateTime());
+ return date.plusDays(i);
+ }
+
+ // }}
+
+ // {{ injected: ToDoItems
+ private ToDoItems toDoItems;
+
+ public void setToDoItems(final ToDoItems toDoItems) {
+ this.toDoItems = toDoItems;
+ }
+ // }}
+
+
+}