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

task 2 of creating entities #78

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
18 changes: 16 additions & 2 deletions 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.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.CascadeType;
import java.util.*;

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

@OneToMany(mappedBy = "advisor")
private List<ClientR> clients;

protected Advisor() {

}

public Advisor(String firstName, String lastName, String address, String phone, String email) {
public Advisor(String firstName, String lastName, String address, String phone, String email,
List<ClientR> clients) {
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
Expand Down Expand Up @@ -83,4 +89,12 @@ public String getEmail() {
public void setEmail(String email) {
this.email = email;
}

public List<ClientR> getClients() {
return clients;
}

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

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Column;
import java.util.*;

@Entity
public class ClientR {

@Id
@GeneratedValue()
private long clientId;

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

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

@OneToMany
private List<Portfolio> portfolios;

protected ClientR() {

}

public ClientR(String firstName, String lastName, String address, String phone, String email, Advisor advisor,
List<Portfolio> portfolios) {
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.phone = phone;
this.email = email;
this.advisor = advisor;
this.portfolios = portfolios;
}

public Long getClientId() {
return clientId;
}

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 Advisor getAdvisor() {
return advisor;
}

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

public List<Portfolio> getPortfolios() {
return portfolios;
}

public void setPortfolios(List<Portfolio> portfolios) {
this.portfolios = portfolios;
}
}
66 changes: 66 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,66 @@
package com.wellsfargo.counselor.entity;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Column;
import jakarta.persistence.OneToMany;
import java.time.LocalDateTime;
import java.util.*;

@Entity
public class Portfolio {

@Id
@GeneratedValue()
private long portfolioId;

@Column(nullable = false)
private LocalDateTime creationDate;

@ManyToOne
@JoinColumn(name = "clientId")
private ClientR client;

@OneToMany
private List<Security> securities;

public Portfolio(long portfolioId, LocalDateTime creationDate, ClientR client, List<Security> securities) {
this.portfolioId = portfolioId;
this.creationDate = creationDate;
this.client = client;
this.securities = securities;
}

public Long getPortfolioId() {
return portfolioId;
}

public LocalDateTime getCreationDate() {
return creationDate;
}

public void setCreationDate(LocalDateTime creationDate) {
this.creationDate = creationDate;
}

public ClientR getClient() {
return client;
}

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

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

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

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

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

import java.time.LocalDateTime;

import jakarta.persistence.Column;

@Entity
public class Security {

@Id
@GeneratedValue()
private long securityId;
@Column(nullable = false)
private String name;
@Column
private String category;
@Column
private String purchasePrice;
@Column
private LocalDateTime purchaseDate;
@Column
private long quantity;
@ManyToOne
@JoinColumn(name = "portfolioId")
private Portfolio portfolio;

protected Security() {
}

// Constructor with parameters
public Security(String name, String category, String purchasePrice, LocalDateTime purchaseDate, long quantity,
Portfolio portfolio) {
this.name = name;
this.category = category;
this.purchasePrice = purchasePrice;
this.purchaseDate = purchaseDate;
this.quantity = quantity;
this.portfolio = portfolio;
}

// Getters and Setters

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

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

public LocalDateTime getPurchaseDate() {
return purchaseDate;
}

public void setPurchaseDate(LocalDateTime purchaseDate) {
this.purchaseDate = purchaseDate;
}

public long getQuantity() {
return quantity;
}

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

public Portfolio getPortfolio() {
return portfolio;
}

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

}