diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Category.java b/ccm-core/src/main/java/org/libreccm/categorization/Category.java
new file mode 100644
index 000000000..022a81e4d
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/categorization/Category.java
@@ -0,0 +1,38 @@
+/*
+ * 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.categorization;
+
+import org.libreccm.core.CcmObject;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@Entity
+@Table(name = "categories")
+public class Category extends CcmObject implements Serializable {
+
+ private static final long serialVersionUID = -7250208963391878547L;
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java
new file mode 100644
index 000000000..833f179c4
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java
@@ -0,0 +1,210 @@
+/*
+ * 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.categorization;
+
+import org.libreccm.core.CcmObject;
+import org.libreccm.l10n.LocalizedString;
+
+import java.io.Serializable;
+import java.net.URI;
+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.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@Entity
+@Table(name = "domains")
+public class Domain extends CcmObject implements Serializable {
+
+ private static final long serialVersionUID = 4012590760598188732L;
+
+ @Column(name = "domain_key", nullable = false, unique = true)
+ private String domainKey;
+
+ @Column(name = "uri", nullable = false, unique = true)
+ private URI uri;
+
+ @Embedded
+ @AssociationOverride(
+ name = "values",
+ joinTable = @JoinTable(name = "category_titles",
+ joinColumns = {
+ @JoinColumn(name = "object_id")}))
+ private LocalizedString title;
+
+ @Embedded
+ @AssociationOverride(
+ name = "values",
+ joinTable = @JoinTable(name = "category_descriptions",
+ joinColumns = {
+ @JoinColumn(name = "object_id")}))
+ private LocalizedString description;
+
+ @Column(name = "version", nullable = false)
+ private String version;
+
+ @Column(name = "released")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date released;
+
+ @ManyToOne
+ private Category root;
+
+ public String getDomainKey() {
+ return domainKey;
+ }
+
+ public void setDomainKey(final String domainKey) {
+ this.domainKey = domainKey;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(final URI uri) {
+ this.uri = uri;
+ }
+
+ 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 String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public Date getReleased() {
+ return new Date(released.getTime());
+ }
+
+ public void setReleased(final Date released) {
+ this.released = new Date(released.getTime());
+ }
+
+ public Category getRoot() {
+ return root;
+ }
+
+ protected void setRoot(final Category root) {
+ this.root = root;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 41 * hash + Objects.hashCode(domainKey);
+ hash = 41 * hash + Objects.hashCode(uri);
+ hash = 41 * hash + Objects.hashCode(title);
+ hash = 41 * hash + Objects.hashCode(description);
+ hash = 41 * hash + Objects.hashCode(version);
+ hash = 41 * hash + Objects.hashCode(released);
+ hash = 41 * hash + Objects.hashCode(root);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Domain other = (Domain) obj;
+ if (!other.canEqual(this)) {
+ return false;
+ }
+
+
+ if (!Objects.equals(domainKey, other.getDomainKey())) {
+ return false;
+ }
+ if (!Objects.equals(uri, other.getUri())) {
+ return false;
+ }
+ if (!Objects.equals(title, other.getTitle())) {
+ return false;
+ }
+ if (!Objects.equals(description, other.getDescription())) {
+ return false;
+ }
+ if (!Objects.equals(version, other.getVersion())) {
+ return false;
+ }
+ if (!Objects.equals(released, other.getReleased())) {
+ return false;
+ }
+ return Objects.equals(root, other.getRoot());
+ }
+
+ @Override
+ public boolean canEqual(final Object obj) {
+ return obj instanceof Domain;
+ }
+
+ @Override
+ public String toString(final String data) {
+ return String.format(
+ ", domainKey = \"%s\", "
+ + "uri = \"%s\", "
+ + "title = \"%s\", "
+ + "version = \"%s\", "
+ + "released = %tF % childs;
+
+ @ManyToOne
+ private Resource parent;
+
+// @Column(name = "resource_type")
+// private String resourceType;
+
+ public LocalizedString getTitle() {
+ return title;
}
- public void setResourceId(long resourceId) {
- this.resourceId = resourceId;
+ public void setTitle(LocalizedString title) {
+ this.title = title;
+ }
+
+ public LocalizedString getDescription() {
+ return description;
+ }
+
+ public void setDescription(LocalizedString description) {
+ this.description = description;
+ }
+
+ public Date getCreated() {
+ return new Date(created.getTime());
+ }
+
+ public void setCreated(final Date created) {
+ this.created = new Date(created.getTime());
+ }
+
+ public List getChilds() {
+ return Collections.unmodifiableList(childs);
+ }
+
+ protected void setChilds(final List childs) {
+ this.childs = childs;
+ }
+
+ protected void addChild(final Resource child) {
+ childs.add(child);
+ }
+
+ protected void removeChild(final Resource child) {
+ childs.remove(child);
+ }
+
+ public Resource getParent() {
+ return parent;
+ }
+
+ protected void setParent(Resource parent) {
+ this.parent = parent;
+ }
+
+// public String getResourceType() {
+// return resourceType;
+// }
+//
+// public void setResourceType(final String resourceType) {
+// this.resourceType = resourceType;
+// }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 29 * hash + Objects.hashCode(title);
+ hash = 29 * hash + Objects.hashCode(description);
+ hash = 29 * hash + Objects.hashCode(created);
+ hash = 29 * hash + Objects.hashCode(parent);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Resource other = (Resource) obj;
+
+ if (!other.canEqual(this)) {
+ return false;
+ }
+
+ if (!Objects.equals(title, other.getTitle())) {
+ return false;
+ }
+ if (!Objects.equals(description, other.getDescription())) {
+ return false;
+ }
+ if (!Objects.equals(created, other.getCreated())) {
+ return false;
+ }
+ return Objects.equals(parent, other.getParent());
+ }
+
+ @Override
+ public boolean canEqual(final Object obj) {
+ return obj instanceof Resource;
+ }
+
+ @Override
+ public String toString(final String data) {
+ return super.toString(
+ String.format(", title = %s, "
+ + "created = %tF %not designed to be
+ * overwritten. But because it is an entity class we can't make the class final.
+ *
+ * @author Jens Pelzetter
+ */
+@Embeddable
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class LocalizedString implements Serializable {
+
+ private static final long serialVersionUID = 7378282657084330425L;
+
+ /**
+ * The localised values of the string.
+ */
+ @ElementCollection
+ @MapKeyColumn(name = "locale")
+ @Column(name = "value")
+ @Lob
+ @XmlElementWrapper(name = "values")
+ @XmlElement(name = "value")
+ private Map values;
+
+ /**
+ * Constructor. Only creates the initial, empty map for new instances.
+ */
+ public LocalizedString() {
+ values = new HashMap<>();
+ }
+
+ /**
+ * Get all localised values.
+ *
+ * @return A unmodifiable {@code Map} containing all localised values of
+ * this localised string.
+ */
+ public Map getValues() {
+ if (values == null) {
+ return null;
+ } else {
+ return Collections.unmodifiableMap(values);
+ }
+ }
+
+ /**
+ * Setter for replacing the complete {@code Map} of values. Only to be used
+ * by JPA and the Repository classes in the package.
+ *
+ * @param values The new map of values.
+ */
+ protected void setValues(final Map values) {
+ this.values = values;
+ }
+
+ /**
+ * Retrieves the values for the default locale.
+ *
+ * @return The localised value for the default locale of the system the
+ * application is running on. In most cases this is not what you
+ * want. Use {@link #getValue(java.util.Locale)} instead.
+ */
+ public String getValue() {
+ return getValue(Locale.getDefault());
+ }
+
+ /**
+ * Retrieves the localised value of a locale.
+ *
+ * @param locale The locale for which the value shall be retrieved.
+ *
+ * @return The localised for the {@code locale} or {@code null} if there is
+ * no value for the provided locale.
+ */
+ public String getValue(final Locale locale) {
+ return values.get(locale);
+ }
+
+ /**
+ * Add a new localised value for a locale. If there is already a value for
+ * the provided locale the value is replaced with the new value.
+ *
+ * @param locale The locale of the provided value.
+ * @param value The localised value for the provided locale.
+ */
+ public void addValue(final Locale locale, final String value) {
+ values.put(locale, value);
+ }
+
+ /**
+ * Removes the value for the provided locale.
+ *
+ * @param locale The locale for which the value shall be removed.
+ */
+ public void removeValue(final Locale locale) {
+ values.remove(locale);
+ }
+
+ /**
+ * Checks if a localised string instance has a value for a locale.
+ *
+ * @param locale The locale.
+ *
+ * @return {@code true} if this localised string has a value for the
+ * provided locale, {@code false} if not.
+ */
+ public boolean hasValue(final Locale locale) {
+ return values.containsKey(locale);
+ }
+
+ /**
+ * Retrieves all present locales.
+ *
+ * @return A {@link Set} containing all locales for which this localised
+ * string has values.
+ */
+ public Set getAvailableLocales() {
+ return values.keySet();
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "%s{ "
+ + "%s"
+ + " }",
+ super.toString(),
+ values.toString());
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 698bfa7a1..b7265825b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -149,6 +149,11 @@
+
+ de.jpdigital
+ hibernate4-ddl-maven-plugin
+ 1.0.0-alpha.1
+