CCM NG: GenericArticle Base class
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3697 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
2c700637ff
commit
b395f787e2
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue