CCM NG/ccm-cms: Refactored/optimised struture for Assets/Attachments.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4387 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-10-17 17:00:49 +00:00
parent 8c9819fce0
commit 1ea46cce5a
22 changed files with 1268 additions and 353 deletions

View File

@ -110,7 +110,7 @@ public class Utilities {
* @deprecated Use Service.getAssetURL(BinaryAsset asset) instead * @deprecated Use Service.getAssetURL(BinaryAsset asset) instead
*/ */
public static String getAssetURL(BinaryAsset asset) { public static String getAssetURL(BinaryAsset asset) {
return getAssetURL(asset.getAssetId()); return getAssetURL(asset.getObjectId());
} }
/** /**
@ -131,7 +131,7 @@ public class Utilities {
/** /**
* Constuct a URL which serves an image. * Construct a URL which serves an image.
* *
* @param asset The image asset whose image is to be served * @param asset The image asset whose image is to be served
* @return the URL which will serve the specified image asset * @return the URL which will serve the specified image asset
@ -141,7 +141,7 @@ public class Utilities {
// StringBuffer buf = new StringBuffer(getServiceURL()); // StringBuffer buf = new StringBuffer(getServiceURL());
StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL ); StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL );
buf.append("stream/image/?"); buf.append("stream/image/?");
buf.append(CmsConstants.IMAGE_ID).append("=").append(asset.getAssetId()); buf.append(CmsConstants.IMAGE_ID).append("=").append(asset.getObjectId());
return buf.toString(); return buf.toString();
} }

View File

@ -19,30 +19,37 @@
package org.librecms.assets; package org.librecms.assets;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import org.libreccm.core.Identifiable; import org.libreccm.categorization.Categorization;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.InheritsPermissions;
import org.librecms.CmsConstants;
import org.librecms.attachments.ItemAttachment;
import java.io.Serializable; import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import javax.persistence.AssociationOverride; import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance; import javax.persistence.Inheritance;
import javax.persistence.InheritanceType; import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* Base class for all assets providing common fields. This class is
* <strong>not</strong> indented for direct use. Only to sub classes should be
* used.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@ -52,26 +59,23 @@ import static org.librecms.CmsConstants.*;
@Audited @Audited
@NamedQueries({ @NamedQueries({
@NamedQuery(name = "Asset.findByUuid", @NamedQuery(name = "Asset.findByUuid",
query = "SELECT a FROM Asset a WHERE a.uuid = :uuid"), query = "SELECT a FROM Asset a WHERE a.uuid = :uuid")
,
@NamedQuery(name = "Asset.findByType", @NamedQuery(name = "Asset.findByType",
query = "SELECT a FROM Asset a " query = "SELECT a FROM Asset a "
+ "WHERE TYPE(a) = :type"), + "WHERE TYPE(a) = :type")
,
@NamedQuery(name = "Asset.findByUuidAndType", @NamedQuery(name = "Asset.findByUuidAndType",
query = "SELECT a FROM Asset a " query = "SELECT a FROM Asset a "
+ "WHERE a.uuid = :uuid " + "WHERE a.uuid = :uuid "
+ "AND TYPE(a) = :type") + "AND TYPE(a) = :type")
}) })
public class Asset implements Identifiable, Serializable { public class Asset extends CcmObject implements InheritsPermissions {
private static final long serialVersionUID = -3499741368562653529L; private static final long serialVersionUID = -3499741368562653529L;
@Column(name = "ASSET_ID") @OneToMany(mappedBy = "asset")
@Id private List<ItemAttachment<?>> itemAttachments;
@GeneratedValue(strategy = GenerationType.AUTO)
private long assetId;
@Column(name = "UUID", unique = true)
private String uuid;
@Embedded @Embedded
@AssociationOverride( @AssociationOverride(
@ -89,23 +93,6 @@ public class Asset implements Identifiable, Serializable {
title = new LocalizedString(); title = new LocalizedString();
} }
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() { public LocalizedString getTitle() {
return title; return title;
} }
@ -114,20 +101,62 @@ public class Asset implements Identifiable, Serializable {
this.title = title; this.title = title;
} }
public List<ItemAttachment<?>> getItemAttachments() {
if (itemAttachments == null) {
return new ArrayList<>();
} else {
return Collections.unmodifiableList(itemAttachments);
}
}
@Override
public Optional<CcmObject> getParent() {
// For sharable assets the parent is the folder in the asset is stored
final Optional<CcmObject> folder = getFolder();
if (folder.isPresent()) {
return folder;
}
if (itemAttachments == null || itemAttachments.isEmpty()) {
return Optional.empty();
} else {
return Optional.of(itemAttachments.get(0).getAttachmentList()
.getItem());
}
}
private Optional<CcmObject> getFolder() {
final Optional<Categorization> result = getCategories()
.stream()
.filter(categorization -> CmsConstants.CATEGORIZATION_TYPE_FOLDER
.equals(categorization.getType()))
.findFirst();
if (result.isPresent()) {
return Optional.of(result.get().getCategory());
} else {
return Optional.empty();
}
}
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 3; int hash = super.hashCode();
hash = 97 * hash + (int) (assetId ^ (assetId >>> 32));
hash = 97 * hash + Objects.hashCode(uuid);
hash = 97 * hash + Objects.hashCode(title); hash = 97 * hash + Objects.hashCode(title);
return hash; return hash;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(final Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (!super.equals(obj)) {
return false;
}
if (obj == null) { if (obj == null) {
return false; return false;
} }
@ -138,37 +167,19 @@ public class Asset implements Identifiable, Serializable {
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
if (assetId != other.getAssetId()) {
return false;
}
if (!Objects.equals(uuid, other.getUuid())) {
return false;
}
return Objects.equals(title, other.getTitle()); return Objects.equals(title, other.getTitle());
} }
@Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof Asset; return obj instanceof Asset;
} }
@Override @Override
public final String toString() {
return toString("");
}
public String toString(final String data) { public String toString(final String data) {
return String.format( return super.toString(String.format(", title = \"%s\"%s",
"%s{ " title,
+ "assetIdd = %d, " data));
+ "uuid = %s, "
+ "title = {}%s"
+ " }",
super.toString(),
assetId,
uuid,
Objects.toString(title),
data);
} }
} }

View File

@ -39,7 +39,7 @@ public class AssetRepository
@Override @Override
public Long getEntityId(final Asset asset) { public Long getEntityId(final Asset asset) {
return asset.getAssetId(); return asset.getObjectId();
} }
@Override @Override
@ -49,7 +49,7 @@ public class AssetRepository
@Override @Override
public boolean isNew(final Asset asset) { public boolean isNew(final Asset asset) {
return asset.getAssetId() == 0; return asset.getObjectId() == 0;
} }
public Optional<Asset> findByUuid(final String uuid) { public Optional<Asset> findByUuid(final String uuid) {

View File

@ -31,6 +31,7 @@ import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* An asset for audio files, for example podcasts of music.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */

View File

@ -42,6 +42,7 @@ import javax.persistence.Convert;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* Base class for all assets storing binary information, like videos.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */

View File

@ -35,6 +35,8 @@ import org.libreccm.l10n.LocalizedString;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* An assets for managing bookmarks which can be used to create links. Useful
* if the same link appears in multiple places.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */

View File

@ -31,6 +31,9 @@ import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* An asset for an external audio file (an audio file which is
* <strong>not</strong>
* stored in the database of LibreCCM.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */

View File

@ -31,11 +31,12 @@ import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* An asset for external videos, like videos from YouTube.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "EXTERNAL_VIDEO_ASSET", schema = DB_SCHEMA) @Table(name = "EXTERNAL_VIDEO_ASSETS", schema = DB_SCHEMA)
@Audited @Audited
public class ExternalVideoAsset extends Bookmark implements Serializable { public class ExternalVideoAsset extends Bookmark implements Serializable {

View File

@ -25,6 +25,7 @@ import org.hibernate.envers.Audited;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* An asset for making files available for download.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@ -55,7 +56,7 @@ public class File extends BinaryAsset implements Serializable {
if (!(obj instanceof File)) { if (!(obj instanceof File)) {
return false; return false;
} }
final BinaryAsset other = (File) obj; final File other = (File) obj;
return other.canEqual(this); return other.canEqual(this);
} }

View File

@ -33,6 +33,8 @@ import javax.persistence.OneToOne;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* An asset for images (in a format which can be displayed by a browser, like
* PNG, JPEG or GIF).
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */

View File

@ -1,102 +0,0 @@
/*
* 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 (!super.equals(obj)) {
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
));
}
}

View File

@ -34,20 +34,21 @@ import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* Assets for side notes (additional informations) for a content item.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "NOTES", schema = DB_SCHEMA) @Table(name = "SIDE_NOTES", schema = DB_SCHEMA)
@Audited @Audited
public class Note extends Asset implements Serializable { public class SideNote extends Asset implements Serializable {
private static final long serialVersionUID = -4566222634780521726L; private static final long serialVersionUID = -4566222634780521726L;
@Embedded @Embedded
@AssociationOverride( @AssociationOverride(
name = "values", name = "values",
joinTable = @JoinTable(name = "NOTE_TEXTS", joinTable = @JoinTable(name = "SIDE_NOTE_TEXTS",
schema = DB_SCHEMA, schema = DB_SCHEMA,
joinColumns = { joinColumns = {
@JoinColumn(name = "ASSET_ID") @JoinColumn(name = "ASSET_ID")
@ -56,7 +57,7 @@ public class Note extends Asset implements Serializable {
) )
private LocalizedString text; private LocalizedString text;
public Note() { public SideNote() {
super(); super();
text = new LocalizedString(); text = new LocalizedString();
} }
@ -88,10 +89,10 @@ public class Note extends Asset implements Serializable {
return false; return false;
} }
if (!(obj instanceof Note)) { if (!(obj instanceof SideNote)) {
return false; return false;
} }
final Note other = (Note) obj; final SideNote other = (SideNote) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
return false; return false;
} }
@ -100,7 +101,7 @@ public class Note extends Asset implements Serializable {
@Override @Override
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
return obj instanceof Note; return obj instanceof SideNote;
} }
@Override @Override

View File

@ -32,11 +32,12 @@ import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* An asset for videos.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@Entity @Entity
@Table(name = "VIDEO_ASSET", schema = DB_SCHEMA) @Table(name = "VIDEO_ASSETS", schema = DB_SCHEMA)
@Audited @Audited
public class VideoAsset extends BinaryAsset implements Serializable { public class VideoAsset extends BinaryAsset implements Serializable {

View File

@ -0,0 +1,28 @@
/*
* 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
*/
/**
* This package contains several classes for assets. Assets are containers
* for information which can be used as addendum for {@link ContentItem}s. They
* are also used for media content like images, videos or files
* like PDFs. Assets are may or may not be reusable. Reusable assets are managed
* inside special folders for each content section. If a asset from one content
* section can be used in another content section depends on the permissions
* of the author of a content item.
*/
package org.librecms.assets;

View File

@ -21,15 +21,12 @@ package org.librecms.attachments;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import org.libreccm.core.Identifiable; import org.libreccm.core.Identifiable;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.librecms.assets.Asset; import org.librecms.contentsection.ContentItem;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator;
import java.util.Objects; import java.util.Objects;
import javax.persistence.AssociationOverride; import javax.persistence.AssociationOverride;
@ -41,33 +38,57 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable; import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* A list of assets attached a {@link ContentItem}. Each {@link ContentItem}
* may have multiple lists of attachments. Each list can be identified by name
* which can be used for example by the theme to determine the position where
* the list is printed.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T>
*/ */
@Entity @Entity
@Table(schema = DB_SCHEMA, name = "ATTACHMENT_LISTS") @Table(name = "ATTACHMENT_LISTS", schema = DB_SCHEMA)
@Audited @Audited
public class AttachmentList<T extends Asset> implements Identifiable, public class AttachmentList implements Identifiable, Serializable {
List<ItemAttachment<T>>,
Serializable {
private static final long serialVersionUID = -7750330135750750047L; private static final long serialVersionUID = -7931234562247075541L;
/**
* Database ID of the list entity.
*/
@Column(name = "LIST_ID") @Column(name = "LIST_ID")
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private long listId; private long listId;
/**
* UUID of the list.
*/
@Column(name = "UUID") @Column(name = "UUID")
private String uuid; private String uuid;
/**
* The {@link ContentItem} which owns this list.
*/
@ManyToOne
@JoinColumn(name = "ITEM_ID")
private ContentItem item;
/**
* The name of the list.
*/
@Column(name = "NAME")
private String name;
/**
* The localised title of the list.
*/
@Embedded @Embedded
@AssociationOverride( @AssociationOverride(
name = "values", name = "values",
@ -78,20 +99,29 @@ public class AttachmentList<T extends Asset> implements Identifiable,
} }
) )
) )
private LocalizedString caption; private LocalizedString title;
@Column(name = "ASSET_TYPE", length = 1024) /**
private String assetType; * The description of the list.
*/
@Embedded
@AssociationOverride(
name = "values",
joinTable = @JoinTable(name = "ATTACHMENT_LIST_DESCRIPTIONS",
schema = DB_SCHEMA,
joinColumns = {
@JoinColumn(name = "LIST_ID")
}))
private LocalizedString description;
@OneToMany(targetEntity = ItemAttachment.class) @OneToMany(mappedBy = "attachmentList")
@JoinColumn(name = "LIST_ID") private List<ItemAttachment<?>> attachments;
private List<ItemAttachment<T>> attachments;
public long getListId() { public long getListId() {
return listId; return listId;
} }
protected void setListId(final long listId) { public void setListId(long listId) {
this.listId = listId; this.listId = listId;
} }
@ -104,170 +134,74 @@ public class AttachmentList<T extends Asset> implements Identifiable,
this.uuid = uuid; this.uuid = uuid;
} }
public LocalizedString getCaption() { public ContentItem getItem() {
return caption; return item;
} }
public void setCaption(final LocalizedString caption) { public void setItem(final ContentItem item) {
this.caption = caption; this.item = item;
} }
public String getAssetType() { public String getName() {
return assetType; return name;
} }
public void setAssetType(final String assetType) { public void setName(final String name) {
this.assetType = assetType; this.name = name;
} }
public List<ItemAttachment<T>> getAttachments() { public LocalizedString getTitle() {
return title;
}
public void setTitle(final LocalizedString title) {
this.title = title;
}
public LocalizedString getDescription() {
return description;
}
public void setDescription(final LocalizedString description) {
this.description = description;
}
public List<ItemAttachment<?>> getAttachments() {
if (attachments == null) { if (attachments == null) {
return null; return new ArrayList<>();
} else { } else {
return Collections.unmodifiableList(attachments); return Collections.unmodifiableList(attachments);
} }
} }
public void setAttachments(List<ItemAttachment<T>> attachments) { protected void setAttachments(final List<ItemAttachment<?>> attachments) {
this.attachments = new ArrayList<>(attachments); this.attachments = Collections.unmodifiableList(attachments);
} }
@Override protected void addAttachment(final ItemAttachment<?> attachment) {
public int size() { attachments.add(attachment);
return attachments.size();
} }
@Override protected void removeAttachment(final ItemAttachment<?> attachment) {
public boolean isEmpty() { attachments.remove(attachment);
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 @Override
public int hashCode() { public int hashCode() {
int hash = 7; int hash = 3;
hash = 97 * hash + (int) (listId ^ (listId >>> 32)); hash = 29 * hash + (int) (listId ^ (listId >>> 32));
hash = 97 * hash + Objects.hashCode(uuid); hash = 29 * hash + Objects.hashCode(uuid);
hash = 97 * hash + Objects.hashCode(caption); hash = 29 * hash + Objects.hashCode(name);
hash = 97 * hash + Objects.hashCode(assetType); hash = 29 * hash + Objects.hashCode(title);
hash = 97 * hash + Objects.hashCode(attachments); hash = 29 * hash + Objects.hashCode(description);
hash = 29 * hash + Objects.hashCode(attachments);
return hash; return hash;
} }
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (obj == null) {
@ -276,23 +210,37 @@ public class AttachmentList<T extends Asset> implements Identifiable,
if (!(obj instanceof AttachmentList)) { if (!(obj instanceof AttachmentList)) {
return false; return false;
} }
final AttachmentList<?> other = (AttachmentList<?>) obj; final AttachmentList other = (AttachmentList) obj;
if (!other.canEqual(this)) { if (!other.canEqual(this)) {
System.out.println("Same object");
return false; return false;
} }
if (listId != other.getListId()) { if (listId != other.getListId()) {
System.out.println("list ids are not equal");
return false; return false;
} }
if (!Objects.equals(uuid, other.getUuid())) { if (!Objects.equals(uuid, other.getUuid())) {
System.out.println("uuid is not equal");
return false; return false;
} }
if (!Objects.equals(caption, other.getCaption())) { if (!Objects.equals(name, other.getName())) {
System.out.println("name is not equal");
return false; return false;
} }
if (!Objects.equals(assetType, other.getAssetType())) { if (!Objects.equals(title, other.getTitle())) {
System.out.println("caption is not equal");
return false; return false;
} }
return Objects.equals(attachments, other.getAttachments()); if (!Objects.equals(description, other.getDescription())) {
System.out.println("description is not equal");
return false;
}
System.out.printf("attachments{%s}.equals({%s}) = %b\n",
Objects.toString(attachments),
Objects.toString(other.getAttachments()),
Objects.equals(attachments, other.getAttachments()));
return Objects.equals(getAttachments(), other.getAttachments());
} }
public boolean canEqual(final Object obj) { public boolean canEqual(final Object obj) {
@ -308,15 +256,17 @@ public class AttachmentList<T extends Asset> implements Identifiable,
return String.format("%s{ " return String.format("%s{ "
+ "listId = %d, " + "listId = %d, "
+ "uuid = %s, " + "uuid = %s, "
+ "name = \"%s\", "
+ "caption = { %s }, " + "caption = { %s }, "
+ "assetType = %s, " + "description = { %s }, "
+ "attachments = { %s }%s" + "attachments = { %s }%s"
+ " }", + " }",
super.toString(), super.toString(),
listId, listId,
uuid, uuid,
Objects.toString(caption), name,
assetType, Objects.toString(title),
Objects.toString(description),
Objects.toString(attachments), Objects.toString(attachments),
data); data);
} }

View File

@ -0,0 +1,100 @@
/*
* 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.libreccm.configuration.Configuration;
import org.libreccm.configuration.Setting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
* Special configuration parameters for attachments.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Configuration
public class AttachmentsConfig {
/**
* Possible names for an {@link AttachmentList} from which the authors can
* choose.
*/
@Setting
private List<String> attachmentListNames = Arrays.asList(new String[]{});
public List<String> getAttachmentListNames() {
if (attachmentListNames == null) {
return new ArrayList<>();
} else {
return new ArrayList<>(attachmentListNames);
}
}
public void setAttachmentListNames(final List<String> attachmentListNames) {
this.attachmentListNames = new ArrayList<>(attachmentListNames);
}
@Override
public int hashCode() {
int hash = 3;
hash = 79 * hash + Objects.hashCode(attachmentListNames);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof AttachmentsConfig)) {
return false;
}
final AttachmentsConfig other = (AttachmentsConfig) obj;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(getAttachmentListNames(),
other.getAttachmentListNames());
}
public boolean canEqual(final Object obj) {
return obj instanceof AttachmentsConfig;
}
@Override
public final String toString() {
return toString("");
}
public String toString(final String data) {
return String.format("%s{ "
+ "attachmentListNames = { %s }%d"
+ " }",
Objects.toString(attachmentListNames),
super.toString());
}
}

View File

@ -31,12 +31,14 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.OneToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;
/** /**
* An intermediate entity to model the relation between an {@link Asset} (either
* shared or not shared) and an {@link AttachmentList}.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T> * @param <T>
@ -49,18 +51,38 @@ public class ItemAttachment<T extends Asset> implements Identifiable,
private static final long serialVersionUID = -9005379413315191984L; private static final long serialVersionUID = -9005379413315191984L;
/**
* The ID of the attachment entity in the database.
*/
@Column(name = "ATTACHMENT_ID") @Column(name = "ATTACHMENT_ID")
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private long attachmentId; private long attachmentId;
/**
* UUID of the attachment.
*/
@Column(name = "uuid") @Column(name = "uuid")
private String uuid; private String uuid;
@OneToOne(targetEntity = Asset.class) /**
* The {@link AttachmentList} to which this attachment belongs.
*/
@ManyToOne
@JoinColumn(name = "ATTACHMENT_LIST_ID")
private AttachmentList attachmentList;
/**
* The {@link Asset} which is linked by this attachment to the
* {@link #attachmentList}.
*/
@ManyToOne(targetEntity = Asset.class)
@JoinColumn(name = "ASSET_ID") @JoinColumn(name = "ASSET_ID")
private T asset; private T asset;
/**
* The sort key of this attachment in {@link #attachmentList}.
*/
@Column(name = "SORT_KEY") @Column(name = "SORT_KEY")
private long sortKey; private long sortKey;
@ -81,6 +103,14 @@ public class ItemAttachment<T extends Asset> implements Identifiable,
this.uuid = uuid; this.uuid = uuid;
} }
public AttachmentList getAttachmentList() {
return attachmentList;
}
protected void setAttachmentList(final AttachmentList attachmentList) {
this.attachmentList = attachmentList;
}
public T getAsset() { public T getAsset() {
return asset; return asset;
} }
@ -102,6 +132,7 @@ public class ItemAttachment<T extends Asset> implements Identifiable,
int hash = 3; int hash = 3;
hash hash
= 71 * hash + (int) (attachmentId ^ (attachmentId >>> 32)); = 71 * hash + (int) (attachmentId ^ (attachmentId >>> 32));
hash = 71 * hash + Objects.hashCode(uuid);
hash = 71 * hash + Objects.hashCode(asset); hash = 71 * hash + Objects.hashCode(asset);
hash = 71 * hash + (int) (sortKey ^ (sortKey >>> 32)); hash = 71 * hash + (int) (sortKey ^ (sortKey >>> 32));
return hash; return hash;
@ -125,6 +156,9 @@ public class ItemAttachment<T extends Asset> implements Identifiable,
if (attachmentId != other.getAttachmentId()) { if (attachmentId != other.getAttachmentId()) {
return false; return false;
} }
if (!Objects.equals(uuid, other.getUuid())) {
return false;
}
if (sortKey != other.getSortKey()) { if (sortKey != other.getSortKey()) {
return false; return false;
} }

View File

@ -205,7 +205,7 @@ public class ContentItem extends CcmObject implements Serializable,
@OneToMany @OneToMany
@JoinColumn(name = "CONTENT_ITEM_ID") @JoinColumn(name = "CONTENT_ITEM_ID")
private List<AttachmentList<?>> attachments; private List<AttachmentList> attachments;
@OneToOne @OneToOne
@JoinColumn(name = "LIFECYCLE_ID") @JoinColumn(name = "LIFECYCLE_ID")
@ -296,14 +296,22 @@ public class ContentItem extends CcmObject implements Serializable,
this.ancestors = ancestors; this.ancestors = ancestors;
} }
public List<AttachmentList<?>> getAttachments() { public List<AttachmentList> getAttachments() {
return Collections.unmodifiableList(attachments); return Collections.unmodifiableList(attachments);
} }
protected void setAttachments(final List<AttachmentList<?>> attachments) { protected void setAttachments(final List<AttachmentList> attachments) {
this.attachments = attachments; this.attachments = attachments;
} }
protected void addAttachmentList(final AttachmentList attachmentList) {
attachments.add(attachmentList);
}
protected void removeAttachmentList(final AttachmentList attachmentList) {
attachments.remove(attachmentList);
}
public Lifecycle getLifecycle() { public Lifecycle getLifecycle() {
return lifecycle; return lifecycle;
} }

View File

@ -0,0 +1,396 @@
alter table CCM_CMS.ASSETS
drop constraint UK_9l2v1u9beyemgjwqx7isbumwh;
alter table CCM_CMS.ASSETS_AUD
drop constraint FK4m4op9s9h5qhndcsssbu55gr2;
alter table CCM_CMS.AttachmentList_ItemAttachment_AUD
drop constraint FKduowjilu7dqfs2oja88tr5oim;
alter table CCM_CMS.AttachmentList_ItemAttachment_AUD
drop constraint FKdtm7qp3n6cojbm9b916plsgtx;
alter table CCM_CMS.ASSETS_AUD
drop constraint FK586j3p95nw2oa6yd06xdw0o5u;
alter table CCM_CMS.ATTACHMENTS
drop constraint FK622uanry14vw27de3d2v9uy57;
alter table CCM_CMS.ASSETS
alter column ASSET_ID rename to OBJECT_ID;
alter table CCM_CMS.ASSETS
drop column if exists UUID;
alter table CCM_CMS.ASSETS_AUD
alter column ASSET_ID rename to object_id;
alter table CCM_CMS.ASSETS_AUD
drop column if exists revtype;
alter table CCM_CMS.ASSETS_AUD
drop column if exists revend;
alter table CCM_CMS.ASSETS_AUD
drop column if exists uuid;
alter table CCM_CMS.BOOKMARKS
drop constraint FKhs1tohpjry5sqdpl3cijl5ppk;
alter table CCM_CMS.BOOKMARKS_AUD
drop constraint FKjrk2tah1gyn67acth3g7olvuc;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS
drop constraint FK5sxviewjxfgk0at60emrpuh3n;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS_AUD
drop constraint FK6814o1fnh49p5ij9cfvr7y00s;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSET
drop constraint FKc6m77lkbfa5ym2s8sq00jkyjf;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSET_AUD
drop constraint FKd5efitnmsrko2vq48ei1mclfv;
alter table CCM_CMS.FILES
drop constraint FK4e8p3tu8ocy43ofs9uifuk8gh;
alter table CCM_CMS.FILES_AUD
drop constraint FK3c9xf8w1dr3q0grxslguvviqn;
alter table CCM_CMS.IMAGES
drop constraint FK9mgknvtu1crw4el5d4sqy8d6c;
alter table CCM_CMS.IMAGES_AUD
drop constraint FK6xggeoexci2har3mceo9naqiy;
alter table CCM_CMS.LEGAL_METADATA
drop constraint FKjxss2fb6khhn68e8ccuksl9hk;
alter table CCM_CMS.LEGAL_METADATA_AUD
drop constraint FKofjkwpepeyb6e8tytnhjfvx49;
alter table CCM_CMS.NOTE_TEXTS
drop constraint FKa0yp21m25o7omtnag0eet8v8q;
alter table CCM_CMS.RELATED_LINKS
drop constraint FKf4r30ra4a2ajuky0tk4lc06n5;
alter table CCM_CMS.RELATED_LINKS_AUD
drop constraint FKkda2cf5ynu7v7udi0ytfmr9ij;
alter table CCM_CMS.REUSABLE_ASSETS
drop constraint FKngdq6f077q6ndqn9o3jc6k14a;
alter table CCM_CMS.REUSABLE_ASSETS
drop constraint FKhvf4mfltp8abbr5u0qgjm2jk2;
alter table CCM_CMS.REUSABLE_ASSETS_AUD
drop constraint FKgyc5gd3cffox4wvjoir6i4gxt;
alter table CCM_CMS.VIDEO_ASSET
drop constraint FKdjjbp8p48xwfqhw0oo79tkyjy;
alter table CCM_CMS.VIDEO_ASSET
drop constraint FK9cynf36vykykyaga2j1xs7jkx;
alter table CCM_CMS.VIDEO_ASSET_AUD
drop constraint FK7qsbfxxg6ixpkjjor4nbkd63i;
create table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS (
LIST_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALE varchar(255) not null,
primary key (LIST_ID, LOCALE)
);
create table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS_AUD (
REV integer not null,
LIST_ID bigint not null,
LOCALIZED_VALUE longvarchar not null,
LOCALE varchar(255) not null,
REVTYPE tinyint,
REVEND integer,
primary key (REV, LIST_ID, LOCALIZED_VALUE, LOCALE)
);
alter table CCM_CMS.ATTACHMENT_LISTS
drop column asset_type;
alter table CCM_CMS.ATTACHMENT_LISTS
add column NAME varchar(255);
alter table CCM_CMS.ATTACHMENT_LISTS
add column ITEM_ID bigint;
alter table CCM_CMS.ATTACHMENT_LISTS_AUD
drop column ASSET_TYPE;
alter table CCM_CMS.ATTACHMENT_LISTS_AUD
add column NAME varchar(255);
alter table CCM_CMS.ATTACHMENT_LISTS_AUD
add column ITEM_ID bigint;
alter table CCM_CMS.AUDIO_ASSETS
drop constraint FKa1m18ejmeknjiibvh2dac6tas;
alter table CCM_CMS.AUDIO_ASSETS_AUD
drop constraint FKaf381a7d420ru9114rqcpr2b4;
alter table CCM_CMS.BINARY_ASSETS
drop constraint FK65sp6cl7d8qjmqgku1bjtpsdy;
alter table CCM_CMS.BINARY_ASSETS_AUD
drop constraint FKovfkjrq3eka9fsfe5sidw07p3;
drop table if exists CCM_CMS.AttachmentList_ItemAttachment_AUD;
alter table CCM_CMS.AUDIO_ASSETS
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.AUDIO_ASSETS_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.BINARY_ASSETS
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.BINARY_ASSETS_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.BOOKMARKS
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.BOOKMARKS_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSET
rename to CCM_CMS.EXTERNAL_VIDEO_ASSETS;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSET_AUD
rename to CCM_CMS.EXTERNAL_VIDEO_ASSETS_AUD;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSETS
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSETS_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.FILES
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.FILES_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.IMAGES
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.IMAGES_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.LEGAL_METADATA
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.LEGAL_METADATA_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.NOTES
RENAME TO CCM_CMS.SIDE_NOTES;
alter table CCM_CMS.NOTES_AUD
RENAME TO CCM_CMS.SIDE_NOTES_AUD;
alter table CCM_CMS.SIDE_NOTES
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.SIDE_NOTES_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.RELATED_LINKS
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.RELATED_LINKS_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
drop table if exists REUSABLE_ASSETS;
drop table if exists REUSABLE_ASSETS_AUD;
alter table CCM_CMS.VIDEO_ASSET
rename to CCM_CMS.VIDEO_ASSETS;
alter table CCM_CMS.VIDEO_ASSET_AUD
rename to CCM_CMS.VIDEO_ASSETS_AUD;
alter table CCM_CMS.VIDEO_ASSETS
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.VIDEO_ASSETS_AUD
alter column ASSET_ID RENAME TO OBJECT_ID;
alter table CCM_CMS.NOTE_TEXTS
rename to CCM_CMS.SIDE_NOTE_TEXTS;
alter table CCM_CMS.ATTACHMENTS
add column ATTACHMENT_LIST_ID bigint;
alter table CCM_CMS.ASSETS
add constraint FKlbiojib44ujxv9eee1sjn67qk
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CMS.ASSETS_AUD
add constraint FKi5q560xg9357da8gc5sukqbw8
foreign key (OBJECT_ID, REV)
references CCM_CORE.CCM_OBJECTS_AUD;
alter table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS
add constraint FKixgpo00r1cqq5jw1s7v6fchpn
foreign key (LIST_ID)
references CCM_CMS.ATTACHMENT_LISTS;
alter table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS_AUD
add constraint FKqhqkm6tas9fdmggv4k1vj0nc7
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS_AUD
add constraint FKqv2o9jffgok4518fb5c85552l
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.ATTACHMENT_LISTS
add constraint FKqyj7ifjfyp7kmsj8fiyxn0am3
foreign key (ITEM_ID)
references CCM_CMS.CONTENT_ITEMS;
alter table CCM_CMS.ATTACHMENTS
add constraint FK3mqbt13sbed2ae0esrps4p0oh
foreign key (ATTACHMENT_LIST_ID)
references CCM_CMS.ATTACHMENT_LISTS;
alter table CCM_CMS.AUDIO_ASSETS
add constraint FKgxpsfjlfsk609c0w2te18y90v
foreign key (OBJECT_ID)
references CCM_CMS.BINARY_ASSETS;
alter table CCM_CMS.AUDIO_ASSETS_AUD
add constraint FKbt11nwbde1en1upceratct6s3
foreign key (OBJECT_ID, REV)
references CCM_CMS.BINARY_ASSETS_AUD;
alter table CCM_CMS.BINARY_ASSETS
add constraint FKltx0jq1u1aflrd20k1c77m8vh
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.BINARY_ASSETS_AUD
add constraint FK1qfap4mxprjk7gnjdcvdxr5mv
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.BOOKMARKS
add constraint FKksnngecvvxmsxdvri4shby2hy
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.BOOKMARKS_AUD
add constraint FK47cpxaw9vnnes2dbr6h3toirl
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS
add constraint FK36xjlvslk0vlekn9lsc7x1c7a
foreign key (OBJECT_ID)
references CCM_CMS.BOOKMARKS;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS_AUD
add constraint FKp3jndaw4k35wb3d6hg5ng4xww
foreign key (OBJECT_ID, REV)
references CCM_CMS.BOOKMARKS_AUD;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSETS
add constraint FK74al02r60wmjgpy009b2291l7
foreign key (OBJECT_ID)
references CCM_CMS.BOOKMARKS;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSETS_AUD
add constraint FKg7q8dy5xbemdw7whdn68xv297
foreign key (OBJECT_ID, REV)
references CCM_CMS.BOOKMARKS_AUD;
alter table CCM_CMS.FILES
add constraint FKpg74w39tfbbuqhcy21u61q138
foreign key (OBJECT_ID)
references CCM_CMS.BINARY_ASSETS;
alter table CCM_CMS.FILES_AUD
add constraint FKdl876a4twd0gkranwqkdmxnwy
foreign key (OBJECT_ID, REV)
references CCM_CMS.BINARY_ASSETS_AUD;
alter table CCM_CMS.IMAGES
add constraint FKmdqranhdstkn6m6d73l15amxs
foreign key (OBJECT_ID)
references CCM_CMS.BINARY_ASSETS;
alter table CCM_CMS.IMAGES_AUD
add constraint FK4jsrdpe6d8is0ybx2p7sxivwf
foreign key (OBJECT_ID, REV)
references CCM_CMS.BINARY_ASSETS_AUD;
alter table CCM_CMS.LEGAL_METADATA
add constraint FKnxl7uyv1ks0qabgeienx2t9d1
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.LEGAL_METADATA_AUD
add constraint FKpt3eqil7iij6t5h1lrnjbb5xs
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.SIDE_NOTE_TEXTS
add constraint FK79g6eg2csjaixrjr2xgael8lm
foreign key (ASSET_ID)
references CCM_CMS.SIDE_NOTES;
alter table CCM_CMS.RELATED_LINKS
add constraint FK35tv60a9kflo17h6xduvwvgis
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.RELATED_LINKS_AUD
add constraint FKiuwk6mcj3h5gccu2aviq3d8lt
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.SIDE_NOTES
add constraint FKea6cikleenmkgw5bwus22mfr3
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.SIDE_NOTES_AUD
add constraint FKl5pkg9mp2ymc2uo4kmlubyp3m
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.VIDEO_ASSETS
add constraint FKjuywvv7wq9pyid5b6ivyrc0yk
foreign key (LEGAL_METADATA_ID)
references CCM_CMS.LEGAL_METADATA;
alter table CCM_CMS.VIDEO_ASSETS
add constraint FKqt2cx1r31kqbqkimdld312i9g
foreign key (OBJECT_ID)
references CCM_CMS.BINARY_ASSETS;
alter table CCM_CMS.VIDEO_ASSETS_AUD
add constraint FKdrx9uu9a03ju7vqvkjretohpk
foreign key (OBJECT_ID, REV)
references CCM_CMS.BINARY_ASSETS_AUD;

View File

@ -0,0 +1,394 @@
alter table CCM_CMS.ASSETS
drop constraint UK_9l2v1u9beyemgjwqx7isbumwh;
alter table CCM_CMS.ASSETS_AUD
drop constraint FK4m4op9s9h5qhndcsssbu55gr2;
alter table CCM_CMS.AttachmentList_ItemAttachment_AUD
drop constraint FKduowjilu7dqfs2oja88tr5oim;
alter table CCM_CMS.AttachmentList_ItemAttachment_AUD
drop constraint FKdtm7qp3n6cojbm9b916plsgtx;
alter table CCM_CMS.ASSETS_AUD
drop constraint FK586j3p95nw2oa6yd06xdw0o5u;
alter table CCM_CMS.ATTACHMENTS
drop constraint FK622uanry14vw27de3d2v9uy57;
alter table CCM_CMS.ASSETS
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.ASSETS
drop column if exists UUID;
alter table CCM_CMS.ASSETS_AUD
rename column ASSET_ID to object_id;
alter table CCM_CMS.ASSETS_AUD
drop column if exists revtype;
alter table CCM_CMS.ASSETS_AUD
drop column if exists revend;
alter table CCM_CMS.ASSETS_AUD
drop column if exists uuid;
alter table CCM_CMS.BOOKMARKS
drop constraint FKhs1tohpjry5sqdpl3cijl5ppk;
alter table CCM_CMS.BOOKMARKS_AUD
drop constraint FKjrk2tah1gyn67acth3g7olvuc;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS
drop constraint FK5sxviewjxfgk0at60emrpuh3n;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS_AUD
drop constraint FK6814o1fnh49p5ij9cfvr7y00s;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSET
drop constraint FKc6m77lkbfa5ym2s8sq00jkyjf;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSET_AUD
drop constraint FKd5efitnmsrko2vq48ei1mclfv;
alter table CCM_CMS.FILES
drop constraint FK4e8p3tu8ocy43ofs9uifuk8gh;
alter table CCM_CMS.FILES_AUD
drop constraint FK3c9xf8w1dr3q0grxslguvviqn;
alter table CCM_CMS.IMAGES
drop constraint FK9mgknvtu1crw4el5d4sqy8d6c;
alter table CCM_CMS.IMAGES_AUD
drop constraint FK6xggeoexci2har3mceo9naqiy;
alter table CCM_CMS.LEGAL_METADATA
drop constraint FKjxss2fb6khhn68e8ccuksl9hk;
alter table CCM_CMS.LEGAL_METADATA_AUD
drop constraint FKofjkwpepeyb6e8tytnhjfvx49;
alter table CCM_CMS.NOTE_TEXTS
drop constraint FKa0yp21m25o7omtnag0eet8v8q;
alter table CCM_CMS.RELATED_LINKS
drop constraint FKf4r30ra4a2ajuky0tk4lc06n5;
alter table CCM_CMS.RELATED_LINKS_AUD
drop constraint FKkda2cf5ynu7v7udi0ytfmr9ij;
alter table CCM_CMS.REUSABLE_ASSETS
drop constraint FKngdq6f077q6ndqn9o3jc6k14a;
alter table CCM_CMS.REUSABLE_ASSETS
drop constraint FKhvf4mfltp8abbr5u0qgjm2jk2;
alter table CCM_CMS.REUSABLE_ASSETS_AUD
drop constraint FKgyc5gd3cffox4wvjoir6i4gxt;
alter table CCM_CMS.VIDEO_ASSET
drop constraint FKdjjbp8p48xwfqhw0oo79tkyjy;
alter table CCM_CMS.VIDEO_ASSET
drop constraint FK9cynf36vykykyaga2j1xs7jkx;
alter table CCM_CMS.VIDEO_ASSET_AUD
drop constraint FK7qsbfxxg6ixpkjjor4nbkd63i;
create table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS (
LIST_ID int8 not null,
LOCALIZED_VALUE text,
LOCALE varchar(255) not null,
primary key (LIST_ID, LOCALE)
);
create table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS_AUD (
REV integer not null,
LIST_ID int8 not null,
LOCALIZED_VALUE text not null,
LOCALE varchar(255) not null,
REVTYPE int2,
REVEND integer,
primary key (REV, LIST_ID, LOCALIZED_VALUE, LOCALE)
);
alter table CCM_CMS.ATTACHMENT_LISTS
drop column asset_type;
alter table CCM_CMS.ATTACHMENT_LISTS
add column NAME varchar(255);
alter table CCM_CMS.ATTACHMENT_LISTS
add column ITEM_ID int8;
alter table CCM_CMS.ATTACHMENT_LISTS_AUD
drop column ASSET_TYPE;
alter table CCM_CMS.ATTACHMENT_LISTS_AUD
add column NAME varchar(255);
alter table CCM_CMS.ATTACHMENT_LISTS_AUD
add column ITEM_ID int8;
alter table CCM_CMS.AUDIO_ASSETS
drop constraint FKa1m18ejmeknjiibvh2dac6tas;
alter table CCM_CMS.AUDIO_ASSETS_AUD
drop constraint FKaf381a7d420ru9114rqcpr2b4;
alter table CCM_CMS.BINARY_ASSETS
drop constraint FK65sp6cl7d8qjmqgku1bjtpsdy;
alter table CCM_CMS.BINARY_ASSETS_AUD
drop constraint FKovfkjrq3eka9fsfe5sidw07p3;
drop table if exists CCM_CMS.AttachmentList_ItemAttachment_AUD;
alter table CCM_CMS.AUDIO_ASSETS
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.AUDIO_ASSETS_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.BINARY_ASSETS
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.BINARY_ASSETS_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.BOOKMARKS
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.BOOKMARKS_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSET
rename to EXTERNAL_VIDEO_ASSETS;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSET_AUD
rename to EXTERNAL_VIDEO_ASSETS_AUD;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSETS
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSETS_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.FILES
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.FILES_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.IMAGES
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.IMAGES_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.LEGAL_METADATA rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.LEGAL_METADATA_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.NOTES
rename to SIDE_NOTES;
alter table CCM_CMS.NOTES_AUD
rename to SIDE_NOTES_AUD;
alter table CCM_CMS.SIDE_NOTES
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.SIDE_NOTES_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.RELATED_LINKS
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.RELATED_LINKS_AUD rename column ASSET_ID to OBJECT_ID;
drop table if exists CCM_CMS.REUSABLE_ASSETS;
drop table if exists CCM_CMS.REUSABLE_ASSETS_AUD;
alter table CCM_CMS.VIDEO_ASSET
rename to VIDEO_ASSETS;
alter table CCM_CMS.VIDEO_ASSET_AUD
rename to VIDEO_ASSETS_AUD;
alter table CCM_CMS.VIDEO_ASSETS
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.VIDEO_ASSETS_AUD
rename column ASSET_ID to OBJECT_ID;
alter table CCM_CMS.NOTE_TEXTS
rename to SIDE_NOTE_TEXTS;
alter table CCM_CMS.ATTACHMENTS
add column ATTACHMENT_LIST_ID int8;
alter table CCM_CMS.ASSETS
add constraint FKlbiojib44ujxv9eee1sjn67qk
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CMS.ASSETS_AUD
add constraint FKi5q560xg9357da8gc5sukqbw8
foreign key (OBJECT_ID, REV)
references CCM_CORE.CCM_OBJECTS_AUD;
alter table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS
add constraint FKixgpo00r1cqq5jw1s7v6fchpn
foreign key (LIST_ID)
references CCM_CMS.ATTACHMENT_LISTS;
alter table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS_AUD
add constraint FKqhqkm6tas9fdmggv4k1vj0nc7
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.ATTACHMENT_LIST_DESCRIPTIONS_AUD
add constraint FKqv2o9jffgok4518fb5c85552l
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CMS.ATTACHMENT_LISTS
add constraint FKqyj7ifjfyp7kmsj8fiyxn0am3
foreign key (ITEM_ID)
references CCM_CMS.CONTENT_ITEMS;
alter table CCM_CMS.ATTACHMENTS
add constraint FK3mqbt13sbed2ae0esrps4p0oh
foreign key (ATTACHMENT_LIST_ID)
references CCM_CMS.ATTACHMENT_LISTS;
alter table CCM_CMS.AUDIO_ASSETS
add constraint FKgxpsfjlfsk609c0w2te18y90v
foreign key (OBJECT_ID)
references CCM_CMS.BINARY_ASSETS;
alter table CCM_CMS.AUDIO_ASSETS_AUD
add constraint FKbt11nwbde1en1upceratct6s3
foreign key (OBJECT_ID, REV)
references CCM_CMS.BINARY_ASSETS_AUD;
alter table CCM_CMS.BINARY_ASSETS
add constraint FKltx0jq1u1aflrd20k1c77m8vh
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.BINARY_ASSETS_AUD
add constraint FK1qfap4mxprjk7gnjdcvdxr5mv
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.BOOKMARKS
add constraint FKksnngecvvxmsxdvri4shby2hy
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.BOOKMARKS_AUD
add constraint FK47cpxaw9vnnes2dbr6h3toirl
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS
add constraint FK36xjlvslk0vlekn9lsc7x1c7a
foreign key (OBJECT_ID)
references CCM_CMS.BOOKMARKS;
alter table CCM_CMS.EXTERNAL_AUDIO_ASSETS_AUD
add constraint FKp3jndaw4k35wb3d6hg5ng4xww
foreign key (OBJECT_ID, REV)
references CCM_CMS.BOOKMARKS_AUD;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSETS
add constraint FK74al02r60wmjgpy009b2291l7
foreign key (OBJECT_ID)
references CCM_CMS.BOOKMARKS;
alter table CCM_CMS.EXTERNAL_VIDEO_ASSETS_AUD
add constraint FKg7q8dy5xbemdw7whdn68xv297
foreign key (OBJECT_ID, REV)
references CCM_CMS.BOOKMARKS_AUD;
alter table CCM_CMS.FILES
add constraint FKpg74w39tfbbuqhcy21u61q138
foreign key (OBJECT_ID)
references CCM_CMS.BINARY_ASSETS;
alter table CCM_CMS.FILES_AUD
add constraint FKdl876a4twd0gkranwqkdmxnwy
foreign key (OBJECT_ID, REV)
references CCM_CMS.BINARY_ASSETS_AUD;
alter table CCM_CMS.IMAGES
add constraint FKmdqranhdstkn6m6d73l15amxs
foreign key (OBJECT_ID)
references CCM_CMS.BINARY_ASSETS;
alter table CCM_CMS.IMAGES_AUD
add constraint FK4jsrdpe6d8is0ybx2p7sxivwf
foreign key (OBJECT_ID, REV)
references CCM_CMS.BINARY_ASSETS_AUD;
alter table CCM_CMS.LEGAL_METADATA
add constraint FKnxl7uyv1ks0qabgeienx2t9d1
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.LEGAL_METADATA_AUD
add constraint FKpt3eqil7iij6t5h1lrnjbb5xs
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.SIDE_NOTE_TEXTS
add constraint FK79g6eg2csjaixrjr2xgael8lm
foreign key (ASSET_ID)
references CCM_CMS.SIDE_NOTES;
alter table CCM_CMS.RELATED_LINKS
add constraint FK35tv60a9kflo17h6xduvwvgis
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.RELATED_LINKS_AUD
add constraint FKiuwk6mcj3h5gccu2aviq3d8lt
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.SIDE_NOTES
add constraint FKea6cikleenmkgw5bwus22mfr3
foreign key (OBJECT_ID)
references CCM_CMS.ASSETS;
alter table CCM_CMS.SIDE_NOTES_AUD
add constraint FKl5pkg9mp2ymc2uo4kmlubyp3m
foreign key (OBJECT_ID, REV)
references CCM_CMS.ASSETS_AUD;
alter table CCM_CMS.VIDEO_ASSETS
add constraint FKjuywvv7wq9pyid5b6ivyrc0yk
foreign key (LEGAL_METADATA_ID)
references CCM_CMS.LEGAL_METADATA;
alter table CCM_CMS.VIDEO_ASSETS
add constraint FKqt2cx1r31kqbqkimdld312i9g
foreign key (OBJECT_ID)
references CCM_CMS.BINARY_ASSETS;
alter table CCM_CMS.VIDEO_ASSETS_AUD
add constraint FKdrx9uu9a03ju7vqvkjretohpk
foreign key (OBJECT_ID, REV)
references CCM_CMS.BINARY_ASSETS_AUD;

View File

@ -27,9 +27,12 @@ import org.libreccm.security.Role;
import org.libreccm.security.User; import org.libreccm.security.User;
import org.libreccm.tests.categories.UnitTest; import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier; import org.libreccm.testutils.EqualsVerifier;
import org.librecms.attachments.ItemAttachment;
import org.librecms.contentsection.ContentItem;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.UUID;
/** /**
* *
@ -43,7 +46,6 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
public static Collection<Class<?>> data() { public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{ return Arrays.asList(new Class<?>[]{
Asset.class, Asset.class,
ReusableAsset.class
}); });
} }
@ -87,12 +89,28 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
category2.setObjectId(-4200); category2.setObjectId(-4200);
category2.setDisplayName("Category 2"); category2.setDisplayName("Category 2");
final ContentItem item1 = new ContentItem();
item1.setDisplayName("item1");
final ContentItem item2 = new ContentItem();
item2.setDisplayName("item2");
final ItemAttachment<Asset> itemAttachment1 = new ItemAttachment<>();
itemAttachment1.setUuid(UUID.randomUUID().toString());
final ItemAttachment<Asset> itemAttachment2 = new ItemAttachment<>();
itemAttachment2.setUuid(UUID.randomUUID().toString());
verifier verifier
.withPrefabValues(CcmObject.class, object1, object2) .withPrefabValues(CcmObject.class, object1, object2)
.withPrefabValues(Role.class, role1, role2) .withPrefabValues(Role.class, role1, role2)
.withPrefabValues(User.class, user1, user2) .withPrefabValues(User.class, user1, user2)
.withPrefabValues(Group.class, group1, group2) .withPrefabValues(Group.class, group1, group2)
.withPrefabValues(Category.class, category1, category2); .withPrefabValues(Category.class, category1, category2)
.withPrefabValues(ContentItem.class, item1, item2)
.withPrefabValues(ItemAttachment.class,
itemAttachment1,
itemAttachment2);
} }

View File

@ -20,12 +20,18 @@ package org.librecms.attachments;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
import org.libreccm.core.CcmObject;
import org.libreccm.security.Group;
import org.libreccm.security.Role;
import org.libreccm.tests.categories.UnitTest; import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier; import org.libreccm.testutils.EqualsVerifier;
import org.librecms.assets.Asset;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.UUID;
/** /**
* *
@ -38,6 +44,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
@Parameterized.Parameters(name = "{0}") @Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() { public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{ return Arrays.asList(new Class<?>[]{
AttachmentsConfig.class,
ItemAttachment.class, ItemAttachment.class,
AttachmentList.class AttachmentList.class
}); });
@ -47,4 +54,62 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
super(clazz); super(clazz);
} }
@Override
protected void addPrefabValues(
final nl.jqno.equalsverifier.EqualsVerifier<?> verifier) {
final ContentSection section1 = new ContentSection();
section1.setDisplayName("section1");
final ContentSection section2 = new ContentSection();
section1.setDisplayName("section2");
final ContentItem item1 = new ContentItem();
item1.setDisplayName("item1");
final ContentItem item2 = new ContentItem();
item2.setDisplayName("item2");
final ItemAttachment<Asset> itemAttachment1 = new ItemAttachment<>();
itemAttachment1.setUuid(UUID.randomUUID().toString());
final ItemAttachment<Asset> itemAttachment2 = new ItemAttachment<>();
itemAttachment2.setUuid(UUID.randomUUID().toString());
final CcmObject object1 = new CcmObject();
object1.setDisplayName("object1");
final CcmObject object2 = new CcmObject();
object2.setDisplayName("object2");
final Role role1 = new Role();
role1.setName("role1");
final Role role2 = new Role();
role1.setName("role2");
final Group group1 = new Group();
group1.setName("group1");
final Group group2 = new Group();
group1.setName("group2");
final Asset asset1 = new Asset();
asset1.setDisplayName("asset1");
final Asset asset2 = new Asset();
asset2.setDisplayName("asset2");
verifier
.withPrefabValues(ContentSection.class, section1, section2)
.withPrefabValues(ContentItem.class, item1, item2)
.withPrefabValues(ItemAttachment.class,
itemAttachment1,
itemAttachment2)
.withPrefabValues(CcmObject.class, object1, object2)
.withPrefabValues(Role.class, role1, role2)
.withPrefabValues(Group.class, group1, group2)
.withPrefabValues(Asset.class, asset1, asset2);
}
} }