CCM NG: Basic entities for the CMS module
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4175 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
7ee9eb50a0
commit
00f2a64c27
|
|
@ -15,6 +15,13 @@
|
|||
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'Z</maven.build.timestamp.format>
|
||||
</properties>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Lesser GPL 2.1</name>
|
||||
<url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<groupId>org.librecms</groupId>
|
||||
<artifactId>ccm-cms</artifactId>
|
||||
|
||||
|
|
@ -195,7 +202,9 @@
|
|||
</dialects>
|
||||
<packages>
|
||||
<param>org.libreccm</param>
|
||||
<param>org.librecms</param>
|
||||
</packages>
|
||||
<persistenceXml>${basedir}/src/main/resources/META-INF/persistence-ddl.xml</persistenceXml>
|
||||
<useEnvers>true</useEnvers>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ import org.libreccm.modules.ShutdownEvent;
|
|||
import org.libreccm.modules.UnInstallEvent;
|
||||
|
||||
@Module(packageName = "org.libreccm.cms",
|
||||
requiredModules = {@RequiredModule(module = org.libreccm.core.CcmCore.class)})
|
||||
requiredModules = {
|
||||
@RequiredModule(module = org.libreccm.core.CcmCore.class)
|
||||
}
|
||||
)
|
||||
public class Cms implements CcmModule {
|
||||
|
||||
@Override
|
||||
|
|
@ -35,5 +38,4 @@ public class Cms implements CcmModule {
|
|||
//ToDo Remove module data
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* 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.librecms.assets;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.core.Identifiable;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(schema = DB_SCHEMA, name = "ASSETS")
|
||||
@Audited
|
||||
public class Asset implements Identifiable, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3499741368562653529L;
|
||||
|
||||
@Column(name = "ASSET_ID")
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long assetId;
|
||||
|
||||
@Column(name = "UUID", unique = true)
|
||||
private String uuid;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "ASSET_TITLES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "ASSET_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString title;
|
||||
|
||||
public long getAssetId() {
|
||||
return assetId;
|
||||
}
|
||||
|
||||
protected void setAssetId(final long assetId) {
|
||||
this.assetId = assetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public LocalizedString getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final LocalizedString title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 97 * hash + (int) (assetId ^ (assetId >>> 32));
|
||||
hash = 97 * hash + Objects.hashCode(uuid);
|
||||
hash = 97 * hash + Objects.hashCode(title);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof Asset)) {
|
||||
return false;
|
||||
}
|
||||
final Asset other = (Asset) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (assetId != other.getAssetId()) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(uuid, other.getUuid())) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(title, other.getTitle());
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof Asset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return toString("");
|
||||
}
|
||||
|
||||
public String toString(final String data) {
|
||||
return String.format(
|
||||
"%s{ "
|
||||
+ "assetIdd = %d, "
|
||||
+ "uuid = %s, "
|
||||
+ "title = {}%s"
|
||||
+ " }",
|
||||
super.toString(),
|
||||
assetId,
|
||||
uuid,
|
||||
Objects.toString(title),
|
||||
data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.librecms.assets;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.core.CcmObject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
* @param <T>
|
||||
*/
|
||||
@Entity
|
||||
@Table(schema = DB_SCHEMA, name = "REUSABLE_ASSETS")
|
||||
@Audited
|
||||
public class ReusableAsset<T extends Asset> extends CcmObject
|
||||
implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1341326042963088198L;
|
||||
|
||||
@OneToOne(targetEntity = Asset.class)
|
||||
@JoinColumn(name = "ASSET_ID")
|
||||
private T asset;
|
||||
|
||||
public T getAsset() {
|
||||
return asset;
|
||||
}
|
||||
|
||||
protected void setAsset(final T asset) {
|
||||
this.asset = asset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = super.hashCode();
|
||||
hash = 11 * hash + Objects.hashCode(asset);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof ReusableAsset)) {
|
||||
return false;
|
||||
}
|
||||
final ReusableAsset<?> other = (ReusableAsset<?>) obj;
|
||||
if (!other.canEqual(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Objects.equals(asset, other.getAsset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof ReusableAsset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(final String data) {
|
||||
return super.toString(String.format(
|
||||
", asset = { %s }%s",
|
||||
Objects.toString(asset),
|
||||
data
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,320 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.librecms.attachments;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.core.Identifiable;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
import org.librecms.assets.Asset;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
* @param <T>
|
||||
*/
|
||||
@Entity
|
||||
@Table(schema = DB_SCHEMA, name = "attachment_lists")
|
||||
@Audited
|
||||
public class AttachmentList<T extends Asset> implements Identifiable,
|
||||
List<ItemAttachment<T>>,
|
||||
Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7750330135750750047L;
|
||||
|
||||
@Column(name = "LIST_ID")
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long listId;
|
||||
|
||||
@Column(name = "UUID")
|
||||
private String uuid;
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "ATTACHMENT_LIST_CAPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "LIST_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString caption;
|
||||
|
||||
@Column(name = "ASSET_TYPE", length = 1024)
|
||||
private String assetType;
|
||||
|
||||
@OneToMany(targetEntity = ItemAttachment.class)
|
||||
@JoinColumn(name = "LIST_ID")
|
||||
private List<ItemAttachment<T>> attachments;
|
||||
|
||||
public long getListId() {
|
||||
return listId;
|
||||
}
|
||||
|
||||
protected void setListId(final long listId) {
|
||||
this.listId = listId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public LocalizedString getCaption() {
|
||||
return caption;
|
||||
}
|
||||
|
||||
public void setCaption(final LocalizedString caption) {
|
||||
this.caption = caption;
|
||||
}
|
||||
|
||||
public String getAssetType() {
|
||||
return assetType;
|
||||
}
|
||||
|
||||
public void setAssetType(final String assetType) {
|
||||
this.assetType = assetType;
|
||||
}
|
||||
|
||||
public List<ItemAttachment<T>> getAttachments() {
|
||||
return Collections.unmodifiableList(attachments);
|
||||
}
|
||||
|
||||
public void setAttachments(List<ItemAttachment<T>> attachments) {
|
||||
this.attachments = new ArrayList<>(attachments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return attachments.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return attachments.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(final Object obj) {
|
||||
return attachments.contains(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ItemAttachment<T>> iterator() {
|
||||
return attachments.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return attachments.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(final T[] array) {
|
||||
return attachments.toArray(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(final ItemAttachment<T> attachment) {
|
||||
return attachments.add(attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(final Object obj) {
|
||||
return attachments.remove(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(final Collection<?> collection) {
|
||||
return attachments.containsAll(collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(
|
||||
final Collection<? extends ItemAttachment<T>> collection) {
|
||||
|
||||
return attachments.addAll(collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(
|
||||
final int index,
|
||||
final Collection<? extends ItemAttachment<T>> collection) {
|
||||
|
||||
return attachments.addAll(index, collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(final Collection<?> collection) {
|
||||
return attachments.removeAll(collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(final Collection<?> collection) {
|
||||
return attachments.retainAll(collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
attachments.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemAttachment<T> get(final int index) {
|
||||
return attachments.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemAttachment<T> set(final int index,
|
||||
final ItemAttachment<T> element) {
|
||||
return attachments.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(final int index, final ItemAttachment<T> element) {
|
||||
attachments.add(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemAttachment<T> remove(final int index) {
|
||||
return attachments.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(final Object obj) {
|
||||
return attachments.indexOf(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(final Object obj) {
|
||||
return attachments.lastIndexOf(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<ItemAttachment<T>> listIterator() {
|
||||
return attachments.listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<ItemAttachment<T>> listIterator(final int index) {
|
||||
return attachments.listIterator(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemAttachment<T>> subList(final int fromIndex,
|
||||
final int toIndex) {
|
||||
return attachments.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 97 * hash + (int) (listId ^ (listId >>> 32));
|
||||
hash = 97 * hash + Objects.hashCode(uuid);
|
||||
hash = 97 * hash + Objects.hashCode(caption);
|
||||
hash = 97 * hash + Objects.hashCode(assetType);
|
||||
hash = 97 * hash + Objects.hashCode(attachments);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof AttachmentList)) {
|
||||
return false;
|
||||
}
|
||||
final AttachmentList<?> other = (AttachmentList<?>) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (listId != other.getListId()) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(uuid, other.getUuid())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(caption, other.getCaption())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(assetType, other.getAssetType())) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(attachments, other.getAttachments());
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof AttachmentList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return toString("");
|
||||
}
|
||||
|
||||
public String toString(final String data) {
|
||||
return String.format("%s{ "
|
||||
+ "listId = %d, "
|
||||
+ "uuid = %s, "
|
||||
+ "caption = { %s }, "
|
||||
+ "assetType = %s, "
|
||||
+ "attachments = { %s }%s"
|
||||
+ " }",
|
||||
super.toString(),
|
||||
listId,
|
||||
uuid,
|
||||
Objects.toString(caption),
|
||||
assetType,
|
||||
Objects.toString(attachments),
|
||||
data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.librecms.attachments;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.libreccm.core.Identifiable;
|
||||
import org.librecms.assets.Asset;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
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;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
* @param <T>
|
||||
*/
|
||||
@Entity
|
||||
@Table(schema = DB_SCHEMA, name = "ATTACHMENTS")
|
||||
@Audited
|
||||
public class ItemAttachment<T extends Asset> implements Identifiable,
|
||||
Serializable {
|
||||
|
||||
private static final long serialVersionUID = -9005379413315191984L;
|
||||
|
||||
@Column(name = "ATTACHMENT_ID")
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long attachmentId;
|
||||
|
||||
@Column(name = "uuid")
|
||||
private String uuid;
|
||||
|
||||
@OneToOne(targetEntity = Asset.class)
|
||||
@JoinColumn(name = "ASSET_ID")
|
||||
private T asset;
|
||||
|
||||
@Column(name = "SORT_KEY")
|
||||
private long sortKey;
|
||||
|
||||
public long getAttachmentId() {
|
||||
return attachmentId;
|
||||
}
|
||||
|
||||
public void setAttachmentId(final long attachmentId) {
|
||||
this.attachmentId = attachmentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public T getAsset() {
|
||||
return asset;
|
||||
}
|
||||
|
||||
public void setAsset(final T asset) {
|
||||
this.asset = asset;
|
||||
}
|
||||
|
||||
public long getSortKey() {
|
||||
return sortKey;
|
||||
}
|
||||
|
||||
public void setSortKey(final long sortKey) {
|
||||
this.sortKey = sortKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash
|
||||
= 71 * hash + (int) (attachmentId ^ (attachmentId >>> 32));
|
||||
hash = 71 * hash + Objects.hashCode(asset);
|
||||
hash = 71 * hash + (int) (sortKey ^ (sortKey >>> 32));
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof ItemAttachment)) {
|
||||
return false;
|
||||
}
|
||||
final ItemAttachment<?> other = (ItemAttachment<?>) obj;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (attachmentId != other.getAttachmentId()) {
|
||||
return false;
|
||||
}
|
||||
if (sortKey != other.getSortKey()) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(asset, other.getAsset());
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof ItemAttachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return toString("");
|
||||
}
|
||||
|
||||
public String toString(final String data) {
|
||||
return String.format("%s{ "
|
||||
+ "attachmentId = %d, "
|
||||
+ "uuid = %s, "
|
||||
+ "asset = { %s }, "
|
||||
+ "sortKey = %d%s"
|
||||
+ " }",
|
||||
super.toString(),
|
||||
attachmentId,
|
||||
uuid,
|
||||
Objects.toString(asset),
|
||||
sortKey,
|
||||
data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,14 +19,18 @@
|
|||
package org.librecms.contentsection;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.envers.RelationTargetAuditMode;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
import org.librecms.attachments.AttachmentList;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
|
|
@ -37,6 +41,7 @@ import javax.persistence.EnumType;
|
|||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
|
|
@ -49,7 +54,7 @@ import javax.persistence.TemporalType;
|
|||
*/
|
||||
@Entity
|
||||
@Audited
|
||||
@Table(name = "content_items", schema = DB_SCHEMA)
|
||||
@Table(name = "CONTENT_ITEMS", schema = DB_SCHEMA)
|
||||
public class ContentItem extends CcmObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5897287630227129653L;
|
||||
|
|
@ -62,18 +67,21 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
*/
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "VALUES",
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_NAMES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString name;
|
||||
|
||||
/**
|
||||
* The content type associated with the content item.
|
||||
*/
|
||||
@OneToOne
|
||||
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
|
||||
private ContentType contentType;
|
||||
|
||||
/**
|
||||
|
|
@ -81,12 +89,14 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
*/
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "VALUES",
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_TITLES",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
@JoinColumn(name = "OBJECT_ID")}
|
||||
))
|
||||
@JoinColumn(name = "OBJECT_ID")
|
||||
}
|
||||
)
|
||||
)
|
||||
private LocalizedString title;
|
||||
|
||||
/**
|
||||
|
|
@ -94,7 +104,7 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
*/
|
||||
@Embedded
|
||||
@AssociationOverride(
|
||||
name = "VALUES",
|
||||
name = "values",
|
||||
joinTable = @JoinTable(name = "CONTENT_ITEM_DESCRIPTIONS",
|
||||
schema = DB_SCHEMA,
|
||||
joinColumns = {
|
||||
|
|
@ -118,9 +128,13 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
* String with the IDs (separated by slashes) of the ancestors of the
|
||||
* content item (aka the path of the content item).
|
||||
*/
|
||||
@Column(name = "ancestors", length = 1024)
|
||||
@Column(name = "ANCESTORS", length = 1024)
|
||||
private String ancestors;
|
||||
|
||||
@OneToMany
|
||||
@JoinColumn(name = "CONTENT_ITEM_ID")
|
||||
private List<AttachmentList<?>> attachments;
|
||||
|
||||
public LocalizedString getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
@ -162,12 +176,20 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
}
|
||||
|
||||
public Date getLaunchDate() {
|
||||
if (launchDate == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new Date(launchDate.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public void setLaunchDate(final Date launchDate) {
|
||||
if (launchDate == null) {
|
||||
this.launchDate = null;
|
||||
} else {
|
||||
this.launchDate = new Date(launchDate.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public String getAncestors() {
|
||||
return ancestors;
|
||||
|
|
@ -177,6 +199,14 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
public List<AttachmentList<?>> getAttachments() {
|
||||
return Collections.unmodifiableList(attachments);
|
||||
}
|
||||
|
||||
protected void setAttachments(final List<AttachmentList<?>> attachments) {
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = super.hashCode();
|
||||
|
|
@ -236,16 +266,19 @@ public class ContentItem extends CcmObject implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString(final String data) {
|
||||
return String.format(", name = {}, "
|
||||
return super.toString(String.format(", name = {}, "
|
||||
+ "contentType = {}, "
|
||||
+ "title = {}, "
|
||||
+ "description = {},"
|
||||
+ "version = %s,"
|
||||
+ "launchDate = %s%s",
|
||||
Objects.toString(name),
|
||||
Objects.toString(contentType),
|
||||
Objects.toString(title),
|
||||
Objects.toString(description),
|
||||
Objects.toString(version),
|
||||
Objects.toString(launchDate));
|
||||
Objects.toString(launchDate),
|
||||
data));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,16 +18,20 @@
|
|||
*/
|
||||
package org.librecms.contentsection;
|
||||
|
||||
import org.libreccm.categorization.Category;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
import org.libreccm.security.Role;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
|
@ -36,36 +40,44 @@ import javax.persistence.Table;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "content_sections", schema = DB_SCHEMA)
|
||||
@Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA)
|
||||
public class ContentSection extends CcmApplication implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -671718122153931727L;
|
||||
|
||||
@Column(name = "label", length = 512)
|
||||
@Column(name = "LABEL", length = 512)
|
||||
private String label;
|
||||
|
||||
@Column(name = "page_resolver_class", length = 1024)
|
||||
@OneToOne
|
||||
@JoinColumn(name = "ROOT_DOCUMENTS_FOLDER_ID")
|
||||
private Category rootDocumentsFolder;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "ROOT_ASSETS_FOLDER_ID")
|
||||
private Category rootAssetsFolder;
|
||||
|
||||
@Column(name = "PAGE_RESOLVER_CLASS", length = 1024)
|
||||
private String pageResolverClass;
|
||||
|
||||
@Column(name = "item_resolver_class", length = 1024)
|
||||
@Column(name = "ITEM_RESOLVER_CLASS", length = 1024)
|
||||
private String itemResolverClass;
|
||||
|
||||
@Column(name = "template_resolver_class", length = 1024)
|
||||
@Column(name = "TEMPLATE_RESOLVER_CLASS", length = 1024)
|
||||
private String templateResolverClass;
|
||||
|
||||
@Column(name = "xml_generator_class", length = 1024)
|
||||
@Column(name = "XML_GENERATOR_CLASS", length = 1024)
|
||||
private String xmlGeneratorClass;
|
||||
|
||||
@OneToOne
|
||||
private Role staffGroup;
|
||||
@JoinColumn(name = "STAFF_ROLE_ID")
|
||||
private Role staffRole;
|
||||
|
||||
@OneToOne
|
||||
private Role viewersGroup;
|
||||
|
||||
@Column(name = "default_locale", length = 10)
|
||||
private String defaultLocale;
|
||||
|
||||
@JoinColumn(name = "VIEWERS_ROLE_ID")
|
||||
private Role viewersRole;
|
||||
|
||||
@Column(name = "DEFAULT_LOCALE")
|
||||
private Locale defaultLocale;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
|
|
@ -75,6 +87,22 @@ public class ContentSection extends CcmApplication implements Serializable {
|
|||
this.label = label;
|
||||
}
|
||||
|
||||
public Category getRootDocumentsFolder() {
|
||||
return rootDocumentsFolder;
|
||||
}
|
||||
|
||||
protected void setRootDocumentFolder(final Category rootDocumentsFolder) {
|
||||
this.rootDocumentsFolder = rootDocumentsFolder;
|
||||
}
|
||||
|
||||
public Category getRootAssetsFolder() {
|
||||
return rootAssetsFolder;
|
||||
}
|
||||
|
||||
protected void setRootAssetsFolder(final Category rootAssetsFolder) {
|
||||
this.rootAssetsFolder = rootAssetsFolder;
|
||||
}
|
||||
|
||||
public String getPageResolverClass() {
|
||||
return pageResolverClass;
|
||||
}
|
||||
|
|
@ -107,27 +135,27 @@ public class ContentSection extends CcmApplication implements Serializable {
|
|||
this.xmlGeneratorClass = xmlGeneratorClass;
|
||||
}
|
||||
|
||||
public Role getStaffGroup() {
|
||||
return staffGroup;
|
||||
public Role getStaffRole() {
|
||||
return staffRole;
|
||||
}
|
||||
|
||||
public void setStaffGroup(final Role staffGroup) {
|
||||
this.staffGroup = staffGroup;
|
||||
public void setStaffRole(final Role staffRole) {
|
||||
this.staffRole = staffRole;
|
||||
}
|
||||
|
||||
public Role getViewersGroup() {
|
||||
return viewersGroup;
|
||||
public Role getViewersRole() {
|
||||
return viewersRole;
|
||||
}
|
||||
|
||||
public void setViewersGroup(final Role viewersGroup) {
|
||||
this.viewersGroup = viewersGroup;
|
||||
public void setViewersRole(final Role viewersRole) {
|
||||
this.viewersRole = viewersRole;
|
||||
}
|
||||
|
||||
public String getDefaultLocale() {
|
||||
public Locale getDefaultLocale() {
|
||||
return defaultLocale;
|
||||
}
|
||||
|
||||
public void setDefaultLocale(final String defaultLocale) {
|
||||
public void setDefaultLocale(final Locale defaultLocale) {
|
||||
this.defaultLocale = defaultLocale;
|
||||
}
|
||||
|
||||
|
|
@ -135,6 +163,8 @@ public class ContentSection extends CcmApplication implements Serializable {
|
|||
public int hashCode() {
|
||||
int hash = super.hashCode();
|
||||
hash = 47 * hash + Objects.hashCode(label);
|
||||
hash = 47 * hash + Objects.hashCode(rootDocumentsFolder);
|
||||
hash = 47 * hash + Objects.hashCode(rootAssetsFolder);
|
||||
hash = 47 * hash + Objects.hashCode(pageResolverClass);
|
||||
hash = 47 * hash + Objects.hashCode(itemResolverClass);
|
||||
hash = 47 * hash + Objects.hashCode(templateResolverClass);
|
||||
|
|
@ -165,6 +195,12 @@ public class ContentSection extends CcmApplication implements Serializable {
|
|||
if (!Objects.equals(label, other.getLabel())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(rootDocumentsFolder, other.getRootDocumentsFolder())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(rootAssetsFolder, other.getRootAssetsFolder())) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(pageResolverClass, other.getPageResolverClass())) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -188,18 +224,23 @@ public class ContentSection extends CcmApplication implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString(final String data) {
|
||||
return super.toString(String.format(", label = \"%s\", "
|
||||
return super.toString(String.format(
|
||||
", label = \"%s\", "
|
||||
+ "rootDocumentsFolder = \"%s\", "
|
||||
+ "rootAssetsFolder = \"%s\", "
|
||||
+ "pageResolverClass = \"%s\", "
|
||||
+ "itemResolverClass = \"%s\", "
|
||||
+ "templateResolverClass = \"%s\", "
|
||||
+ "xmlGeneratorClass = \"%s\", "
|
||||
+ "defaultLocale = \"%s\"%s",
|
||||
label,
|
||||
Objects.toString(rootDocumentsFolder),
|
||||
Objects.toString(rootAssetsFolder),
|
||||
pageResolverClass,
|
||||
itemResolverClass,
|
||||
templateResolverClass,
|
||||
xmlGeneratorClass,
|
||||
defaultLocale,
|
||||
Objects.toString(defaultLocale),
|
||||
data));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ import javax.persistence.Table;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "content_types", schema = DB_SCHEMA)
|
||||
@Table(name = "CONTENT_TYPES", schema = DB_SCHEMA)
|
||||
public class ContentType extends CcmObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2708659750560382851L;
|
||||
|
||||
@Column(name = "content_item_class", length = 1024)
|
||||
@Column(name = "CONTENT_ITEM_CLASS", length = 1024)
|
||||
private String contentItemClass;
|
||||
|
||||
@Embedded
|
||||
|
|
@ -69,10 +69,10 @@ public class ContentType extends CcmObject implements Serializable {
|
|||
))
|
||||
private LocalizedString description;
|
||||
|
||||
@Column(name = "ancestors", length = 1024)
|
||||
@Column(name = "ANCESTORS", length = 1024)
|
||||
private String ancestors;
|
||||
|
||||
@Column(name = "descendants", length = 1024)
|
||||
@Column(name = "DESCENDANTS", length = 1024)
|
||||
private String descendants;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.libreccm.l10n.LocalizedString;
|
|||
*/
|
||||
@Entity
|
||||
@Audited
|
||||
@Table(name = "articles", schema = DB_SCHEMA)
|
||||
@Table(name = "ARTICLES", schema = DB_SCHEMA)
|
||||
public class GenericArticle extends ContentItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6737443527969703121L;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
author: Jens Pelzetter
|
||||
-->
|
||||
|
||||
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||
version="2.1">
|
||||
|
||||
<persistence-unit name="LibreCCM" transaction-type="JTA">
|
||||
|
||||
<!--
|
||||
Enforce JPA provider
|
||||
Not really necessary here because we don't use any Hibernate
|
||||
specific features, but makes it easier to manage to database
|
||||
creation scripts.
|
||||
-->
|
||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||
|
||||
<jta-data-source>java:/comp/env/jdbc/libreccm/db</jta-data-source>
|
||||
|
||||
<properties>
|
||||
<!-- Properties for Hibernate -->
|
||||
<property name="hibernate.hbm2ddl.auto" value="validate"/>
|
||||
<property name="hibernate.connection.autocommit" value="false" />
|
||||
<property name="hibernate.id.new_generator_mappings" value="true"/>
|
||||
|
||||
<!--
|
||||
Properties for Hibernate Envers
|
||||
We are using the ValidityAuditStrategy here because it is faster
|
||||
when querying data than the DefaultStrategy
|
||||
-->
|
||||
<property name="org.hibernate.envers.audit_strategy"
|
||||
value="org.hibernate.envers.strategy.ValidityAuditStrategy"/>
|
||||
</properties>
|
||||
|
||||
</persistence-unit>
|
||||
|
||||
</persistence>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.librecms.assets;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.libreccm.tests.categories.UnitTest;
|
||||
import org.libreccm.testutils.EqualsVerifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
@org.junit.experimental.categories.Category(UnitTest.class)
|
||||
public class EqualsAndHashCodeTest extends EqualsVerifier {
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Class<?>> data() {
|
||||
return Arrays.asList(new Class<?>[]{
|
||||
Asset.class,
|
||||
ReusableAsset.class
|
||||
});
|
||||
}
|
||||
|
||||
public EqualsAndHashCodeTest(final Class<?> clazz) {
|
||||
super(clazz);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.librecms.attachments;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.libreccm.tests.categories.UnitTest;
|
||||
import org.libreccm.testutils.EqualsVerifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
@org.junit.experimental.categories.Category(UnitTest.class)
|
||||
public class EqualsAndHashCodeTest extends EqualsVerifier {
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Class<?>> data() {
|
||||
return Arrays.asList(new Class<?>[]{
|
||||
ItemAttachment.class,
|
||||
AttachmentList.class
|
||||
});
|
||||
}
|
||||
|
||||
public EqualsAndHashCodeTest(final Class<?> clazz) {
|
||||
super(clazz);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.librecms.contentsection;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.Domain;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.Resource;
|
||||
import org.libreccm.security.Group;
|
||||
import org.libreccm.security.Role;
|
||||
import org.libreccm.security.User;
|
||||
import org.libreccm.tests.categories.UnitTest;
|
||||
import org.libreccm.testutils.EqualsVerifier;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
@org.junit.experimental.categories.Category(UnitTest.class)
|
||||
public class EqualsAndHashCodeTest extends EqualsVerifier {
|
||||
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Class<?>> data() {
|
||||
return Arrays.asList(new Class<?>[]{
|
||||
ContentItem.class,
|
||||
ContentSection.class,
|
||||
ContentType.class
|
||||
});
|
||||
}
|
||||
|
||||
public EqualsAndHashCodeTest(final Class<?> clazz) {
|
||||
super(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addPrefabValues(
|
||||
final nl.jqno.equalsverifier.EqualsVerifier<?> verifier) {
|
||||
|
||||
final ContentItem item1 = new ContentItem();
|
||||
item1.setObjectId(-1100);
|
||||
item1.setDisplayName("Object 1");
|
||||
|
||||
final ContentItem item2 = new ContentItem();
|
||||
item2.setObjectId(-1200);
|
||||
item2.setDisplayName("Object 2");
|
||||
|
||||
final ContentSection section1 = new ContentSection();
|
||||
section1.setObjectId(-2100);
|
||||
section1.setDisplayName("Section 1");
|
||||
|
||||
final ContentSection section2 = new ContentSection();
|
||||
section2.setObjectId(-2200);
|
||||
section2.setDisplayName("Section 2");
|
||||
|
||||
final CcmObject object1 = new CcmObject();
|
||||
object1.setObjectId(-3100);
|
||||
object1.setDisplayName("Object 1");
|
||||
|
||||
final CcmObject object2 = new CcmObject();
|
||||
object2.setObjectId(-3200);
|
||||
object2.setDisplayName("Object 2");
|
||||
|
||||
final Category category1 = new Category();
|
||||
category1.setObjectId(-4100);
|
||||
category1.setDisplayName("Category 1");
|
||||
|
||||
final Category category2 = new Category();
|
||||
category2.setObjectId(-4200);
|
||||
category2.setDisplayName("Category 2");
|
||||
|
||||
final ContentType contentType1 = new ContentType();
|
||||
contentType1.setObjectId(-5100);
|
||||
contentType1.setDisplayName("Content Type 1");
|
||||
|
||||
final ContentType contentType2 = new ContentType();
|
||||
contentType2.setObjectId(-5200);
|
||||
contentType2.setDisplayName("Content Type 2");
|
||||
|
||||
final Role role1 = new Role();
|
||||
role1.setName("role1");
|
||||
|
||||
final Role role2 = new Role();
|
||||
role2.setName("role2");
|
||||
|
||||
final User user1 = new TestUser();
|
||||
user1.setName("user1");
|
||||
|
||||
final User user2 = new TestUser();
|
||||
user2.setName("user2");
|
||||
|
||||
final Group group1 = new Group();
|
||||
group1.setName("group1");
|
||||
|
||||
final Group group2 = new Group();
|
||||
group2.setName("group2");
|
||||
|
||||
final CcmApplication application1 = new CcmApplication();
|
||||
application1.setDisplayName("Application 1");
|
||||
|
||||
final CcmApplication application2 = new CcmApplication();
|
||||
application2.setDisplayName("Application 2");
|
||||
|
||||
final Domain domain1 = new Domain();
|
||||
domain1.setDisplayName("Domain 1");
|
||||
|
||||
final Domain domain2 = new Domain();
|
||||
domain2.setDisplayName("Domain 2");
|
||||
|
||||
final Resource resource1 = new Resource();
|
||||
resource1.setDisplayName("Resource 1");
|
||||
|
||||
final Resource resource2 = new Resource();
|
||||
resource2.setDisplayName("Resource 2");
|
||||
|
||||
verifier
|
||||
.withPrefabValues(ContentItem.class, item1, item2)
|
||||
.withPrefabValues(ContentSection.class, section1, section2)
|
||||
.withPrefabValues(CcmObject.class, object1, object2)
|
||||
.withPrefabValues(Category.class, category1, category2)
|
||||
.withPrefabValues(ContentType.class, contentType1, contentType2)
|
||||
.withPrefabValues(Role.class, role1, role2)
|
||||
.withPrefabValues(User.class, user1, user2)
|
||||
.withPrefabValues(Group.class, group1, group2)
|
||||
.withPrefabValues(CcmApplication.class, application1, application2)
|
||||
.withPrefabValues(Domain.class, domain1, domain2)
|
||||
.withPrefabValues(Resource.class, resource1, resource2);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link User} has a protected constructor, so have have do this to create
|
||||
* users for the test...
|
||||
*/
|
||||
private class TestUser extends User {
|
||||
|
||||
private static final long serialVersionUID = -9052762220990453621L;
|
||||
|
||||
protected TestUser() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.libreccm.core;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.libreccm.categorization.Categorization;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryManager;
|
||||
|
|
@ -39,6 +38,7 @@ import javax.validation.constraints.NotNull;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -48,6 +48,8 @@ import java.util.Objects;
|
|||
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
/**
|
||||
* Root class of all entities in LibreCCM which need categorisation and
|
||||
* permission services.
|
||||
|
|
@ -105,6 +107,7 @@ public class CcmObject implements Identifiable, Serializable {
|
|||
* A human readable name identifying this {@code CcmObject}
|
||||
*/
|
||||
@Column(name = "DISPLAY_NAME")
|
||||
@Audited
|
||||
@XmlElement(name = "display-name", namespace = CORE_XML_NS)
|
||||
private String displayName;
|
||||
|
||||
|
|
@ -364,11 +367,13 @@ public class CcmObject implements Identifiable, Serializable {
|
|||
return String.format(
|
||||
"%s{ "
|
||||
+ "objectId = %d, "
|
||||
+ "uuid = %s, "
|
||||
+ "displayName = \"%s\""
|
||||
+ "%s"
|
||||
+ " }",
|
||||
super.toString(),
|
||||
objectId,
|
||||
uuid,
|
||||
displayName,
|
||||
data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
create table CCM_CORE.CCM_OBJECTS_AUD (
|
||||
OBJECT_ID bigint not null,
|
||||
REV integer not null,
|
||||
REVTYPE tinyint,
|
||||
REVEND integer,
|
||||
DISPLAY_NAME varchar(255),
|
||||
primary key (OBJECT_ID, REV)
|
||||
);
|
||||
|
||||
alter table CCM_CORE.CCM_OBJECTS_AUD
|
||||
add constraint FKr00eauutiyvocno8ckx6h9nw6
|
||||
foreign key (REV)
|
||||
references CCM_CORE.CCM_REVISIONS;
|
||||
|
||||
alter table CCM_CORE.CCM_OBJECTS_AUD
|
||||
add constraint FKo5s37ctcdny7tmewjwv7705h5
|
||||
foreign key (REVEND)
|
||||
references CCM_CORE.CCM_REVISIONS;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
create table CCM_CORE.CCM_OBJECTS_AUD (
|
||||
OBJECT_ID int8 not null,
|
||||
REV int4 not null,
|
||||
REVTYPE int2,
|
||||
REVEND int4,
|
||||
DISPLAY_NAME varchar(255),
|
||||
primary key (OBJECT_ID, REV)
|
||||
);
|
||||
|
||||
alter table CCM_CORE.CCM_OBJECTS_AUD
|
||||
add constraint FKr00eauutiyvocno8ckx6h9nw6
|
||||
foreign key (REV)
|
||||
references CCM_CORE.CCM_REVISIONS;
|
||||
|
||||
alter table CCM_CORE.CCM_OBJECTS_AUD
|
||||
add constraint FKo5s37ctcdny7tmewjwv7705h5
|
||||
foreign key (REVEND)
|
||||
references CCM_CORE.CCM_REVISIONS;
|
||||
Loading…
Reference in New Issue