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/10/23 14:38:29 UTC
[5/6] git commit: ISIS-928: enhance Todo app to demonstrate how to
disable/hide all members in a class.
ISIS-928: enhance Todo app to demonstrate how to disable/hide all members in a class.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/a5b42588
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/a5b42588
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/a5b42588
Branch: refs/heads/master
Commit: a5b42588bed30c615b50c8b5864597dd7f01c435
Parents: 2618e35
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Oct 23 11:20:25 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Oct 23 13:12:11 2014 +0100
----------------------------------------------------------------------
.../dom/src/main/java/dom/todo/ToDoItem.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/a5b42588/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 501a989..e70da55 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
@@ -689,6 +689,23 @@ public class ToDoItem implements Categorized, Comparable<ToDoItem> {
//region > object-level validation
/**
+ * Prevent user from viewing another user's data.
+ */
+ public boolean hidden() {
+ // uncomment to enable. As things stand, the disabled() method below instead will make object "read-only".
+ //return !Objects.equal(getOwnedBy(), container.getUser().getName());
+ return false;
+ }
+
+ /**
+ * Prevent user from modifying any other user's data.
+ */
+ public String disabled(Identifier.Type type){
+ if(Objects.equal(getOwnedBy(), container.getUser().getName())) { return null; }
+ return "This object is owned by '" + getOwnedBy() + "' and cannot be modified by you";
+ }
+
+ /**
* In a real app, if this were actually a rule, then we'd expect that
* invoking the {@link #completed() done} action would clear the {@link #getDueBy() dueBy}
* property (rather than require the user to have to clear manually).
@@ -699,8 +716,11 @@ public class ToDoItem implements Categorized, Comparable<ToDoItem> {
}
return null;
}
+
+
//endregion
+
//region > programmatic helpers
@Programmatic // excluded from the framework's metamodel
public boolean isDue() {