diff --git a/ccm-cms/src/main/java/org/librecms/assets/SideNote.java b/ccm-cms/src/main/java/org/librecms/assets/SideNote.java index 52925c48b..7e6e338d7 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/SideNote.java +++ b/ccm-cms/src/main/java/org/librecms/assets/SideNote.java @@ -45,13 +45,23 @@ public class SideNote extends Asset implements Serializable { private static final long serialVersionUID = -4566222634780521726L; + @Embedded + @AssociationOverride( + name = "values", + joinTable = @JoinTable(name = "SIDE_NOTE_TITLES", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "SIDE_NOTE_ID") + })) + private LocalizedString title; + @Embedded @AssociationOverride( name = "values", joinTable = @JoinTable(name = "SIDE_NOTE_TEXTS", schema = DB_SCHEMA, joinColumns = { - @JoinColumn(name = "ASSET_ID") + @JoinColumn(name = "SIDE_NOTE_ID") } ) ) 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 447bf1cce..c49bbd32b 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 @@ -237,6 +237,27 @@ alter table CCM_CMS.VIDEO_ASSETS_AUD alter table CCM_CMS.NOTE_TEXTS rename to CCM_CMS.SIDE_NOTE_TEXTS; +alter table CCM_CMS.SIDE_NOTE_TEXTS + alter column ASSET_ID RENAME TO SIDE_NOTE_ID; + +create table CCM_CMS.SIDE_NOTE_TITLES ( + SIDE_NOTE_ID bigint not null, + LOCALIZED_VALUE longvarchar, + LOCALE varchar(255) not null, + primary key (SIDE_NOTE_ID, LOCALE) +); + +create table CCM_CMS.SIDE_NOTE_TITLES_AUD ( + REV integer not null, + SIDE_NOTE_ID bigint not null, + LOCALIZED_VALUE longvarchar not null, + LOCALE varchar(255) not null, + REVTYPE tinyint, + REVEND integer, + primary key (REV, SIDE_NOTE_ID, LOCALIZED_VALUE, LOCALE) +); + + alter table CCM_CMS.ATTACHMENTS add column ATTACHMENT_LIST_ID bigint; @@ -357,7 +378,7 @@ alter table CCM_CMS.LEGAL_METADATA_AUD alter table CCM_CMS.SIDE_NOTE_TEXTS add constraint FK79g6eg2csjaixrjr2xgael8lm - foreign key (ASSET_ID) + foreign key (SIDE_NOTE_ID) references CCM_CMS.SIDE_NOTES; alter table CCM_CMS.RELATED_LINKS @@ -394,3 +415,18 @@ alter table CCM_CMS.VIDEO_ASSETS_AUD add constraint FKdrx9uu9a03ju7vqvkjretohpk foreign key (OBJECT_ID, REV) references CCM_CMS.BINARY_ASSETS_AUD; + +alter table CCM_CMS.SIDE_NOTE_TITLES + add constraint FKf8c9mw6p4ijiba77t32uh7i0o + foreign key (SIDE_NOTE_ID) + references CCM_CMS.SIDE_NOTES; + +alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKkuw32q22sotku83khh1xda7sf + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + +alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKbqgawobyevpbgxsnbbs9vwooq + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; 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 dd7c3ab4e..874e60585 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 @@ -235,6 +235,26 @@ alter table CCM_CMS.VIDEO_ASSETS_AUD alter table CCM_CMS.NOTE_TEXTS rename to SIDE_NOTE_TEXTS; +alter table CCM_CMS.SIDE_NOTE_TEXTS + rename column ASSET_ID to SIDE_NOTE_ID; + +create table CCM_CMS.SIDE_NOTE_TITLES ( + SIDE_NOTE_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (SIDE_NOTE_ID, LOCALE) +); + +create table CCM_CMS.SIDE_NOTE_TITLES_AUD ( + REV int4 not null, + SIDE_NOTE_ID int8 not null, + LOCALIZED_VALUE text not null, + LOCALE varchar(255) not null, + REVTYPE int2, + REVEND int4, + primary key (REV, SIDE_NOTE_ID, LOCALIZED_VALUE, LOCALE) +); + alter table CCM_CMS.ATTACHMENTS add column ATTACHMENT_LIST_ID int8; @@ -355,7 +375,7 @@ alter table CCM_CMS.LEGAL_METADATA_AUD alter table CCM_CMS.SIDE_NOTE_TEXTS add constraint FK79g6eg2csjaixrjr2xgael8lm - foreign key (ASSET_ID) + foreign key (SIDE_NOTE_ID) references CCM_CMS.SIDE_NOTES; alter table CCM_CMS.RELATED_LINKS @@ -392,3 +412,18 @@ alter table CCM_CMS.VIDEO_ASSETS_AUD add constraint FKdrx9uu9a03ju7vqvkjretohpk foreign key (OBJECT_ID, REV) references CCM_CMS.BINARY_ASSETS_AUD; + +alter table CCM_CMS.SIDE_NOTE_TITLES + add constraint FKf8c9mw6p4ijiba77t32uh7i0o + foreign key (SIDE_NOTE_ID) + references CCM_CMS.SIDE_NOTES; + +alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKkuw32q22sotku83khh1xda7sf + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + +alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKbqgawobyevpbgxsnbbs9vwooq + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; 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 57ab37504..de7977653 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, @@ -798,20 +798,37 @@ CREATE SCHEMA ccm_cms; ); create table CCM_CMS.SIDE_NOTE_TEXTS ( - ASSET_ID bigint not null, + SIDE_NOTE_ID bigint not null, LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, - primary key (ASSET_ID, LOCALE) + primary key (SIDE_NOTE_ID, LOCALE) ); create table CCM_CMS.SIDE_NOTE_TEXTS_AUD ( REV integer not null, - ASSET_ID bigint not null, + SIDE_NOTE_ID bigint not null, LOCALIZED_VALUE longvarchar not null, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, ASSET_ID, LOCALIZED_VALUE, LOCALE) + primary key (REV, SIDE_NOTE_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table CCM_CMS.SIDE_NOTE_TITLES ( + SIDE_NOTE_ID bigint not null, + LOCALIZED_VALUE longvarchar, + LOCALE varchar(255) not null, + primary key (SIDE_NOTE_ID, LOCALE) + ); + + create table CCM_CMS.SIDE_NOTE_TITLES_AUD ( + REV integer not null, + SIDE_NOTE_ID bigint not null, + LOCALIZED_VALUE longvarchar not null, + LOCALE varchar(255) not null, + REVTYPE tinyint, + REVEND integer, + primary key (REV, SIDE_NOTE_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.SIDE_NOTES ( @@ -1363,11 +1380,11 @@ CREATE SCHEMA ccm_cms; SETTING_ID bigint not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, - SETTING_VALUE_DOUBLE double, - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_BIG_DECIMAL decimal(19,2), - SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_LONG bigint, + SETTING_VALUE_BOOLEAN boolean, + SETTING_VALUE_STRING varchar(1024), + SETTING_VALUE_DOUBLE double, primary key (SETTING_ID) ); @@ -2229,8 +2246,8 @@ create sequence hibernate_sequence start with 1 increment by 1; references CCM_CMS.ASSETS_AUD; alter table CCM_CMS.SIDE_NOTE_TEXTS - add constraint FK3c357rqa9kanmmpaggdapvjli - foreign key (ASSET_ID) + add constraint FK4mvpioee23u1qswmn1fekipoh + foreign key (SIDE_NOTE_ID) references CCM_CMS.SIDE_NOTES; alter table CCM_CMS.SIDE_NOTE_TEXTS_AUD @@ -2243,6 +2260,21 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (REVEND) references CCM_CORE.CCM_REVISIONS; + alter table CCM_CMS.SIDE_NOTE_TITLES + add constraint FKf8c9mw6p4ijiba77t32uh7i0o + foreign key (SIDE_NOTE_ID) + references CCM_CMS.SIDE_NOTES; + + alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKkuw32q22sotku83khh1xda7sf + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKbqgawobyevpbgxsnbbs9vwooq + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + alter table CCM_CMS.SIDE_NOTES add constraint FKea6cikleenmkgw5bwus22mfr3 foreign key (OBJECT_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 40410bcb8..0642276a6 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,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 int8 not null, LOCALIZED_VALUE text, LOCALE varchar(255) not null, @@ -798,20 +798,37 @@ CREATE SCHEMA ccm_cms; ); create table CCM_CMS.SIDE_NOTE_TEXTS ( - ASSET_ID int8 not null, + SIDE_NOTE_ID int8 not null, LOCALIZED_VALUE text, LOCALE varchar(255) not null, - primary key (ASSET_ID, LOCALE) + primary key (SIDE_NOTE_ID, LOCALE) ); create table CCM_CMS.SIDE_NOTE_TEXTS_AUD ( REV int4 not null, - ASSET_ID int8 not null, + SIDE_NOTE_ID int8 not null, LOCALIZED_VALUE text not null, LOCALE varchar(255) not null, REVTYPE int2, REVEND int4, - primary key (REV, ASSET_ID, LOCALIZED_VALUE, LOCALE) + primary key (REV, SIDE_NOTE_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table CCM_CMS.SIDE_NOTE_TITLES ( + SIDE_NOTE_ID int8 not null, + LOCALIZED_VALUE text, + LOCALE varchar(255) not null, + primary key (SIDE_NOTE_ID, LOCALE) + ); + + create table CCM_CMS.SIDE_NOTE_TITLES_AUD ( + REV int4 not null, + SIDE_NOTE_ID int8 not null, + LOCALIZED_VALUE text not null, + LOCALE varchar(255) not null, + REVTYPE int2, + REVEND int4, + primary key (REV, SIDE_NOTE_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.SIDE_NOTES ( @@ -1363,11 +1380,11 @@ CREATE SCHEMA ccm_cms; SETTING_ID int8 not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, - SETTING_VALUE_DOUBLE float8, - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_BIG_DECIMAL numeric(19, 2), - SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_LONG int8, + SETTING_VALUE_BOOLEAN boolean, + SETTING_VALUE_STRING varchar(1024), + SETTING_VALUE_DOUBLE float8, primary key (SETTING_ID) ); @@ -2229,8 +2246,8 @@ create sequence hibernate_sequence start 1 increment 1; references CCM_CMS.ASSETS_AUD; alter table CCM_CMS.SIDE_NOTE_TEXTS - add constraint FK3c357rqa9kanmmpaggdapvjli - foreign key (ASSET_ID) + add constraint FK4mvpioee23u1qswmn1fekipoh + foreign key (SIDE_NOTE_ID) references CCM_CMS.SIDE_NOTES; alter table CCM_CMS.SIDE_NOTE_TEXTS_AUD @@ -2243,6 +2260,21 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (REVEND) references CCM_CORE.CCM_REVISIONS; + alter table CCM_CMS.SIDE_NOTE_TITLES + add constraint FKf8c9mw6p4ijiba77t32uh7i0o + foreign key (SIDE_NOTE_ID) + references CCM_CMS.SIDE_NOTES; + + alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKkuw32q22sotku83khh1xda7sf + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKbqgawobyevpbgxsnbbs9vwooq + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + alter table CCM_CMS.SIDE_NOTES add constraint FKea6cikleenmkgw5bwus22mfr3 foreign key (OBJECT_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 0d5e3020f..de7977653 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,8 +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, @@ -799,20 +798,37 @@ CREATE SCHEMA ccm_cms; ); create table CCM_CMS.SIDE_NOTE_TEXTS ( - ASSET_ID bigint not null, + SIDE_NOTE_ID bigint not null, LOCALIZED_VALUE longvarchar, LOCALE varchar(255) not null, - primary key (ASSET_ID, LOCALE) + primary key (SIDE_NOTE_ID, LOCALE) ); create table CCM_CMS.SIDE_NOTE_TEXTS_AUD ( REV integer not null, - ASSET_ID bigint not null, + SIDE_NOTE_ID bigint not null, LOCALIZED_VALUE longvarchar not null, LOCALE varchar(255) not null, REVTYPE tinyint, REVEND integer, - primary key (REV, ASSET_ID, LOCALIZED_VALUE, LOCALE) + primary key (REV, SIDE_NOTE_ID, LOCALIZED_VALUE, LOCALE) + ); + + create table CCM_CMS.SIDE_NOTE_TITLES ( + SIDE_NOTE_ID bigint not null, + LOCALIZED_VALUE longvarchar, + LOCALE varchar(255) not null, + primary key (SIDE_NOTE_ID, LOCALE) + ); + + create table CCM_CMS.SIDE_NOTE_TITLES_AUD ( + REV integer not null, + SIDE_NOTE_ID bigint not null, + LOCALIZED_VALUE longvarchar not null, + LOCALE varchar(255) not null, + REVTYPE tinyint, + REVEND integer, + primary key (REV, SIDE_NOTE_ID, LOCALIZED_VALUE, LOCALE) ); create table CCM_CMS.SIDE_NOTES ( @@ -1364,11 +1380,11 @@ CREATE SCHEMA ccm_cms; SETTING_ID bigint not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, - SETTING_VALUE_DOUBLE double, - SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_BIG_DECIMAL decimal(19,2), - SETTING_VALUE_STRING varchar(1024), SETTING_VALUE_LONG bigint, + SETTING_VALUE_BOOLEAN boolean, + SETTING_VALUE_STRING varchar(1024), + SETTING_VALUE_DOUBLE double, primary key (SETTING_ID) ); @@ -2230,8 +2246,8 @@ create sequence hibernate_sequence start with 1 increment by 1; references CCM_CMS.ASSETS_AUD; alter table CCM_CMS.SIDE_NOTE_TEXTS - add constraint FK3c357rqa9kanmmpaggdapvjli - foreign key (ASSET_ID) + add constraint FK4mvpioee23u1qswmn1fekipoh + foreign key (SIDE_NOTE_ID) references CCM_CMS.SIDE_NOTES; alter table CCM_CMS.SIDE_NOTE_TEXTS_AUD @@ -2244,6 +2260,21 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (REVEND) references CCM_CORE.CCM_REVISIONS; + alter table CCM_CMS.SIDE_NOTE_TITLES + add constraint FKf8c9mw6p4ijiba77t32uh7i0o + foreign key (SIDE_NOTE_ID) + references CCM_CMS.SIDE_NOTES; + + alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKkuw32q22sotku83khh1xda7sf + foreign key (REV) + references CCM_CORE.CCM_REVISIONS; + + alter table CCM_CMS.SIDE_NOTE_TITLES_AUD + add constraint FKbqgawobyevpbgxsnbbs9vwooq + foreign key (REVEND) + references CCM_CORE.CCM_REVISIONS; + alter table CCM_CMS.SIDE_NOTES add constraint FKea6cikleenmkgw5bwus22mfr3 foreign key (OBJECT_ID)