Added Gourmet Model Entities

This commit is contained in:
Tim Holloway 2021-12-28 13:30:53 -05:00
parent 5eb3df20dc
commit 6ba1eb7fea
15 changed files with 1230 additions and 22 deletions

16
pom.xml
View File

@ -6,13 +6,13 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.mousetech.gourmet</groupId> <groupId>com.mousetech.gourmet</groupId>
<artifactId>jsf-primefaces-datatable</artifactId> <artifactId>gourmetj</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.1.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>jsf-primefaces-datatable</name> <name>GourmetJ</name>
<description>JSF PrimeFaces DataTable Example</description> <description>Gourmet Recipe Manager (Spring Boot)</description>
<url>https://codenotfound.com/jsf-primefaces-datatable-example.html</url> <url>https://www.mousetech.com</url>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -53,6 +53,12 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>

View File

@ -24,23 +24,23 @@ public class Category implements Serializable {
@Column(name="id") @Column(name="id")
private Long id; private Long id;
// @ManyToOne(fetch=FetchType.EAGER, optional = false) @ManyToOne(fetch=FetchType.EAGER, optional = false)
// @JoinColumn(name="recipe_id") @JoinColumn(name="recipe_id")
// private Recipe recipe; private Recipe recipe;
//
// /** /**
// * @return the parent recipe * @return the parent recipe
// */ */
// public Recipe getRecipe() { public Recipe getRecipe() {
// return recipe; return recipe;
// } }
//
// /** /**
// * @param recipe the parent recipe to set * @param recipe the parent recipe to set
// */ */
// public void setRecipe(Recipe recipe) { public void setRecipe(Recipe recipe) {
// this.recipe = recipe; this.recipe = recipe;
// } }
public Category() { public Category() {
} }

View File

@ -0,0 +1,54 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "convtable" database table.
*
*/
@Entity
@Table(name="\"convtable\"")
@NamedQuery(name="Convtable.findAll", query="SELECT c FROM Convtable c")
public class Convtable implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="\"ckey\"")
private Integer ckey;
@Id
@Column(name="\"id\"")
private int id;
@Column(name="\"value\"")
private String value;
public Convtable() {
}
public Integer getCkey() {
return this.ckey;
}
public void setCkey(Integer ckey) {
this.ckey = ckey;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,54 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "crossunitdict" database table.
*
*/
@Entity
@Table(name="\"crossunitdict\"")
@NamedQuery(name="Crossunitdict.findAll", query="SELECT c FROM Crossunitdict c")
public class Crossunitdict implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="\"cukey\"")
private Integer cukey;
@Id
@Column(name="\"id\"")
private int id;
@Column(name="\"value\"")
private String value;
public Crossunitdict() {
}
public Integer getCukey() {
return this.cukey;
}
public void setCukey(Integer cukey) {
this.cukey = cukey;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,54 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "density" database table.
*
*/
@Entity
@Table(name="\"density\"")
@NamedQuery(name="Density.findAll", query="SELECT d FROM Density d")
public class Density implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="\"dkey\"")
private Integer dkey;
@Id
@Column(name="\"id\"")
private int id;
@Column(name="\"value\"")
private String value;
public Density() {
}
public Integer getDkey() {
return this.dkey;
}
public void setDkey(Integer dkey) {
this.dkey = dkey;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,76 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "info" database table.
*
*/
@Entity
@Table(name="\"info\"")
@NamedQuery(name="Info.findAll", query="SELECT i FROM Info i")
public class Info implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="\"last_access\"")
private int lastAccess;
@Id
@Column(name="\"rowid\"")
private int rowid;
@Column(name="\"version_major\"")
private int versionMajor;
@Column(name="\"version_minor\"")
private int versionMinor;
@Column(name="\"version_super\"")
private int versionSuper;
public Info() {
}
public int getLastAccess() {
return this.lastAccess;
}
public void setLastAccess(int lastAccess) {
this.lastAccess = lastAccess;
}
public int getRowid() {
return this.rowid;
}
public void setRowid(int rowid) {
this.rowid = rowid;
}
public int getVersionMajor() {
return this.versionMajor;
}
public void setVersionMajor(int versionMajor) {
this.versionMajor = versionMajor;
}
public int getVersionMinor() {
return this.versionMinor;
}
public void setVersionMinor(int versionMinor) {
this.versionMinor = versionMinor;
}
public int getVersionSuper() {
return this.versionSuper;
}
public void setVersionSuper(int versionSuper) {
this.versionSuper = versionSuper;
}
}

View File

@ -0,0 +1,223 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "ingredients" database table.
* The display model is @see IngredientUI. Persistence
* is usually done along with the containing recipe via
* @see RecipeService.
*/
@Entity
@Table(name = "ingredients")
@NamedQuery(name = "Ingredient.findAll", query = "SELECT i FROM Ingredient i")
public class Ingredient implements Serializable, IngredientIF {
private static final long serialVersionUID = 1L;
@ManyToOne(fetch = FetchType.LAZY, cascade = {
CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, optional = true)
@JoinColumn(name = "ingkey",insertable = false, updatable = false, nullable = true)
Shopcat shopCat;
/**
* @return the shopCat
*/
public Shopcat getShopCat() {
return shopCat;
}
/**
* @param shopCat the shopCat to set
*/
public void setShopCat(Shopcat shopCat) {
this.shopCat = shopCat;
}
@Column(name = "amount")
private Double amount;
@Column(name = "deleted")
private Integer deleted;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "inggroup")
private String inggroup;
@Column(name = "ingkey")
private String ingkey;
@Column(name = "item")
private String item;
@Column(name = "optional")
private Integer optional;
@Column(name = "position")
private Integer position;
@Column(name = "rangeamount")
private Double rangeamount;
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "recipe_id")
Recipe recipe;
@Column(name = "refid")
private Long refid;
@Column(name = "shopoptional")
private Integer shopoptional;
@Column(name = "unit")
private String unit;
public Ingredient() {
}
@Override
public Double getAmount() {
return this.amount;
}
@Override
public void setAmount(Double amount) {
this.amount = amount;
}
@Override
public Integer getDeleted() {
return this.deleted;
}
@Override
public void setDeleted(Integer deleted) {
this.deleted = deleted;
}
@Override
public Long getId() {
return this.id;
}
@Override
public void setId(Long id) {
this.id = id;
}
@Override
public String getInggroup() {
return this.inggroup;
}
@Override
public void setInggroup(String inggroup) {
this.inggroup = inggroup;
}
@Override
public String getIngkey() {
return this.ingkey;
}
@Override
public void setIngkey(String ingkey) {
this.ingkey = ingkey;
}
@Override
public String getItem() {
return this.item;
}
@Override
public void setItem(String item) {
this.item = item;
}
@Override
public Integer getOptional() {
return this.optional;
}
@Override
public void setOptional(Integer optional) {
this.optional = optional;
}
@Override
public Integer getPosition() {
return this.position;
}
@Override
public void setPosition(Integer position) {
this.position = position;
}
@Override
public Double getRangeamount() {
return this.rangeamount;
}
@Override
public void setRangeamount(Double rangeamount) {
this.rangeamount = rangeamount;
}
// public Long getRecipeId() {
// return this.recipeId;
// }
//
// public void setRecipeId(Long recipeId) {
// this.recipeId = recipeId;
// }
@Override
public Recipe getRecipe() {
return recipe;
}
@Override
public void setRecipe(Recipe recipe) {
this.recipe = recipe;
}
@Override
public Long getRefid() {
return this.refid;
}
@Override
public void setRefid(Long refid) {
this.refid = refid;
}
@Override
public Integer getShopoptional() {
return this.shopoptional;
}
@Override
public void setShopoptional(Integer shopoptional) {
this.shopoptional = shopoptional;
}
@Override
public String getUnit() {
return this.unit;
}
@Override
public void setUnit(String unit) {
this.unit = unit;
}
@Override
public String toString() {
return this.getItem();
}
}

View File

@ -0,0 +1,64 @@
package com.mousetech.gourmetj.persistence.model;
public interface IngredientIF {
Double getAmount();
void setAmount(Double amount);
Integer getDeleted();
void setDeleted(Integer deleted);
Long getId();
void setId(Long id);
String getInggroup();
void setInggroup(String inggroup);
String getIngkey();
void setIngkey(String ingkey);
String getItem();
void setItem(String item);
Integer getOptional();
void setOptional(Integer optional);
Integer getPosition();
void setPosition(Integer position);
Double getRangeamount();
void setRangeamount(Double rangeamount);
// public Long getRecipeId() {
// return this.recipeId;
// }
//
// public void setRecipeId(Long recipeId) {
// this.recipeId = recipeId;
// }
Recipe getRecipe();
void setRecipe(Recipe recipe);
Long getRefid();
void setRefid(Long refid);
Integer getShopoptional();
void setShopoptional(Integer shopoptional);
String getUnit();
void setUnit(String unit);
}

View File

@ -0,0 +1,76 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "keylookup" database table.
*
*/
@Entity
@Table(name="\"keylookup\"")
@NamedQuery(name="Keylookup.findAll", query="SELECT k FROM Keylookup k")
public class Keylookup implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="\"count\"")
private int count;
@Id
@Column(name="\"id\"")
private int id;
@Column(name="\"ingkey\"")
private String ingkey;
@Column(name="\"item\"")
private String item;
@Column(name="\"word\"")
private String word;
public Keylookup() {
}
public int getCount() {
return this.count;
}
public void setCount(int count) {
this.count = count;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getIngkey() {
return this.ingkey;
}
public void setIngkey(String ingkey) {
this.ingkey = ingkey;
}
public String getItem() {
return this.item;
}
public void setItem(String item) {
this.item = item;
}
public String getWord() {
return this.word;
}
public void setWord(String word) {
this.word = word;
}
}

View File

@ -0,0 +1,54 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "pantry" database table.
*
*/
@Entity
@Table(name="\"pantry\"")
@NamedQuery(name="Pantry.findAll", query="SELECT p FROM Pantry p")
public class Pantry implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="\"id\"")
private int id;
@Column(name="\"ingkey\"")
private Integer ingkey;
@Column(name="\"pantry\"")
private String pantry;
public Pantry() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public Integer getIngkey() {
return this.ingkey;
}
public void setIngkey(Integer ingkey) {
this.ingkey = ingkey;
}
public String getPantry() {
return this.pantry;
}
public void setPantry(String pantry) {
this.pantry = pantry;
}
}

View File

@ -0,0 +1,87 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "plugin_info" database table.
*
*/
@Entity
@Table(name="\"plugin_info\"")
@NamedQuery(name="PluginInfo.findAll", query="SELECT p FROM PluginInfo p")
public class PluginInfo implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="\"id\"")
private int id;
@Id
@Column(name="\"plugin\"")
private String plugin;
@Column(name="\"plugin_version\"")
private String pluginVersion;
@Column(name="\"version_major\"")
private int versionMajor;
@Column(name="\"version_minor\"")
private int versionMinor;
@Column(name="\"version_super\"")
private int versionSuper;
public PluginInfo() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getPlugin() {
return this.plugin;
}
public void setPlugin(String plugin) {
this.plugin = plugin;
}
public String getPluginVersion() {
return this.pluginVersion;
}
public void setPluginVersion(String pluginVersion) {
this.pluginVersion = pluginVersion;
}
public int getVersionMajor() {
return this.versionMajor;
}
public void setVersionMajor(int versionMajor) {
this.versionMajor = versionMajor;
}
public int getVersionMinor() {
return this.versionMinor;
}
public void setVersionMinor(int versionMinor) {
this.versionMinor = versionMinor;
}
public int getVersionSuper() {
return this.versionSuper;
}
public void setVersionSuper(int versionSuper) {
this.versionSuper = versionSuper;
}
}

View File

@ -0,0 +1,267 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;
/**
* The persistent class for the "recipe" database table.
* Persisted by @see RecipeDAO
*/
@Entity
@Table(name = "recipe")
@NamedQueries({
@NamedQuery(name = "Recipe.findAll", query = "SELECT r FROM Recipe r"),
@NamedQuery(name = "Recipe.findByTitle", query = "SELECT r FROM Recipe r WHERE r.title LIKE concat('%', :searchText,'%')") })
public class Recipe implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "cooktime")
private Integer cooktime;
@Column(name = "cuisine")
private String cuisine;
@Column(name = "deleted")
private Integer deleted;
@Column(name = "description")
private String description;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "image")
private byte[] image;
// Actual Ingredient_hash field is VARCHAR(32) - UUID???
@OneToMany(fetch = FetchType.LAZY, mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Ingredient> ingredientHash = new ArrayList<Ingredient>();
@Column(name = "instructions")
private String instructions;
@Column(name = "last_modified")
private Integer lastModified;
@Column(name = "link")
private String link;
@Column(name = "modifications")
private String modifications;
@Column(name = "preptime")
private Integer preptime;
@Column(name = "rating")
private Integer rating;
@Column(name = "recipe_hash")
private Long recipeHash;
@Column(name = "servings")
private Double servings;
@Column(name = "source")
private String source;
@Column(name = "thumb")
private byte[] thumb;
@Column(name = "title")
private String title;
@Column(name = "yield_unit")
private Integer yieldUnit;
@Column(name = "yields")
private Double yields;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Category> categories =
new ArrayList<Category>();
/**
* @param categories the categories to set
*/
public void setCategories(List<Category> categories) {
this.categories = categories;
}
public Recipe() {
}
public Integer getCooktime() {
return this.cooktime;
}
public void setCooktime(Integer cooktime) {
this.cooktime = cooktime;
}
public String getCuisine() {
return this.cuisine;
}
public void setCuisine(String cuisine) {
this.cuisine = cuisine;
}
public Integer getDeleted() {
return this.deleted;
}
public void setDeleted(Integer deleted) {
this.deleted = deleted;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public byte[] getImage() {
return this.image;
}
public void setImage(byte[] image) {
this.image = image;
}
public List<Ingredient> getIngredientHash() {
return this.ingredientHash;
}
public void setIngredientHash(
List<Ingredient> ingredientHash) {
this.ingredientHash = ingredientHash;
}
public String getInstructions() {
return this.instructions;
}
public void setInstructions(String instructions) {
this.instructions = instructions;
}
public Integer getLastModified() {
return this.lastModified;
}
public void setLastModified(Integer lastModified) {
this.lastModified = lastModified;
}
public String getLink() {
return this.link;
}
public void setLink(String link) {
this.link = link;
}
public String getModifications() {
return this.modifications;
}
public void setModifications(String modifications) {
this.modifications = modifications;
}
public Integer getPreptime() {
return this.preptime;
}
public void setPreptime(Integer preptime) {
this.preptime = preptime;
}
public Integer getRating() {
return this.rating;
}
public void setRating(Integer rating) {
this.rating = rating;
}
public Long getRecipeHash() {
return this.recipeHash;
}
public void setRecipeHash(Long recipeHash) {
this.recipeHash = recipeHash;
}
public Double getServings() {
return this.servings;
}
public void setServings(Double servings) {
this.servings = servings;
}
public String getSource() {
return this.source;
}
public void setSource(String source) {
this.source = source;
}
public byte[] getThumb() {
return this.thumb;
}
public void setThumb(byte[] thumb) {
this.thumb = thumb;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getYieldUnit() {
return this.yieldUnit;
}
public void setYieldUnit(Integer yieldUnit) {
this.yieldUnit = yieldUnit;
}
public Double getYields() {
return this.yields;
}
public void setYields(Double yields) {
this.yields = yields;
}
@Override
public String toString() {
return "Recipe #" + this.getId() + " " + this.getTitle();
}
public List<Category> getCategories() {
return this.categories;
}
}

View File

@ -0,0 +1,85 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
/**
* The persistent class for the "shopcats" database table.
*
* Properly, a Shopcat should be an optional ManyToOne reference
* from Ingredient, but the database schema does not rigorously
* enforce that. To do so, Ingredient.ingKey would be formally
* declared as a foreign key and in Shopcat.ingKey would be declared
* as a unique key (and could serve as primary key).
*
* Failing that, crud can accumulate in the database and it's
* mostly dealt with in the @see ReceipeDAO.
*
*/
@Entity
@Table(name = "shopcats")
@NamedQueries({
@NamedQuery(name = "Shopcat.findAll", query = "SELECT s FROM Shopcat s"),
@NamedQuery(name = "Shopcat.findIngkey", query = "SELECT s FROM Shopcat s where s.ingkey = :ingkey") })
public class Shopcat implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "ingkey")
@NotNull
// @UniqueConstraint(name="ingkey")
private String ingkey;
// @OneToMany ingredients
@Column(name = "position")
private Integer position;
@Column(name = "shopcategory")
private String shopcategory;
public Shopcat() {
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getIngkey() {
return this.ingkey;
}
public void setIngkey(String ingkey) {
this.ingkey = ingkey;
}
public Integer getPosition() {
return this.position;
}
public void setPosition(Integer position) {
this.position = position;
}
public String getShopcategory() {
return this.shopcategory;
}
public void setShopcategory(String shopcategory) {
this.shopcategory = shopcategory;
}
@Override
public String toString() {
return "Shopcat for " + ingkey + "(" + shopcategory
+ ")";
}
}

View File

@ -0,0 +1,54 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "shopcatsorder" database table.
*
*/
@Entity
@Table(name="\"shopcatsorder\"")
@NamedQuery(name="Shopcatsorder.findAll", query="SELECT s FROM Shopcatsorder s")
public class Shopcatsorder implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="\"id\"")
private int id;
@Column(name="\"position\"")
private int position;
@Column(name="\"shopcategory\"")
private Integer shopcategory;
public Shopcatsorder() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public int getPosition() {
return this.position;
}
public void setPosition(int position) {
this.position = position;
}
public Integer getShopcategory() {
return this.shopcategory;
}
public void setShopcategory(Integer shopcategory) {
this.shopcategory = shopcategory;
}
}

View File

@ -0,0 +1,54 @@
package com.mousetech.gourmetj.persistence.model;
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the "unitdict" database table.
*
*/
@Entity
@Table(name="\"unitdict\"")
@NamedQuery(name="Unitdict.findAll", query="SELECT u FROM Unitdict u")
public class Unitdict implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="\"id\"")
private int id;
@Column(name="\"ukey\"")
private Integer ukey;
@Column(name="\"value\"")
private String value;
public Unitdict() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public Integer getUkey() {
return this.ukey;
}
public void setUkey(Integer ukey) {
this.ukey = ukey;
}
public String getValue() {
return this.value;
}
public void setValue(String value) {
this.value = value;
}
}