From b395f787e2b36aba4acef1929298c38337308e64 Mon Sep 17 00:00:00 2001 From: jensp Date: Mon, 19 Oct 2015 07:42:33 +0000 Subject: [PATCH] CCM NG: GenericArticle Base class git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3697 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/contenttypes/GenericArticle.java | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 ccm-cms/src/main/java/org/libreccm/cms/contenttypes/GenericArticle.java diff --git a/ccm-cms/src/main/java/org/libreccm/cms/contenttypes/GenericArticle.java b/ccm-cms/src/main/java/org/libreccm/cms/contenttypes/GenericArticle.java new file mode 100644 index 000000000..7025aa65f --- /dev/null +++ b/ccm-cms/src/main/java/org/libreccm/cms/contenttypes/GenericArticle.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.cms.contenttypes; + +import java.io.Serializable; +import java.util.Objects; +import javax.persistence.AssociationOverride; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Table; +import org.hibernate.envers.Audited; + +import static org.libreccm.cms.CmsConstants.*; + +import org.libreccm.cms.contentsection.ContentItem; +import org.libreccm.l10n.LocalizedString; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Audited +@Table(name = "articles", schema = DB_SCHEMA) +public class GenericArticle extends ContentItem implements Serializable { + + private static final long serialVersionUID = -6737443527969703121L; + + @Embedded + @AssociationOverride( + name = "VALUES", + joinTable = @JoinTable(name = "ARTICLE_TEXTS", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID")} + )) + private LocalizedString text; + + public LocalizedString getText() { + return text; + } + + public void setText(final LocalizedString text) { + this.text = text; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 17 * hash + Objects.hashCode(text); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof GenericArticle)) { + return false; + } + final GenericArticle other = (GenericArticle) obj; + if(!other.canEqual(this)) { + return false; + } + + return Objects.equals(text, other.getText()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof GenericArticle; + } + +}