+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * 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.jshopcore.model.category;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-
-/**
- * A product category
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Entity (name = "category")
-@Table (name = "category")
-public class ProductCategory implements Category {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 21_458_945_712_659L;
-
- /**
- * Id number of category
- */
- @Id
- @GeneratedValue (strategy = GenerationType.IDENTITY)
- @Column (name = "category_id", nullable = false)
- private Long categoryId;
-
- /**
- * Title of category
- */
- @Basic (optional = false)
- @Column (name = "category_title", length = 100, nullable = false, unique = true)
- private String categoryTitle;
-
- /**
- * Parent category
- */
- @JoinColumn (name = "parent_id")
- @OneToOne (targetEntity = ProductCategory.class, cascade = CascadeType.REFRESH)
- private Category parentCategory;
-
- /**
- * Constructor which accepts all database fields
- * <p>
- * @param categoryId Id number of database record
- * @param categoryTitle Category categoryTitle
- * @param parentCategory Parent category
- */
- public ProductCategory (final Long categoryId, final String categoryTitle, final Category parentCategory) {
- // Set all here
- this.categoryId = categoryId;
- this.categoryTitle = categoryTitle;
- this.parentCategory = parentCategory;
- }
-
- /**
- * Default constructor
- */
- public ProductCategory () {
- }
-
- @Override
- public void copyAll (final Category category) {
- // Copy all data
- this.setParentCategory(category.getParentCategory());
- this.setCategoryTitle(category.getCategoryTitle());
- }
-
- @Override
- public Long getCategoryId () {
- return this.categoryId;
- }
-
- @Override
- public void setCategoryId (final Long categoryId) {
- this.categoryId = categoryId;
- }
-
- @Override
- public String getCategoryTitle () {
- return this.categoryTitle;
- }
-
- @Override
- public void setCategoryTitle (final String categoryTitle) {
- this.categoryTitle = categoryTitle;
- }
-
- @Override
- public Category getParentCategory () {
- return this.parentCategory;
- }
-
- @Override
- public void setParentCategory (final Category parentCategory) {
- this.parentCategory = parentCategory;
- }
-}