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 2014/09/26 19:43:38 UTC
git commit: ISIS-866: example of usage in the todoapp.
Repository: isis
Updated Branches:
refs/heads/master 97fec9f45 -> 73298e02c
ISIS-866: example of usage in the todoapp.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/73298e02
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/73298e02
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/73298e02
Branch: refs/heads/master
Commit: 73298e02c0f3c22774e06950f610b75551cf31e8
Parents: 97fec9f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Sep 26 18:43:23 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri Sep 26 18:43:23 2014 +0100
----------------------------------------------------------------------
.../applib/services/wrapper/WrapperFactory.java | 5 ++-
.../dom/src/main/java/dom/todo/ToDoItem.java | 32 ++++++++++++++------
.../java/dom/todo/ToDoItemSubscriptions.java | 10 +++---
.../webapp/src/main/resources/webapp/realm1.ini | 5 ++-
4 files changed, 33 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/73298e02/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java b/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java
index 4a1a6de..60af57d 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java
@@ -207,13 +207,16 @@ public interface WrapperFactory {
* Whether the supplied object has been wrapped.
*
* @param <T>
- * @param possibleWrapper
+ * @param possibleWrappedDomainObject
* - object that might or might not be a wrapper.
* @return
*/
@Programmatic
<T> boolean isWrapper(T possibleWrappedDomainObject);
+
+
+
/**
* All {@link InteractionListener}s that have been registered using
* {@link #addInteractionListener(InteractionListener)}.
http://git-wip-us.apache.org/repos/asf/isis/blob/73298e02/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItem.java
----------------------------------------------------------------------
diff --git a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItem.java b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItem.java
index dd8f19c..7aaff27 100644
--- a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItem.java
+++ b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItem.java
@@ -37,9 +37,11 @@ import org.apache.isis.applib.annotation.*;
import org.apache.isis.applib.annotation.ActionSemantics.Of;
import org.apache.isis.applib.annotation.Bulk.AppliesTo;
import org.apache.isis.applib.annotation.Bulk.InteractionContext.InvokedAs;
+import org.apache.isis.applib.security.UserMemento;
import org.apache.isis.applib.services.eventbus.ActionInteractionEvent;
import org.apache.isis.applib.services.eventbus.EventBusService;
import org.apache.isis.applib.services.scratchpad.Scratchpad;
+import org.apache.isis.applib.services.wrapper.HiddenException;
import org.apache.isis.applib.services.wrapper.WrapperFactory;
import org.apache.isis.applib.util.ObjectContracts;
import org.apache.isis.applib.util.TitleBuffer;
@@ -112,8 +114,13 @@ public class ToDoItem implements Categorized, Comparable<ToDoItem> {
if (isComplete()) {
buf.append("- Completed!");
} else {
- if (getDueBy() != null) {
- buf.append(" due by", getDueBy());
+ try {
+ final LocalDate dueBy = wrapperFactory.wrap(this).getDueBy();
+ if (dueBy != null) {
+ buf.append(" due by", dueBy);
+ }
+ } catch(HiddenException ex) {
+ // ignore
}
}
return buf.toString();
@@ -154,6 +161,11 @@ public class ToDoItem implements Categorized, Comparable<ToDoItem> {
return dueBy;
}
+ public boolean hideDueBy() {
+ final UserMemento user = container.getUser();
+ return user.hasRole("realm1:noDueBy_role");
+ }
+
public void setDueBy(final LocalDate dueBy) {
this.dueBy = dueBy;
}
@@ -650,34 +662,34 @@ public class ToDoItem implements Categorized, Comparable<ToDoItem> {
//region > lifecycle callbacks
public void created() {
- LOG.debug("lifecycle callback: created: " + container.titleOf(this));
+ LOG.debug("lifecycle callback: created: " + this.toString());
}
public void loaded() {
- LOG.debug("lifecycle callback: loaded: " + container.titleOf(this));
+ LOG.debug("lifecycle callback: loaded: " + this.toString());
}
public void persisting() {
- LOG.debug("lifecycle callback: persisting: " + container.titleOf(this));
+ LOG.debug("lifecycle callback: persisting: " + this.toString());
}
public void persisted() {
- LOG.debug("lifecycle callback: persisted: " + container.titleOf(this));
+ LOG.debug("lifecycle callback: persisted: " + this.toString());
}
public void updating() {
- LOG.debug("lifecycle callback: updating: " + container.titleOf(this));
+ LOG.debug("lifecycle callback: updating: " + this.toString());
}
public void updated() {
- LOG.debug("lifecycle callback: updated: " + container.titleOf(this));
+ LOG.debug("lifecycle callback: updated: " + this.toString());
}
public void removing() {
- LOG.debug("lifecycle callback: removing: " + container.titleOf(this));
+ LOG.debug("lifecycle callback: removing: " + this.toString());
}
public void removed() {
- LOG.debug("lifecycle callback: removed: " + container.titleOf(this));
+ LOG.debug("lifecycle callback: removed: " + this.toString());
}
//endregion
http://git-wip-us.apache.org/repos/asf/isis/blob/73298e02/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java
----------------------------------------------------------------------
diff --git a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java
index ff3b375..d28860d 100644
--- a/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java
+++ b/example/application/todoapp/dom/src/main/java/dom/todo/ToDoItemSubscriptions.java
@@ -115,7 +115,7 @@ public class ToDoItemSubscriptions {
case EXECUTING:
break;
case EXECUTED:
- LOG.info("Received ToDoItem.CompletedEvent for : " + container.titleOf(ev.getSource()));
+ LOG.info("Received ToDoItem.CompletedEvent for : " + ev.getSource().toString());
break;
}
}
@@ -151,7 +151,7 @@ public class ToDoItemSubscriptions {
case EXECUTING:
break;
case EXECUTED:
- LOG.info("Received ActionInteractionEvent, " + container.titleOf(ev.getSource()) + ", invoked " + ev.getIdentifier().getMemberName());
+ LOG.info("Received ActionInteractionEvent, " + ev.getSource().toString() + ", invoked " + ev.getIdentifier().getMemberName());
onExecutedVetoIfRequired();
break;
}
@@ -183,7 +183,7 @@ public class ToDoItemSubscriptions {
case EXECUTING:
break;
case EXECUTED:
- LOG.info("Received PropertyInteractionEvent, " + container.titleOf(ev.getSource()) + ", changed " + ev.getIdentifier().getMemberName() + " : " + ev.getOldValue() + " -> " + ev.getNewValue());
+ LOG.info("Received PropertyInteractionEvent, " + ev.getSource().toString() + ", changed " + ev.getIdentifier().getMemberName() + " : " + ev.getOldValue() + " -> " + ev.getNewValue());
onExecutedVetoIfRequired();
if(ev.getIdentifier().getMemberName().contains("description")) {
@@ -233,9 +233,9 @@ public class ToDoItemSubscriptions {
break;
case EXECUTED:
if(ev.getOf() == CollectionInteractionEvent.Of.ADD_TO) {
- LOG.info("Received CollectionInteractionEvent, " + container.titleOf(ev.getSource()) + ", added to " + ev.getIdentifier().getMemberName() + " : " + ev.getValue());
+ LOG.info("Received CollectionInteractionEvent, " + ev.getSource().toString() + ", added to " + ev.getIdentifier().getMemberName() + " : " + ev.getValue());
} else {
- LOG.info("Received CollectionInteractionEvent, " + container.titleOf(ev.getSource()) + ", removed from " + ev.getIdentifier().getMemberName() + " : " + ev.getValue());
+ LOG.info("Received CollectionInteractionEvent, " + ev.getSource().toString() + ", removed from " + ev.getIdentifier().getMemberName() + " : " + ev.getValue());
}
onExecutedVetoIfRequired();
break;
http://git-wip-us.apache.org/repos/asf/isis/blob/73298e02/example/application/todoapp/webapp/src/main/resources/webapp/realm1.ini
----------------------------------------------------------------------
diff --git a/example/application/todoapp/webapp/src/main/resources/webapp/realm1.ini b/example/application/todoapp/webapp/src/main/resources/webapp/realm1.ini
index 57036eb..1473390 100644
--- a/example/application/todoapp/webapp/src/main/resources/webapp/realm1.ini
+++ b/example/application/todoapp/webapp/src/main/resources/webapp/realm1.ini
@@ -35,7 +35,7 @@
sven = pass, admin_role
dick = pass, readwrite_role, dashboard_role, analysis_role, self-install_role
bob = pass, readwrite_role, dashboard_role, self-install_role
-joe = pass, readwrite_role, self-install_role
+joe = pass, readwrite_role, self-install_role, noDueBy_role
guest = guest, readonly_role
@@ -86,13 +86,12 @@ analysis_role = *:ToDoItemAnalysis:*:*,\
*:ToDoItemsByCategoryViewModel:*:*,\
*:ToDoItemsByDateRangeViewModel:*:*
-self-install_role = *:ToDoItemsFixturesService:installFixtures:*
+self-install_role = *:ToDoItemsFixturesService:*:*
admin_role = *
-
#
# some additional role/perms
# require IsisPermissionResolver to be configured in shiro.ini