SlideShare a Scribd company logo
Creating a Facebook Clone - Part XX
@Entity
public class Notification {
@Id
private String id;
@ManyToOne
private User user;
private String text;
private String reaction;
private int reactionColor;
private long date;
private boolean wasRead;
private String postId;
private String commentId;
public Notification() {
id = UUID.randomUUID().toString();
}
public NotificationDAO getDAO() {
return new NotificationDAO(id, user.getDAO(), text, reaction,
Notification
@Entity
public class Notification {
@Id
private String id;
@ManyToOne
private User user;
private String text;
private String reaction;
private int reactionColor;
private long date;
private boolean wasRead;
private String postId;
private String commentId;
public Notification() {
id = UUID.randomUUID().toString();
}
public NotificationDAO getDAO() {
return new NotificationDAO(id, user.getDAO(), text, reaction,
Notification
private long date;
private boolean wasRead;
private String postId;
private String commentId;
public Notification() {
id = UUID.randomUUID().toString();
}
public NotificationDAO getDAO() {
return new NotificationDAO(id, user.getDAO(), text, reaction,
reactionColor, date, wasRead, postId, commentId);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
Notification
return date;
}
public void setDate(long date) {
this.date = date;
}
public boolean isWasRead() {
return wasRead;
}
public void setWasRead(boolean wasRead) {
this.wasRead = wasRead;
}
public String getPostId() {
return postId;
}
public void setPostId(String postId) {
this.postId = postId;
}
public String getCommentId() {
return commentId;
}
public void setCommentId(String commentId) {
this.commentId = commentId;
}
}
Notification
public class NotificationDAO {
private String id;
private UserDAO user;
private String text;
private String reaction;
private int reactionColor;
private long date;
private boolean wasRead;
private String postId;
private String commentId;
public NotificationDAO() {
}
public NotificationDAO(String id, UserDAO user, String text,
String reaction, int reactionColor, long date, boolean wasRead,
String postId, String commentId) {
this.id = id;
this.user = user;
this.text = text;
NotificationDAO
return date;
}
public void setDate(long date) {
this.date = date;
}
public boolean isWasRead() {
return wasRead;
}
public void setWasRead(boolean wasRead) {
this.wasRead = wasRead;
}
public String getPostId() {
return postId;
}
public void setPostId(String postId) {
this.postId = postId;
}
public String getCommentId() {
return commentId;
}
public void setCommentId(String commentId) {
this.commentId = commentId;
}
}
NotificationDAO
Newsfeed
✦Why Newsfeed Entity?
✦Consistency
✦Tune Experience
© Codename One 2017 all rights reserved
@Entity
public class Newsfeed {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@ManyToOne
private User parent;
@ManyToOne
private Post entry;
private long postDay;
private long postTimestamp;
private int rank;
public Newsfeed() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
Newsfeed
@Entity
public class Newsfeed {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@ManyToOne
private User parent;
@ManyToOne
private Post entry;
private long postDay;
private long postTimestamp;
private int rank;
public Newsfeed() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
Newsfeed
@Entity
public class Newsfeed {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@ManyToOne
private User parent;
@ManyToOne
private Post entry;
private long postDay;
private long postTimestamp;
private int rank;
public Newsfeed() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
Newsfeed
@Entity
public class Newsfeed {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@ManyToOne
private User parent;
@ManyToOne
private Post entry;
private long postDay;
private long postTimestamp;
private int rank;
public Newsfeed() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
Newsfeed
@Entity
public class Newsfeed {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@ManyToOne
private User parent;
@ManyToOne
private Post entry;
private long postDay;
private long postTimestamp;
private int rank;
public Newsfeed() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
Newsfeed
private User parent;
@ManyToOne
private Post entry;
private long postDay;
private long postTimestamp;
private int rank;
public Newsfeed() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public User getParent() {
return parent;
}
public void setParent(User parent) {
this.parent = parent;
}
public Post getEntry() {
return entry;
}
Newsfeed
return entry;
}
public void setEntry(Post entry) {
this.entry = entry;
}
public int getRank() {
return rank;
}
public void setRank(int rank) {
this.rank = rank;
}
public long getPostDay() {
return postDay;
}
public void setPostDay(long postDay) {
this.postDay = postDay;
}
public long getPostTimestamp() {
return postTimestamp;
}
public void setPostTimestamp(long postTimestamp) {
this.postTimestamp = postTimestamp;
}
}
Newsfeed
public interface NewsfeedRepository extends CrudRepository<Newsfeed, Long>{
@Query("select n from Newsfeed n where n.parent.authtoken = ?1")
public Page<Newsfeed> findNewsfeedForUser(
String auth, Pageable page);
}
NewsfeedRepository
@Entity
public class ShadowUser {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String fullName;
private String phone;
private String email;
private String secondaryPhone;
@ManyToOne
private User owner;
public ShadowUser() {
}
public ShadowUser(ShadowUserDAO dao, User owner) {
this.fullName = dao.getFullName();
this.phone = dao.getPhone();
this.email = dao.getEmail();
ShadowUser
@Entity
public class ShadowUser {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String fullName;
private String phone;
private String email;
private String secondaryPhone;
@ManyToOne
private User owner;
public ShadowUser() {
}
public ShadowUser(ShadowUserDAO dao, User owner) {
this.fullName = dao.getFullName();
this.phone = dao.getPhone();
this.email = dao.getEmail();
ShadowUser
@Entity
public class ShadowUser {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String fullName;
private String phone;
private String email;
private String secondaryPhone;
@ManyToOne
private User owner;
public ShadowUser() {
}
public ShadowUser(ShadowUserDAO dao, User owner) {
this.fullName = dao.getFullName();
this.phone = dao.getPhone();
this.email = dao.getEmail();
ShadowUser
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String fullName;
private String phone;
private String email;
private String secondaryPhone;
@ManyToOne
private User owner;
public ShadowUser() {
}
public ShadowUser(ShadowUserDAO dao, User owner) {
this.fullName = dao.getFullName();
this.phone = dao.getPhone();
this.email = dao.getEmail();
this.secondaryPhone = dao.getSecondaryPhone();
this.owner = owner;
}
public Long getId() {
return id;
}
public void setId(Long id) {
ShadowUser
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSecondaryPhone() {
return secondaryPhone;
}
public void setSecondaryPhone(String secondaryPhone) {
this.secondaryPhone = secondaryPhone;
}
public User getOwner() {
return owner;
}
public void setOwner(User owner) {
this.owner = owner;
}
}
ShadowUser
public class ShadowUserDAO {
private String fullName;
private String phone;
private String email;
private String secondaryPhone;
public ShadowUserDAO() {
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
ShadowUserDAO
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSecondaryPhone() {
return secondaryPhone;
}
public void setSecondaryPhone(String secondaryPhone) {
this.secondaryPhone = secondaryPhone;
}
}
ShadowUserDAO
public interface ShadowUserRepository extends
CrudRepository<ShadowUser, Long> {
@Query("select n from ShadowUser n where n.owner.authtoken = ?1")
public List<ShadowUser> findShadowUsers(String auth);
@Query("select n from ShadowUser n where n.phone = ?1 or "
+ "n.secondaryPhone = ?1")
public List<ShadowUser> findByPhone(String phone);
@Query("select n from ShadowUser n where n.email = ?1")
public List<ShadowUser> findByEmail(String email);
@Query("select count(n) from ShadowUser n where "
+ "n.owner.authtoken = ?1")
public Long countByUser(String auth);
@Query("select n from ShadowUser n where n.owner.authtoken = ?1 and "
+ "n.fullName = ?2")
public List<ShadowUser> findByFullName(String auth, String fullName);
}
ShadowUserRepository
public interface ShadowUserRepository extends
CrudRepository<ShadowUser, Long> {
@Query("select n from ShadowUser n where n.owner.authtoken = ?1")
public List<ShadowUser> findShadowUsers(String auth);
@Query("select n from ShadowUser n where n.phone = ?1 or "
+ "n.secondaryPhone = ?1")
public List<ShadowUser> findByPhone(String phone);
@Query("select n from ShadowUser n where n.email = ?1")
public List<ShadowUser> findByEmail(String email);
@Query("select count(n) from ShadowUser n where "
+ "n.owner.authtoken = ?1")
public Long countByUser(String auth);
@Query("select n from ShadowUser n where n.owner.authtoken = ?1 and "
+ "n.fullName = ?2")
public List<ShadowUser> findByFullName(String auth, String fullName);
}
ShadowUserRepository
public interface ShadowUserRepository extends
CrudRepository<ShadowUser, Long> {
@Query("select n from ShadowUser n where n.owner.authtoken = ?1")
public List<ShadowUser> findShadowUsers(String auth);
@Query("select n from ShadowUser n where n.phone = ?1 or "
+ "n.secondaryPhone = ?1")
public List<ShadowUser> findByPhone(String phone);
@Query("select n from ShadowUser n where n.email = ?1")
public List<ShadowUser> findByEmail(String email);
@Query("select count(n) from ShadowUser n where "
+ "n.owner.authtoken = ?1")
public Long countByUser(String auth);
@Query("select n from ShadowUser n where n.owner.authtoken = ?1 and "
+ "n.fullName = ?2")
public List<ShadowUser> findByFullName(String auth, String fullName);
}
ShadowUserRepository

More Related Content

PDF
Creating a Facebook Clone - Part XX - Transcript.pdf
PDF
Creating a Facebook Clone - Part XIX.pdf
PDF
Creating a Facebook Clone - Part XIX - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXIV - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXIII - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXIV.pdf
PDF
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
PDF
Creating a Facebook Clone - Part XXXVIII.pdf
Creating a Facebook Clone - Part XX - Transcript.pdf
Creating a Facebook Clone - Part XIX.pdf
Creating a Facebook Clone - Part XIX - Transcript.pdf
Creating a Facebook Clone - Part XXIV - Transcript.pdf
Creating a Facebook Clone - Part XXIII - Transcript.pdf
Creating a Facebook Clone - Part XXIV.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII.pdf

Similar to Creating a Facebook Clone - Part XX.pdf (11)

PDF
Creating a Facebook Clone - Part XVII.pdf
PDF
Creating a Facebook Clone - Part XXI.pdf
PDF
Creating a Facebook Clone - Part XXIII.pdf
PDF
Creating a Facebook Clone - Part XVIII.pdf
PDF
Creating a Facebook Clone - Part XXII.pdf
PDF
create-netflix-clone-03-server_transcript.pdf
PDF
NOSQL part of the SpringOne 2GX 2010 keynote
PPTX
Simplifying Persistence for Java and MongoDB with Morphia
PPT
Spring data
PDF
Creating a Facebook Clone - Part XI.pdf
PDF
Creating a Facebook Clone - Part XIV.pdf
Creating a Facebook Clone - Part XVII.pdf
Creating a Facebook Clone - Part XXI.pdf
Creating a Facebook Clone - Part XXIII.pdf
Creating a Facebook Clone - Part XVIII.pdf
Creating a Facebook Clone - Part XXII.pdf
create-netflix-clone-03-server_transcript.pdf
NOSQL part of the SpringOne 2GX 2010 keynote
Simplifying Persistence for Java and MongoDB with Morphia
Spring data
Creating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XIV.pdf
Ad

More from ShaiAlmog1 (20)

PDF
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
PDF
create-netflix-clone-06-client-ui.pdf
PDF
create-netflix-clone-01-introduction_transcript.pdf
PDF
create-netflix-clone-02-server_transcript.pdf
PDF
create-netflix-clone-04-server-continued_transcript.pdf
PDF
create-netflix-clone-01-introduction.pdf
PDF
create-netflix-clone-06-client-ui_transcript.pdf
PDF
create-netflix-clone-03-server.pdf
PDF
create-netflix-clone-04-server-continued.pdf
PDF
create-netflix-clone-05-client-model_transcript.pdf
PDF
create-netflix-clone-02-server.pdf
PDF
create-netflix-clone-05-client-model.pdf
PDF
Creating a Whatsapp Clone - Part II.pdf
PDF
Creating a Whatsapp Clone - Part IX - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part II - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part V - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IV - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IV.pdf
PDF
Creating a Whatsapp Clone - Part I - Transcript.pdf
PDF
Creating a Whatsapp Clone - Part IX.pdf
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-01-introduction.pdf
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-03-server.pdf
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-02-server.pdf
create-netflix-clone-05-client-model.pdf
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part IX.pdf
Ad

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Spectroscopy.pptx food analysis technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
sap open course for s4hana steps from ECC to s4
Mobile App Security Testing_ A Comprehensive Guide.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Programs and apps: productivity, graphics, security and other tools
Diabetes mellitus diagnosis method based random forest with bat algorithm
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The AUB Centre for AI in Media Proposal.docx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...
Spectroscopy.pptx food analysis technology

Creating a Facebook Clone - Part XX.pdf

  • 1. Creating a Facebook Clone - Part XX
  • 2. @Entity public class Notification { @Id private String id; @ManyToOne private User user; private String text; private String reaction; private int reactionColor; private long date; private boolean wasRead; private String postId; private String commentId; public Notification() { id = UUID.randomUUID().toString(); } public NotificationDAO getDAO() { return new NotificationDAO(id, user.getDAO(), text, reaction, Notification
  • 3. @Entity public class Notification { @Id private String id; @ManyToOne private User user; private String text; private String reaction; private int reactionColor; private long date; private boolean wasRead; private String postId; private String commentId; public Notification() { id = UUID.randomUUID().toString(); } public NotificationDAO getDAO() { return new NotificationDAO(id, user.getDAO(), text, reaction, Notification
  • 4. private long date; private boolean wasRead; private String postId; private String commentId; public Notification() { id = UUID.randomUUID().toString(); } public NotificationDAO getDAO() { return new NotificationDAO(id, user.getDAO(), text, reaction, reactionColor, date, wasRead, postId, commentId); } public String getId() { return id; } public void setId(String id) { this.id = id; } public User getUser() { return user; } public void setUser(User user) { this.user = user; Notification
  • 5. return date; } public void setDate(long date) { this.date = date; } public boolean isWasRead() { return wasRead; } public void setWasRead(boolean wasRead) { this.wasRead = wasRead; } public String getPostId() { return postId; } public void setPostId(String postId) { this.postId = postId; } public String getCommentId() { return commentId; } public void setCommentId(String commentId) { this.commentId = commentId; } } Notification
  • 6. public class NotificationDAO { private String id; private UserDAO user; private String text; private String reaction; private int reactionColor; private long date; private boolean wasRead; private String postId; private String commentId; public NotificationDAO() { } public NotificationDAO(String id, UserDAO user, String text, String reaction, int reactionColor, long date, boolean wasRead, String postId, String commentId) { this.id = id; this.user = user; this.text = text; NotificationDAO
  • 7. return date; } public void setDate(long date) { this.date = date; } public boolean isWasRead() { return wasRead; } public void setWasRead(boolean wasRead) { this.wasRead = wasRead; } public String getPostId() { return postId; } public void setPostId(String postId) { this.postId = postId; } public String getCommentId() { return commentId; } public void setCommentId(String commentId) { this.commentId = commentId; } } NotificationDAO
  • 8. Newsfeed ✦Why Newsfeed Entity? ✦Consistency ✦Tune Experience © Codename One 2017 all rights reserved
  • 9. @Entity public class Newsfeed { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @ManyToOne private User parent; @ManyToOne private Post entry; private long postDay; private long postTimestamp; private int rank; public Newsfeed() { } public Long getId() { return id; } public void setId(Long id) { Newsfeed
  • 10. @Entity public class Newsfeed { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @ManyToOne private User parent; @ManyToOne private Post entry; private long postDay; private long postTimestamp; private int rank; public Newsfeed() { } public Long getId() { return id; } public void setId(Long id) { Newsfeed
  • 11. @Entity public class Newsfeed { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @ManyToOne private User parent; @ManyToOne private Post entry; private long postDay; private long postTimestamp; private int rank; public Newsfeed() { } public Long getId() { return id; } public void setId(Long id) { Newsfeed
  • 12. @Entity public class Newsfeed { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @ManyToOne private User parent; @ManyToOne private Post entry; private long postDay; private long postTimestamp; private int rank; public Newsfeed() { } public Long getId() { return id; } public void setId(Long id) { Newsfeed
  • 13. @Entity public class Newsfeed { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @ManyToOne private User parent; @ManyToOne private Post entry; private long postDay; private long postTimestamp; private int rank; public Newsfeed() { } public Long getId() { return id; } public void setId(Long id) { Newsfeed
  • 14. private User parent; @ManyToOne private Post entry; private long postDay; private long postTimestamp; private int rank; public Newsfeed() { } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public User getParent() { return parent; } public void setParent(User parent) { this.parent = parent; } public Post getEntry() { return entry; } Newsfeed
  • 15. return entry; } public void setEntry(Post entry) { this.entry = entry; } public int getRank() { return rank; } public void setRank(int rank) { this.rank = rank; } public long getPostDay() { return postDay; } public void setPostDay(long postDay) { this.postDay = postDay; } public long getPostTimestamp() { return postTimestamp; } public void setPostTimestamp(long postTimestamp) { this.postTimestamp = postTimestamp; } } Newsfeed
  • 16. public interface NewsfeedRepository extends CrudRepository<Newsfeed, Long>{ @Query("select n from Newsfeed n where n.parent.authtoken = ?1") public Page<Newsfeed> findNewsfeedForUser( String auth, Pageable page); } NewsfeedRepository
  • 17. @Entity public class ShadowUser { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String fullName; private String phone; private String email; private String secondaryPhone; @ManyToOne private User owner; public ShadowUser() { } public ShadowUser(ShadowUserDAO dao, User owner) { this.fullName = dao.getFullName(); this.phone = dao.getPhone(); this.email = dao.getEmail(); ShadowUser
  • 18. @Entity public class ShadowUser { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String fullName; private String phone; private String email; private String secondaryPhone; @ManyToOne private User owner; public ShadowUser() { } public ShadowUser(ShadowUserDAO dao, User owner) { this.fullName = dao.getFullName(); this.phone = dao.getPhone(); this.email = dao.getEmail(); ShadowUser
  • 19. @Entity public class ShadowUser { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String fullName; private String phone; private String email; private String secondaryPhone; @ManyToOne private User owner; public ShadowUser() { } public ShadowUser(ShadowUserDAO dao, User owner) { this.fullName = dao.getFullName(); this.phone = dao.getPhone(); this.email = dao.getEmail(); ShadowUser
  • 20. @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String fullName; private String phone; private String email; private String secondaryPhone; @ManyToOne private User owner; public ShadowUser() { } public ShadowUser(ShadowUserDAO dao, User owner) { this.fullName = dao.getFullName(); this.phone = dao.getPhone(); this.email = dao.getEmail(); this.secondaryPhone = dao.getSecondaryPhone(); this.owner = owner; } public Long getId() { return id; } public void setId(Long id) { ShadowUser
  • 21. return phone; } public void setPhone(String phone) { this.phone = phone; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getSecondaryPhone() { return secondaryPhone; } public void setSecondaryPhone(String secondaryPhone) { this.secondaryPhone = secondaryPhone; } public User getOwner() { return owner; } public void setOwner(User owner) { this.owner = owner; } } ShadowUser
  • 22. public class ShadowUserDAO { private String fullName; private String phone; private String email; private String secondaryPhone; public ShadowUserDAO() { } public String getFullName() { return fullName; } public void setFullName(String fullName) { this.fullName = fullName; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getEmail() { ShadowUserDAO
  • 23. return fullName; } public void setFullName(String fullName) { this.fullName = fullName; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getSecondaryPhone() { return secondaryPhone; } public void setSecondaryPhone(String secondaryPhone) { this.secondaryPhone = secondaryPhone; } } ShadowUserDAO
  • 24. public interface ShadowUserRepository extends CrudRepository<ShadowUser, Long> { @Query("select n from ShadowUser n where n.owner.authtoken = ?1") public List<ShadowUser> findShadowUsers(String auth); @Query("select n from ShadowUser n where n.phone = ?1 or " + "n.secondaryPhone = ?1") public List<ShadowUser> findByPhone(String phone); @Query("select n from ShadowUser n where n.email = ?1") public List<ShadowUser> findByEmail(String email); @Query("select count(n) from ShadowUser n where " + "n.owner.authtoken = ?1") public Long countByUser(String auth); @Query("select n from ShadowUser n where n.owner.authtoken = ?1 and " + "n.fullName = ?2") public List<ShadowUser> findByFullName(String auth, String fullName); } ShadowUserRepository
  • 25. public interface ShadowUserRepository extends CrudRepository<ShadowUser, Long> { @Query("select n from ShadowUser n where n.owner.authtoken = ?1") public List<ShadowUser> findShadowUsers(String auth); @Query("select n from ShadowUser n where n.phone = ?1 or " + "n.secondaryPhone = ?1") public List<ShadowUser> findByPhone(String phone); @Query("select n from ShadowUser n where n.email = ?1") public List<ShadowUser> findByEmail(String email); @Query("select count(n) from ShadowUser n where " + "n.owner.authtoken = ?1") public Long countByUser(String auth); @Query("select n from ShadowUser n where n.owner.authtoken = ?1 and " + "n.fullName = ?2") public List<ShadowUser> findByFullName(String auth, String fullName); } ShadowUserRepository
  • 26. public interface ShadowUserRepository extends CrudRepository<ShadowUser, Long> { @Query("select n from ShadowUser n where n.owner.authtoken = ?1") public List<ShadowUser> findShadowUsers(String auth); @Query("select n from ShadowUser n where n.phone = ?1 or " + "n.secondaryPhone = ?1") public List<ShadowUser> findByPhone(String phone); @Query("select n from ShadowUser n where n.email = ?1") public List<ShadowUser> findByEmail(String email); @Query("select count(n) from ShadowUser n where " + "n.owner.authtoken = ?1") public Long countByUser(String auth); @Query("select n from ShadowUser n where n.owner.authtoken = ?1 and " + "n.fullName = ?2") public List<ShadowUser> findByFullName(String auth, String fullName); } ShadowUserRepository