From c0a8a5d3c0bc48baae700af8b998f2ca07af0859 Mon Sep 17 00:00:00 2001 From: harshavardhan Date: Sat, 6 Jul 2024 00:52:33 -0500 Subject: [PATCH 1/2] Using JPA created classes for each Entity in data model --- .../wellsfargo/counselor/entity/Client.java | 90 ++++++++++++++++++ .../counselor/entity/Portfolio.java | 45 +++++++++ .../wellsfargo/counselor/entity/Security.java | 93 +++++++++++++++++++ 3 files changed, 228 insertions(+) create mode 100644 src/main/java/com/wellsfargo/counselor/entity/Client.java create mode 100644 src/main/java/com/wellsfargo/counselor/entity/Portfolio.java create mode 100644 src/main/java/com/wellsfargo/counselor/entity/Security.java diff --git a/src/main/java/com/wellsfargo/counselor/entity/Client.java b/src/main/java/com/wellsfargo/counselor/entity/Client.java new file mode 100644 index 00000000..838beebf --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Client.java @@ -0,0 +1,90 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; + +@Entity +public class Client { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long clientId; + + @ManyToOne + private Advisor advisorId; + + @Column(nullable = false) + private String firstName; + + @Column(nullable = false) + private String lastName; + + @Column(nullable = false) + private String address; + + @Column(nullable = false) + private String phone; + + + @Column(nullable = false) + private String email; + + public Client() { + } + + public Client(Advisor advisorId, String firstName, String lastName, String address, String phone, String email) { + this.advisorId = advisorId; + this.firstName = firstName; + this.lastName = lastName; + this.address = address; + this.phone = phone; + this.email = email; + } + + public Advisor getAdvisorId() { + return advisorId; + } + + public void setAdvisorId(Advisor advisorId) { + this.advisorId = advisorId; + } + + 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 getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + 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; + } +} diff --git a/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java b/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java new file mode 100644 index 00000000..851af76d --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java @@ -0,0 +1,45 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; + +import java.util.Date; + +@Entity +public class Portfolio { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long portfolioId; + + @ManyToOne + private Client clientId; + + @Column(nullable = false) + private Date creationDate; + + + public Portfolio() { + + } + + public Portfolio(Client clientId, Date creationDate) { + this.clientId = clientId; + this.creationDate = creationDate; + } + + public Client getClientId() { + return clientId; + } + + public void setClientId(Client clientId) { + this.clientId = clientId; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } +} diff --git a/src/main/java/com/wellsfargo/counselor/entity/Security.java b/src/main/java/com/wellsfargo/counselor/entity/Security.java new file mode 100644 index 00000000..7de40d0b --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Security.java @@ -0,0 +1,93 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; + +import java.util.Date; + +@Entity +public class Security { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long securityId; + + @ManyToOne + private Portfolio portfolioId; + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private String category; + + @Column(nullable = false) + private double purchasePrice; + + @Column(nullable = false) + private Date purchaseDate; + + @Column(nullable = false) + private double quantity; + + + public Security(Portfolio portfolioId, String name, String category, double purchasePrice, Date purchaseDate, double quantity) { + this.portfolioId = portfolioId; + this.name = name; + this.category = category; + this.purchasePrice = purchasePrice; + this.purchaseDate = purchaseDate; + this.quantity = quantity; + } + + public Security() { + } + + + public Portfolio getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(Portfolio portfolioId) { + this.portfolioId = portfolioId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Date getPurchaseDate() { + return purchaseDate; + } + + public void setPurchaseDate(Date purchaseDate) { + this.purchaseDate = purchaseDate; + } + + public double getPurchasePrice() { + return purchasePrice; + } + + public void setPurchasePrice(double purchasePrice) { + this.purchasePrice = purchasePrice; + } + + public double getQuantity() { + return quantity; + } + + public void setQuantity(double quantity) { + this.quantity = quantity; + } +} From bc1b4a04e4ebd19cf039b82c92b347996be8e74f Mon Sep 17 00:00:00 2001 From: harshavardhan Date: Sat, 6 Jul 2024 00:57:18 -0500 Subject: [PATCH 2/2] Using JPA created classes for each Entity in data model --- src/main/java/com/wellsfargo/counselor/entity/Client.java | 1 + src/main/java/com/wellsfargo/counselor/entity/Portfolio.java | 1 - src/main/java/com/wellsfargo/counselor/entity/Security.java | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/wellsfargo/counselor/entity/Client.java b/src/main/java/com/wellsfargo/counselor/entity/Client.java index 838beebf..cede67e6 100644 --- a/src/main/java/com/wellsfargo/counselor/entity/Client.java +++ b/src/main/java/com/wellsfargo/counselor/entity/Client.java @@ -87,4 +87,5 @@ public String getEmail() { public void setEmail(String email) { this.email = email; } + } diff --git a/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java b/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java index 851af76d..ad6b9539 100644 --- a/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java +++ b/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java @@ -17,7 +17,6 @@ public class Portfolio { @Column(nullable = false) private Date creationDate; - public Portfolio() { } diff --git a/src/main/java/com/wellsfargo/counselor/entity/Security.java b/src/main/java/com/wellsfargo/counselor/entity/Security.java index 7de40d0b..872f5810 100644 --- a/src/main/java/com/wellsfargo/counselor/entity/Security.java +++ b/src/main/java/com/wellsfargo/counselor/entity/Security.java @@ -59,6 +59,7 @@ public void setName(String name) { this.name = name; } + public String getCategory() { return category; }