Skip to content

Commit

Permalink
INITIAL DB MODEL
Browse files Browse the repository at this point in the history
  • Loading branch information
FairWindCo committed Oct 6, 2015
1 parent 890ced1 commit 8bae8cf
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package ua.pp.fairwind.favorid.internalDB.model;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Version;
import javax.persistence.*;
import java.util.Date;

/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "AGREEMENTS")
public class Agreement {
@Id
@GeneratedValue
Expand All @@ -19,6 +18,7 @@ public class Agreement {
Date planEndDate;
Date endDate;
@ManyToOne
@JoinColumn(name = "counterparty_id")
Counterparty counterparty;

@Version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "CONTACTS")
public class Contact {
@Id
@GeneratedValue
Long id;
@ManyToOne
@JoinColumn(name = "contact_type_id")
ContactType contactType;
String contact;
@Version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class Counterparty {
@OneToMany
@JsonManagedReference
Set<Contact> contacts=new HashSet<>();
@OneToMany
@OneToMany(mappedBy = "counterparty")
@JsonManagedReference
Set<Person> persons=new HashSet<>();
@OneToMany
@OneToMany(mappedBy = "counterparty")
@JsonManagedReference
Set<Counterparty> counterparties=new HashSet<>();
Set<Agreement> agriments =new HashSet<>();
@Version
private long version;

Expand All @@ -44,12 +44,12 @@ public void removePerson(Person person){
persons.remove(person);
}

public void addPerson(Counterparty counterparty){
counterparties.add(counterparty);
public void addPerson(Agreement agreement){
agriments.add(agreement);
}

public void removePerson(Counterparty counterparty){
counterparties.remove(counterparty);
public void removePerson(Agreement agreement){
agriments.remove(agreement);
}

public Long getId() {
Expand Down Expand Up @@ -100,11 +100,11 @@ public void setVersion(long version) {
this.version = version;
}

public Set<Counterparty> getCounterparties() {
return counterparties;
public Set<Agreement> getAgriments() {
return agriments;
}

public void setCounterparties(Set<Counterparty> counterparties) {
this.counterparties = counterparties;
public void setAgriments(Set<Agreement> counterparties) {
this.agriments = counterparties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,58 @@
import ua.pp.fairwind.favorid.internalDB.model.administrative.User;
import ua.pp.fairwind.favorid.internalDB.model.directories.DocumentType;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Version;
import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "DOCUMENTS")
public class Document {
@Id
@GeneratedValue
Long id;
@ManyToOne
@JoinColumn(name = "documentType_ID")
DocumentType documentType;
String number;
String name;
String description;

@ManyToOne
@JsonManagedReference
@JoinColumn(name = "counterparty_from_ID")
Counterparty counterparty_from;
@ManyToOne
@JsonManagedReference
@JoinColumn(name = "counterparty_to_ID")
Counterparty counterparty_to;
@ManyToOne
@JsonManagedReference
@JoinColumn(name = "person_from_ID")
Person person_from;
@ManyToOne
@JsonManagedReference
@JoinColumn(name = "person_to_ID")
Person person_to;
@JsonManagedReference
@ManyToOne
@JoinColumn(name = "agreement_ID")
Agreement agreement;

@ManyToOne
@JsonManagedReference
@JoinColumn(name = "parent_id")
Document parent;
@ManyToOne

@OneToMany
@JsonManagedReference
Set<Document> atachments=new HashSet<>();
@ManyToOne

@OneToMany
@JsonManagedReference
Set<DocumentFile> documentFiles=new HashSet<>();

Expand All @@ -59,9 +67,11 @@ public class Document {
Date modificationDate;
@ManyToOne
@CreatedBy
@JoinColumn(name = "created_user_id")
User creationUser;
@ManyToOne
@LastModifiedBy
@JoinColumn(name = "modify_user_id")
User modificationUser;

@Version
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package ua.pp.fairwind.favorid.internalDB.model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "FILES")
public class DocumentFile {
@Id
@GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "PERSONS")
public class Person {
@Id
@GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@
/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "TASKS")
public class Task {
@Id
@GeneratedValue
Long id;
String name;
String description;
@ManyToOne
@JoinColumn(name = "task__type_id")
TaskType taskType;
@ManyToOne
Counterparty counterparty;
@ManyToOne
@JsonManagedReference
@JoinColumn(name = "responsible_person_id")
Person responsible;
@ManyToMany
@JoinTable(name = "EXECUTORS",joinColumns = @JoinColumn(name="task_id"),inverseJoinColumns = @JoinColumn(name="person_id"))
@JsonManagedReference
Set<Person> executors=new HashSet<>();
Date startDate;
Expand All @@ -38,6 +43,7 @@ public class Task {
Date modificationDate;
@ManyToMany
@JsonManagedReference
@JoinTable(name = "TASK_DOCUMENTS",joinColumns = @JoinColumn(name="task_id"),inverseJoinColumns = @JoinColumn(name="document_id"))
Set<Document> taskDocuments=new HashSet<>();
@ManyToOne
@CreatedBy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package ua.pp.fairwind.favorid.internalDB.model.administrative;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.persistence.*;

/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "USER_ROELS")
public class Role {
@Id
@GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class User {

@JsonManagedReference
@ManyToOne
@JoinColumn(name = "person_id")
private Person person;
@Version
private long versionId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package ua.pp.fairwind.favorid.internalDB.model.directories;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.persistence.*;

/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "CONTACT_TYPES")
public class ContactType {
@Id
@GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package ua.pp.fairwind.favorid.internalDB.model.directories;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.persistence.*;

/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "DOCUMENT_TYPES")
public class DocumentType {
@Id
@GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package ua.pp.fairwind.favorid.internalDB.model.directories;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.persistence.*;

/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "POSITIONS")
public class Position {
@Id
@GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package ua.pp.fairwind.favorid.internalDB.model.directories;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.persistence.*;

/**
* Created by Ñåðãåé on 06.10.2015.
*/
@Entity
@Table(name = "TASK_TYPES")
public class TaskType {
@Id
@GeneratedValue
Expand Down

0 comments on commit 8bae8cf

Please sign in to comment.