-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hoangtle
committed
Nov 3, 2016
1 parent
d63c992
commit c766e02
Showing
7 changed files
with
491 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.trhoanglee.expense.domain; | ||
|
||
import java.util.Date; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
import javax.persistence.Temporal; | ||
import javax.persistence.TemporalType; | ||
|
||
@Entity | ||
@Table(name = "EXPENSES") | ||
public class Expense { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "ID") | ||
private Long id; | ||
|
||
@Column(name = "DESCRIPTION") | ||
private String description; | ||
|
||
@Column(name = "TOTAL") | ||
private Long total; | ||
|
||
@Temporal(TemporalType.DATE) | ||
@Column(name = "EXPENSE_DATE") | ||
private Date date; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "TEAM_ID") | ||
private Team team; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public Long getTotal() { | ||
return total; | ||
} | ||
|
||
public void setTotal(Long total) { | ||
this.total = total; | ||
} | ||
|
||
public Team getTeam() { | ||
return team; | ||
} | ||
|
||
public void setTeam(Team team) { | ||
this.team = team; | ||
} | ||
|
||
public Date getDate() { | ||
return date; | ||
} | ||
|
||
public void setDate(Date date) { | ||
this.date = date; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.trhoanglee.expense.domain; | ||
|
||
import java.util.Date; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
import javax.persistence.Temporal; | ||
import javax.persistence.TemporalType; | ||
|
||
@Entity | ||
@Table(name = "FUNDS") | ||
public class Fund { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "ID") | ||
private Long id; | ||
|
||
@Column(name = "COMMENT") | ||
private String comment; | ||
|
||
@Column(name = "TOTAL") | ||
private Long total; | ||
|
||
@Temporal(TemporalType.DATE) | ||
@Column(name = "FUND_DATE") | ||
private Date date; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "TEAM_MEMBER_ID") | ||
private TeamMember teamMember; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Date getDate() { | ||
return date; | ||
} | ||
|
||
public void setDate(Date date) { | ||
this.date = date; | ||
} | ||
|
||
public TeamMember getTeamMember() { | ||
return teamMember; | ||
} | ||
|
||
public void setTeamMember(TeamMember teamMember) { | ||
this.teamMember = teamMember; | ||
} | ||
|
||
public Long getTotal() { | ||
return total; | ||
} | ||
|
||
public void setTotal(Long total) { | ||
this.total = total; | ||
} | ||
|
||
public String getComment() { | ||
return comment; | ||
} | ||
|
||
public void setComment(String comment) { | ||
this.comment = comment; | ||
} | ||
|
||
} |
104 changes: 104 additions & 0 deletions
104
src/main/java/com/trhoanglee/expense/domain/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.trhoanglee.expense.domain; | ||
|
||
import java.util.Date; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Column; | ||
import javax.persistence.Embedded; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.OneToMany; | ||
import javax.persistence.Table; | ||
import javax.persistence.Temporal; | ||
import javax.persistence.TemporalType; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
@Entity | ||
@Table(name = "MEMBERS") | ||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) | ||
public class Member { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "ID") | ||
private Long id; | ||
|
||
@Embedded | ||
private Name name; | ||
|
||
@Column(name = "EMAIL") | ||
private String email; | ||
|
||
@Column(name = "MOBILE") | ||
private String mobile; | ||
|
||
@Temporal(TemporalType.DATE) | ||
@Column(name = "DOB") | ||
private Date dob; | ||
|
||
@OneToMany(mappedBy = "team", cascade = CascadeType.ALL) | ||
private Set<TeamMember> joinedTeams = new HashSet<>(); | ||
|
||
@OneToMany(mappedBy = "manager", cascade = CascadeType.ALL) | ||
private Set<Team> managedTeams = new HashSet<>(); | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Name getName() { | ||
return name; | ||
} | ||
|
||
public void setName(Name name) { | ||
this.name = name; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public String getMobile() { | ||
return mobile; | ||
} | ||
|
||
public void setMobile(String mobile) { | ||
this.mobile = mobile; | ||
} | ||
|
||
public Date getDob() { | ||
return dob; | ||
} | ||
|
||
public void setDob(Date dob) { | ||
this.dob = dob; | ||
} | ||
|
||
public Set<TeamMember> getJoinedTeams() { | ||
return joinedTeams; | ||
} | ||
|
||
public void setJoinedTeams(Set<TeamMember> joinedTeams) { | ||
this.joinedTeams = joinedTeams; | ||
} | ||
|
||
public Set<Team> getManagedTeams() { | ||
return managedTeams; | ||
} | ||
|
||
public void setManagedTeams(Set<Team> managedTeams) { | ||
this.managedTeams = managedTeams; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.trhoanglee.expense.domain; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
|
||
import org.hibernate.annotations.Formula; | ||
|
||
@Embeddable | ||
public class Name { | ||
|
||
@Column(name = "FIRST_NAME") | ||
private String firstName; | ||
|
||
@Column(name = "MIDDLE_NAME") | ||
private String middleName; | ||
|
||
@Column(name = "LAST_NAME") | ||
private String lastName; | ||
|
||
@Formula("CONCAT(FIRST_NAME, ' ', MIDDLE_NAME, ' ', LAST_NAME)") | ||
private String fullNameFML; | ||
|
||
public Name() { | ||
//this required by Hibernate default | ||
} | ||
|
||
public Name(String firstName, String middleName, String lastName) { | ||
this.firstName = firstName; | ||
this.middleName = middleName; | ||
this.lastName = lastName; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
public String getMiddleName() { | ||
return middleName; | ||
} | ||
|
||
public void setMiddleName(String middleName) { | ||
this.middleName = middleName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
|
||
public String getFullNameFML() { | ||
return fullNameFML; | ||
} | ||
|
||
public void setFullNameFML(String fullNameFML) { | ||
this.fullNameFML = fullNameFML; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("Name FML: %s %s %s", firstName, middleName, lastName); | ||
} | ||
|
||
} |
Oops, something went wrong.