Skip to content

Commit

Permalink
added Offering and Price entity
Browse files Browse the repository at this point in the history
  • Loading branch information
serhii-buhaiov committed Nov 18, 2017
1 parent 98345c9 commit 7ed39a6
Show file tree
Hide file tree
Showing 40 changed files with 2,327 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .jhipster/Offering.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "one-to-many",
"relationshipName": "prices",
"otherEntityName": "price",
"otherEntityRelationshipName": "offering"
},
{
"relationshipName": "offering",
"otherEntityName": "offering",
"relationshipType": "many-to-one",
"otherEntityField": "id"
},
{
"relationshipType": "one-to-many",
"relationshipName": "childs",
"otherEntityName": "offering",
"otherEntityRelationshipName": "offering"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "description",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20171118114136",
"entityTableName": "offering",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false
}
26 changes: 26 additions & 0 deletions .jhipster/Price.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"fluentMethods": true,
"relationships": [
{
"relationshipName": "offering",
"otherEntityName": "offering",
"relationshipType": "many-to-one",
"otherEntityField": "id"
}
],
"fields": [
{
"fieldName": "value",
"fieldType": "Double",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20171118114137",
"entityTableName": "price",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public JCacheManagerCustomizer cacheManagerCustomizer() {
cm.createCache(org.apeps.firstapp.domain.User.class.getName() + ".authorities", jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.PersistentToken.class.getName(), jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.User.class.getName() + ".persistentTokens", jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.Offering.class.getName(), jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.Offering.class.getName() + ".prices", jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.Offering.class.getName() + ".childs", jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.Price.class.getName(), jcacheConfiguration);
// jhipster-needle-ehcache-add-entry
};
}
Expand Down
177 changes: 177 additions & 0 deletions src/main/java/org/apeps/firstapp/domain/Offering.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
package org.apeps.firstapp.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 Offering.
*/
@Entity
@Table(name = "offering")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Offering implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;

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

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

@OneToMany(mappedBy = "offering")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Price> prices = new HashSet<>();

@ManyToOne
private Offering offering;

@OneToMany(mappedBy = "offering")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Offering> childs = 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 getName() {
return name;
}

public Offering name(String name) {
this.name = name;
return this;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public Offering description(String description) {
this.description = description;
return this;
}

public void setDescription(String description) {
this.description = description;
}

public Set<Price> getPrices() {
return prices;
}

public Offering prices(Set<Price> prices) {
this.prices = prices;
return this;
}

public Offering addPrices(Price price) {
this.prices.add(price);
price.setOffering(this);
return this;
}

public Offering removePrices(Price price) {
this.prices.remove(price);
price.setOffering(null);
return this;
}

public void setPrices(Set<Price> prices) {
this.prices = prices;
}

public Offering getOffering() {
return offering;
}

public Offering offering(Offering offering) {
this.offering = offering;
return this;
}

public void setOffering(Offering offering) {
this.offering = offering;
}

public Set<Offering> getChilds() {
return childs;
}

public Offering childs(Set<Offering> offerings) {
this.childs = offerings;
return this;
}

public Offering addChilds(Offering offering) {
this.childs.add(offering);
offering.setOffering(this);
return this;
}

public Offering removeChilds(Offering offering) {
this.childs.remove(offering);
offering.setOffering(null);
return this;
}

public void setChilds(Set<Offering> offerings) {
this.childs = offerings;
}
// 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;
}
Offering offering = (Offering) o;
if (offering.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), offering.getId());
}

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

@Override
public String toString() {
return "Offering{" +
"id=" + getId() +
", name='" + getName() + "'" +
", description='" + getDescription() + "'" +
"}";
}
}
96 changes: 96 additions & 0 deletions src/main/java/org/apeps/firstapp/domain/Price.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package org.apeps.firstapp.domain;

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

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;

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

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;

@NotNull
@Column(name = "jhi_value", nullable = false)
private Double value;

@ManyToOne
private Offering offering;

// 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 Double getValue() {
return value;
}

public Price value(Double value) {
this.value = value;
return this;
}

public void setValue(Double value) {
this.value = value;
}

public Offering getOffering() {
return offering;
}

public Price offering(Offering offering) {
this.offering = offering;
return this;
}

public void setOffering(Offering offering) {
this.offering = offering;
}
// 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;
}
Price price = (Price) o;
if (price.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), price.getId());
}

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

@Override
public String toString() {
return "Price{" +
"id=" + getId() +
", value='" + getValue() + "'" +
"}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.apeps.firstapp.repository;

import org.apeps.firstapp.domain.Offering;
import org.springframework.stereotype.Repository;

import org.springframework.data.jpa.repository.*;


/**
* Spring Data JPA repository for the Offering entity.
*/
@SuppressWarnings("unused")
@Repository
public interface OfferingRepository extends JpaRepository<Offering, Long> {

}
16 changes: 16 additions & 0 deletions src/main/java/org/apeps/firstapp/repository/PriceRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.apeps.firstapp.repository;

import org.apeps.firstapp.domain.Price;
import org.springframework.stereotype.Repository;

import org.springframework.data.jpa.repository.*;


/**
* Spring Data JPA repository for the Price entity.
*/
@SuppressWarnings("unused")
@Repository
public interface PriceRepository extends JpaRepository<Price, Long> {

}
Loading

0 comments on commit 7ed39a6

Please sign in to comment.