Hi All,
I must say that the project is looking amazing!!! Congratulations Spring team and Neo4J team to bring this together... I must say I was already in love with NoSQL using MongoDB, but Graph Databases with Neo4J is just a piece of art!!! After watching the presentation about Spring Data Graph, I must say I was hooked after I saw the term "Polyglot Persistence" and I decided to give this a try!!!
Suppose I have an RBAC model such that users are granted action permissions to applications... The questions I'd like to answer about it is as follows:
1. Which permissions a user have been granted to a set of applications?
2. Which users have certain action permissions to an application?
User <---> Permission <---> Application
By reading the documentation, I thought I could use a @Direction.BOTH implementation of a @RelationshipEntity using a @RelatedToVia aggregation on my User @NodeEntity... Here's the code snippet for User...
The implementation of the Application @NodeEntity... At this point, I decided to paste the same code, but with a different property name and same "type" value for the annotation @RelatedToVia using @Direction.BOTH...Code:@NodeEntity public class User { @Indexed private String id; @Indexed private String username; @RelatedToVia(type = "grantedPermissions", Direction.BOTH, elementClass = Permission.class) Iterable<Permission> permissions; public Iterable<Permission> getPermissions() { return this.permissions; } ... ... }
Now here are the questions for the implementation Permission as @RelationshipEntity...Code:@NodeEntity public class Application { @Indexed private String id; @Indexed private String name; ... ... @RelatedToVia(type = "grantedPermissions", Direction.BOTH, elementClass = Permission.class) Iterable<Permission> permittedUsers; public Iterable<Permission> getPermittedUsers() { return this.permittedUsers; } }
1. Can I express the @StartNode and the @EndNode in the same property on a @RelationshipEntity?
2. Given the "public enum Action { CREATE, VIEW, EDIT, DELETE }", can I have a set of ENUMs as a @RelationshipEntity property?
Here's the implementation of the @RelationshipEntity...
Would this work? I'm still setting up my environment and I'm adding this to the my-restaurants-social application based on the Neo4J presentation...Code:@RelationshipEntity public class Permission { @StartNode @EndNode private User user; @EndNode @StartNode private Application application; private Set<Action> actions; public Permission() { } public void addAction(Action action) { this.actions.add(action); } }
Thanks
Marcello


Reply With Quote
