Skip to content

Commit

Permalink
Merge pull request #7 from qlefevre/jhipster-entities-rh-176276589173…
Browse files Browse the repository at this point in the history
…3200

Add entities using the JDL model `RH`
  • Loading branch information
qlefevre authored Feb 18, 2018
2 parents 7f1b4cd + ada6d25 commit e03bc85
Show file tree
Hide file tree
Showing 88 changed files with 5,372 additions and 16 deletions.
17 changes: 17 additions & 0 deletions .jhipster/Congee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "date",
"fieldType": "Instant"
}
],
"changelogDate": "20180218182621",
"entityTableName": "congee",
"dto": "mapstruct",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"angularJSSuffix": "mySuffix"
}
27 changes: 27 additions & 0 deletions .jhipster/Department.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "one-to-many",
"relationshipName": "employees",
"otherEntityName": "employee",
"otherEntityRelationshipName": "department"
}
],
"fields": [
{
"fieldName": "departmentName",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20180218182622",
"entityTableName": "department",
"dto": "mapstruct",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"angularJSSuffix": "mySuffix"
}
45 changes: 45 additions & 0 deletions .jhipster/Employee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "one-to-one",
"relationshipName": "department",
"otherEntityName": "department",
"otherEntityField": "id",
"ownerSide": true,
"otherEntityRelationshipName": "employee"
},
{
"relationshipName": "department",
"otherEntityName": "department",
"relationshipType": "many-to-one",
"otherEntityField": "id"
}
],
"fields": [
{
"fieldName": "firstName",
"fieldType": "String"
},
{
"fieldName": "lastName",
"fieldType": "String"
},
{
"fieldName": "email",
"fieldType": "String"
},
{
"fieldName": "hireDate",
"fieldType": "Instant"
}
],
"changelogDate": "20180218182620",
"javadoc": "The Employee entity.",
"entityTableName": "employee",
"dto": "mapstruct",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"angularJSSuffix": "mySuffix"
}
33 changes: 17 additions & 16 deletions rh.jh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

entity User {
name String,
password String,
}
//entity User {
// name String,
// password String,
//}

entity Role {
name Role
}

//entity Role {
// name Role
//}

/**
* The Employee entity.
Expand All @@ -30,17 +31,17 @@ entity Department {



enum Role {
USER, DRH, DG, DGA
}
//enum Role {
// USER, DRH, DG, DGA
//}

relationship OneToOne {
User{employee} to Employee
}
//relationship OneToOne {
// User{employee} to Employee
//}

relationship OneToOne {
User{role} to Role
}
//relationship OneToOne {
// User{role} to Role
//}

relationship OneToOne {
Employee{department} to Department
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public JCacheManagerCustomizer cacheManagerCustomizer() {
cm.createCache(io.github.jhipster.application.domain.User.class.getName(), jcacheConfiguration);
cm.createCache(io.github.jhipster.application.domain.Authority.class.getName(), jcacheConfiguration);
cm.createCache(io.github.jhipster.application.domain.User.class.getName() + ".authorities", jcacheConfiguration);
cm.createCache(io.github.jhipster.application.domain.Employee.class.getName(), jcacheConfiguration);
cm.createCache(io.github.jhipster.application.domain.Congee.class.getName(), jcacheConfiguration);
cm.createCache(io.github.jhipster.application.domain.Department.class.getName(), jcacheConfiguration);
cm.createCache(io.github.jhipster.application.domain.Department.class.getName() + ".employees", jcacheConfiguration);
// jhipster-needle-ehcache-add-entry
};
}
Expand Down
79 changes: 79 additions & 0 deletions src/main/java/io/github/jhipster/application/domain/Congee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package io.github.jhipster.application.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

import java.io.Serializable;
import java.time.Instant;
import java.util.Objects;

/**
* A Congee.
*/
@Entity
@Table(name = "congee")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Congee implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "jhi_date")
private Instant date;

// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Instant getDate() {
return date;
}

public Congee date(Instant date) {
this.date = date;
return this;
}

public void setDate(Instant date) {
this.date = date;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Congee congee = (Congee) o;
if (congee.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), congee.getId());
}

@Override
public int hashCode() {
return Objects.hashCode(getId());
}

@Override
public String toString() {
return "Congee{" +
"id=" + getId() +
", date='" + getDate() + "'" +
"}";
}
}
113 changes: 113 additions & 0 deletions src/main/java/io/github/jhipster/application/domain/Department.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package io.github.jhipster.application.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.*;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;

/**
* A Department.
*/
@Entity
@Table(name = "department")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Department implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotNull
@Column(name = "department_name", nullable = false)
private String departmentName;

@OneToMany(mappedBy = "department")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Employee> employees = new HashSet<>();

// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getDepartmentName() {
return departmentName;
}

public Department departmentName(String departmentName) {
this.departmentName = departmentName;
return this;
}

public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}

public Set<Employee> getEmployees() {
return employees;
}

public Department employees(Set<Employee> employees) {
this.employees = employees;
return this;
}

public Department addEmployees(Employee employee) {
this.employees.add(employee);
employee.setDepartment(this);
return this;
}

public Department removeEmployees(Employee employee) {
this.employees.remove(employee);
employee.setDepartment(null);
return this;
}

public void setEmployees(Set<Employee> employees) {
this.employees = employees;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Department department = (Department) o;
if (department.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), department.getId());
}

@Override
public int hashCode() {
return Objects.hashCode(getId());
}

@Override
public String toString() {
return "Department{" +
"id=" + getId() +
", departmentName='" + getDepartmentName() + "'" +
"}";
}
}
Loading

0 comments on commit e03bc85

Please sign in to comment.