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

Added 3 classes and adjusted code to fit data model specifications. #72

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
85 changes: 45 additions & 40 deletions src/main/java/com/wellsfargo/counselor/entity/Advisor.java
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
package com.wellsfargo.counselor.entity;


import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import javax.persistence.*;

@Entity
public class Advisor {
public class Client {

@Id
@GeneratedValue()
private long advisorId;
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long clientId;

@Column(nullable = false)
private String firstName;
private String name;

@Column(nullable = false)
private String lastName;
@Column(nullable = false, unique = true)
private String email;

@Column(nullable = false)
private String phoneNumber;

@Column
private String address;

@Column(nullable = false)
private String phone;
@ManyToOne
@JoinColumn(name = "advisor_id", nullable = false)
private FinancialAdvisor financialAdvisor;

@Column(nullable = false)
private String email;
@OneToOne(mappedBy = "client", cascade = CascadeType.ALL, orphanRemoval = true)
private Portfolio portfolio;

protected Advisor() {
public Client(String name, String email, String phoneNumber, String address, FinancialAdvisor financialAdvisor) {
this.name = name;
this.email = email;
this.phoneNumber = phoneNumber;
this.address = address;
this.financialAdvisor = financialAdvisor;
}

public Long getClientId() {
return clientId;
}

public Advisor(String firstName, String lastName, String address, String phone, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.phone = phone;
this.email = email;
public String getName() {
return name;
}

public Long getAdvisorId() {
return advisorId;
public void setName(String name) {
this.name = name;
}

public String getFirstName() {
return firstName;
public String getEmail() {
return email;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
public void setEmail(String email) {
this.email = email;
}

public String getLastName() {
return lastName;
public String getPhoneNumber() {
return phoneNumber;
}

public void setLastName(String lastName) {
this.lastName = lastName;
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}

public String getAddress() {
Expand All @@ -68,19 +72,20 @@ public void setAddress(String address) {
this.address = address;
}

public String getPhone() {
return phone;
public FinancialAdvisor getFinancialAdvisor() {
return financialAdvisor;
}

public void setPhone(String phone) {
this.phone = phone;
public void setFinancialAdvisor(FinancialAdvisor financialAdvisor) {
this.financialAdvisor = financialAdvisor;
}

public String getEmail() {
return email;
public Portfolio getPortfolio() {
return portfolio;
}

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

92 changes: 92 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,92 @@
package com.wellsfargo.counselor.entity;

import javax.persistence.*;

@Entity
public class Client {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long clientId;

@Column(nullable = false)
private String name;

@Column(nullable = false, unique = true)
private String email;

@Column(nullable = false)
private String phoneNumber;

@Column
private String address;

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

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

public Client(String name, String email, String phoneNumber, String address, Advisor advisor) {
this.name = name;
this.email = email;
this.phoneNumber = phoneNumber;
this.address = address;
this.advisor = advisor;
}

public Long getClientId() {
return clientId;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getPhoneNumber() {
return phoneNumber;
}

public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

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


44 changes: 44 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,44 @@
package com.wellsfargo.counselor.entity;

import javax.persistence.*;
import java.util.List;

@Entity
public class Portfolio {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long portfolioId;

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

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

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

public Long getPortfolioId() {
return portfolioId;
}

public Client getClient() {
return client;
}

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

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

public void setSecurities(List<Security> securities) {
this.securities = securities;
}
}

93 changes: 93 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,93 @@
package com.wellsfargo.counselor.entity;

import javax.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 double purchasePrice;

@Column(nullable = false)
private int quantity;

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

public Security(String name, String category, LocalDate purchaseDate, double purchasePrice, int 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 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) {
this.purchaseDate = purchaseDate;
}

public double getPurchasePrice() {
return purchasePrice;
}

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

public int getQuantity() {
return quantity;
}

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

public Portfolio getPortfolio() {
return portfolio;
}

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