// Path: spring-data-neo4j4-demo/src/main/java/org/springframework/data/neo4j/demo/data/GroupInfo.java
// @NodeEntity
// @Data
// @EqualsAndHashCode(of = "groupName")
// public class GroupInfo {
//     @NotNull
//     private String groupName;
//     @NotNull
//     @Relationship(type = "OWNER")
//     private UserInfo groupOwner;
//     @GraphId
//     private Long id;
// 
//     public GroupInfo() {
//         super();
//     }
// 
//     public GroupInfo(String groupName, UserInfo groupOwner) {
//         super();
//         this.groupName = groupName;
//         this.groupOwner = groupOwner;
//     }
// }
// 
// Path: spring-data-neo4j4-demo/src/main/java/org/springframework/data/neo4j/demo/data/GroupMember.java
// @RelationshipEntity(type = "GROUPMEMBER")
// @Data
// @EqualsAndHashCode(of = {"member", "memberOfgroup"})
// public class GroupMember {
//     @NotNull
//     private Boolean enabled;
//     @GraphId
//     private Long id;
//     @NotNull
//     @StartNode
//     private UserInfo member;
//     @NotNull
//     @EndNode
//     private GroupInfo memberOfgroup;
// 
//     public GroupMember() {
//         super();
//     }
// 
//     public GroupMember(GroupInfo memberOfgroup, UserInfo member, Boolean enabled) {
//         super();
//         this.memberOfgroup = memberOfgroup;
//         this.member = member;
//         this.enabled = enabled;
//     }
// }
// 
// Path: spring-data-neo4j4-demo/src/main/java/org/springframework/data/neo4j/demo/data/UserInfo.java
// @NodeEntity
// @Data
// @EqualsAndHashCode(of = "userId")
// public class UserInfo implements Comparable<UserInfo> {
//     @DateTimeFormat(style = "M-")
//     private Date dateOfBirth;
//     private String emailAddress;
//     @NotNull
//     private String fullName;
//     @GraphId
//     private Long id;
//     @NotNull
//     private String userId;
// 
//     public UserInfo() {
//         super();
//     }
// 
//     public UserInfo(String userId, String fullName) {
//         super();
//         this.userId = userId;
//         this.fullName = fullName;
//     }
// 
//     @Override
//     public int compareTo(UserInfo o) {
//         int result = 0;
//         if (userId != null && o.userId != null) {
//             result = userId.compareTo(o.userId);
//         }
//         return result;
//     }
// }


import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.demo.data.GroupInfo;
import org.springframework.data.neo4j.demo.data.GroupMember;
import org.springframework.data.neo4j.demo.data.UserInfo;
import org.springframework.data.neo4j.repository.GraphRepository;
import java.util.List;
package org.springframework.data.neo4j.demo.repository;



public interface GroupMemberRepository extends GraphRepository<GroupMember> {
    @Query("MATCH (user:UserInfo)-[member:GROUPMEMBER]->(group:GroupInfo) WHERE group.groupName={0} AND member.enabled = true RETURN user")
    List<UserInfo> findActiveMembersOfGroup(String group);
    @Query("MATCH (user:UserInfo)-[member:GROUPMEMBER]->(group:GroupInfo) WHERE group.groupName={0} RETURN user")
    List<UserInfo> findAllMembersOfGroup(String group);
    List<GroupMember> findByEnabledTrueAndMemberOfgroupGroupName(String group);
    List<GroupMember> findByMemberOfgroup(GroupInfo group);
    List<GroupMember> findByMemberOfgroupAndEnabledTrue(GroupInfo group);
    List<GroupMember> findByMemberUserIdAndEnabledTrue(String userId);
    @Query("MATCH (user:UserInfo)-[member:GROUPMEMBER]->(group:GroupInfo) WHERE user.userId={0} AND member.enabled = true RETURN group")
// Path: spring-data-neo4j4-demo/src/main/java/org/springframework/data/neo4j/demo/data/GroupInfo.java
// @NodeEntity
// @Data
// @EqualsAndHashCode(of = "groupName")
// public class GroupInfo {
//     @NotNull
//     private String groupName;
//     @NotNull
//     @Relationship(type = "OWNER")
//     private UserInfo groupOwner;
//     @GraphId
//     private Long id;
// 
//     public GroupInfo() {
//         super();
//     }
// 
//     public GroupInfo(String groupName, UserInfo groupOwner) {
//         super();
//         this.groupName = groupName;
//         this.groupOwner = groupOwner;
//     }
// }
// 
// Path: spring-data-neo4j4-demo/src/main/java/org/springframework/data/neo4j/demo/data/GroupMember.java
// @RelationshipEntity(type = "GROUPMEMBER")
// @Data
// @EqualsAndHashCode(of = {"member", "memberOfgroup"})
// public class GroupMember {
//     @NotNull
//     private Boolean enabled;
//     @GraphId
//     private Long id;
//     @NotNull
//     @StartNode
//     private UserInfo member;
//     @NotNull
//     @EndNode
//     private GroupInfo memberOfgroup;
// 
//     public GroupMember() {
//         super();
//     }
// 
//     public GroupMember(GroupInfo memberOfgroup, UserInfo member, Boolean enabled) {
//         super();
//         this.memberOfgroup = memberOfgroup;
//         this.member = member;
//         this.enabled = enabled;
//     }
// }
// 
// Path: spring-data-neo4j4-demo/src/main/java/org/springframework/data/neo4j/demo/data/UserInfo.java
// @NodeEntity
// @Data
// @EqualsAndHashCode(of = "userId")
// public class UserInfo implements Comparable<UserInfo> {
//     @DateTimeFormat(style = "M-")
//     private Date dateOfBirth;
//     private String emailAddress;
//     @NotNull
//     private String fullName;
//     @GraphId
//     private Long id;
//     @NotNull
//     private String userId;
// 
//     public UserInfo() {
//         super();
//     }
// 
//     public UserInfo(String userId, String fullName) {
//         super();
//         this.userId = userId;
//         this.fullName = fullName;
//     }
// 
//     @Override
//     public int compareTo(UserInfo o) {
//         int result = 0;
//         if (userId != null && o.userId != null) {
//             result = userId.compareTo(o.userId);
//         }
//         return result;
//     }
// }


// Path: spring-data-neo4j4-demo/src/main/java/org/springframework/data/neo4j/demo/repository/GroupMemberRepository.java
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.demo.data.GroupInfo;
import org.springframework.data.neo4j.demo.data.GroupMember;
import org.springframework.data.neo4j.demo.data.UserInfo;
import org.springframework.data.neo4j.repository.GraphRepository;
import java.util.List;

package org.springframework.data.neo4j.demo.repository;



public interface GroupMemberRepository extends GraphRepository<GroupMember> {
    @Query("MATCH (user:UserInfo)-[member:GROUPMEMBER]->(group:GroupInfo) WHERE group.groupName={0} AND member.enabled = true RETURN user")
    List<UserInfo> findActiveMembersOfGroup(String group);
    @Query("MATCH (user:UserInfo)-[member:GROUPMEMBER]->(group:GroupInfo) WHERE group.groupName={0} RETURN user")
    List<UserInfo> findAllMembersOfGroup(String group);
    List<GroupMember> findByEnabledTrueAndMemberOfgroupGroupName(String group);
    List<GroupMember> findByMemberOfgroup(GroupInfo group);
    List<GroupMember> findByMemberOfgroupAndEnabledTrue(GroupInfo group);
    List<GroupMember> findByMemberUserIdAndEnabledTrue(String userId);
    @Query("MATCH (user:UserInfo)-[member:GROUPMEMBER]->(group:GroupInfo) WHERE user.userId={0} AND member.enabled = true RETURN group")
    List<GroupInfo> findGroupsForUser(String userId);