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

all the entities added #73

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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down
65 changes: 42 additions & 23 deletions src/main/java/com/wellsfargo/counselor/entity/Advisor.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.wellsfargo.counselor.entity;


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

import java.lang.reflect.GenericArrayType;
import java.util.List;

@Entity
public class Advisor {

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

@Column(nullable = false)
Expand All @@ -25,62 +25,81 @@ public class Advisor {
@Column(nullable = false)
private String phone;


@Column(nullable = false)
private String email;

@OneToMany(mappedBy = "advisor", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Client> clients;


protected Advisor() {

}

public Advisor(String firstName, String lastName, String address, String phone, String email) {
public Advisor(long advisorId, String firstName, String lastName, String address, String phone, String email, List<Client> clients) {
this.advisorId = advisorId;
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.phone = phone;
this.email = email;
this.clients = clients;
}

public Long getAdvisorId() {
public long getAdvisorId() {
return advisorId;
}

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 List<Client> getClients() {
return clients;
}

public void setAdvisorId(long advisorId) {
this.advisorId = advisorId;
}

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

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

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

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

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

public void setClients(List<Client> clients) {
this.clients = clients;
}
}
112 changes: 112 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,112 @@
package com.wellsfargo.counselor.entity;

import jakarta.persistence.*;
import org.hibernate.engine.internal.Cascade;

@Entity
public class Client {

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


@ManyToOne
@JoinColumn(name = "advisor_id", 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 = "protofolio", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Protfolio protfolioId;

public Client() {
}

public Client(long clientId, Advisor advisor, String firstName, String lastName, String address, String phone, String email, Protfolio protfolioId) {
this.clientId = clientId;
this.advisor = advisor;
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.phone = phone;
this.email = email;
this.protfolioId = protfolioId;
}

public long getClientId() {
return clientId;
}

public Advisor getAdvisor() {
return advisor;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public String getAddress() {
return address;
}

public String getPhone() {
return phone;
}

public String getEmail() {
return email;
}

public Protfolio getProtfolioId() {
return protfolioId;
}

public void setClientId(long clientId) {
this.clientId = clientId;
}

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

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

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

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

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

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

public void setProtfolioId(Protfolio protfolioId) {
this.protfolioId = protfolioId;
}
}
64 changes: 64 additions & 0 deletions src/main/java/com/wellsfargo/counselor/entity/Protfolio.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.wellsfargo.counselor.entity;

import jakarta.persistence.*;

import java.util.Date;
import java.util.List;

@Entity
public class Protfolio {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int protfolioId;

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

@Column(nullable = false)
private Date creationDate;
@OneToMany(mappedBy="security",cascade = CascadeType.ALL,fetch = FetchType.LAZY)
private List<Security> securities;

public Protfolio() {
}

public Protfolio(int protfolioId, Client clientId, Date creationDate, List<Security> securities) {
this.protfolioId = protfolioId;
this.clientId = clientId;
this.creationDate = creationDate;
this.securities = securities;
}

public int getProtfolioId() {
return protfolioId;
}

public Client getClientId() {
return clientId;
}

public Date getCreationDate() {
return creationDate;
}

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

public void setProtfolioId(int protfolioId) {
this.protfolioId = protfolioId;
}

public void setClientId(Client clientId) {
this.clientId = clientId;
}

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

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