From bd22739ebde83909c12fd5f30a19be4591ec9c55 Mon Sep 17 00:00:00 2001 From: Dragomir Todorov Date: Fri, 16 Nov 2018 10:23:54 +0200 Subject: [PATCH 1/6] NY-4610: Added filtering to username --- .../account/grid/ag/AdminServiceImpl.java | 3 +- .../nynja/account/grid/ag/AgGridService.java | 70 +++++++++++++++---- .../account/models/AccountByUsername.java | 23 +++++- ...untByAuthenticationProviderRepository.java | 4 +- .../AccountByUsernameRepository.java | 4 ++ 5 files changed, 86 insertions(+), 18 deletions(-) diff --git a/src/main/java/biz/nynja/account/grid/ag/AdminServiceImpl.java b/src/main/java/biz/nynja/account/grid/ag/AdminServiceImpl.java index 535bd2c..a63b1ed 100644 --- a/src/main/java/biz/nynja/account/grid/ag/AdminServiceImpl.java +++ b/src/main/java/biz/nynja/account/grid/ag/AdminServiceImpl.java @@ -45,7 +45,8 @@ public class AdminServiceImpl extends AdminAccountServiceGrpc.AdminAccountServic @Override public void getAllAccounts(GetAllAccountsRequest request, StreamObserver responseObserver) { - AccountsAdminResponse response = agGridService.getData(request.getEndRow(), request.getStartRow()); + AccountsAdminResponse response = agGridService.getData(request.getEndRow(), request.getStartRow(), + request.getFilterModelList()); responseObserver.onNext(response); responseObserver.onCompleted(); diff --git a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java index 1913427..3c8177e 100644 --- a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java +++ b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java @@ -4,54 +4,96 @@ package biz.nynja.account.grid.ag; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collections; import java.util.List; -import java.util.Map; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.cassandra.core.query.CassandraPageRequest; +import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Sort.Direction; import org.springframework.stereotype.Service; import biz.nynja.account.admin.grpc.AccountAdminResponse; import biz.nynja.account.admin.grpc.AccountsAdminResponse; +import biz.nynja.account.admin.grpc.FilterModel; import biz.nynja.account.grpc.AccountDetails; import biz.nynja.account.models.Account; +import biz.nynja.account.models.AccountByUsername; +import biz.nynja.account.repositories.AccountByUsernameRepository; import biz.nynja.account.repositories.AccountRepository; @Service public class AgGridService { + private static final String FILTER_USERNAME = "username"; + private AccountRepository accountRepository; - private Slice accounts = null; + private AccountByUsernameRepository accountByUsernameRepository; @Autowired - public AgGridService(AccountRepository accountRepository) { + public AgGridService(AccountRepository accountRepository, AccountByUsernameRepository accountByUsernameRepository) { this.accountRepository = accountRepository; + this.accountByUsernameRepository = accountByUsernameRepository; } - public AccountsAdminResponse getData(int endRow, int startRow) { + public AccountsAdminResponse getData(int endRow, int startRow, List filterModelList) { - Map> pivotValues = new HashMap>(); + Slice accounts = null; + List rows = new ArrayList<>(); - // Sort sort = new Sort(new Sort.Order(Direction.ASC, "type")); + Pageable pageable = CassandraPageRequest.of(0, endRow, Direction.ASC); - Pageable pageable = CassandraPageRequest.of(0, endRow); + if (filterModelList.isEmpty()) { + accounts = accountRepository.findAll(pageable); + } else { + accounts = retrieveFilterResults(pageable, filterModelList); + } - accounts = accountRepository.findAll(pageable); - List rows = new ArrayList<>(); accounts.getContent().subList(startRow - 1, accounts.getNumberOfElements()).forEach(account -> { AccountDetails accountDetails = account.toProto(); rows.add(accountDetails); }); - // create response with our results - - AccountsAdminResponse response = AccountsAdminResponse.newBuilder() + return AccountsAdminResponse.newBuilder() .setAccountsResponse(AccountAdminResponse.newBuilder().addAllAccountDetails(rows).build()).build(); - return response; + } + + private Slice retrieveFilterResults(Pageable pageable, List filterModelList) { + List accounts = new ArrayList<>(); + for (FilterModel filterModel : filterModelList) { + if (accounts.isEmpty()) { + accounts.addAll(getFilteredResults(pageable, filterModel)); + } else { + accounts.retainAll(getFilteredResults(pageable, filterModel)); + } + } + + return new PageImpl<>(accounts); + } + + private List getFilteredResults(Pageable pageable, FilterModel filterModel) { + switch (filterModel.getColId()) { + case FILTER_USERNAME: + Slice listAccountsByUsername = accountByUsernameRepository + .findByUsername(filterModel.getFilterValue(), pageable); + return listAccountsByUsername.stream().map(t -> t.getAccount()).collect(Collectors.toList()); + default: + break; + } + return Collections.emptyList(); + + // • First name + // • Last name + // • Email + // • Phone number + // • Social profile + // • Access status + // • Created (creation timestamp) + // • Updated (last updated timestamp } } diff --git a/src/main/java/biz/nynja/account/models/AccountByUsername.java b/src/main/java/biz/nynja/account/models/AccountByUsername.java index 2286507..aa1c96e 100644 --- a/src/main/java/biz/nynja/account/models/AccountByUsername.java +++ b/src/main/java/biz/nynja/account/models/AccountByUsername.java @@ -3,15 +3,14 @@ */ package biz.nynja.account.models; -import java.nio.ByteBuffer; import java.time.LocalDate; import java.util.Set; import java.util.UUID; import biz.nynja.account.grpc.AccessStatus; import biz.nynja.account.grpc.AccountDetails; -import biz.nynja.account.grpc.Role; import biz.nynja.account.grpc.AccountDetails.Builder; +import biz.nynja.account.grpc.Role; public class AccountByUsername { @@ -366,4 +365,24 @@ public class AccountByUsername { } + public Account getAccount() { + Account account = new Account(); + account.setAccountId(getAccountId()); + account.setProfileId(getProfileId()); + account.setAuthenticationProvider(getAuthenticationProvider()); + account.setAuthenticationProviderType(getAuthenticationProviderType()); + account.setAccountMark(getAccountMark()); + account.setAccountName(getAccountName()); + account.setFirstName(getFirstName()); + account.setLastName(getLastName()); + account.setUsername(getUsername()); + account.setQrCode(getQrCode()); + account.setAvatar(getAvatar()); + account.setRoles(getRoles()); + account.setAccessStatus(getAccessStatus()); + account.setContactsInfo(getContactsInfo()); + + return account; + } + } diff --git a/src/main/java/biz/nynja/account/repositories/AccountByAuthenticationProviderRepository.java b/src/main/java/biz/nynja/account/repositories/AccountByAuthenticationProviderRepository.java index 73f9cb7..f348103 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountByAuthenticationProviderRepository.java +++ b/src/main/java/biz/nynja/account/repositories/AccountByAuthenticationProviderRepository.java @@ -11,7 +11,9 @@ import org.springframework.stereotype.Repository; import biz.nynja.account.models.AccountByAuthenticationProvider; @Repository -public interface AccountByAuthenticationProviderRepository extends CassandraRepository { +public interface AccountByAuthenticationProviderRepository + extends CassandraRepository { List findAllByAuthenticationProvider(String authenticationProvider); + } diff --git a/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java b/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java index 647a918..5cca921 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java +++ b/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java @@ -4,6 +4,8 @@ package biz.nynja.account.repositories; import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; import org.springframework.stereotype.Repository; import biz.nynja.account.models.AccountByUsername; @@ -13,4 +15,6 @@ public interface AccountByUsernameRepository extends CassandraRepository findByUsername(String username, Pageable pageable); + } -- GitLab From 89f53a202da54261c28f2d3aefd7842c57472778 Mon Sep 17 00:00:00 2001 From: Dragomir Todorov Date: Fri, 16 Nov 2018 14:18:29 +0200 Subject: [PATCH 2/6] NY-4610: Added filtering by contains and equals --- .../nynja/account/grid/ag/AgGridService.java | 22 ++++++++++++++----- .../AccountByUsernameRepository.java | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java index 3c8177e..037a8ef 100644 --- a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java +++ b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java @@ -13,12 +13,12 @@ import org.springframework.data.cassandra.core.query.CassandraPageRequest; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort.Direction; import org.springframework.stereotype.Service; import biz.nynja.account.admin.grpc.AccountAdminResponse; import biz.nynja.account.admin.grpc.AccountsAdminResponse; import biz.nynja.account.admin.grpc.FilterModel; +import biz.nynja.account.admin.grpc.FilterModel.Type; import biz.nynja.account.grpc.AccountDetails; import biz.nynja.account.models.Account; import biz.nynja.account.models.AccountByUsername; @@ -41,11 +41,10 @@ public class AgGridService { } public AccountsAdminResponse getData(int endRow, int startRow, List filterModelList) { - Slice accounts = null; List rows = new ArrayList<>(); - Pageable pageable = CassandraPageRequest.of(0, endRow, Direction.ASC); + Pageable pageable = CassandraPageRequest.of(0, endRow); if (filterModelList.isEmpty()) { accounts = accountRepository.findAll(pageable); @@ -78,9 +77,7 @@ public class AgGridService { private List getFilteredResults(Pageable pageable, FilterModel filterModel) { switch (filterModel.getColId()) { case FILTER_USERNAME: - Slice listAccountsByUsername = accountByUsernameRepository - .findByUsername(filterModel.getFilterValue(), pageable); - return listAccountsByUsername.stream().map(t -> t.getAccount()).collect(Collectors.toList()); + return retrieveUsernameFilteredResults(pageable, filterModel); default: break; } @@ -96,4 +93,17 @@ public class AgGridService { // • Updated (last updated timestamp } + private List retrieveUsernameFilteredResults(Pageable pageable, FilterModel filterModel) { + Slice listAccountsByUsername; + if (Type.EQUALS.equals(filterModel.getType())) { + listAccountsByUsername = accountByUsernameRepository.findByUsername(filterModel.getFilterValue(), pageable); + } else if (Type.CONTAINS.equals(filterModel.getType())) { + listAccountsByUsername = accountByUsernameRepository.findByUsernameContains(filterModel.getFilterValue(), + pageable); + } else { + return Collections.emptyList(); + } + return listAccountsByUsername.stream().map(t -> t.getAccount()).collect(Collectors.toList()); + } + } diff --git a/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java b/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java index 5cca921..2d1e273 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java +++ b/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java @@ -17,4 +17,6 @@ public interface AccountByUsernameRepository extends CassandraRepository findByUsername(String username, Pageable pageable); + Slice findByUsernameContains(String username, Pageable pageable); + } -- GitLab From b5357e99162ccea09d8da66199baf0108f071517 Mon Sep 17 00:00:00 2001 From: Dragomir Todorov Date: Mon, 19 Nov 2018 15:46:51 +0200 Subject: [PATCH 3/6] NY-4610: Added first, last names and access status --- .../nynja/account/StartupScriptsListener.java | 26 +- .../nynja/account/grid/ag/AgGridService.java | 66 ++- .../account/models/AccountByAccessStatus.java | 382 ++++++++++++++++++ .../account/models/AccountByFirstName.java | 382 ++++++++++++++++++ .../account/models/AccountByLastName.java | 382 ++++++++++++++++++ .../AccountByAccessStatusRepository.java | 18 + .../AccountByFirstNameRepository.java | 18 + .../AccountByLastNameRepository.java | 18 + .../AccountByUsernameRepository.java | 2 - 9 files changed, 1279 insertions(+), 15 deletions(-) create mode 100644 src/main/java/biz/nynja/account/models/AccountByAccessStatus.java create mode 100644 src/main/java/biz/nynja/account/models/AccountByFirstName.java create mode 100644 src/main/java/biz/nynja/account/models/AccountByLastName.java create mode 100644 src/main/java/biz/nynja/account/repositories/AccountByAccessStatusRepository.java create mode 100644 src/main/java/biz/nynja/account/repositories/AccountByFirstNameRepository.java create mode 100644 src/main/java/biz/nynja/account/repositories/AccountByLastNameRepository.java diff --git a/src/main/java/biz/nynja/account/StartupScriptsListener.java b/src/main/java/biz/nynja/account/StartupScriptsListener.java index ac797ab..d0c0118 100644 --- a/src/main/java/biz/nynja/account/StartupScriptsListener.java +++ b/src/main/java/biz/nynja/account/StartupScriptsListener.java @@ -13,8 +13,9 @@ import com.datastax.driver.core.Session; import biz.nynja.account.configuration.CassandraConfig; /** - * This acts as {@link CassandraConfig} startupScripts executor - * but activated after the spring has setup the needed tables though JPA + * This acts as {@link CassandraConfig} startupScripts executor but activated after the spring has setup the needed + * tables though JPA + * * @author dragomir.todorov * */ @@ -52,16 +53,29 @@ public class StartupScriptsListener { + ".accountbyusername AS SELECT * FROM account " + "WHERE username IS NOT NULL " + "PRIMARY KEY (username, accountid);"; + String scriptAccountViewByFirstName = "CREATE MATERIALIZED VIEW IF NOT EXISTS " + keyspace + + ".accountbyfirstname AS SELECT * FROM account " + "WHERE firstname IS NOT NULL " + + "PRIMARY KEY (firstname, accountid);"; + + String scriptAccountViewByLastName = "CREATE MATERIALIZED VIEW IF NOT EXISTS " + keyspace + + ".accountbylastname AS SELECT * FROM account " + "WHERE lastname IS NOT NULL " + + "PRIMARY KEY (lastname, accountid);"; + + String scriptAccountViewByAccessStatus = "CREATE MATERIALIZED VIEW IF NOT EXISTS " + keyspace + + ".accountbyaccessstatus AS SELECT * FROM account " + "WHERE accessstatus IS NOT NULL " + + "PRIMARY KEY (accessstatus, accountid);"; + String scriptPendingAccountViewByAuthenticationProvider = "CREATE MATERIALIZED VIEW IF NOT EXISTS " + keyspace - + ".pendingaccountbyauthenticationprovider AS SELECT * FROM pendingaccount " + "WHERE authenticationprovider IS NOT NULL " - + "PRIMARY KEY (authenticationprovider, accountid);"; + + ".pendingaccountbyauthenticationprovider AS SELECT * FROM pendingaccount " + + "WHERE authenticationprovider IS NOT NULL " + "PRIMARY KEY (authenticationprovider, accountid);"; String scriptAccountViewByQrCode = "CREATE MATERIALIZED VIEW IF NOT EXISTS " + keyspace + ".accountbyqrcode AS SELECT * FROM account " + "WHERE qrcode IS NOT NULL " + "PRIMARY KEY (qrcode, accountid);"; return Arrays.asList(scriptAccountViewByProfileId, scriptAccountViewByAuthProvider, - scriptAccountViewByAccountName, scriptAccountViewByUsername, - scriptPendingAccountViewByAuthenticationProvider, scriptAccountViewByQrCode); + scriptAccountViewByAccountName, scriptAccountViewByUsername, + scriptPendingAccountViewByAuthenticationProvider, scriptAccountViewByQrCode, + scriptAccountViewByFirstName, scriptAccountViewByLastName, scriptAccountViewByAccessStatus); } } \ No newline at end of file diff --git a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java index 037a8ef..5993eb8 100644 --- a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java +++ b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java @@ -21,7 +21,13 @@ import biz.nynja.account.admin.grpc.FilterModel; import biz.nynja.account.admin.grpc.FilterModel.Type; import biz.nynja.account.grpc.AccountDetails; import biz.nynja.account.models.Account; +import biz.nynja.account.models.AccountByAccessStatus; +import biz.nynja.account.models.AccountByFirstName; +import biz.nynja.account.models.AccountByLastName; import biz.nynja.account.models.AccountByUsername; +import biz.nynja.account.repositories.AccountByAccessStatusRepository; +import biz.nynja.account.repositories.AccountByFirstNameRepository; +import biz.nynja.account.repositories.AccountByLastNameRepository; import biz.nynja.account.repositories.AccountByUsernameRepository; import biz.nynja.account.repositories.AccountRepository; @@ -29,15 +35,26 @@ import biz.nynja.account.repositories.AccountRepository; public class AgGridService { private static final String FILTER_USERNAME = "username"; + private static final String FILTER_FIRST_NAME = "firstname"; + private static final String FILTER_LAST_NAME = "lastname"; + private static final String FILTER_ACCESS_STATUS = "accessStatus"; private AccountRepository accountRepository; - private AccountByUsernameRepository accountByUsernameRepository; + private AccountByFirstNameRepository accountByFirstNameRepository; + private AccountByLastNameRepository accountByLastNameRepository; + private AccountByAccessStatusRepository accountByAccessStatusRepository; @Autowired - public AgGridService(AccountRepository accountRepository, AccountByUsernameRepository accountByUsernameRepository) { + public AgGridService(AccountRepository accountRepository, AccountByUsernameRepository accountByUsernameRepository, + AccountByFirstNameRepository accountByFirstNameRepository, + AccountByLastNameRepository accountByLastNameRepository, + AccountByAccessStatusRepository accountByAccessStatusRepository) { this.accountRepository = accountRepository; this.accountByUsernameRepository = accountByUsernameRepository; + this.accountByFirstNameRepository = accountByFirstNameRepository; + this.accountByLastNameRepository = accountByLastNameRepository; + this.accountByAccessStatusRepository = accountByAccessStatusRepository; } public AccountsAdminResponse getData(int endRow, int startRow, List filterModelList) { @@ -78,6 +95,12 @@ public class AgGridService { switch (filterModel.getColId()) { case FILTER_USERNAME: return retrieveUsernameFilteredResults(pageable, filterModel); + case FILTER_FIRST_NAME: + return retrieveFirstnameFilteredResults(pageable, filterModel); + case FILTER_LAST_NAME: + return retrieveLastnameFilteredResults(pageable, filterModel); + case FILTER_ACCESS_STATUS: + return retrieveAccessStatusFilteredResults(pageable, filterModel); default: break; } @@ -85,25 +108,54 @@ public class AgGridService { // • First name // • Last name + // • Access status + // • Email // • Phone number // • Social profile - // • Access status // • Created (creation timestamp) // • Updated (last updated timestamp } private List retrieveUsernameFilteredResults(Pageable pageable, FilterModel filterModel) { Slice listAccountsByUsername; - if (Type.EQUALS.equals(filterModel.getType())) { + if (Type.EQUALS.equals(filterModel.getType())) { // ONLY EQUALS is supported at the moment listAccountsByUsername = accountByUsernameRepository.findByUsername(filterModel.getFilterValue(), pageable); - } else if (Type.CONTAINS.equals(filterModel.getType())) { - listAccountsByUsername = accountByUsernameRepository.findByUsernameContains(filterModel.getFilterValue(), - pageable); } else { return Collections.emptyList(); } return listAccountsByUsername.stream().map(t -> t.getAccount()).collect(Collectors.toList()); } + private List retrieveFirstnameFilteredResults(Pageable pageable, FilterModel filterModel) { + Slice listAccountsByFirstname; + if (Type.EQUALS.equals(filterModel.getType())) { // Only EQUALS is supported at the moment + listAccountsByFirstname = accountByFirstNameRepository.findByFirstName(filterModel.getFilterValue(), + pageable); + } else { + return Collections.emptyList(); + } + return listAccountsByFirstname.stream().map(t -> t.getAccount()).collect(Collectors.toList()); + } + + private List retrieveLastnameFilteredResults(Pageable pageable, FilterModel filterModel) { + Slice listAccountsByLastname; + if (Type.EQUALS.equals(filterModel.getType())) { // Only EQUALS is supported at the moment + listAccountsByLastname = accountByLastNameRepository.findByLastName(filterModel.getFilterValue(), pageable); + } else { + return Collections.emptyList(); + } + return listAccountsByLastname.stream().map(t -> t.getAccount()).collect(Collectors.toList()); + } + + private List retrieveAccessStatusFilteredResults(Pageable pageable, FilterModel filterModel) { + Slice listAccountsByAccessStatus; + if (Type.EQUALS.equals(filterModel.getType())) { // Only EQUALS is supported at the moment + listAccountsByAccessStatus = accountByAccessStatusRepository + .findByAccessStatus(filterModel.getFilterValue(), pageable); + } else { + return Collections.emptyList(); + } + return listAccountsByAccessStatus.stream().map(t -> t.getAccount()).collect(Collectors.toList()); + } } diff --git a/src/main/java/biz/nynja/account/models/AccountByAccessStatus.java b/src/main/java/biz/nynja/account/models/AccountByAccessStatus.java new file mode 100644 index 0000000..9e61915 --- /dev/null +++ b/src/main/java/biz/nynja/account/models/AccountByAccessStatus.java @@ -0,0 +1,382 @@ +/** + * Copyright (C) 2018 Nynja Inc. All rights reserved. + */ +package biz.nynja.account.models; + +import java.time.LocalDate; +import java.util.Set; +import java.util.UUID; + +import biz.nynja.account.grpc.AccessStatus; +import biz.nynja.account.grpc.AccountDetails; +import biz.nynja.account.grpc.AccountDetails.Builder; +import biz.nynja.account.grpc.Role; + +public class AccountByAccessStatus { + + private UUID profileId; + private UUID accountId; + private String accountMark; + private String authenticationProvider; + private String authenticationProviderType; + private String firstName; + private String lastName; + private String avatar; + private String accountName; + private String username; + private Long creationTimestamp; + private Long lastUpdateTimestamp; + private Set contactsInfo; + private String qrCode; + private Set roles; + private String accessStatus; + private LocalDate birthday; + + public UUID getProfileId() { + return profileId; + } + + public void setProfileId(UUID profileId) { + this.profileId = profileId; + } + + public UUID getAccountId() { + return accountId; + } + + public void setAccountId(UUID accountId) { + this.accountId = accountId; + } + + public String getAccountMark() { + return accountMark; + } + + public void setAccountMark(String accountMark) { + this.accountMark = accountMark; + } + + public String getAuthenticationProvider() { + return authenticationProvider; + } + + public void setAuthenticationProvider(String authenticationProvider) { + this.authenticationProvider = authenticationProvider; + } + + public String getAuthenticationProviderType() { + return authenticationProviderType; + } + + public void setAuthenticationProviderType(String authenticationProviderType) { + this.authenticationProviderType = authenticationProviderType; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Long getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(Long creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + public Long getLastUpdateTimestamp() { + return lastUpdateTimestamp; + } + + public void setLastUpdateTimestamp(Long lastUpdateTimestamp) { + this.lastUpdateTimestamp = lastUpdateTimestamp; + } + + public Set getContactsInfo() { + return contactsInfo; + } + + public void setContactsInfo(Set contactsInfo) { + this.contactsInfo = contactsInfo; + } + + public String getQrCode() { + return qrCode; + } + + public void setQrCode(String qrCode) { + this.qrCode = qrCode; + } + + public Set getRoles() { + return roles; + } + + public void setRoles(Set roles) { + this.roles = roles; + } + + public String getAccessStatus() { + return accessStatus; + } + + public void setAccessStatus(String accessStatus) { + this.accessStatus = accessStatus; + } + + public LocalDate getBirthday() { + return birthday; + } + + public void setBirthday(LocalDate birthday) { + this.birthday = birthday; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((accessStatus == null) ? 0 : accessStatus.hashCode()); + result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); + result = prime * result + ((accountMark == null) ? 0 : accountMark.hashCode()); + result = prime * result + ((accountName == null) ? 0 : accountName.hashCode()); + result = prime * result + ((authenticationProvider == null) ? 0 : authenticationProvider.hashCode()); + result = prime * result + ((authenticationProviderType == null) ? 0 : authenticationProviderType.hashCode()); + result = prime * result + ((avatar == null) ? 0 : avatar.hashCode()); + result = prime * result + ((birthday == null) ? 0 : birthday.hashCode()); + result = prime * result + ((contactsInfo == null) ? 0 : contactsInfo.hashCode()); + result = prime * result + ((creationTimestamp == null) ? 0 : creationTimestamp.hashCode()); + result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + ((lastUpdateTimestamp == null) ? 0 : lastUpdateTimestamp.hashCode()); + result = prime * result + ((profileId == null) ? 0 : profileId.hashCode()); + result = prime * result + ((qrCode == null) ? 0 : qrCode.hashCode()); + result = prime * result + ((roles == null) ? 0 : roles.hashCode()); + result = prime * result + ((username == null) ? 0 : username.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AccountByAccessStatus other = (AccountByAccessStatus) obj; + if (accessStatus == null) { + if (other.accessStatus != null) + return false; + } else if (!accessStatus.equals(other.accessStatus)) + return false; + if (accountId == null) { + if (other.accountId != null) + return false; + } else if (!accountId.equals(other.accountId)) + return false; + if (accountMark == null) { + if (other.accountMark != null) + return false; + } else if (!accountMark.equals(other.accountMark)) + return false; + if (accountName == null) { + if (other.accountName != null) + return false; + } else if (!accountName.equals(other.accountName)) + return false; + if (authenticationProvider == null) { + if (other.authenticationProvider != null) + return false; + } else if (!authenticationProvider.equals(other.authenticationProvider)) + return false; + if (authenticationProviderType == null) { + if (other.authenticationProviderType != null) + return false; + } else if (!authenticationProviderType.equals(other.authenticationProviderType)) + return false; + if (avatar == null) { + if (other.avatar != null) + return false; + } else if (!avatar.equals(other.avatar)) + return false; + if (birthday == null) { + if (other.birthday != null) + return false; + } else if (!birthday.equals(other.birthday)) + return false; + if (contactsInfo == null) { + if (other.contactsInfo != null) + return false; + } else if (!contactsInfo.equals(other.contactsInfo)) + return false; + if (creationTimestamp == null) { + if (other.creationTimestamp != null) + return false; + } else if (!creationTimestamp.equals(other.creationTimestamp)) + return false; + if (firstName == null) { + if (other.firstName != null) + return false; + } else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } else if (!lastName.equals(other.lastName)) + return false; + if (lastUpdateTimestamp == null) { + if (other.lastUpdateTimestamp != null) + return false; + } else if (!lastUpdateTimestamp.equals(other.lastUpdateTimestamp)) + return false; + if (profileId == null) { + if (other.profileId != null) + return false; + } else if (!profileId.equals(other.profileId)) + return false; + if (qrCode == null) { + if (other.qrCode != null) + return false; + } else if (!qrCode.equals(other.qrCode)) + return false; + if (roles == null) { + if (other.roles != null) + return false; + } else if (!roles.equals(other.roles)) + return false; + if (username == null) { + if (other.username != null) + return false; + } else if (!username.equals(other.username)) + return false; + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("AccountByUsername [profileId=").append(profileId).append(", accountId=").append(accountId) + .append(", accountMark=").append(accountMark).append(", authenticationProvider=") + .append(authenticationProvider).append(", authenticationProviderType=") + .append(authenticationProviderType).append(", firstName=").append(firstName).append(", lastName=") + .append(lastName).append(", avatar=").append(avatar).append(", accountName=").append(accountName) + .append(", username=").append(username).append(", creationTimestamp=").append(creationTimestamp) + .append(", lastUpdateTimestamp=").append(lastUpdateTimestamp).append(", contactsInfo=") + .append(contactsInfo).append(", qrCode=").append(qrCode).append(", roles=").append(roles) + .append(", accessStatus=").append(accessStatus).append(", birthday=").append(birthday).append("]"); + return builder.toString(); + } + + public AccountDetails toProto() { + + Builder builder = AccountDetails.newBuilder(); + + if (getAccountId() != null) { + builder.setAccountId(getAccountId().toString()); + } + if (getProfileId() != null) { + builder.setProfileId(getProfileId().toString()); + } + if (getAuthenticationProvider() != null) { + builder.setAuthenticationIdentifier(getAuthenticationProvider()); + } + if (getAuthenticationProviderType() != null) { + builder.setAuthenticationType(getAuthenticationProviderType()); + } + if (getAccountMark() != null) { + builder.setAccountMark(getAccountMark()); + } + if (getAccountName() != null) { + builder.setAccountName(getAccountName()); + } + if (getFirstName() != null) { + builder.setFirstName(getFirstName()); + } + if (getLastName() != null) { + builder.setLastName(getLastName()); + } + if (getUsername() != null) { + builder.setUsername(getUsername()); + } + if (getQrCode() != null) { + builder.setQrCode(getQrCode()); + } + if (getAvatar() != null) { + builder.setAvatar(avatar); + } + if (getRoles() != null) { + for (String role : getRoles()) { + builder.addRoles(Role.valueOf(role)); + } + } + if (getAccessStatus() != null) { + builder.setAccessStatus(AccessStatus.valueOf(getAccessStatus())); + } + if (getContactsInfo() != null) { + for (ContactInfo c : contactsInfo) { + builder.addContactsInfo(c.toProto()); + } + } + + return builder.build(); + + } + + public Account getAccount() { + Account account = new Account(); + account.setAccountId(getAccountId()); + account.setProfileId(getProfileId()); + account.setAuthenticationProvider(getAuthenticationProvider()); + account.setAuthenticationProviderType(getAuthenticationProviderType()); + account.setAccountMark(getAccountMark()); + account.setAccountName(getAccountName()); + account.setFirstName(getFirstName()); + account.setLastName(getLastName()); + account.setUsername(getUsername()); + account.setQrCode(getQrCode()); + account.setAvatar(getAvatar()); + account.setRoles(getRoles()); + account.setAccessStatus(getAccessStatus()); + account.setContactsInfo(getContactsInfo()); + + return account; + } + +} diff --git a/src/main/java/biz/nynja/account/models/AccountByFirstName.java b/src/main/java/biz/nynja/account/models/AccountByFirstName.java new file mode 100644 index 0000000..a26aac1 --- /dev/null +++ b/src/main/java/biz/nynja/account/models/AccountByFirstName.java @@ -0,0 +1,382 @@ +/** + * Copyright (C) 2018 Nynja Inc. All rights reserved. + */ +package biz.nynja.account.models; + +import java.time.LocalDate; +import java.util.Set; +import java.util.UUID; + +import biz.nynja.account.grpc.AccessStatus; +import biz.nynja.account.grpc.AccountDetails; +import biz.nynja.account.grpc.AccountDetails.Builder; +import biz.nynja.account.grpc.Role; + +public class AccountByFirstName { + + private UUID profileId; + private UUID accountId; + private String accountMark; + private String authenticationProvider; + private String authenticationProviderType; + private String firstName; + private String lastName; + private String avatar; + private String accountName; + private String username; + private Long creationTimestamp; + private Long lastUpdateTimestamp; + private Set contactsInfo; + private String qrCode; + private Set roles; + private String accessStatus; + private LocalDate birthday; + + public UUID getProfileId() { + return profileId; + } + + public void setProfileId(UUID profileId) { + this.profileId = profileId; + } + + public UUID getAccountId() { + return accountId; + } + + public void setAccountId(UUID accountId) { + this.accountId = accountId; + } + + public String getAccountMark() { + return accountMark; + } + + public void setAccountMark(String accountMark) { + this.accountMark = accountMark; + } + + public String getAuthenticationProvider() { + return authenticationProvider; + } + + public void setAuthenticationProvider(String authenticationProvider) { + this.authenticationProvider = authenticationProvider; + } + + public String getAuthenticationProviderType() { + return authenticationProviderType; + } + + public void setAuthenticationProviderType(String authenticationProviderType) { + this.authenticationProviderType = authenticationProviderType; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Long getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(Long creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + public Long getLastUpdateTimestamp() { + return lastUpdateTimestamp; + } + + public void setLastUpdateTimestamp(Long lastUpdateTimestamp) { + this.lastUpdateTimestamp = lastUpdateTimestamp; + } + + public Set getContactsInfo() { + return contactsInfo; + } + + public void setContactsInfo(Set contactsInfo) { + this.contactsInfo = contactsInfo; + } + + public String getQrCode() { + return qrCode; + } + + public void setQrCode(String qrCode) { + this.qrCode = qrCode; + } + + public Set getRoles() { + return roles; + } + + public void setRoles(Set roles) { + this.roles = roles; + } + + public String getAccessStatus() { + return accessStatus; + } + + public void setAccessStatus(String accessStatus) { + this.accessStatus = accessStatus; + } + + public LocalDate getBirthday() { + return birthday; + } + + public void setBirthday(LocalDate birthday) { + this.birthday = birthday; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((accessStatus == null) ? 0 : accessStatus.hashCode()); + result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); + result = prime * result + ((accountMark == null) ? 0 : accountMark.hashCode()); + result = prime * result + ((accountName == null) ? 0 : accountName.hashCode()); + result = prime * result + ((authenticationProvider == null) ? 0 : authenticationProvider.hashCode()); + result = prime * result + ((authenticationProviderType == null) ? 0 : authenticationProviderType.hashCode()); + result = prime * result + ((avatar == null) ? 0 : avatar.hashCode()); + result = prime * result + ((birthday == null) ? 0 : birthday.hashCode()); + result = prime * result + ((contactsInfo == null) ? 0 : contactsInfo.hashCode()); + result = prime * result + ((creationTimestamp == null) ? 0 : creationTimestamp.hashCode()); + result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + ((lastUpdateTimestamp == null) ? 0 : lastUpdateTimestamp.hashCode()); + result = prime * result + ((profileId == null) ? 0 : profileId.hashCode()); + result = prime * result + ((qrCode == null) ? 0 : qrCode.hashCode()); + result = prime * result + ((roles == null) ? 0 : roles.hashCode()); + result = prime * result + ((username == null) ? 0 : username.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AccountByFirstName other = (AccountByFirstName) obj; + if (accessStatus == null) { + if (other.accessStatus != null) + return false; + } else if (!accessStatus.equals(other.accessStatus)) + return false; + if (accountId == null) { + if (other.accountId != null) + return false; + } else if (!accountId.equals(other.accountId)) + return false; + if (accountMark == null) { + if (other.accountMark != null) + return false; + } else if (!accountMark.equals(other.accountMark)) + return false; + if (accountName == null) { + if (other.accountName != null) + return false; + } else if (!accountName.equals(other.accountName)) + return false; + if (authenticationProvider == null) { + if (other.authenticationProvider != null) + return false; + } else if (!authenticationProvider.equals(other.authenticationProvider)) + return false; + if (authenticationProviderType == null) { + if (other.authenticationProviderType != null) + return false; + } else if (!authenticationProviderType.equals(other.authenticationProviderType)) + return false; + if (avatar == null) { + if (other.avatar != null) + return false; + } else if (!avatar.equals(other.avatar)) + return false; + if (birthday == null) { + if (other.birthday != null) + return false; + } else if (!birthday.equals(other.birthday)) + return false; + if (contactsInfo == null) { + if (other.contactsInfo != null) + return false; + } else if (!contactsInfo.equals(other.contactsInfo)) + return false; + if (creationTimestamp == null) { + if (other.creationTimestamp != null) + return false; + } else if (!creationTimestamp.equals(other.creationTimestamp)) + return false; + if (firstName == null) { + if (other.firstName != null) + return false; + } else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } else if (!lastName.equals(other.lastName)) + return false; + if (lastUpdateTimestamp == null) { + if (other.lastUpdateTimestamp != null) + return false; + } else if (!lastUpdateTimestamp.equals(other.lastUpdateTimestamp)) + return false; + if (profileId == null) { + if (other.profileId != null) + return false; + } else if (!profileId.equals(other.profileId)) + return false; + if (qrCode == null) { + if (other.qrCode != null) + return false; + } else if (!qrCode.equals(other.qrCode)) + return false; + if (roles == null) { + if (other.roles != null) + return false; + } else if (!roles.equals(other.roles)) + return false; + if (username == null) { + if (other.username != null) + return false; + } else if (!username.equals(other.username)) + return false; + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("AccountByUsername [profileId=").append(profileId).append(", accountId=").append(accountId) + .append(", accountMark=").append(accountMark).append(", authenticationProvider=") + .append(authenticationProvider).append(", authenticationProviderType=") + .append(authenticationProviderType).append(", firstName=").append(firstName).append(", lastName=") + .append(lastName).append(", avatar=").append(avatar).append(", accountName=").append(accountName) + .append(", username=").append(username).append(", creationTimestamp=").append(creationTimestamp) + .append(", lastUpdateTimestamp=").append(lastUpdateTimestamp).append(", contactsInfo=") + .append(contactsInfo).append(", qrCode=").append(qrCode).append(", roles=").append(roles) + .append(", accessStatus=").append(accessStatus).append(", birthday=").append(birthday).append("]"); + return builder.toString(); + } + + public AccountDetails toProto() { + + Builder builder = AccountDetails.newBuilder(); + + if (getAccountId() != null) { + builder.setAccountId(getAccountId().toString()); + } + if (getProfileId() != null) { + builder.setProfileId(getProfileId().toString()); + } + if (getAuthenticationProvider() != null) { + builder.setAuthenticationIdentifier(getAuthenticationProvider()); + } + if (getAuthenticationProviderType() != null) { + builder.setAuthenticationType(getAuthenticationProviderType()); + } + if (getAccountMark() != null) { + builder.setAccountMark(getAccountMark()); + } + if (getAccountName() != null) { + builder.setAccountName(getAccountName()); + } + if (getFirstName() != null) { + builder.setFirstName(getFirstName()); + } + if (getLastName() != null) { + builder.setLastName(getLastName()); + } + if (getUsername() != null) { + builder.setUsername(getUsername()); + } + if (getQrCode() != null) { + builder.setQrCode(getQrCode()); + } + if (getAvatar() != null) { + builder.setAvatar(avatar); + } + if (getRoles() != null) { + for (String role : getRoles()) { + builder.addRoles(Role.valueOf(role)); + } + } + if (getAccessStatus() != null) { + builder.setAccessStatus(AccessStatus.valueOf(getAccessStatus())); + } + if (getContactsInfo() != null) { + for (ContactInfo c : contactsInfo) { + builder.addContactsInfo(c.toProto()); + } + } + + return builder.build(); + + } + + public Account getAccount() { + Account account = new Account(); + account.setAccountId(getAccountId()); + account.setProfileId(getProfileId()); + account.setAuthenticationProvider(getAuthenticationProvider()); + account.setAuthenticationProviderType(getAuthenticationProviderType()); + account.setAccountMark(getAccountMark()); + account.setAccountName(getAccountName()); + account.setFirstName(getFirstName()); + account.setLastName(getLastName()); + account.setUsername(getUsername()); + account.setQrCode(getQrCode()); + account.setAvatar(getAvatar()); + account.setRoles(getRoles()); + account.setAccessStatus(getAccessStatus()); + account.setContactsInfo(getContactsInfo()); + + return account; + } + +} diff --git a/src/main/java/biz/nynja/account/models/AccountByLastName.java b/src/main/java/biz/nynja/account/models/AccountByLastName.java new file mode 100644 index 0000000..2809b8a --- /dev/null +++ b/src/main/java/biz/nynja/account/models/AccountByLastName.java @@ -0,0 +1,382 @@ +/** + * Copyright (C) 2018 Nynja Inc. All rights reserved. + */ +package biz.nynja.account.models; + +import java.time.LocalDate; +import java.util.Set; +import java.util.UUID; + +import biz.nynja.account.grpc.AccessStatus; +import biz.nynja.account.grpc.AccountDetails; +import biz.nynja.account.grpc.AccountDetails.Builder; +import biz.nynja.account.grpc.Role; + +public class AccountByLastName { + + private UUID profileId; + private UUID accountId; + private String accountMark; + private String authenticationProvider; + private String authenticationProviderType; + private String firstName; + private String lastName; + private String avatar; + private String accountName; + private String username; + private Long creationTimestamp; + private Long lastUpdateTimestamp; + private Set contactsInfo; + private String qrCode; + private Set roles; + private String accessStatus; + private LocalDate birthday; + + public UUID getProfileId() { + return profileId; + } + + public void setProfileId(UUID profileId) { + this.profileId = profileId; + } + + public UUID getAccountId() { + return accountId; + } + + public void setAccountId(UUID accountId) { + this.accountId = accountId; + } + + public String getAccountMark() { + return accountMark; + } + + public void setAccountMark(String accountMark) { + this.accountMark = accountMark; + } + + public String getAuthenticationProvider() { + return authenticationProvider; + } + + public void setAuthenticationProvider(String authenticationProvider) { + this.authenticationProvider = authenticationProvider; + } + + public String getAuthenticationProviderType() { + return authenticationProviderType; + } + + public void setAuthenticationProviderType(String authenticationProviderType) { + this.authenticationProviderType = authenticationProviderType; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public Long getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(Long creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + public Long getLastUpdateTimestamp() { + return lastUpdateTimestamp; + } + + public void setLastUpdateTimestamp(Long lastUpdateTimestamp) { + this.lastUpdateTimestamp = lastUpdateTimestamp; + } + + public Set getContactsInfo() { + return contactsInfo; + } + + public void setContactsInfo(Set contactsInfo) { + this.contactsInfo = contactsInfo; + } + + public String getQrCode() { + return qrCode; + } + + public void setQrCode(String qrCode) { + this.qrCode = qrCode; + } + + public Set getRoles() { + return roles; + } + + public void setRoles(Set roles) { + this.roles = roles; + } + + public String getAccessStatus() { + return accessStatus; + } + + public void setAccessStatus(String accessStatus) { + this.accessStatus = accessStatus; + } + + public LocalDate getBirthday() { + return birthday; + } + + public void setBirthday(LocalDate birthday) { + this.birthday = birthday; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((accessStatus == null) ? 0 : accessStatus.hashCode()); + result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); + result = prime * result + ((accountMark == null) ? 0 : accountMark.hashCode()); + result = prime * result + ((accountName == null) ? 0 : accountName.hashCode()); + result = prime * result + ((authenticationProvider == null) ? 0 : authenticationProvider.hashCode()); + result = prime * result + ((authenticationProviderType == null) ? 0 : authenticationProviderType.hashCode()); + result = prime * result + ((avatar == null) ? 0 : avatar.hashCode()); + result = prime * result + ((birthday == null) ? 0 : birthday.hashCode()); + result = prime * result + ((contactsInfo == null) ? 0 : contactsInfo.hashCode()); + result = prime * result + ((creationTimestamp == null) ? 0 : creationTimestamp.hashCode()); + result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + ((lastUpdateTimestamp == null) ? 0 : lastUpdateTimestamp.hashCode()); + result = prime * result + ((profileId == null) ? 0 : profileId.hashCode()); + result = prime * result + ((qrCode == null) ? 0 : qrCode.hashCode()); + result = prime * result + ((roles == null) ? 0 : roles.hashCode()); + result = prime * result + ((username == null) ? 0 : username.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AccountByLastName other = (AccountByLastName) obj; + if (accessStatus == null) { + if (other.accessStatus != null) + return false; + } else if (!accessStatus.equals(other.accessStatus)) + return false; + if (accountId == null) { + if (other.accountId != null) + return false; + } else if (!accountId.equals(other.accountId)) + return false; + if (accountMark == null) { + if (other.accountMark != null) + return false; + } else if (!accountMark.equals(other.accountMark)) + return false; + if (accountName == null) { + if (other.accountName != null) + return false; + } else if (!accountName.equals(other.accountName)) + return false; + if (authenticationProvider == null) { + if (other.authenticationProvider != null) + return false; + } else if (!authenticationProvider.equals(other.authenticationProvider)) + return false; + if (authenticationProviderType == null) { + if (other.authenticationProviderType != null) + return false; + } else if (!authenticationProviderType.equals(other.authenticationProviderType)) + return false; + if (avatar == null) { + if (other.avatar != null) + return false; + } else if (!avatar.equals(other.avatar)) + return false; + if (birthday == null) { + if (other.birthday != null) + return false; + } else if (!birthday.equals(other.birthday)) + return false; + if (contactsInfo == null) { + if (other.contactsInfo != null) + return false; + } else if (!contactsInfo.equals(other.contactsInfo)) + return false; + if (creationTimestamp == null) { + if (other.creationTimestamp != null) + return false; + } else if (!creationTimestamp.equals(other.creationTimestamp)) + return false; + if (firstName == null) { + if (other.firstName != null) + return false; + } else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } else if (!lastName.equals(other.lastName)) + return false; + if (lastUpdateTimestamp == null) { + if (other.lastUpdateTimestamp != null) + return false; + } else if (!lastUpdateTimestamp.equals(other.lastUpdateTimestamp)) + return false; + if (profileId == null) { + if (other.profileId != null) + return false; + } else if (!profileId.equals(other.profileId)) + return false; + if (qrCode == null) { + if (other.qrCode != null) + return false; + } else if (!qrCode.equals(other.qrCode)) + return false; + if (roles == null) { + if (other.roles != null) + return false; + } else if (!roles.equals(other.roles)) + return false; + if (username == null) { + if (other.username != null) + return false; + } else if (!username.equals(other.username)) + return false; + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("AccountByUsername [profileId=").append(profileId).append(", accountId=").append(accountId) + .append(", accountMark=").append(accountMark).append(", authenticationProvider=") + .append(authenticationProvider).append(", authenticationProviderType=") + .append(authenticationProviderType).append(", firstName=").append(firstName).append(", lastName=") + .append(lastName).append(", avatar=").append(avatar).append(", accountName=").append(accountName) + .append(", username=").append(username).append(", creationTimestamp=").append(creationTimestamp) + .append(", lastUpdateTimestamp=").append(lastUpdateTimestamp).append(", contactsInfo=") + .append(contactsInfo).append(", qrCode=").append(qrCode).append(", roles=").append(roles) + .append(", accessStatus=").append(accessStatus).append(", birthday=").append(birthday).append("]"); + return builder.toString(); + } + + public AccountDetails toProto() { + + Builder builder = AccountDetails.newBuilder(); + + if (getAccountId() != null) { + builder.setAccountId(getAccountId().toString()); + } + if (getProfileId() != null) { + builder.setProfileId(getProfileId().toString()); + } + if (getAuthenticationProvider() != null) { + builder.setAuthenticationIdentifier(getAuthenticationProvider()); + } + if (getAuthenticationProviderType() != null) { + builder.setAuthenticationType(getAuthenticationProviderType()); + } + if (getAccountMark() != null) { + builder.setAccountMark(getAccountMark()); + } + if (getAccountName() != null) { + builder.setAccountName(getAccountName()); + } + if (getFirstName() != null) { + builder.setFirstName(getFirstName()); + } + if (getLastName() != null) { + builder.setLastName(getLastName()); + } + if (getUsername() != null) { + builder.setUsername(getUsername()); + } + if (getQrCode() != null) { + builder.setQrCode(getQrCode()); + } + if (getAvatar() != null) { + builder.setAvatar(avatar); + } + if (getRoles() != null) { + for (String role : getRoles()) { + builder.addRoles(Role.valueOf(role)); + } + } + if (getAccessStatus() != null) { + builder.setAccessStatus(AccessStatus.valueOf(getAccessStatus())); + } + if (getContactsInfo() != null) { + for (ContactInfo c : contactsInfo) { + builder.addContactsInfo(c.toProto()); + } + } + + return builder.build(); + + } + + public Account getAccount() { + Account account = new Account(); + account.setAccountId(getAccountId()); + account.setProfileId(getProfileId()); + account.setAuthenticationProvider(getAuthenticationProvider()); + account.setAuthenticationProviderType(getAuthenticationProviderType()); + account.setAccountMark(getAccountMark()); + account.setAccountName(getAccountName()); + account.setFirstName(getFirstName()); + account.setLastName(getLastName()); + account.setUsername(getUsername()); + account.setQrCode(getQrCode()); + account.setAvatar(getAvatar()); + account.setRoles(getRoles()); + account.setAccessStatus(getAccessStatus()); + account.setContactsInfo(getContactsInfo()); + + return account; + } + +} diff --git a/src/main/java/biz/nynja/account/repositories/AccountByAccessStatusRepository.java b/src/main/java/biz/nynja/account/repositories/AccountByAccessStatusRepository.java new file mode 100644 index 0000000..a6f8c94 --- /dev/null +++ b/src/main/java/biz/nynja/account/repositories/AccountByAccessStatusRepository.java @@ -0,0 +1,18 @@ +/** + * Copyright (C) 2018 Nynja Inc. All rights reserved. + */ +package biz.nynja.account.repositories; + +import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.stereotype.Repository; + +import biz.nynja.account.models.AccountByAccessStatus; + +@Repository +public interface AccountByAccessStatusRepository extends CassandraRepository { + + Slice findByAccessStatus(String accessStatus, Pageable pageable); + +} diff --git a/src/main/java/biz/nynja/account/repositories/AccountByFirstNameRepository.java b/src/main/java/biz/nynja/account/repositories/AccountByFirstNameRepository.java new file mode 100644 index 0000000..b61fff9 --- /dev/null +++ b/src/main/java/biz/nynja/account/repositories/AccountByFirstNameRepository.java @@ -0,0 +1,18 @@ +/** + * Copyright (C) 2018 Nynja Inc. All rights reserved. + */ +package biz.nynja.account.repositories; + +import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.stereotype.Repository; + +import biz.nynja.account.models.AccountByFirstName; + +@Repository +public interface AccountByFirstNameRepository extends CassandraRepository { + + Slice findByFirstName(String firstname, Pageable pageable); + +} diff --git a/src/main/java/biz/nynja/account/repositories/AccountByLastNameRepository.java b/src/main/java/biz/nynja/account/repositories/AccountByLastNameRepository.java new file mode 100644 index 0000000..50625ae --- /dev/null +++ b/src/main/java/biz/nynja/account/repositories/AccountByLastNameRepository.java @@ -0,0 +1,18 @@ +/** + * Copyright (C) 2018 Nynja Inc. All rights reserved. + */ +package biz.nynja.account.repositories; + +import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.stereotype.Repository; + +import biz.nynja.account.models.AccountByLastName; + +@Repository +public interface AccountByLastNameRepository extends CassandraRepository { + + Slice findByLastName(String lastname, Pageable pageable); + +} diff --git a/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java b/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java index 2d1e273..5cca921 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java +++ b/src/main/java/biz/nynja/account/repositories/AccountByUsernameRepository.java @@ -17,6 +17,4 @@ public interface AccountByUsernameRepository extends CassandraRepository findByUsername(String username, Pageable pageable); - Slice findByUsernameContains(String username, Pageable pageable); - } -- GitLab From 36cce67fe903cf7d7c4ba1be17555ea2055b9396 Mon Sep 17 00:00:00 2001 From: Dragomir Todorov Date: Mon, 19 Nov 2018 16:04:28 +0200 Subject: [PATCH 4/6] NY-4610: Added todo on different place --- .../biz/nynja/account/grid/ag/AgGridService.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java index 5993eb8..981d40e 100644 --- a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java +++ b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java @@ -101,20 +101,17 @@ public class AgGridService { return retrieveLastnameFilteredResults(pageable, filterModel); case FILTER_ACCESS_STATUS: return retrieveAccessStatusFilteredResults(pageable, filterModel); + // TODO implement filter for these fields + // • Created (creation timestamp) + // • Updated (last updated timestamp + // • Email + // • Phone number + // • Social profile default: break; } return Collections.emptyList(); - // • First name - // • Last name - // • Access status - - // • Email - // • Phone number - // • Social profile - // • Created (creation timestamp) - // • Updated (last updated timestamp } private List retrieveUsernameFilteredResults(Pageable pageable, FilterModel filterModel) { -- GitLab From b25eb87b524c27312ab237182f649f5d3b4a4db8 Mon Sep 17 00:00:00 2001 From: Dragomir Todorov Date: Tue, 20 Nov 2018 10:18:02 +0200 Subject: [PATCH 5/6] NY-4610: Added timestamps --- .../biz/nynja/account/models/AccountByAccessStatus.java | 2 ++ .../biz/nynja/account/models/AccountByFirstName.java | 9 +++++++++ .../java/biz/nynja/account/models/AccountByLastName.java | 2 ++ .../java/biz/nynja/account/models/AccountByUsername.java | 2 ++ 4 files changed, 15 insertions(+) diff --git a/src/main/java/biz/nynja/account/models/AccountByAccessStatus.java b/src/main/java/biz/nynja/account/models/AccountByAccessStatus.java index 9e61915..e601eda 100644 --- a/src/main/java/biz/nynja/account/models/AccountByAccessStatus.java +++ b/src/main/java/biz/nynja/account/models/AccountByAccessStatus.java @@ -375,6 +375,8 @@ public class AccountByAccessStatus { account.setRoles(getRoles()); account.setAccessStatus(getAccessStatus()); account.setContactsInfo(getContactsInfo()); + account.setCreationTimestamp(getCreationTimestamp()); + account.setLastUpdateTimestamp(getLastUpdateTimestamp()); return account; } diff --git a/src/main/java/biz/nynja/account/models/AccountByFirstName.java b/src/main/java/biz/nynja/account/models/AccountByFirstName.java index a26aac1..5f9efd9 100644 --- a/src/main/java/biz/nynja/account/models/AccountByFirstName.java +++ b/src/main/java/biz/nynja/account/models/AccountByFirstName.java @@ -355,6 +355,13 @@ public class AccountByFirstName { } } + if (getCreationTimestamp() != null) { + builder.setCreationTimestamp(getCreationTimestamp()); + } + if (getLastUpdateTimestamp() != null) { + builder.setLastUpdateTimestamp(getLastUpdateTimestamp()); + } + return builder.build(); } @@ -375,6 +382,8 @@ public class AccountByFirstName { account.setRoles(getRoles()); account.setAccessStatus(getAccessStatus()); account.setContactsInfo(getContactsInfo()); + account.setCreationTimestamp(getCreationTimestamp()); + account.setLastUpdateTimestamp(getLastUpdateTimestamp()); return account; } diff --git a/src/main/java/biz/nynja/account/models/AccountByLastName.java b/src/main/java/biz/nynja/account/models/AccountByLastName.java index 2809b8a..7beb8d4 100644 --- a/src/main/java/biz/nynja/account/models/AccountByLastName.java +++ b/src/main/java/biz/nynja/account/models/AccountByLastName.java @@ -375,6 +375,8 @@ public class AccountByLastName { account.setRoles(getRoles()); account.setAccessStatus(getAccessStatus()); account.setContactsInfo(getContactsInfo()); + account.setCreationTimestamp(getCreationTimestamp()); + account.setLastUpdateTimestamp(getLastUpdateTimestamp()); return account; } diff --git a/src/main/java/biz/nynja/account/models/AccountByUsername.java b/src/main/java/biz/nynja/account/models/AccountByUsername.java index aa1c96e..6e5f930 100644 --- a/src/main/java/biz/nynja/account/models/AccountByUsername.java +++ b/src/main/java/biz/nynja/account/models/AccountByUsername.java @@ -381,6 +381,8 @@ public class AccountByUsername { account.setRoles(getRoles()); account.setAccessStatus(getAccessStatus()); account.setContactsInfo(getContactsInfo()); + account.setCreationTimestamp(getCreationTimestamp()); + account.setLastUpdateTimestamp(getLastUpdateTimestamp()); return account; } -- GitLab From 1da2df197a59aa8bf3b2673d3acd21e7d70dcb2a Mon Sep 17 00:00:00 2001 From: Dragomir Todorov Date: Tue, 20 Nov 2018 10:58:01 +0200 Subject: [PATCH 6/6] NY-4610: Renamed a few properties --- .../biz/nynja/account/grid/ag/AgGridService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java index 981d40e..3e35baa 100644 --- a/src/main/java/biz/nynja/account/grid/ag/AgGridService.java +++ b/src/main/java/biz/nynja/account/grid/ag/AgGridService.java @@ -18,7 +18,7 @@ import org.springframework.stereotype.Service; import biz.nynja.account.admin.grpc.AccountAdminResponse; import biz.nynja.account.admin.grpc.AccountsAdminResponse; import biz.nynja.account.admin.grpc.FilterModel; -import biz.nynja.account.admin.grpc.FilterModel.Type; +import biz.nynja.account.admin.grpc.FilterModel.FilterType; import biz.nynja.account.grpc.AccountDetails; import biz.nynja.account.models.Account; import biz.nynja.account.models.AccountByAccessStatus; @@ -38,6 +38,8 @@ public class AgGridService { private static final String FILTER_FIRST_NAME = "firstname"; private static final String FILTER_LAST_NAME = "lastname"; private static final String FILTER_ACCESS_STATUS = "accessStatus"; + private static final String FILTER_CREATION_TIMESTAMP = "creationTimestamp"; + private static final String FILTER_LAST_UPDATED_TIMESTAMP = "lastUpdatedTimestamp"; private AccountRepository accountRepository; private AccountByUsernameRepository accountByUsernameRepository; @@ -116,7 +118,7 @@ public class AgGridService { private List retrieveUsernameFilteredResults(Pageable pageable, FilterModel filterModel) { Slice listAccountsByUsername; - if (Type.EQUALS.equals(filterModel.getType())) { // ONLY EQUALS is supported at the moment + if (FilterType.EQUALS.equals(filterModel.getFilterType())) { // ONLY EQUALS is supported at the moment listAccountsByUsername = accountByUsernameRepository.findByUsername(filterModel.getFilterValue(), pageable); } else { return Collections.emptyList(); @@ -126,7 +128,7 @@ public class AgGridService { private List retrieveFirstnameFilteredResults(Pageable pageable, FilterModel filterModel) { Slice listAccountsByFirstname; - if (Type.EQUALS.equals(filterModel.getType())) { // Only EQUALS is supported at the moment + if (FilterType.EQUALS.equals(filterModel.getFilterType())) { // Only EQUALS is supported at the moment listAccountsByFirstname = accountByFirstNameRepository.findByFirstName(filterModel.getFilterValue(), pageable); } else { @@ -137,7 +139,7 @@ public class AgGridService { private List retrieveLastnameFilteredResults(Pageable pageable, FilterModel filterModel) { Slice listAccountsByLastname; - if (Type.EQUALS.equals(filterModel.getType())) { // Only EQUALS is supported at the moment + if (FilterType.EQUALS.equals(filterModel.getFilterType())) { // Only EQUALS is supported at the moment listAccountsByLastname = accountByLastNameRepository.findByLastName(filterModel.getFilterValue(), pageable); } else { return Collections.emptyList(); @@ -147,7 +149,7 @@ public class AgGridService { private List retrieveAccessStatusFilteredResults(Pageable pageable, FilterModel filterModel) { Slice listAccountsByAccessStatus; - if (Type.EQUALS.equals(filterModel.getType())) { // Only EQUALS is supported at the moment + if (FilterType.EQUALS.equals(filterModel.getFilterType())) { // Only EQUALS is supported at the moment listAccountsByAccessStatus = accountByAccessStatusRepository .findByAccessStatus(filterModel.getFilterValue(), pageable); } else { -- GitLab