Skip to content

Commit

Permalink
Merge pull request #11 from apeps/shop-entity
Browse files Browse the repository at this point in the history
issue #4
  • Loading branch information
maxK-user authored Dec 8, 2017
2 parents c31cdc3 + 19da006 commit a7baa2c
Show file tree
Hide file tree
Showing 59 changed files with 3,870 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .jhipster/Category.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "one-to-many",
"relationshipName": "item",
"otherEntityName": "item",
"otherEntityRelationshipName": "category"
},
{
"relationshipType": "many-to-one",
"relationshipName": "parent",
"otherEntityName": "category",
"otherEntityField": "id"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20171118104227",
"entityTableName": "category",
"dto": "no",
"pagination": "pagination",
"service": "serviceClass",
"jpaMetamodelFiltering": false
}
35 changes: 35 additions & 0 deletions .jhipster/Customer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "one-to-many",
"relationshipName": "item",
"otherEntityName": "item",
"otherEntityRelationshipName": "customer"
}
],
"fields": [
{
"fieldName": "firstName",
"fieldType": "String"
},
{
"fieldName": "lastName",
"fieldType": "String"
},
{
"fieldName": "email",
"fieldType": "String"
},
{
"fieldName": "telephone",
"fieldType": "String"
}
],
"changelogDate": "20171118104228",
"entityTableName": "customer",
"dto": "no",
"pagination": "pagination",
"service": "no",
"jpaMetamodelFiltering": false
}
40 changes: 40 additions & 0 deletions .jhipster/Item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipName": "category",
"otherEntityName": "category",
"otherEntityField": "id"
},
{
"relationshipName": "customer",
"otherEntityName": "customer",
"relationshipType": "many-to-one",
"otherEntityField": "id"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "description",
"fieldType": "String"
},
{
"fieldName": "price",
"fieldType": "Integer"
}
],
"changelogDate": "20171118104226",
"entityTableName": "item",
"dto": "no",
"pagination": "infinite-scroll",
"service": "serviceClass",
"jpaMetamodelFiltering": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ 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.Item.class.getName(), jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.Category.class.getName(), jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.Category.class.getName() + ".items", jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.Customer.class.getName(), jcacheConfiguration);
cm.createCache(org.apeps.firstapp.domain.Customer.class.getName() + ".items", jcacheConfiguration);
// jhipster-needle-ehcache-add-entry
};
}
Expand Down
129 changes: 129 additions & 0 deletions src/main/java/org/apeps/firstapp/domain/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
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 Category.
*/
@Entity
@Table(name = "category")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Category 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;

@OneToMany(mappedBy = "category")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Item> items = new HashSet<>();

@ManyToOne
private Category parent;

// 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 Category name(String name) {
this.name = name;
return this;
}

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

public Set<Item> getItems() {
return items;
}

public Category items(Set<Item> items) {
this.items = items;
return this;
}

public Category addItem(Item item) {
this.items.add(item);
item.setCategory(this);
return this;
}

public Category removeItem(Item item) {
this.items.remove(item);
item.setCategory(null);
return this;
}

public void setItems(Set<Item> items) {
this.items = items;
}

public Category getParent() {
return parent;
}

public Category parent(Category category) {
this.parent = category;
return this;
}

public void setParent(Category category) {
this.parent = category;
}
// 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;
}
Category category = (Category) o;
if (category.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), category.getId());
}

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

@Override
public String toString() {
return "Category{" +
"id=" + getId() +
", name='" + getName() + "'" +
"}";
}
}
Loading

0 comments on commit a7baa2c

Please sign in to comment.