SlideShare a Scribd company logo
1 of 16
Download to read offline
Creating a WhatsApp Clone - Part XII
@Entity
@Indexed
public class ChatGroup {
@Id
private String id;
@Field
private String name;
@Field
private String tagline;
@Temporal(TemporalType.DATE)
private Date creationDate;
@ManyToOne
private Media avatar;
ChatGroup
@Entity
@Indexed
public class ChatGroup {
@Id
private String id;
@Field
private String name;
@Field
private String tagline;
@Temporal(TemporalType.DATE)
private Date creationDate;
@ManyToOne
private Media avatar;
ChatGroup
@Temporal(TemporalType.DATE)
private Date creationDate;
@ManyToOne
private Media avatar;
@ManyToOne
private User createdBy;
@OneToMany
@OrderBy("name ASC")
private Set<User> admins;
@OneToMany
@OrderBy("name ASC")
private Set<User> members;
public ChatGroup() {
id = UUID.randomUUID().toString();
}
ChatGroup
@Temporal(TemporalType.DATE)
private Date creationDate;
@ManyToOne
private Media avatar;
@ManyToOne
private User createdBy;
@OneToMany
@OrderBy("name ASC")
private Set<User> admins;
@OneToMany
@OrderBy("name ASC")
private Set<User> members;
public ChatGroup() {
id = UUID.randomUUID().toString();
}
ChatGroup
package com.codename1.whatsapp.server.entities;
import org.springframework.data.repository.CrudRepository;
public interface ChatGroupRepository extends
CrudRepository<ChatGroup, String> {
}
ChatGroupRepository
@Entity
@Indexed
public class ChatMessage {
@Id
private String id;
@ManyToOne
private User author;
@ManyToOne
private User sentTo;
@ManyToOne
private ChatGroup sentToGroup;
@Temporal(TemporalType.TIMESTAMP)
private Date messageTime;
private String body;
ChatMessage
@Entity
@Indexed
public class ChatMessage {
@Id
private String id;
@ManyToOne
private User author;
@ManyToOne
private User sentTo;
@ManyToOne
private ChatGroup sentToGroup;
@Temporal(TemporalType.TIMESTAMP)
private Date messageTime;
private String body;
ChatMessage
@Entity
@Indexed
public class ChatMessage {
@Id
private String id;
@ManyToOne
private User author;
@ManyToOne
private User sentTo;
@ManyToOne
private ChatGroup sentToGroup;
@Temporal(TemporalType.TIMESTAMP)
private Date messageTime;
private String body;
ChatGroupRepository
private User author;
@ManyToOne
private User sentTo;
@ManyToOne
private ChatGroup sentToGroup;
@Temporal(TemporalType.TIMESTAMP)
private Date messageTime;
private String body;
private boolean ack;
@OneToMany
@OrderBy("date ASC")
private Set<Media> attachments;
public ChatMessage() {
id = UUID.randomUUID().toString();
}
ChatMessage
private User author;
@ManyToOne
private User sentTo;
@ManyToOne
private ChatGroup sentToGroup;
@Temporal(TemporalType.TIMESTAMP)
private Date messageTime;
private String body;
private boolean ack;
@OneToMany
@OrderBy("date ASC")
private Set<Media> attachments;
public ChatMessage() {
id = UUID.randomUUID().toString();
}
ChatMessage
private User author;
@ManyToOne
private User sentTo;
@ManyToOne
private ChatGroup sentToGroup;
@Temporal(TemporalType.TIMESTAMP)
private Date messageTime;
private String body;
private boolean ack;
@OneToMany
@OrderBy("date ASC")
private Set<Media> attachments;
public ChatMessage() {
id = UUID.randomUUID().toString();
}
ChatMessage
private User author;
@ManyToOne
private User sentTo;
@ManyToOne
private ChatGroup sentToGroup;
@Temporal(TemporalType.TIMESTAMP)
private Date messageTime;
private String body;
private boolean ack;
@OneToMany
@OrderBy("date ASC")
private Set<Media> attachments;
public ChatMessage() {
id = UUID.randomUUID().toString();
}
ChatMessage
@OrderBy("date ASC")
private Set<Media> attachments;
public ChatMessage() {
id = UUID.randomUUID().toString();
}
public MessageDAO getDAO() {
String[] a;
if(attachments != null && !attachments.isEmpty()) {
a = new String[attachments.size()];
Iterator<Media> i = attachments.iterator();
for(int iter = 0 ; iter < a.length ; iter++) {
a[iter] = i.next().getId();
}
} else {
a = new String[0];
}
return new MessageDAO(id, author.getId(),
sentTo != null ? sentTo.getId() : sentToGroup.getId(),
messageTime, body, a);
}
ChatMessage
package com.codename1.whatsapp.server.entities;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
public interface ChatMessageRepository extends
CrudRepository<ChatMessage, String> {
@Query("select n from ChatMessage n where n.ack = false and "
+ "n.sentTo.id = ?1 order by messageTime asc")
public List<ChatMessage> findByUnAcked(String sentTo);
}
ChatMessageRepository
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
public class MessageDAO {
private String id;
private String authorId;
private String sentTo;
@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss.SSS")
private Date time;
private String body;
private String[] attachments;
public MessageDAO() {
}
public MessageDAO(String id, String authorId, String sentTo,
Date time, String body, String[] attachments) {
this.id = id;
this.authorId = authorId;
this.sentTo = sentTo;
this.time = time;
MessageDAO

More Related Content

Similar to Creating a Whatsapp Clone - Part XII.pdf

Creating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdfCreating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfShaiAlmog1
 
Creating an Uber Clone - Part XI.pdf
Creating an Uber Clone - Part XI.pdfCreating an Uber Clone - Part XI.pdf
Creating an Uber Clone - Part XI.pdfShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XVIII - Transcript.pdf
Creating a Facebook Clone - Part XVIII - Transcript.pdfCreating a Facebook Clone - Part XVIII - Transcript.pdf
Creating a Facebook Clone - Part XVIII - Transcript.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XXIII.pdf
Creating a Facebook Clone - Part XXIII.pdfCreating a Facebook Clone - Part XXIII.pdf
Creating a Facebook Clone - Part XXIII.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part III.pdf
Creating a Whatsapp Clone - Part III.pdfCreating a Whatsapp Clone - Part III.pdf
Creating a Whatsapp Clone - Part III.pdfShaiAlmog1
 
Beyond Logging: Using MongoDB to Power a Private Social Network (Oh, and log ...
Beyond Logging: Using MongoDB to Power a Private Social Network (Oh, and log ...Beyond Logging: Using MongoDB to Power a Private Social Network (Oh, and log ...
Beyond Logging: Using MongoDB to Power a Private Social Network (Oh, and log ...justinjenkins
 
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdfCreating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XXIV.pdf
Creating a Facebook Clone - Part XXIV.pdfCreating a Facebook Clone - Part XXIV.pdf
Creating a Facebook Clone - Part XXIV.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdfCreating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XVII.pdf
Creating a Facebook Clone - Part XVII.pdfCreating a Facebook Clone - Part XVII.pdf
Creating a Facebook Clone - Part XVII.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part XIII.pdf
Creating a Whatsapp Clone - Part XIII.pdfCreating a Whatsapp Clone - Part XIII.pdf
Creating a Whatsapp Clone - Part XIII.pdfShaiAlmog1
 
Creating an Uber Clone - Part XII.pdf
Creating an Uber Clone - Part XII.pdfCreating an Uber Clone - Part XII.pdf
Creating an Uber Clone - Part XII.pdfShaiAlmog1
 
Overview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdfOverview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdfinfo961251
 
Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6Moaid Hathot
 

Similar to Creating a Whatsapp Clone - Part XII.pdf (20)

Creating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdfCreating a Whatsapp Clone - Part XI - Transcript.pdf
Creating a Whatsapp Clone - Part XI - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Creating an Uber Clone - Part XI.pdf
Creating an Uber Clone - Part XI.pdfCreating an Uber Clone - Part XI.pdf
Creating an Uber Clone - Part XI.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
Creating a Facebook Clone - Part XVIII - Transcript.pdf
Creating a Facebook Clone - Part XVIII - Transcript.pdfCreating a Facebook Clone - Part XVIII - Transcript.pdf
Creating a Facebook Clone - Part XVIII - Transcript.pdf
 
Creating a Facebook Clone - Part XXIII.pdf
Creating a Facebook Clone - Part XXIII.pdfCreating a Facebook Clone - Part XXIII.pdf
Creating a Facebook Clone - Part XXIII.pdf
 
Creating a Whatsapp Clone - Part III.pdf
Creating a Whatsapp Clone - Part III.pdfCreating a Whatsapp Clone - Part III.pdf
Creating a Whatsapp Clone - Part III.pdf
 
Beyond Logging: Using MongoDB to Power a Private Social Network (Oh, and log ...
Beyond Logging: Using MongoDB to Power a Private Social Network (Oh, and log ...Beyond Logging: Using MongoDB to Power a Private Social Network (Oh, and log ...
Beyond Logging: Using MongoDB to Power a Private Social Network (Oh, and log ...
 
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdfCreating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
 
Creating a Facebook Clone - Part XXIV.pdf
Creating a Facebook Clone - Part XXIV.pdfCreating a Facebook Clone - Part XXIV.pdf
Creating a Facebook Clone - Part XXIV.pdf
 
Creating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdfCreating a Facebook Clone - Part XXXI - Transcript.pdf
Creating a Facebook Clone - Part XXXI - Transcript.pdf
 
Android
AndroidAndroid
Android
 
Creating a Facebook Clone - Part XVII.pdf
Creating a Facebook Clone - Part XVII.pdfCreating a Facebook Clone - Part XVII.pdf
Creating a Facebook Clone - Part XVII.pdf
 
Creating a Whatsapp Clone - Part XIII.pdf
Creating a Whatsapp Clone - Part XIII.pdfCreating a Whatsapp Clone - Part XIII.pdf
Creating a Whatsapp Clone - Part XIII.pdf
 
Dev Day Andreas Roth.pdf
Dev Day Andreas Roth.pdfDev Day Andreas Roth.pdf
Dev Day Andreas Roth.pdf
 
Creating an Uber Clone - Part XII.pdf
Creating an Uber Clone - Part XII.pdfCreating an Uber Clone - Part XII.pdf
Creating an Uber Clone - Part XII.pdf
 
Overview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdfOverview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdf
 
Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6
 
Architecure components by Paulina Szklarska
Architecure components by Paulina SzklarskaArchitecure components by Paulina Szklarska
Architecure components by Paulina Szklarska
 

More from ShaiAlmog1

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

More from ShaiAlmog1 (20)

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

Recently uploaded

PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfUK Journal
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPTiSEO AI
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 

Recently uploaded (20)

PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 

Creating a Whatsapp Clone - Part XII.pdf

  • 1. Creating a WhatsApp Clone - Part XII
  • 2. @Entity @Indexed public class ChatGroup { @Id private String id; @Field private String name; @Field private String tagline; @Temporal(TemporalType.DATE) private Date creationDate; @ManyToOne private Media avatar; ChatGroup
  • 3. @Entity @Indexed public class ChatGroup { @Id private String id; @Field private String name; @Field private String tagline; @Temporal(TemporalType.DATE) private Date creationDate; @ManyToOne private Media avatar; ChatGroup
  • 4. @Temporal(TemporalType.DATE) private Date creationDate; @ManyToOne private Media avatar; @ManyToOne private User createdBy; @OneToMany @OrderBy("name ASC") private Set<User> admins; @OneToMany @OrderBy("name ASC") private Set<User> members; public ChatGroup() { id = UUID.randomUUID().toString(); } ChatGroup
  • 5. @Temporal(TemporalType.DATE) private Date creationDate; @ManyToOne private Media avatar; @ManyToOne private User createdBy; @OneToMany @OrderBy("name ASC") private Set<User> admins; @OneToMany @OrderBy("name ASC") private Set<User> members; public ChatGroup() { id = UUID.randomUUID().toString(); } ChatGroup
  • 6. package com.codename1.whatsapp.server.entities; import org.springframework.data.repository.CrudRepository; public interface ChatGroupRepository extends CrudRepository<ChatGroup, String> { } ChatGroupRepository
  • 7. @Entity @Indexed public class ChatMessage { @Id private String id; @ManyToOne private User author; @ManyToOne private User sentTo; @ManyToOne private ChatGroup sentToGroup; @Temporal(TemporalType.TIMESTAMP) private Date messageTime; private String body; ChatMessage
  • 8. @Entity @Indexed public class ChatMessage { @Id private String id; @ManyToOne private User author; @ManyToOne private User sentTo; @ManyToOne private ChatGroup sentToGroup; @Temporal(TemporalType.TIMESTAMP) private Date messageTime; private String body; ChatMessage
  • 9. @Entity @Indexed public class ChatMessage { @Id private String id; @ManyToOne private User author; @ManyToOne private User sentTo; @ManyToOne private ChatGroup sentToGroup; @Temporal(TemporalType.TIMESTAMP) private Date messageTime; private String body; ChatGroupRepository
  • 10. private User author; @ManyToOne private User sentTo; @ManyToOne private ChatGroup sentToGroup; @Temporal(TemporalType.TIMESTAMP) private Date messageTime; private String body; private boolean ack; @OneToMany @OrderBy("date ASC") private Set<Media> attachments; public ChatMessage() { id = UUID.randomUUID().toString(); } ChatMessage
  • 11. private User author; @ManyToOne private User sentTo; @ManyToOne private ChatGroup sentToGroup; @Temporal(TemporalType.TIMESTAMP) private Date messageTime; private String body; private boolean ack; @OneToMany @OrderBy("date ASC") private Set<Media> attachments; public ChatMessage() { id = UUID.randomUUID().toString(); } ChatMessage
  • 12. private User author; @ManyToOne private User sentTo; @ManyToOne private ChatGroup sentToGroup; @Temporal(TemporalType.TIMESTAMP) private Date messageTime; private String body; private boolean ack; @OneToMany @OrderBy("date ASC") private Set<Media> attachments; public ChatMessage() { id = UUID.randomUUID().toString(); } ChatMessage
  • 13. private User author; @ManyToOne private User sentTo; @ManyToOne private ChatGroup sentToGroup; @Temporal(TemporalType.TIMESTAMP) private Date messageTime; private String body; private boolean ack; @OneToMany @OrderBy("date ASC") private Set<Media> attachments; public ChatMessage() { id = UUID.randomUUID().toString(); } ChatMessage
  • 14. @OrderBy("date ASC") private Set<Media> attachments; public ChatMessage() { id = UUID.randomUUID().toString(); } public MessageDAO getDAO() { String[] a; if(attachments != null && !attachments.isEmpty()) { a = new String[attachments.size()]; Iterator<Media> i = attachments.iterator(); for(int iter = 0 ; iter < a.length ; iter++) { a[iter] = i.next().getId(); } } else { a = new String[0]; } return new MessageDAO(id, author.getId(), sentTo != null ? sentTo.getId() : sentToGroup.getId(), messageTime, body, a); } ChatMessage
  • 15. package com.codename1.whatsapp.server.entities; import java.util.List; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; public interface ChatMessageRepository extends CrudRepository<ChatMessage, String> { @Query("select n from ChatMessage n where n.ack = false and " + "n.sentTo.id = ?1 order by messageTime asc") public List<ChatMessage> findByUnAcked(String sentTo); } ChatMessageRepository
  • 16. import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; public class MessageDAO { private String id; private String authorId; private String sentTo; @JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss.SSS") private Date time; private String body; private String[] attachments; public MessageDAO() { } public MessageDAO(String id, String authorId, String sentTo, Date time, String body, String[] attachments) { this.id = id; this.authorId = authorId; this.sentTo = sentTo; this.time = time; MessageDAO