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

Flow #74

Open
wants to merge 1 commit into
base: flow
Choose a base branch
from
Open

Flow #74

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

import jakarta.persistence.*;

@Entity
public class Client {

@Id
@GeneratedValue
private long clientId;

@Column(nullable = false)
private String name;

@Column(nullable = false)
private String contactInfo;

// Foreign key reference to Advisor
@ManyToOne
@JoinColumn(name = "advisor_id", nullable = false)
private Advisor advisor;

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

protected Client() {}

public Client(String name, String contactInfo, Advisor advisor) {
this.name = name;
this.contactInfo = contactInfo;
this.advisor = advisor;
}

// Getters and Setters
public long getClientId() { return clientId; }

public String getName() { return name; }

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

public String getContactInfo() { return contactInfo; }

public void setContactInfo(String contactInfo) { this.contactInfo = contactInfo; }

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

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

@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)
private List<Security> securities;

protected Portfolio() {}

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

// Getters and Setters
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; }
}
69 changes: 69 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,69 @@
package com.wellsfargo.counselor.entity;

import jakarta.persistence.*;
import java.time.LocalDate;

@Entity
public class Security {

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

protected Security() {}

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

// Getters and Setters
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; }
}