diff --git a/ccm-archetype-module/src/main/resources/module-info/__groupId__.__artifactId__.properties b/ccm-archetype-module/src/main/resources/archetype-resources/src/main/resources/module-info/__groupId__.__artifactId__.properties similarity index 100% rename from ccm-archetype-module/src/main/resources/module-info/__groupId__.__artifactId__.properties rename to ccm-archetype-module/src/main/resources/archetype-resources/src/main/resources/module-info/__groupId__.__artifactId__.properties diff --git a/ccm-cms-archetype-contenttype/pom.xml b/ccm-cms-archetype-contenttype/pom.xml new file mode 100644 index 000000000..aaecdc1a8 --- /dev/null +++ b/ccm-cms-archetype-contenttype/pom.xml @@ -0,0 +1,20 @@ + + + + 4.0.0 + + org.libreccm + libreccm-parent + 7.0.0-SNAPSHOT + + + org.libreccm.cms + ccm-cms-archetype-contenttype + 7.0.0-SNAPSHOT + LibreCCM CMS Archetype for Contenttypes + + http://cms.libreccm.org + diff --git a/ccm-cms-archetype-contenttype/src/main/resources/META-INF/maven/archetype-metadata.xml b/ccm-cms-archetype-contenttype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 000000000..dc4194780 --- /dev/null +++ b/ccm-cms-archetype-contenttype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,34 @@ + + + + + ${artifactId} + + + ${artifactId} + + + + + + src/main/java + + + src/main/resources/db/migrations + + + src/main/resources/META-INF + + + src/main/resources/module-info + + + src/test/java + + + + diff --git a/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/pom.xml b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 000000000..3d261893b --- /dev/null +++ b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,318 @@ + + + 4.0.0 + + + UTF-8 + ${maven.build.timestamp} + yyyy-MM-dd'T'HH:mm:ss'Z'Z + + + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + + javax + javaee-api + jar + provided + + + + org.libreccm + ccm-core + ${project.parent.version} + provided + + + + org.hibernate + hibernate-entitymanager + + + + org.hibernate + hibernate-validator + + + + junit + junit + test + + + + org.hamcrest + hamcrest-core + test + + + org.hamcrest + hamcrest-library + test + + + + org.libreccm + ccm-testutils + ${project.parent.version} + test + + + + nl.jqno.equalsverifier + equalsverifier + test + + + + org.jboss.arquillian.junit + arquillian-junit-container + test + + + org.jboss.arquillian.extension + arquillian-persistence-dbunit + test + + + org.jboss.arquillian.extension + arquillian-transaction-impl-base + test + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + test + + + + com.h2database + h2 + test + + + + + + ${artifactId} + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.7 + 1.7 + true + true + ${project.build.sourceEncoding} + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + org.libreccm.tests.categories.UnitTest + + + + + org.jacoco + jacoco-maven-plugin + 0.7.5.201505241946 + + + default-prepare-agent + + prepare-agent + + + + default-report + prepare-package + + report + + + + default-check + + check + + + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + 0.60 + + + + + + + + + + + de.jpdigital + hibernate4-ddl-maven-plugin + + + h2 + mysql5_innodb + oracle10g + postgresql9 + + + org.libreccm + + true + + + + + gen-ddl + + process-classes + + + + + + + + src/main/resources + true + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + true + true + + http://docs.oracle.com/javase/7/docs/api/ + http://docs.oracle.com/javaee/7/api/ + http://docs.jboss.org/hibernate/orm/4.3/javadocs/ + + private + true + UTF-8 + UTF-8 + UTF-8 + true + true + true + true + false + org.jboss.apiviz.APIviz + + org.jboss.apiviz + apiviz + 1.3.2.GA + + true + + -sourceclasspath ${project.build.outputDirectory} + + + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.5 + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.18.1 + + + org.jacoco + jacoco-maven-plugin + 0.7.5.201505241946 + + + org.codehaus.mojo + findbugs-maven-plugin + 3.0.1 + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.4 + + true + utf-8 + 1.7 + + /rulesets/java/basic.xml + /rulesets/java/braces.xml + /rulesets/java/clone.xml + /rulesets/java/codesize.xml + /rulesets/java/design.xml + /rulesets/java/empty.xml + /rulesets/java/finalizers.xml + /rulesets/java/imports.xml + /rulesets/java/javabeans.xml + /rulesets/java/junit.xml + /rulesets/java/naming.xml + /rulesets/java/optimizations.xml + /rulesets/java/strictexception.xml + /rulesets/java/strings.xml + /rulesets/java/sunsecure.xml + /rulesets/java/typeresolution.xml + /rulesets/java/unnecessary.xml + /rulesets/java/unusedcode.xml + + + + + org.codehaus.mojo + javancss-maven-plugin + 2.1 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.8 + + + + dependencies + license + + + + + false + + + + +< + diff --git a/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__.java b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__.java new file mode 100644 index 000000000..2b66e9eaf --- /dev/null +++ b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__.java @@ -0,0 +1,22 @@ +/* + * Add your license here, for example LGPL + */ +package ${package}; + +import static ${package}.${typeName}Constants.*; + +import org.hibernate.envers.Audited; + +import org.libreccm.cms.contentsection.ContentItem; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Audited +@Table(name = "${type_name}", schema = DB_SCHEMA) +public class ${typeName} extends ContentItem implements Serializable { + +} diff --git a/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__Constants.java b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__Constants.java new file mode 100644 index 000000000..dc13292b7 --- /dev/null +++ b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__Constants.java @@ -0,0 +1,11 @@ +package ${package}; + +public ${typeName}Constants { + + public static final String DB_SCHEMA = "${schemaName}"; + + private ${typeName}Constants() { + //Nothing + } + +} diff --git a/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__Module.java b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__Module.java new file mode 100644 index 000000000..67dace6cb --- /dev/null +++ b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/java/__typeName__Module.java @@ -0,0 +1,39 @@ +/** + * Add your license here, for example LGPL + */ +package ${package}; + +import org.libreccm.modules.CcmModule; +import org.libreccm.modules.InitEvent; +import org.libreccm.modules.InstallEvent; +import org.libreccm.modules.Module; +import org.libreccm.modules.RequiredModule; +import org.libreccm.modules.ShutdownEvent; +import org.libreccm.modules.UnInstallEvent; + +@Module(packageName="${package}", + requiredModules = {@RequiredModule(module = org.libreccm.core.CcmCore)}) +public class ${moduleClass} implements CcmModule { + + @Override + public void install(final InstallEvent event) { + //ToDo Create initial data for the module if neccessary + } + + @Override + public void init(final InitEvent event) { + //ToDo Add initialisation logic necessary for your module + } + + @Override + public void shutdown(final ShutdownEvent event) { + //ToDo Add shutdown logic if necessary + } + + @Override + public void uninstall(final UnInstallEvent event) { + //ToDo Remove module data + } + + +} diff --git a/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule new file mode 100644 index 000000000..6d53c7177 --- /dev/null +++ b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/resources/META-INF/services/org.libreccm.modules.CcmModule @@ -0,0 +1 @@ +${package}.${typeName} diff --git a/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/resources/module-info/__groupId__.__artifactId__.properties b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/resources/module-info/__groupId__.__artifactId__.properties new file mode 100644 index 000000000..b9f3b36c8 --- /dev/null +++ b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/main/resources/module-info/__groupId__.__artifactId__.properties @@ -0,0 +1,4 @@ +groupId=${project.groupId} +artifactId=${project.artifactId} +version=${project.version} +build.date=${timestamp} diff --git a/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/test/java/AppTest.java b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/test/java/AppTest.java new file mode 100644 index 000000000..3f3cdf49c --- /dev/null +++ b/ccm-cms-archetype-contenttype/src/main/resources/archetype-resources/src/test/java/AppTest.java @@ -0,0 +1,38 @@ +package $org.libreccm.cms; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/ccm-cms/pom.xml b/ccm-cms/pom.xml index 55770dd50..ca5f2664a 100644 --- a/ccm-cms/pom.xml +++ b/ccm-cms/pom.xml @@ -19,7 +19,7 @@ ccm-cms 7.0.0-SNAPSHOT - ccm-cms + LibreCCM CMS diff --git a/ccm-cms/src/main/java/org/libreccm/cms/CmsConstants.java b/ccm-cms/src/main/java/org/libreccm/cms/CmsConstants.java new file mode 100644 index 000000000..104000165 --- /dev/null +++ b/ccm-cms/src/main/java/org/libreccm/cms/CmsConstants.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.cms; + +/** + * + * @author Jens Pelzetter + */ +public class CmsConstants { + + public static final String CMS_XML_NS = "http://cms.libreccm.org"; + + public static final String DB_SCHEMA = "CCM_CMS"; + + private CmsConstants() { + //Nothing + } + +} diff --git a/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItem.java b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItem.java new file mode 100644 index 000000000..70afe1790 --- /dev/null +++ b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItem.java @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.cms.contentsection; + +import org.hibernate.envers.Audited; + +import static org.libreccm.cms.CmsConstants.*; + +import org.libreccm.core.CcmObject; +import org.libreccm.l10n.LocalizedString; + +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; + +import javax.persistence.AssociationOverride; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Audited +@Table(name = "content_items", schema = DB_SCHEMA) +public class ContentItem extends CcmObject implements Serializable { + + private static final long serialVersionUID = 5897287630227129653L; + + @Embedded + @AssociationOverride( + name = "VALUES", + joinTable = @JoinTable(name = "CONTENT_ITEM_NAMES", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID")} + )) + private LocalizedString name; + + @OneToOne + private ContentType contentType; + + @Embedded + @AssociationOverride( + name = "VALUES", + joinTable = @JoinTable(name = "CONTENT_ITEM_TITLES", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID")} + )) + private LocalizedString title; + + @Embedded + @AssociationOverride( + name = "VALUES", + joinTable = @JoinTable(name = "CONTENT_ITEM_DESCRIPTIONS", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID")} + )) + private LocalizedString description; + + @Enumerated(EnumType.STRING) + private ContentItemVersion version; + + @Temporal(TemporalType.DATE) + private Date launchDate; + + @Column(name = "ancestors", length = 1024) + private String ancestors; + + public LocalizedString getName() { + return name; + } + + public void setName(final LocalizedString name) { + this.name = name; + } + + public ContentType getContentType() { + return contentType; + } + + public void setContentType(final ContentType contentType) { + this.contentType = contentType; + } + + 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 ContentItemVersion getVersion() { + return version; + } + + public void setVersion(final ContentItemVersion version) { + this.version = version; + } + + public Date getLaunchDate() { + return new Date(launchDate.getTime()); + } + + public void setLaunchDate(final Date launchDate) { + this.launchDate = new Date(launchDate.getTime()); + } + + public String getAncestors() { + return ancestors; + } + + public void setAncestors(final String ancestors) { + this.ancestors = ancestors; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 59 * hash + Objects.hashCode(name); + hash = 59 * hash + Objects.hashCode(contentType); + hash = 59 * hash + Objects.hashCode(title); + hash = 59 * hash + Objects.hashCode(description); + hash = 59 * hash + Objects.hashCode(version); + hash = 59 * hash + Objects.hashCode(launchDate); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof ContentItem)) { + return false; + } + + final ContentItem other = (ContentItem) obj; + if (!other.canEqual(this)) { + return false; + } + + if (!Objects.equals(name, other.getName())) { + return false; + } + if (!Objects.equals(contentType, other.getContentType())) { + return false; + } + if (!Objects.equals(title, other.getTitle())) { + return false; + } + if (!Objects.equals(description, other.getDescription())) { + return false; + } + if (version != other.getVersion()) { + return false; + } + if (!Objects.equals(launchDate, other.getLaunchDate())) { + return false; + } + return true; + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof ContentItem; + } + + @Override + public String toString(final String data) { + return String.format(", name = {}, " + + "contentType = {}, " + + "title = {}, " + + "version = %s," + + "launchDate = %s%s", + Objects.toString(name), + Objects.toString(contentType), + Objects.toString(description), + Objects.toString(version), + Objects.toString(launchDate)); + } + +} diff --git a/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItemMode.java b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItemMode.java new file mode 100644 index 000000000..afdff3ba9 --- /dev/null +++ b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItemMode.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.cms.contentsection; + +/** + * + * @author Jens Pelzetter + */ +public enum ContentItemMode { + + DEFAULT, + INTERNAL, + HIDDEN + +} diff --git a/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItemVersion.java b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItemVersion.java new file mode 100644 index 000000000..c762153b3 --- /dev/null +++ b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentItemVersion.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.cms.contentsection; + +/** + * + * @author Jens Pelzetter + */ +public enum ContentItemVersion { + + DRAFT, + LIVE + +} diff --git a/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentSection.java b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentSection.java new file mode 100644 index 000000000..92bff1628 --- /dev/null +++ b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentSection.java @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.cms.contentsection; + +import static org.libreccm.cms.CmsConstants.*; + +import org.libreccm.core.Group; +import org.libreccm.web.CcmApplication; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = "content_sections", schema = DB_SCHEMA) +public class ContentSection extends CcmApplication implements Serializable { + + private static final long serialVersionUID = -671718122153931727L; + + @Column(name = "label", length = 512) + private String label; + + @Column(name = "page_resolver_class", length = 1024) + private String pageResolverClass; + + @Column(name = "item_resolver_class", length = 1024) + private String itemResolverClass; + + @Column(name = "template_resolver_class", length = 1024) + private String templateResolverClass; + + @Column(name = "xml_generator_class", length = 1024) + private String xmlGeneratorClass; + + @OneToOne + private Group staffGroup; + + @OneToOne + private Group viewersGroup; + + @Column(name = "default_locale", length = 10) + private String defaultLocale; + + + + public String getLabel() { + return label; + } + + public void setLabel(final String label) { + this.label = label; + } + + public String getPageResolverClass() { + return pageResolverClass; + } + + public void setPageResolverClass(final String pageResolverClass) { + this.pageResolverClass = pageResolverClass; + } + + public String getItemResolverClass() { + return itemResolverClass; + } + + public void setItemResolverClass(final String itemResolverClass) { + this.itemResolverClass = itemResolverClass; + } + + public String getTemplateResolverClass() { + return templateResolverClass; + } + + public void setTemplateResolverClass(final String templateResolverClass) { + this.templateResolverClass = templateResolverClass; + } + + public String getXmlGeneratorClass() { + return xmlGeneratorClass; + } + + public void setXmlGeneratorClass(final String xmlGeneratorClass) { + this.xmlGeneratorClass = xmlGeneratorClass; + } + + public Group getStaffGroup() { + return staffGroup; + } + + public void setStaffGroup(final Group staffGroup) { + this.staffGroup = staffGroup; + } + + public Group getViewersGroup() { + return viewersGroup; + } + + public void setViewersGroup(final Group viewersGroup) { + this.viewersGroup = viewersGroup; + } + + public String getDefaultLocale() { + return defaultLocale; + } + + public void setDefaultLocale(final String defaultLocale) { + this.defaultLocale = defaultLocale; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 47 * hash + Objects.hashCode(label); + hash = 47 * hash + Objects.hashCode(pageResolverClass); + hash = 47 * hash + Objects.hashCode(itemResolverClass); + hash = 47 * hash + Objects.hashCode(templateResolverClass); + hash = 47 * hash + Objects.hashCode(xmlGeneratorClass); + hash = 47 * hash + Objects.hashCode(defaultLocale); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof ContentSection)) { + return false; + } + + final ContentSection other = (ContentSection) obj; + if (!other.canEqual(this)) { + return false; + } + + if (!Objects.equals(label, other.getLabel())) { + return false; + } + if (!Objects.equals(pageResolverClass, other.getPageResolverClass())) { + return false; + } + if (!Objects.equals(itemResolverClass, other.getItemResolverClass())) { + return false; + } + if (!Objects.equals(templateResolverClass, + other.getTemplateResolverClass())) { + return false; + } + if (!Objects.equals(xmlGeneratorClass, other.getXmlGeneratorClass())) { + return false; + } + return Objects.equals(defaultLocale, other.getDefaultLocale()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof ContentSection; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", label = \"%s\", " + + "pageResolverClass = \"%s\", " + + "itemResolverClass = \"%s\", " + + "templateResolverClass = \"%s\", " + + "xmlGeneratorClass = \"%s\", " + + "defaultLocale = \"%s\"%s", + label, + pageResolverClass, + itemResolverClass, + templateResolverClass, + xmlGeneratorClass, + defaultLocale, + data)); + } + +} diff --git a/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentType.java b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentType.java new file mode 100644 index 000000000..cbebb8442 --- /dev/null +++ b/ccm-cms/src/main/java/org/libreccm/cms/contentsection/ContentType.java @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2015 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.libreccm.cms.contentsection; + +import static org.libreccm.cms.CmsConstants.*; + +import org.libreccm.core.CcmObject; +import org.libreccm.l10n.LocalizedString; + +import java.io.Serializable; +import java.util.Objects; + +import javax.persistence.AssociationOverride; +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Table; + +/** + * + * @author Jens Pelzetter + */ +@Entity +@Table(name = "content_types", schema = DB_SCHEMA) +public class ContentType extends CcmObject implements Serializable { + + private static final long serialVersionUID = -2708659750560382851L; + + @Column(name = "content_item_class", length = 1024) + private String contentItemClass; + + @Embedded + @AssociationOverride( + name = "VALUES", + joinTable = @JoinTable(name = "CONTENT_TYPE_LABELS", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID")} + )) + private LocalizedString label; + + @Embedded + @AssociationOverride( + name = "VALUES", + joinTable = @JoinTable(name = "CONTENT_TYPE_DESCRIPTIONS", + schema = DB_SCHEMA, + joinColumns = { + @JoinColumn(name = "OBJECT_ID")} + )) + private LocalizedString description; + + @Column(name = "ancestors", length = 1024) + private String ancestors; + + @Column(name = "descendants", length = 1024) + private String descendants; + + @Enumerated(EnumType.STRING) + private ContentItemMode mode; + + //ToDo references for authoring kit etc + public String getContentItemClass() { + return contentItemClass; + } + + public void setContentItemClass(final String contentItemClass) { + this.contentItemClass = contentItemClass; + } + + public LocalizedString getLabel() { + return label; + } + + public void setLabel(final LocalizedString label) { + this.label = label; + } + + public LocalizedString getDescription() { + return description; + } + + public void setDescription(final LocalizedString description) { + this.description = description; + } + + public String getAncestors() { + return ancestors; + } + + public void setAncestors(final String ancestors) { + this.ancestors = ancestors; + } + + public String getDescendants() { + return descendants; + } + + public void setDescendants(final String descendants) { + this.descendants = descendants; + } + + public ContentItemMode getMode() { + return mode; + } + + public void setMode(final ContentItemMode mode) { + this.mode = mode; + } + + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = 79 * hash + Objects.hashCode(contentItemClass); + hash = 79 * hash + Objects.hashCode(label); + hash = 79 * hash + Objects.hashCode(description); + hash = 79 * hash + Objects.hashCode(mode); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof ContentType)) { + return false; + } + + final ContentType other = (ContentType) obj; + if (!other.canEqual(this)) { + return false; + } + + if (!Objects.equals(contentItemClass, other.getContentItemClass())) { + return false; + } + if (!Objects.equals(label, other.getLabel())) { + return false; + } + if (!Objects.equals(description, other.getDescription())) { + return false; + } + return mode == other.getMode(); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof ContentType; + } + + @Override + public String toString(final String data) { + return super.toString(String.format(", contentItemClass = \"%s\", " + + "label = {%s}, " + + "mode = %s%s", + contentItemClass, + Objects.toString(label), + mode, + data)); + } + +} diff --git a/pom.xml b/pom.xml index 5f074f86e..3000979fa 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,7 @@ ccm-archetype-module ccm-cms + ccm-cms-archetype-contenttype