Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented ERD Data Model Entities #57

Open
wants to merge 1 commit into
base: flow
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/main/java/com/wellsfargo/counselor/entity/Advisor.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.wellsfargo.counselor.entity;


import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import java.util.Set;

@Entity
public class Advisor {
Expand All @@ -28,6 +30,9 @@ public class Advisor {
@Column(nullable = false)
private String email;

@OneToMany(mappedBy = "advisor")
private Set<Client> clients;

protected Advisor() {

}
Expand Down Expand Up @@ -83,4 +88,12 @@ public String getEmail() {
public void setEmail(String email) {
this.email = email;
}

public Set<Client> getClients() {
return clients;
}

public void setClients(Set<Client> clients) {
this.clients = clients;
}
}
115 changes: 115 additions & 0 deletions src/main/java/com/wellsfargo/counselor/entity/Client.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.wellsfargo.counselor.entity;


import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Column;
import jakarta.persistence.OneToOne;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.CascadeType;

@Entity
public class Client {

@Id
@GeneratedValue()
private long clientId;

@ManyToOne
@JoinColumn(name = "advisorId", nullable = false)
private Advisor advisor;

@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;

@OneToOne(mappedBy = "client", cascade = CascadeType.ALL)
private Portfolio portfolio;

protected Client() {

}

public Client(String firstName, String lastName, String address, String phone, String email) {
this.advisor = advisor;
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.phone = phone;
this.email = email;
}

public long getClientId() {
return clientId;
}

public Advisor getAdvisor() {
return advisor;
}

public void setAdvisor(Advisor advisor) {
this.advisor = advisor;
}

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;
}

public Portfolio getPortfolio() {
return portfolio;
}

public void setPortfolio(Portfolio portfolio) {
this.portfolio = portfolio;
}

}
68 changes: 68 additions & 0 deletions src/main/java/com/wellsfargo/counselor/entity/Portfolio.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.wellsfargo.counselor.entity;


import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Column;
import jakarta.persistence.OneToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.CascadeType;
import java.util.Set;

@Entity
public class Portfolio {

@Id
@GeneratedValue()
private long portfolioId;

@OneToOne
@JoinColumn(name = "clientId", nullable = false)
private Client client;

@Column(nullable = false)
private String portfolioName;


@OneToMany(mappedBy = "portfolio", cascade = CascadeType.ALL)
private Set<Security> securities;

protected Portfolio() {

}

public Portfolio(Client client, String portfolioName) {
this.client = client;
this.portfolioName = portfolioName;
}

public long getPortfolioId() {
return portfolioId;
}

public Client getClient() {
return client;
}

public void setClient(Client client) {
this.client = client;
}

public String getPortfolioName() {
return portfolioName;
}

public void setPortfolioName(String portfolioName) {
this.portfolioName = portfolioName;
}

public Set<Security> getSecurities() {
return securities;
}

public void setSecurities(Set<Security> securities) {
this.securities = securities;
}
}
105 changes: 105 additions & 0 deletions src/main/java/com/wellsfargo/counselor/entity/Security.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.wellsfargo.counselor.entity;


import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Column;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.util.Date;

@Entity
public class Security {

@Id
@GeneratedValue()
private long securityId;

@ManyToOne
@JoinColumn(name = "portfolioId", nullable = false)
private Portfolio portfolio;

@Column(nullable = false)
private String name;

@Column(nullable = false)
private String category;

@Column(nullable = false)
@Temporal(TemporalType.DATE)
private Date purchaseDate;

@Column(nullable = false)
private String purchasePrice;

@Column(nullable = false)
private int quantity;

protected Security() {

}

public Security(Portfolio portfolio, String name, String category, Date purchaseDate, String purchasePrice, int quantity) {
this.portfolio = portfolio;
this.name = name;
this.category = category;
this.purchaseDate = purchaseDate;
this.purchasePrice = purchasePrice;
this.quantity = quantity;
}

public Long getSecurityId() {
return securityId;
}

public Portfolio getPortfolio() {
return portfolio;
}

public void setPortfolio(Portfolio portfolio) {
this.portfolio = portfolio;
}

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 String getPurchasePrice() {
return purchasePrice;
}

public void setPurchasePrice(String purchasePrice) {
this.purchasePrice = purchasePrice;
}

public int getQuantity() {
return quantity;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}
}