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

Add entities using the JDL model admin #8

Open
wants to merge 2 commits into
base: master
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
36 changes: 36 additions & 0 deletions .jhipster/Bet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "Bet",
"fields": [
{
"fieldName": "chips",
"fieldType": "Integer"
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"otherEntityName": "gameUser",
"otherEntityRelationshipName": "bet",
"relationshipName": "user",
"otherEntityField": "id"
},
{
"relationshipType": "many-to-one",
"otherEntityName": "hand",
"otherEntityRelationshipName": "bet",
"relationshipName": "hand",
"otherEntityField": "id"
}
],
"changelogDate": "20200329103100",
"entityTableName": "bet",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
21 changes: 21 additions & 0 deletions .jhipster/Game.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Game",
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"relationships": [],
"changelogDate": "20200329103000",
"entityTableName": "game",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
36 changes: 36 additions & 0 deletions .jhipster/GameCommission.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "GameCommission",
"fields": [
{
"fieldName": "commission",
"fieldType": "Integer"
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"otherEntityName": "game",
"otherEntityRelationshipName": "gameCommission",
"relationshipName": "game",
"otherEntityField": "id"
},
{
"relationshipType": "many-to-one",
"otherEntityName": "gameUser",
"otherEntityRelationshipName": "commission",
"relationshipName": "gameUser",
"otherEntityField": "id"
}
],
"changelogDate": "20200329102900",
"entityTableName": "game_commission",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
32 changes: 32 additions & 0 deletions .jhipster/GameUser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "GameUser",
"fields": [
{
"fieldName": "username",
"fieldType": "String"
},
{
"fieldName": "password",
"fieldType": "String"
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"otherEntityName": "gameCommission",
"otherEntityRelationshipName": "gameUser",
"relationshipName": "commission"
}
],
"changelogDate": "20200329102800",
"entityTableName": "game_user",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
36 changes: 36 additions & 0 deletions .jhipster/Hand.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "Hand",
"fields": [
{
"fieldName": "status",
"fieldType": "HandStatus",
"fieldValues": "Begin,End"
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"otherEntityName": "bet",
"otherEntityRelationshipName": "hand",
"relationshipName": "bet"
},
{
"relationshipType": "many-to-one",
"otherEntityName": "game",
"otherEntityRelationshipName": "hand",
"relationshipName": "game",
"otherEntityField": "id"
}
],
"changelogDate": "20200329103200",
"entityTableName": "hand",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"clientRootFolder": "",
"applications": "*"
}
35 changes: 35 additions & 0 deletions admin.jh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
entity GameUser {
username String
password String
}

entity GameCommission {
commission Integer
}

entity Game {
name String
}

entity Bet {
chips Integer
}

entity Hand {
status HandStatus
}

enum HandStatus {
Begin, End
}

relationship ManyToOne {
Hand{game} to Game
GameCommission{game} to Game
Bet{user} to GameUser
}

relationship OneToMany {
GameUser{commission} to GameCommission
Hand{bet} to Bet{hand}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public JCacheManagerCustomizer cacheManagerCustomizer() {
createCache(cm, com.mycompany.myapp.domain.User.class.getName());
createCache(cm, com.mycompany.myapp.domain.Authority.class.getName());
createCache(cm, com.mycompany.myapp.domain.User.class.getName() + ".authorities");
createCache(cm, com.mycompany.myapp.domain.GameUser.class.getName());
createCache(cm, com.mycompany.myapp.domain.GameUser.class.getName() + ".commissions");
createCache(cm, com.mycompany.myapp.domain.GameCommission.class.getName());
createCache(cm, com.mycompany.myapp.domain.Game.class.getName());
createCache(cm, com.mycompany.myapp.domain.Bet.class.getName());
createCache(cm, com.mycompany.myapp.domain.Hand.class.getName());
createCache(cm, com.mycompany.myapp.domain.Hand.class.getName() + ".bets");
// jhipster-needle-ehcache-add-entry
};
}
Expand Down
109 changes: 109 additions & 0 deletions src/main/java/com/mycompany/myapp/domain/Bet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package com.mycompany.myapp.domain;

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

import javax.persistence.*;

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

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

private static final long serialVersionUID = 1L;

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

@Column(name = "chips")
private Integer chips;

@ManyToOne
@JsonIgnoreProperties("bets")
private GameUser user;

@ManyToOne
@JsonIgnoreProperties("bets")
private Hand hand;

// 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 Integer getChips() {
return chips;
}

public Bet chips(Integer chips) {
this.chips = chips;
return this;
}

public void setChips(Integer chips) {
this.chips = chips;
}

public GameUser getUser() {
return user;
}

public Bet user(GameUser gameUser) {
this.user = gameUser;
return this;
}

public void setUser(GameUser gameUser) {
this.user = gameUser;
}

public Hand getHand() {
return hand;
}

public Bet hand(Hand hand) {
this.hand = hand;
return this;
}

public void setHand(Hand hand) {
this.hand = hand;
}
// 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 instanceof Bet)) {
return false;
}
return id != null && id.equals(((Bet) o).id);
}

@Override
public int hashCode() {
return 31;
}

@Override
public String toString() {
return "Bet{" +
"id=" + getId() +
", chips=" + getChips() +
"}";
}
}
Loading