import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
import org.mxchange.jproduct.model.category.Category;
import org.mxchange.jproduct.model.category.ProductCategory;
+import org.mxchange.jproduct.model.product.agegroup.AgeGroup;
/**
* Generic product class
* TODO: Find a better name
*/
@Entity (name = "generic_products")
-@Table (name = "generic_products")
+@Table (
+ name = "generic_products",
+ indexes = {
+ @Index (
+ name = "idx_i18n_age_size",
+ columnList = "product_i18n_key,product_age_group,product_size",
+ unique = true
+ )
+ }
+)
@NamedQueries (
{
@NamedQuery (name = "AllProducts", query = "SELECT p FROM generic_products AS p ORDER BY p.productId ASC"),
@Transient
private static final long serialVersionUID = 54_578_571_769_283L;
+ /**
+ * Product's age group (if any)
+ */
+ @Column (name = "product_age_group")
+ @Enumerated (EnumType.STRING)
+ private AgeGroup productAgeGroup;
+
/**
* Availability of product
*/
* I18n key of product
*/
@Basic (optional = false)
- @Column (name = "product_i18n_key", length = 100, nullable = false, unique = true)
+ @Column (name = "product_i18n_key", length = 100, nullable = false)
private String productI18nKey;
/**
@Column (name = "product_number")
private Long productNumber;
+ /**
+ * Product size (like for shoes, clothing)
+ */
+ @Column (name = "product_size", length = 10)
+ private String productSize;
+
/**
* Tax rate (0-1, by 1=100%)
*/
return false;
} else if (!Objects.equals(this.getProductI18nKey(), product.getProductI18nKey())) {
return false;
+ } else if (!Objects.equals(this.getProductAgeGroup(), product.getProductAgeGroup())) {
+ return false;
+ } else if (!Objects.equals(this.getProductSize(), product.getProductSize())) {
+ return false;
}
return true;
}
+ @Override
+ public AgeGroup getProductAgeGroup () {
+ return this.productAgeGroup;
+ }
+
+ @Override
+ public void setProductAgeGroup (final AgeGroup productAgeGroup) {
+ this.productAgeGroup = productAgeGroup;
+ }
+
@Override
public Boolean getProductAvailability () {
return this.productAvailability;
this.productNumber = productNumber;
}
+ @Override
+ public String getProductSize () {
+ return this.productSize;
+ }
+
+ @Override
+ public void setProductSize (final String productSize) {
+ this.productSize = productSize;
+ }
+
@Override
public Float getProductTaxRate () {
return this.productTaxRate;
hash = 23 * hash + Objects.hashCode(this.getProductId());
hash = 23 * hash + Objects.hashCode(this.getProductI18nKey());
+ hash = 23 * hash + Objects.hashCode(this.getProductAgeGroup());
+ hash = 23 * hash + Objects.hashCode(this.getProductSize());
return hash;
}
import java.util.Date;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jproduct.model.category.Category;
+import org.mxchange.jproduct.model.product.agegroup.AgeGroup;
/**
* An interface for in database storable products
*/
void setProductNumber (final Long productNumber);
+ /**
+ * Getter for product's size
+ * <p>
+ * @return Product's size
+ */
+ String getProductSize ();
+
+ /**
+ * Setter for product's size
+ * <p>
+ * @param productSize Product's size
+ */
+ void setProductSize (final String productSize);
+
+ /**
+ * Getter for product's age group
+ * <p>
+ * @return Product's age group
+ */
+ AgeGroup getProductAgeGroup ();
+
+ /**
+ * Setter for product's age group
+ * <p>
+ * @param productAgeGroup Product's age group
+ */
+ void setProductAgeGroup (final AgeGroup productAgeGroup);
+
@Override
boolean equals (final Object object);
--- /dev/null
+/*
+ * Copyright (C) 2017 Roland Haeder<roland@mxchange.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jproduct.model.product.agegroup;
+
+/**
+ * An enumeration for age classes
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public enum AgeGroup {
+
+ /**
+ * Age group "new born"
+ */
+ AGE_GROUP_NEWBORN("AGE_GROUP_NEWBORN"), //NOI18N
+ /**
+ * Age group "baby"
+ */
+ AGE_GROUP_BABY("AGE_GROUP_BABY"), //NOI18N
+ /**
+ * Age group "child"
+ */
+ AGE_GROUP_CHILD("AGE_GROUP_CHILD"), //NOI18N
+ /**
+ * Age group "youth"
+ */
+ AGE_GROUP_YOUTH("AGE_GROUP_YOUTH"), //NOI18N
+ /**
+ * Age group "adult"
+ */
+ AGE_GROUP_ADULT("AGE_GROUP_ADULT"), //NOI18N
+ /**
+ * Age group "senior"
+ */
+ AGE_GROUP_SENIOR("AGE_GROUP_SENIOR"); //NOI18N//NOI18N
+
+ /**
+ * I18n key for age group/class
+ */
+ private final String i18nKey;
+
+ /**
+ * Constructor with all enumeration fields
+ * <p>
+ * @param i18nKey I18n key for age class
+ */
+ private AgeGroup (final String i18nKey) {
+ // Set all values
+ this.i18nKey = i18nKey;
+ }
+
+ /**
+ * Getter for age group's i18n key
+ * <p>
+ * @return Age group's i18n key
+ */
+ public String getI18nKey () {
+ return this.i18nKey;
+ }
+
+}