diff --git a/ccm-cms/src/main/java/org/librecms/attachments/AttachmentList.java b/ccm-cms/src/main/java/org/librecms/attachments/AttachmentList.java index 65aee5e19..e7cc6d739 100644 --- a/ccm-cms/src/main/java/org/librecms/attachments/AttachmentList.java +++ b/ccm-cms/src/main/java/org/librecms/attachments/AttachmentList.java @@ -45,11 +45,11 @@ import javax.persistence.Table; 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. - * + * 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 Jens Pelzetter */ @Entity @@ -58,7 +58,7 @@ import static org.librecms.CmsConstants.*; public class AttachmentList implements Identifiable, Serializable { private static final long serialVersionUID = -7931234562247075541L; - + /** * Database ID of the list entity. */ @@ -86,6 +86,13 @@ public class AttachmentList implements Identifiable, Serializable { @Column(name = "NAME") private String name; + /** + * A order index for ordering multiple attachment lists with the same + * {@link #name}. + */ + @Column(name = "LIST_ORDER") + private long order; + /** * The localised title of the list. */ @@ -150,6 +157,14 @@ public class AttachmentList implements Identifiable, Serializable { this.name = name; } + public long getOrder() { + return order; + } + + public void setOrder(final long order) { + this.order = order; + } + public LocalizedString getTitle() { return title; } @@ -192,6 +207,7 @@ public class AttachmentList implements Identifiable, Serializable { hash = 29 * hash + (int) (listId ^ (listId >>> 32)); hash = 29 * hash + Objects.hashCode(uuid); hash = 29 * hash + Objects.hashCode(name); + hash = 29 * hash + (int) (order ^ (order >>> 32)); hash = 29 * hash + Objects.hashCode(title); hash = 29 * hash + Objects.hashCode(description); hash = 29 * hash + Objects.hashCode(attachments); @@ -201,7 +217,7 @@ public class AttachmentList implements Identifiable, Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { - + return true; } if (obj == null) { @@ -224,6 +240,9 @@ public class AttachmentList implements Identifiable, Serializable { System.out.println("uuid is not equal"); return false; } + if (order != other.getOrder()) { + return false; + } if (!Objects.equals(name, other.getName())) { System.out.println("name is not equal"); return false; @@ -236,7 +255,7 @@ public class AttachmentList implements Identifiable, Serializable { System.out.println("description is not equal"); return false; } - System.out.printf("attachments{%s}.equals({%s}) = %b\n", + System.out.printf("attachments{%s}.equals({%s}) = %b\n", Objects.toString(attachments), Objects.toString(other.getAttachments()), Objects.equals(attachments, other.getAttachments())); @@ -257,6 +276,7 @@ public class AttachmentList implements Identifiable, Serializable { + "listId = %d, " + "uuid = %s, " + "name = \"%s\", " + + "order = %d, " + "caption = { %s }, " + "description = { %s }, " + "attachments = { %s }%s" @@ -265,6 +285,7 @@ public class AttachmentList implements Identifiable, Serializable { listId, uuid, name, + order, Objects.toString(title), Objects.toString(description), Objects.toString(attachments), diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_8__update_assets_and_attachments.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_8__update_assets_and_attachments.sql index c49bbd32b..3a36f52c2 100644 --- a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_8__update_assets_and_attachments.sql +++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_8__update_assets_and_attachments.sql @@ -123,6 +123,9 @@ alter table CCM_CMS.ATTACHMENT_LISTS alter table CCM_CMS.ATTACHMENT_LISTS add column ITEM_ID bigint; +alter table CCM_CMS.ATTACHMENT_LISTS + add column LIST_ORDER bigint; + alter table CCM_CMS.ATTACHMENT_LISTS_AUD drop column ASSET_TYPE; @@ -132,6 +135,9 @@ alter table CCM_CMS.ATTACHMENT_LISTS_AUD alter table CCM_CMS.ATTACHMENT_LISTS_AUD add column ITEM_ID bigint; +alter table CCM_CMS.ATTACHMENT_LISTS_AUD + add column LIST_ORDER bigint; + alter table CCM_CMS.AUDIO_ASSETS drop constraint FKa1m18ejmeknjiibvh2dac6tas; diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_8__update_assets_and_attachments.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_8__update_assets_and_attachments.sql index 874e60585..033726bc5 100644 --- a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_8__update_assets_and_attachments.sql +++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_8__update_assets_and_attachments.sql @@ -123,6 +123,9 @@ alter table CCM_CMS.ATTACHMENT_LISTS alter table CCM_CMS.ATTACHMENT_LISTS add column ITEM_ID int8; +alter table CCM_CMS.ATTACHMENT_LISTS + add column LIST_ORDER int8; + alter table CCM_CMS.ATTACHMENT_LISTS_AUD drop column ASSET_TYPE; @@ -132,6 +135,9 @@ alter table CCM_CMS.ATTACHMENT_LISTS_AUD alter table CCM_CMS.ATTACHMENT_LISTS_AUD add column ITEM_ID int8; +alter table CCM_CMS.ATTACHMENT_LISTS_AUD + add column LIST_ORDER int8; + alter table CCM_CMS.AUDIO_ASSETS drop constraint FKa1m18ejmeknjiibvh2dac6tas; diff --git a/ccm-cms/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_cms_schema.sql b/ccm-cms/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_cms_schema.sql index de7977653..8faf1c5fd 100644 --- a/ccm-cms/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_cms_schema.sql +++ b/ccm-cms/src/test/resources-wildfly-remote-h2-mem/scripts/create_ccm_cms_schema.sql @@ -6,7 +6,7 @@ DROP SEQUENCE IF EXISTS hibernate_sequence; CREATE SCHEMA ccm_core; CREATE SCHEMA ccm_cms; -create table CCM_CMS.ARTICLE_LEADS ( + create table CCM_CMS.ARTICLE_LEADS ( OBJECT_ID bigint not null, LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, @@ -106,6 +106,7 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.ATTACHMENT_LISTS ( LIST_ID bigint not null, NAME varchar(255), + LIST_ORDER bigint, UUID varchar(255), ITEM_ID bigint, CONTENT_ITEM_ID bigint, @@ -118,6 +119,7 @@ create table CCM_CMS.ARTICLE_LEADS ( REVTYPE tinyint, REVEND integer, NAME varchar(255), + LIST_ORDER bigint, UUID varchar(255), ITEM_ID bigint, primary key (LIST_ID, REV) @@ -1381,10 +1383,10 @@ create table CCM_CMS.ARTICLE_LEADS ( CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, SETTING_VALUE_BIG_DECIMAL decimal(19,2), - SETTING_VALUE_LONG bigint, - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_DOUBLE double, + SETTING_VALUE_BOOLEAN boolean, + SETTING_VALUE_LONG bigint, primary key (SETTING_ID) ); diff --git a/ccm-cms/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_cms_schema.sql b/ccm-cms/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_cms_schema.sql index 0642276a6..3daa47681 100644 --- a/ccm-cms/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_cms_schema.sql +++ b/ccm-cms/src/test/resources-wildfly-remote-pgsql/scripts/create_ccm_cms_schema.sql @@ -6,7 +6,8 @@ DROP SEQUENCE IF EXISTS hibernate_sequence; CREATE SCHEMA ccm_core; CREATE SCHEMA ccm_cms; -create table CCM_CMS.ARTICLE_LEADS ( + + create table CCM_CMS.ARTICLE_LEADS ( OBJECT_ID int8 not null, LOCALIZED_VALUE text, LOCALE varchar(255) not null, @@ -106,6 +107,7 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.ATTACHMENT_LISTS ( LIST_ID int8 not null, NAME varchar(255), + LIST_ORDER int8, UUID varchar(255), ITEM_ID int8, CONTENT_ITEM_ID int8, @@ -118,6 +120,7 @@ create table CCM_CMS.ARTICLE_LEADS ( REVTYPE int2, REVEND int4, NAME varchar(255), + LIST_ORDER int8, UUID varchar(255), ITEM_ID int8, primary key (LIST_ID, REV) @@ -1381,10 +1384,10 @@ create table CCM_CMS.ARTICLE_LEADS ( CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, SETTING_VALUE_BIG_DECIMAL numeric(19, 2), - SETTING_VALUE_LONG int8, - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_DOUBLE float8, + SETTING_VALUE_BOOLEAN boolean, + SETTING_VALUE_LONG int8, primary key (SETTING_ID) ); diff --git a/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql b/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql index de7977653..8faf1c5fd 100644 --- a/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql +++ b/ccm-cms/src/test/resources/datasets/create_ccm_cms_schema.sql @@ -6,7 +6,7 @@ DROP SEQUENCE IF EXISTS hibernate_sequence; CREATE SCHEMA ccm_core; CREATE SCHEMA ccm_cms; -create table CCM_CMS.ARTICLE_LEADS ( + create table CCM_CMS.ARTICLE_LEADS ( OBJECT_ID bigint not null, LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, @@ -106,6 +106,7 @@ create table CCM_CMS.ARTICLE_LEADS ( create table CCM_CMS.ATTACHMENT_LISTS ( LIST_ID bigint not null, NAME varchar(255), + LIST_ORDER bigint, UUID varchar(255), ITEM_ID bigint, CONTENT_ITEM_ID bigint, @@ -118,6 +119,7 @@ create table CCM_CMS.ARTICLE_LEADS ( REVTYPE tinyint, REVEND integer, NAME varchar(255), + LIST_ORDER bigint, UUID varchar(255), ITEM_ID bigint, primary key (LIST_ID, REV) @@ -1381,10 +1383,10 @@ create table CCM_CMS.ARTICLE_LEADS ( CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, SETTING_VALUE_BIG_DECIMAL decimal(19,2), - SETTING_VALUE_LONG bigint, - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_DOUBLE double, + SETTING_VALUE_BOOLEAN boolean, + SETTING_VALUE_LONG bigint, primary key (SETTING_ID) );