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..cc9a9708 --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Client.java @@ -0,0 +1,84 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; + +@Entity +public class Client { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long ClientId; + @Column(nullable = false) + private String name; + @Column(nullable = false) + private String contact; + + + @ManyToOne + @JoinColumn(name="advisor_id", nullable = false) + private Advisor advisor; + + @OneToOne + @JoinColumn(name="portfolio_id", nullable = false) + private Portfolio portfolio; + + protected Client(){ + + } + + public Client(String name,String contact,Advisor advisor,Portfolio portfolio){ + this.name = name; + this.contact = contact; + this.advisor = advisor; + this.portfolio = portfolio; + + } + + public Advisor getAdvisor() { + return advisor; + } + + public void setAdvisor(Advisor advisor) { + this.advisor = advisor; + } + + public Portfolio getPortfolio() { + return portfolio; + } + + public void setPortfolio(Portfolio portfolio) { + this.portfolio = portfolio; + } + + public Advisor getAdvisorId() { + return advisor; + } + + public void setAdvisorId(Advisor advisor) { + this.advisor = advisor; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public long getClientId() { + return ClientId; + } + + public void setClientId(long clientId) { + ClientId = clientId; + } +} 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..80f5d2dd --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java @@ -0,0 +1,57 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; + +import java.util.Set; + + +@Entity +public class Portfolio { + + @Id + @GeneratedValue() + private long PortfolioId; + + @OneToOne + @JoinColumn(name="client_id", nullable = false) + private Client client; + + @OneToMany(mappedBy = "portfolio", cascade = CascadeType.ALL, orphanRemoval = true) + private Set securities; + + + protected Portfolio(){ + } + + public Portfolio(Set securities) { + this.securities = securities; + } + + public Portfolio(Client client) { + this.client = client; + } + + public long getPortfolioId() { + return PortfolioId; + } + + public Set getSecurities() { + return securities; + } + + public void setSecurities(Set securities) { + this.securities = securities; + } + + public Client getClient() { + return client; + } + + public void setClient(Client client) { + this.client = client; + } + + public void setPortfolioId(long portfolioId) { + PortfolioId = portfolioId; + } +} 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..473f2ed4 --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Security.java @@ -0,0 +1,98 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; + +import java.time.LocalDate; + +@Entity +public class Security { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long securityId; + @Column(nullable = false) + private String name; + @Column(nullable = false) + private String category; + @Column(nullable = false) + private LocalDate PurchaseDate; + @Column(nullable = false) + private Integer PurchasePrice; + @Column(nullable = false) + private Integer Quantity; + + @ManyToOne + @JoinColumn(name = "portfolio_id", nullable = false) + private Portfolio portfolio; + + public Security(String name, String category, LocalDate purchaseDate, Integer purchasePrice, Integer quantity, Portfolio portfolio) { + this.name = name; + this.category = category; + this.PurchaseDate = purchaseDate; + this.PurchasePrice = purchasePrice; + this.Quantity = quantity; + this.portfolio = portfolio; + } + + public long getSecurityId() { + return securityId; + } + + public void setSecurityId(long securityId) { + this.securityId = securityId; + } + + 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 LocalDate getPurchaseDate() { + return PurchaseDate; + } + + public void setPurchaseDate(LocalDate purchaseDate) { + PurchaseDate = purchaseDate; + } + + public Integer getPurchasePrice() { + return PurchasePrice; + } + + public void setPurchasePrice(Integer purchasePrice) { + PurchasePrice = purchasePrice; + } + + public Integer getQuantity() { + return Quantity; + } + + public void setQuantity(Integer quantity) { + Quantity = quantity; + } + + public Portfolio getPortfolio() { + return portfolio; + } + + public void setPortfolio(Portfolio portfolio) { + this.portfolio = portfolio; + } + + protected Security(){ + + } + + +}