@Override
 public boolean isProjectOwner(
     long projectId, Long usingAccount, boolean isAdmin, Set<Identity> identities) {
   if (identities == null) {
     return false;
   }
   if (isAdmin) {
     return true;
   }
   if (usingAccount != null && usingAccount.equals(projectId)) {
     return false;
   }
   Set<ProjectMemberRecord> projectMembers = new HashSet<>();
   Condition allMembers = DSL.falseCondition();
   for (Identity id : identities) {
     allMembers =
         allMembers.or(
             PROJECT_MEMBER
                 .EXTERNAL_ID
                 .eq(id.getExternalId())
                 .and(PROJECT_MEMBER.EXTERNAL_ID_TYPE.eq(id.getExternalIdType()))
                 .and(PROJECT_MEMBER.ROLE.eq(ProjectConstants.OWNER))
                 .and(PROJECT_MEMBER.PROJECT_ID.eq(projectId))
                 .and(PROJECT_MEMBER.STATE.eq(CommonStatesConstants.ACTIVE))
                 .and(PROJECT_MEMBER.REMOVED.isNull()));
   }
   projectMembers.addAll(create().selectFrom(PROJECT_MEMBER).where(allMembers).fetch());
   return !projectMembers.isEmpty();
 }
 public List<? extends ProjectMember> getActiveProjectMembers(long id) {
   return create()
       .selectFrom(PROJECT_MEMBER)
       .where(PROJECT_MEMBER.PROJECT_ID.eq(id))
       .and(PROJECT_MEMBER.STATE.eq(CommonStatesConstants.ACTIVE))
       .and(PROJECT_MEMBER.REMOVED.isNull())
       .orderBy(PROJECT_MEMBER.ID.asc())
       .fetch();
 }
 public List<? extends ProjectMember> getProjectMembersByIdentity(
     long projectId, Set<Identity> identities) {
   Condition allMembers = DSL.falseCondition();
   for (Identity identity : identities) {
     allMembers =
         allMembers.or(
             PROJECT_MEMBER
                 .EXTERNAL_ID
                 .eq(identity.getExternalId())
                 .and(PROJECT_MEMBER.EXTERNAL_ID_TYPE.eq(identity.getExternalIdType()))
                 .and(PROJECT_MEMBER.REMOVED.isNull())
                 .and(PROJECT_MEMBER.STATE.eq(CommonStatesConstants.ACTIVE))
                 .and(PROJECT_MEMBER.PROJECT_ID.eq(projectId)));
   }
   SelectQuery<Record> query = create().selectQuery();
   query.addFrom(PROJECT_MEMBER);
   query.addConditions(allMembers);
   query.setDistinct(true);
   return query.fetchInto(PROJECT_MEMBER);
 }