diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemResolver.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemResolver.java index 59b094412..2c77b5a8a 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemResolver.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemResolver.java @@ -26,7 +26,6 @@ import org.librecms.contentsection.ContentSection; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; -import java.math.BigDecimal; /** *

diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java index 4aae3c743..ee0a6ba6f 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItem.java @@ -66,50 +66,62 @@ import static org.librecms.CmsConstants.*; @NamedQueries({ @NamedQuery( name = "ContentItem.findByType", - query = "SELECT i FROM ContentItem i WHERE TYPE(I) = :type"), + query = "SELECT i FROM ContentItem i WHERE TYPE(i) = :type"), @NamedQuery( name = "ContentItem.findByFolder", - query = "SELECT c.categorizedObject FROM Categorization c " + query = "SELECT i FROM ContentItem i " + + "JOIN i.categories c " + "WHERE c.category = :folder " - + "AND TYPE(c.categorizedObject) IN ContentItem"), + + "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "'"), @NamedQuery( name = "ContentItem.countItemsInFolder", - query = "SELECT COUNT(c) FROM Categorization c " + query = "SELECT count(i) FROM ContentItem i " + + "JOIN i.categories c " + "WHERE c.category = :folder " - + "AND TYPE(c.categorizedObject) IN ContentItem"), + + "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "'"), @NamedQuery( name = "ContentItem.countByNameInFolder", - query = "SELECT count(c) FROM Categorization c " + query = "SELECT COUNT(i) FROM ContentItem i " + + "JOIN i.categories c " + "WHERE c.category = :folder " - + "AND c.categorizedObject.displayName = :name"), + + "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' " + + "AND i.displayName = :name"), @NamedQuery( - name = "ContentItem.filterByNameAndFolder", - query = "SELECT c.categorizedObject FROM Categorization c " + name = "ContentItem.filterByFolderAndName", + query = "SELECT i FROM ContentItem i " + + "JOIN i.categories c " + "WHERE c.category = :folder " - + "AND TYPE(c.categorizedObject) IN (ContentItem)" - + "AND (LOWER(c.categorizedObject.displayName) LIKE CONCAT(LOWER(:name), '%') "), + + "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' " + + "AND LOWER(i.displayName) LIKE CONCAT(LOWER(:name), '%')"), @NamedQuery( - name = "ContentItem.countFilterByNameAndFolder", - query = "SELECT count(c) FROM Categorization c " + name = "ContentItem.countFilterByFolderAndName", + query = "SELECT COUNT(i) FROM ContentItem i " + + "JOIN i.categories c " + "WHERE c.category = :folder " - + "AND TYPE(c.categorizedObject) IN (ContentItem)" - + "AND LOWER(c.categorizedObject.displayName) LIKE CONCAT(LOWER(:name), '%s') "), + + "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' " + + "AND LOWER(i.displayName) LIKE CONCAT(LOWER(:name), '%')" + // query = "SELECT COUNT(c) FROM Categorization c " + // + "JOIN c.categorizedObject o " + // + "WHERE c.category = :folder " + // + "AND TYPE(o) IN (ContentItem) " + // + "AND LOWER(o.displayName) LIKE CONCAT(LOWER(:name), '%s') " + ), @NamedQuery( name = "ContentItem.hasLiveVersion", query = "SELECT (CASE WHEN COUNT(i) > 0 THEN true ELSE false END) " + "FROM ContentItem i " - + "WHERE i.uuid = :uuid " - + "AND i.version = \"LIVE\""), + + "WHERE i.uuid = ':uuid' " + + "AND i.version = 'LIVE'"), @NamedQuery( name = "ContentItem.findDraftVersion", query = "SELECT i FROM ContentItem i " - + "WHERE i.uuid = :uuid " - + "AND i.version = \"DRAFT\""), + + "WHERE i.uuid = ':uuid' " + + "AND i.version = 'DRAFT'"), @NamedQuery( name = "ContentItem.findLiveVersion", query = "SELECT i FROM ContentItem i " - + "WHERE i.uuid = :uuid " - + "AND i.version = \"LIVE\"") + + "WHERE i.uuid = ':uuid' " + + "AND i.version = 'LIVE'") }) public class ContentItem extends CcmObject implements Serializable, diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemRepository.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemRepository.java index da6ce27cf..81aca4833 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemRepository.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentItemRepository.java @@ -25,6 +25,7 @@ import org.libreccm.core.CcmObjectRepository; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; @@ -167,7 +168,7 @@ public class ContentItemRepository .createNamedQuery("ContentItem.findByFolder", ContentItem.class); query.setParameter("folder", folder); - + return query.getResultList(); } @@ -213,7 +214,7 @@ public class ContentItemRepository public List filterByFolderAndName(final Category folder, final String name) { final TypedQuery query = getEntityManager() - .createNamedQuery("ContentItem.filterByNameAndFolder", + .createNamedQuery("ContentItem.filterByFolderAndName", ContentItem.class); query.setParameter("folder", folder); query.setParameter("name", name); @@ -233,7 +234,7 @@ public class ContentItemRepository public long countFilterByFolderAndName(final Category folder, final String name) { final TypedQuery query = getEntityManager() - .createNamedQuery("ContentItem.countFilterByNameAndFolder", + .createNamedQuery("ContentItem.countFilterByFolderAndName", Long.class); query.setParameter("folder", folder); query.setParameter("name", name); diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSection.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSection.java index d72e4b33e..749f366c8 100644 --- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSection.java +++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSection.java @@ -126,6 +126,7 @@ public class ContentSection extends CcmApplication implements Serializable { @OneToMany @JoinTable( name = "CONTENT_SECTION_LIFECYCLE_DEFINITIONS", + schema = DB_SCHEMA, joinColumns = { @JoinColumn(name = "CONTENT_SECTION_ID") }, @@ -138,6 +139,7 @@ public class ContentSection extends CcmApplication implements Serializable { @OneToMany @JoinTable( name = "CONTENT_SECTION_WORKFLOW_TEMPLATES", + schema = DB_SCHEMA, joinColumns = { @JoinColumn(name = "CONTENT_SECTION_ID") }, diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_4__add_section_lifecycle_workflow.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_4__add_section_lifecycle_workflow.sql index ced67a920..b4592c9de 100644 --- a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_4__add_section_lifecycle_workflow.sql +++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_4__add_section_lifecycle_workflow.sql @@ -1,35 +1,35 @@ -create table CONTENT_SECTION_LIFECYCLE_DEFINITIONS ( +create table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS ( CONTENT_SECTION_ID bigint not null, LIFECYCLE_DEFINITION_ID bigint not null ); -create table CONTENT_SECTION_WORKFLOW_TEMPLATES ( +create table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES ( CONTENT_SECTION_ID bigint not null, WORKFLOW_TEMPLATE_ID bigint not null ); -alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS +alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS add constraint UK_dhbp1f81iaw6sl7tg36xh439e unique (LIFECYCLE_DEFINITION_ID); -alter table CONTENT_SECTION_WORKFLOW_TEMPLATES +alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES add constraint UK_goj42ghwu4tf1akfb2r6ensns unique (WORKFLOW_TEMPLATE_ID); -alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS +alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS add constraint FKqnsnk1eju8vrbm7x0wr5od4ll foreign key (LIFECYCLE_DEFINITION_ID) references CCM_CMS.LIFECYLE_DEFINITIONS; -alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS +alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS add constraint FK7daejlunqsnhgky4b92n019a9 foreign key (CONTENT_SECTION_ID) references CCM_CMS.CONTENT_SECTIONS; -alter table CONTENT_SECTION_WORKFLOW_TEMPLATES +alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES add constraint FKrx08cdjm9tutrp5lvfhgslw48 foreign key (WORKFLOW_TEMPLATE_ID) references CCM_CORE.WORKFLOW_TEMPLATES; -alter table CONTENT_SECTION_WORKFLOW_TEMPLATES +alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES add constraint FK6kuejkcl9hcbkr8q6bdlatt8q foreign key (CONTENT_SECTION_ID) references CCM_CMS.CONTENT_SECTIONS; \ No newline at end of file diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_4__add_section_lifecycle_workflow.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_4__add_section_lifecycle_workflow.sql index 3139cb2c3..83255d861 100644 --- a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_4__add_section_lifecycle_workflow.sql +++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_4__add_section_lifecycle_workflow.sql @@ -1,35 +1,35 @@ -create table CONTENT_SECTION_LIFECYCLE_DEFINITIONS ( +create table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS ( CONTENT_SECTION_ID int8 not null, LIFECYCLE_DEFINITION_ID int8 not null ); -create table CONTENT_SECTION_WORKFLOW_TEMPLATES ( +create table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES ( CONTENT_SECTION_ID int8 not null, WORKFLOW_TEMPLATE_ID int8 not null ); -alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS +alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS add constraint UK_dhbp1f81iaw6sl7tg36xh439e unique (LIFECYCLE_DEFINITION_ID); -alter table CONTENT_SECTION_WORKFLOW_TEMPLATES +alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES add constraint UK_goj42ghwu4tf1akfb2r6ensns unique (WORKFLOW_TEMPLATE_ID); -alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS +alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS add constraint FKqnsnk1eju8vrbm7x0wr5od4ll foreign key (LIFECYCLE_DEFINITION_ID) references CCM_CMS.LIFECYLE_DEFINITIONS; -alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS +alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS add constraint FK7daejlunqsnhgky4b92n019a9 foreign key (CONTENT_SECTION_ID) references CCM_CMS.CONTENT_SECTIONS; -alter table CONTENT_SECTION_WORKFLOW_TEMPLATES +alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES add constraint FKrx08cdjm9tutrp5lvfhgslw48 foreign key (WORKFLOW_TEMPLATE_ID) references CCM_CORE.WORKFLOW_TEMPLATES; -alter table CONTENT_SECTION_WORKFLOW_TEMPLATES +alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES add constraint FK6kuejkcl9hcbkr8q6bdlatt8q foreign key (CONTENT_SECTION_ID) references CCM_CMS.CONTENT_SECTIONS; \ No newline at end of file diff --git a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java index 6d4483b1d..fd2ccde44 100644 --- a/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java +++ b/ccm-cms/src/test/java/org/librecms/contentsection/ContentItemRepositoryTest.java @@ -69,7 +69,7 @@ public class ContentItemRepositoryTest { @Inject private ContentItemRepository itemRepo; - + @Inject private CategoryRepository categoryRepo; @@ -127,7 +127,7 @@ public class ContentItemRepositoryTest { return ShrinkWrap .create(WebArchive.class, - "LibreCCM-org.libreccm.cms.contentsection.ContentItemRepositoryTest.war") + "LibreCCM-org.librecms.contentsection.ContentItemRepositoryTest.war") .addPackage(org.libreccm.auditing.CcmRevision.class.getPackage()) .addPackage(org.libreccm.categorization.Categorization.class .getPackage()) @@ -157,6 +157,7 @@ public class ContentItemRepositoryTest { com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class) .addClass( com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class) + .addClass(com.arsdigita.cms.dispatcher.ItemResolver.class) .addPackage(com.arsdigita.util.Lockable.class.getPackage()) .addPackage(com.arsdigita.web.BaseServlet.class.getPackage()) .addPackage(org.librecms.Cms.class.getPackage()) @@ -184,7 +185,7 @@ public class ContentItemRepositoryTest { @Test @InSequence(100) @UsingDataSet("datasets/org/librecms/contentsection/" - + "ContentItemRepositoryTest/data.xml") + + "ContentItemRepositoryTest/data.xml") public void findByIdAndType() { final Optional

article1 = itemRepo.findById( -10100L, Article.class); @@ -212,8 +213,7 @@ public class ContentItemRepositoryTest { assertThat(newsAsArticle.isPresent(), is(false)); assertThat(articleAsNews.isPresent(), is(false)); } - - + @Test @InSequence(200) @UsingDataSet("datasets/org/librecms/contentsection/" @@ -254,7 +254,7 @@ public class ContentItemRepositoryTest { final List
articles = itemRepo.findByType(Article.class); assertThat(articles, is(not(nullValue()))); assertThat(articles.size(), is(3)); - + final List news = itemRepo.findByType(News.class); assertThat(news, is(not(nullValue()))); assertThat(news.size(), is(1)); @@ -266,12 +266,87 @@ public class ContentItemRepositoryTest { + "ContentItemRepositoryTest/data.xml") public void findByFolder() { final Category folder = categoryRepo.findById(-2100L); - + + assertThat(folder.getObjects().size(), is(4)); + final List items = itemRepo.findByFolder(folder); - + assertThat(items, is(not(nullValue()))); assertThat(items.size(), is(4)); - } - + + @Test + @InSequence(410) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentItemRepositoryTest/data.xml") + public void countItemsInFolder() { + final Category folder = categoryRepo.findById(-2100L); + + assertThat(itemRepo.countItemsInFolder(folder), is(4L)); + } + + @Test + @InSequence(500) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentItemRepositoryTest/data.xml") + public void countByNameInFolder() { + final Category folder = categoryRepo.findById(-2100L); + + assertThat(itemRepo.countByNameInFolder(folder, "article1"), is(1L)); + assertThat(itemRepo.countByNameInFolder(folder, "article2"), is(1L)); + assertThat(itemRepo.countByNameInFolder(folder, "article3"), is(1L)); + assertThat(itemRepo.countByNameInFolder(folder, "article4"), is(0L)); + assertThat(itemRepo.countByNameInFolder(folder, "article"), is(0L)); + assertThat(itemRepo.countByNameInFolder(folder, "news1"), is(1L)); + } + + @Test + @InSequence(500) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentItemRepositoryTest/data.xml") + public void filterByFolderAndName() { + final Category folder = categoryRepo.findById(-2100L); + + final List articles = itemRepo.filterByFolderAndName( + folder, "article"); + final List news = itemRepo.filterByFolderAndName(folder, + "news"); + + assertThat(articles.size(), is(3)); + assertThat(news.size(), is(1)); + + assertThat(articles.get(0).getDisplayName(), is(equalTo("article1"))); + assertThat(articles.get(1).getDisplayName(), is(equalTo("article2"))); + assertThat(articles.get(2).getDisplayName(), is(equalTo("article3"))); + + assertThat(news.get(0).getDisplayName(), is(equalTo("news1"))); + } + + @Test + @InSequence(510) + @UsingDataSet("datasets/org/librecms/contentsection/" + + "ContentItemRepositoryTest/data.xml") + public void countFilterByFolderAndName() { + final Category folder = categoryRepo.findById(-2100L); + + assertThat(itemRepo.countFilterByFolderAndName(folder, "article"), + is(3L)); + assertThat(itemRepo.countFilterByFolderAndName(folder, "art"), + is(3L)); + assertThat(itemRepo.countFilterByFolderAndName(folder, "article1"), + is(1L)); + assertThat(itemRepo.countFilterByFolderAndName(folder, "article2"), + is(1L)); + assertThat(itemRepo.countFilterByFolderAndName(folder, "article3"), + is(1L)); + + assertThat(itemRepo.countFilterByFolderAndName(folder, "news"), + is(1L)); + + assertThat(itemRepo.countFilterByFolderAndName(folder, "article10"), + is(0L)); + assertThat(itemRepo.countFilterByFolderAndName(folder, "foo"), + is(0L)); + } + } 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 9ec884e2b..5b1435a5c 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 clob, LOCALE varchar(255) not null, @@ -170,7 +170,7 @@ CREATE SCHEMA ccm_cms; create table CCM_CMS.BINARY_ASSETS ( ASSET_DATA blob, FILENAME varchar(512) not null, - MIME_TYPE binary(512) not null, + MIME_TYPE varchar(512) not null, DATA_SIZE bigint, ASSET_ID bigint not null, primary key (ASSET_ID) @@ -181,7 +181,7 @@ CREATE SCHEMA ccm_cms; REV integer not null, ASSET_DATA blob, FILENAME varchar(512), - MIME_TYPE binary(512), + MIME_TYPE varchar(512), DATA_SIZE bigint, primary key (ASSET_ID, REV) ); @@ -273,6 +273,8 @@ CREATE SCHEMA ccm_cms; VERSION varchar(255), OBJECT_ID bigint not null, CONTENT_TYPE_ID bigint, + LIFECYCLE_ID bigint, + WORKFLOW_ID bigint, primary key (OBJECT_ID) ); @@ -283,6 +285,8 @@ CREATE SCHEMA ccm_cms; LAUNCH_DATE date, VERSION varchar(255), CONTENT_TYPE_ID bigint, + LIFECYCLE_ID bigint, + WORKFLOW_ID bigint, primary key (OBJECT_ID, REV) ); @@ -876,10 +880,10 @@ CREATE SCHEMA ccm_cms; create table CCM_CORE.CATEGORIZATIONS ( CATEGORIZATION_ID bigint not null, - TYPE varchar(255), CATEGORY_ORDER bigint, CATEGORY_INDEX boolean, OBJECT_ORDER bigint, + TYPE varchar(255), OBJECT_ID bigint, CATEGORY_ID bigint, primary key (CATEGORIZATION_ID) @@ -1331,11 +1335,11 @@ CREATE SCHEMA ccm_cms; SETTING_ID bigint not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, + SETTING_VALUE_LONG bigint, + SETTING_VALUE_BIG_DECIMAL decimal(19,2), SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), - SETTING_VALUE_LONG bigint, SETTING_VALUE_DOUBLE double, - SETTING_VALUE_BIG_DECIMAL decimal(19,2), primary key (SETTING_ID) ); @@ -1475,6 +1479,22 @@ CREATE SCHEMA ccm_cms; add constraint UK5whinfxdaepqs09e5ia9y71uk unique (CONFIGURATION_CLASS, NAME); create sequence hibernate_sequence start with 1 increment by 1; + create table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS ( + CONTENT_SECTION_ID bigint not null, + LIFECYCLE_DEFINITION_ID bigint not null + ); + + create table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES ( + CONTENT_SECTION_ID bigint not null, + WORKFLOW_TEMPLATE_ID bigint not null + ); + + alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS + add constraint UK_dhbp1f81iaw6sl7tg36xh439e unique (LIFECYCLE_DEFINITION_ID); + + alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES + add constraint UK_goj42ghwu4tf1akfb2r6ensns unique (WORKFLOW_TEMPLATE_ID); + alter table CCM_CMS.ARTICLE_LEADS add constraint FK4g66u3qtfyepw0f733kuiiaul foreign key (OBJECT_ID) @@ -1705,6 +1725,16 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (CONTENT_TYPE_ID) references CCM_CMS.CONTENT_TYPES; + alter table CCM_CMS.CONTENT_ITEMS + add constraint FKfh1nm46qpw6xcwkmgaqw2iu3h + foreign key (LIFECYCLE_ID) + references CCM_CMS.LIFECYCLES; + + alter table CCM_CMS.CONTENT_ITEMS + add constraint FKl00ldjygr6as8gqbt3j14ke7j + foreign key (WORKFLOW_ID) + references CCM_CORE.WORKFLOWS; + alter table CCM_CMS.CONTENT_ITEMS add constraint FK1fr2q5y1wpmrufruja5ivfpuf foreign key (OBJECT_ID) @@ -1750,6 +1780,21 @@ create sequence hibernate_sequence start with 1 increment by 1; foreign key (OBJECT_ID) references CCM_CMS.CONTENT_TYPES; + alter table CCM_CMS.CONTENT_TYPES + add constraint FKriohuo8093its1k5rgoc5yrfc + foreign key (CONTENT_SECTION_ID) + references CCM_CMS.CONTENT_SECTIONS; + + alter table CCM_CMS.CONTENT_TYPES + add constraint FK8s83we1tuh9r3j57dyos69wfa + foreign key (DEFAULT_LIFECYCLE_ID) + references CCM_CMS.LIFECYLE_DEFINITIONS; + + alter table CCM_CMS.CONTENT_TYPES + add constraint FKhnu9oikw8rpf22lt5fmk41t7k + foreign key (DEFAULT_WORKFLOW) + references CCM_CORE.WORKFLOW_TEMPLATES; + alter table CCM_CMS.CONTENT_TYPES add constraint FK96vwsbqfbdg33ujeeawajr0v4 foreign key (OBJECT_ID) @@ -2689,3 +2734,23 @@ create sequence hibernate_sequence start with 1 increment by 1; add constraint FKefpdf9ojplu7loo31hfm0wl2h foreign key (TASK_ID) references CCM_CORE.WORKFLOW_TASKS; + + alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS + add constraint FKqnsnk1eju8vrbm7x0wr5od4ll + foreign key (LIFECYCLE_DEFINITION_ID) + references CCM_CMS.LIFECYLE_DEFINITIONS; + + alter table CCM_CMS.CONTENT_SECTION_LIFECYCLE_DEFINITIONS + add constraint FK7daejlunqsnhgky4b92n019a9 + foreign key (CONTENT_SECTION_ID) + references CCM_CMS.CONTENT_SECTIONS; + + alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES + add constraint FKrx08cdjm9tutrp5lvfhgslw48 + foreign key (WORKFLOW_TEMPLATE_ID) + references CCM_CORE.WORKFLOW_TEMPLATES; + + alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES + add constraint FK6kuejkcl9hcbkr8q6bdlatt8q + foreign key (CONTENT_SECTION_ID) + references CCM_CMS.CONTENT_SECTIONS; \ No newline at end of file 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 1b40462ab..b5910df68 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 @@ -170,7 +170,7 @@ CREATE SCHEMA ccm_cms; create table CCM_CMS.BINARY_ASSETS ( ASSET_DATA oid, FILENAME varchar(512) not null, - MIME_TYPE bytea not null, + MIME_TYPE varchar(512) not null, DATA_SIZE int8, ASSET_ID int8 not null, primary key (ASSET_ID) @@ -181,7 +181,7 @@ CREATE SCHEMA ccm_cms; REV int4 not null, ASSET_DATA oid, FILENAME varchar(512), - MIME_TYPE bytea, + MIME_TYPE varchar(512), DATA_SIZE int8, primary key (ASSET_ID, REV) ); @@ -273,6 +273,8 @@ CREATE SCHEMA ccm_cms; VERSION varchar(255), OBJECT_ID int8 not null, CONTENT_TYPE_ID int8, + LIFECYCLE_ID int8, + WORKFLOW_ID int8, primary key (OBJECT_ID) ); @@ -283,6 +285,8 @@ CREATE SCHEMA ccm_cms; LAUNCH_DATE date, VERSION varchar(255), CONTENT_TYPE_ID int8, + LIFECYCLE_ID int8, + WORKFLOW_ID int8, primary key (OBJECT_ID, REV) ); @@ -876,10 +880,10 @@ CREATE SCHEMA ccm_cms; create table CCM_CORE.CATEGORIZATIONS ( CATEGORIZATION_ID int8 not null, - TYPE varchar(255), CATEGORY_ORDER int8, CATEGORY_INDEX boolean, OBJECT_ORDER int8, + TYPE varchar(255), OBJECT_ID int8, CATEGORY_ID int8, primary key (CATEGORIZATION_ID) @@ -1331,11 +1335,11 @@ CREATE SCHEMA ccm_cms; SETTING_ID int8 not null, CONFIGURATION_CLASS varchar(512) not null, NAME varchar(512) not null, + SETTING_VALUE_LONG int8, + SETTING_VALUE_BIG_DECIMAL numeric(19, 2), SETTING_VALUE_BOOLEAN boolean, SETTING_VALUE_STRING varchar(1024), - SETTING_VALUE_LONG int8, SETTING_VALUE_DOUBLE float8, - SETTING_VALUE_BIG_DECIMAL numeric(19, 2), primary key (SETTING_ID) ); @@ -1475,6 +1479,22 @@ CREATE SCHEMA ccm_cms; add constraint UK5whinfxdaepqs09e5ia9y71uk unique (CONFIGURATION_CLASS, NAME); create sequence hibernate_sequence start 1 increment 1; + create table CONTENT_SECTION_LIFECYCLE_DEFINITIONS ( + CONTENT_SECTION_ID int8 not null, + LIFECYCLE_DEFINITION_ID int8 not null + ); + + create table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES ( + CONTENT_SECTION_ID int8 not null, + WORKFLOW_TEMPLATE_ID int8 not null + ); + + alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS + add constraint UK_dhbp1f81iaw6sl7tg36xh439e unique (LIFECYCLE_DEFINITION_ID); + + alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES + add constraint UK_goj42ghwu4tf1akfb2r6ensns unique (WORKFLOW_TEMPLATE_ID); + alter table CCM_CMS.ARTICLE_LEADS add constraint FK4g66u3qtfyepw0f733kuiiaul foreign key (OBJECT_ID) @@ -1705,6 +1725,16 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (CONTENT_TYPE_ID) references CCM_CMS.CONTENT_TYPES; + alter table CCM_CMS.CONTENT_ITEMS + add constraint FKfh1nm46qpw6xcwkmgaqw2iu3h + foreign key (LIFECYCLE_ID) + references CCM_CMS.LIFECYCLES; + + alter table CCM_CMS.CONTENT_ITEMS + add constraint FKl00ldjygr6as8gqbt3j14ke7j + foreign key (WORKFLOW_ID) + references CCM_CORE.WORKFLOWS; + alter table CCM_CMS.CONTENT_ITEMS add constraint FK1fr2q5y1wpmrufruja5ivfpuf foreign key (OBJECT_ID) @@ -1750,6 +1780,21 @@ create sequence hibernate_sequence start 1 increment 1; foreign key (OBJECT_ID) references CCM_CMS.CONTENT_TYPES; + alter table CCM_CMS.CONTENT_TYPES + add constraint FKriohuo8093its1k5rgoc5yrfc + foreign key (CONTENT_SECTION_ID) + references CCM_CMS.CONTENT_SECTIONS; + + alter table CCM_CMS.CONTENT_TYPES + add constraint FK8s83we1tuh9r3j57dyos69wfa + foreign key (DEFAULT_LIFECYCLE_ID) + references CCM_CMS.LIFECYLE_DEFINITIONS; + + alter table CCM_CMS.CONTENT_TYPES + add constraint FKhnu9oikw8rpf22lt5fmk41t7k + foreign key (DEFAULT_WORKFLOW) + references CCM_CORE.WORKFLOW_TEMPLATES; + alter table CCM_CMS.CONTENT_TYPES add constraint FK96vwsbqfbdg33ujeeawajr0v4 foreign key (OBJECT_ID) @@ -2689,3 +2734,23 @@ create sequence hibernate_sequence start 1 increment 1; add constraint FKefpdf9ojplu7loo31hfm0wl2h foreign key (TASK_ID) references CCM_CORE.WORKFLOW_TASKS; + + alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS + add constraint FKqnsnk1eju8vrbm7x0wr5od4ll + foreign key (LIFECYCLE_DEFINITION_ID) + references CCM_CMS.LIFECYLE_DEFINITIONS; + + alter table CONTENT_SECTION_LIFECYCLE_DEFINITIONS + add constraint FK7daejlunqsnhgky4b92n019a9 + foreign key (CONTENT_SECTION_ID) + references CCM_CMS.CONTENT_SECTIONS; + + alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES + add constraint FKrx08cdjm9tutrp5lvfhgslw48 + foreign key (WORKFLOW_TEMPLATE_ID) + references CCM_CORE.WORKFLOW_TEMPLATES; + + alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES + add constraint FK6kuejkcl9hcbkr8q6bdlatt8q + foreign key (CONTENT_SECTION_ID) + references CCM_CMS.CONTENT_SECTIONS; \ No newline at end of file diff --git a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml index ecaf31e2b..64f6c3143 100644 --- a/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml +++ b/ccm-cms/src/test/resources/datasets/org/librecms/contentsection/ContentItemRepositoryTest/data.xml @@ -13,12 +13,12 @@ - + @@ -150,25 +150,29 @@ object_id="-10100" category_order="1" object_order="1" - category_index="false" /> + category_index="false" + type="folder" /> + category_index="false" + type="folder" /> + category_index="false" + type="folder" /> + category_index="false" + type="folder" /> diff --git a/ccm-cms/src/test/resources/scripts/h2-cleanup.sql b/ccm-cms/src/test/resources/scripts/h2-cleanup.sql index 1cc8cb956..da1998a07 100644 --- a/ccm-cms/src/test/resources/scripts/h2-cleanup.sql +++ b/ccm-cms/src/test/resources/scripts/h2-cleanup.sql @@ -12,12 +12,16 @@ DELETE FROM ccm_cms.content_item_titles; DELETE FROM ccm_cms.content_items; +DELETE FROM ccm_cms.content_section_lifecycle_definitions; + DELETE FROM ccm_cms.lifecycle_definition_labels; DELETE FROM ccm_cms.lifecycle_definition_descriptions; DELETE FROM ccm_cms.lifecyle_definitions; +DELETE FROM ccm_cms.content_section_workflow_templates; + DELETE FROM ccm_core.workflow_templates; DELETE FROM ccm_cms.content_type_labels; diff --git a/ccm-cms/src/test/resources/scripts/pgsql-cleanup.sql b/ccm-cms/src/test/resources/scripts/pgsql-cleanup.sql index a6d401c36..4aaff222f 100644 --- a/ccm-cms/src/test/resources/scripts/pgsql-cleanup.sql +++ b/ccm-cms/src/test/resources/scripts/pgsql-cleanup.sql @@ -12,12 +12,16 @@ DELETE FROM ccm_cms.content_item_titles; DELETE FROM ccm_cms.content_items; +DELETE FROM ccm_cms.content_section_lifecycle_definitions; + DELETE FROM ccm_cms.lifecycle_definition_labels; DELETE FROM ccm_cms.lifecycle_definition_descriptions; DELETE FROM ccm_cms.lifecyle_definitions; +DELETE FROM ccm_cms.content_section_workflow_templates; + DELETE FROM ccm_core.workflow_templates; DELETE FROM ccm_cms.content_type_labels;