diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java b/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java
index d358b7e67..3cbff234e 100644
--- a/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java
+++ b/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java
@@ -38,6 +38,8 @@ import java.util.Objects;
* The methods provided by the {@link CategoryManager} take care of that.
*
* @author Jens Pelzetter
+ *
+ * @apiviz.has org.libreccm.core.CcmObject
*/
@Entity
@Table(name = "categorizations")
diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Category.java b/ccm-core/src/main/java/org/libreccm/categorization/Category.java
index 0501316c4..25a0f214a 100644
--- a/ccm-core/src/main/java/org/libreccm/categorization/Category.java
+++ b/ccm-core/src/main/java/org/libreccm/categorization/Category.java
@@ -22,6 +22,8 @@ import org.hibernate.validator.constraints.NotBlank;
import org.libreccm.core.CcmObject;
import java.io.Serializable;
+import java.util.AbstractList;
+import java.util.ArrayList;
import java.util.List;
import javax.persistence.AssociationOverride;
@@ -52,6 +54,8 @@ import javax.validation.constraints.Pattern;
* classes.
*
* @author Jens Pelzetter
+ *
+ * @apiviz.composedOf org.libreccm.categorization.Categorization
*/
@Entity
@Table(name = "categories")
@@ -80,11 +84,11 @@ public class Category extends CcmObject implements Serializable {
*/
@Embedded
@AssociationOverride(
- name = "values",
- joinTable = @JoinTable(name = "category_titles",
- joinColumns = {
- @JoinColumn(name = "object_id")}
- ))
+ name = "values",
+ joinTable = @JoinTable(name = "category_titles",
+ joinColumns = {
+ @JoinColumn(name = "object_id")}
+ ))
private LocalizedString title;
/**
@@ -92,11 +96,11 @@ public class Category extends CcmObject implements Serializable {
*/
@Embedded
@AssociationOverride(
- name = "values",
- joinTable = @JoinTable(name = "category_descriptions",
- joinColumns = {
- @JoinColumn(name = "object_id")}
- ))
+ name = "values",
+ joinTable = @JoinTable(name = "category_descriptions",
+ joinColumns = {
+ @JoinColumn(name = "object_id")}
+ ))
private LocalizedString description;
/**
@@ -146,6 +150,14 @@ public class Category extends CcmObject implements Serializable {
@Column(name = "category_order")
private long categoryOrder;
+ public Category() {
+ super();
+ title = new LocalizedString();
+ description = new LocalizedString();
+ objects = new ArrayList<>();
+ subCategories = new ArrayList<>();
+ }
+
public String getUniqueId() {
return uniqueId;
}
@@ -271,7 +283,7 @@ public class Category extends CcmObject implements Serializable {
@Override
public int hashCode() {
- int hash = 5;
+ int hash = super.hashCode();
hash = 23 * hash + Objects.hashCode(uniqueId);
hash = 23 * hash + Objects.hashCode(name);
hash = 23 * hash + Objects.hashCode(title);
@@ -290,6 +302,10 @@ public class Category extends CcmObject implements Serializable {
"PMD.StdCyclomaticComplexity",
"PMD.ModifiedCyclomaticComplexity"})
public boolean equals(final Object obj) {
+ if (!super.equals(obj)) {
+ return false;
+ }
+
if (obj == null) {
return false;
}
@@ -336,13 +352,13 @@ public class Category extends CcmObject implements Serializable {
@Override
public String toString(final String data) {
return super.toString(String.format(", uniqueId = %s, "
- + "name = \"%s\", "
- + "title = %s, "
- + "enabled = %b, "
- + "visible = %b, "
- + "abstractCategory = %b, "
- + "parentCategory = %s, "
- + "categoryOrder = %d%s",
+ + "name = \"%s\", "
+ + "title = %s, "
+ + "enabled = %b, "
+ + "visible = %b, "
+ + "abstractCategory = %b, "
+ + "parentCategory = %s, "
+ + "categoryOrder = %d%s",
uniqueId,
name,
title.toString(),
diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java
index ca25ecee1..7a31bf184 100644
--- a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java
+++ b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java
@@ -25,6 +25,7 @@ import org.libreccm.l10n.LocalizedString;
import java.io.Serializable;
import java.net.URI;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -44,14 +45,14 @@ import javax.persistence.TemporalType;
import javax.validation.constraints.Pattern;
/**
- * A domain is collection of categories designed a specific purpose. This
- * entity replaces the {@code Domain} entity from the old {@code ccm-ldn-terms}
- * module as well as the {@code CategoryPurpose} entity from the old
+ * A domain is collection of categories designed a specific purpose. This entity
+ * replaces the {@code Domain} entity from the old {@code ccm-ldn-terms} module
+ * as well as the {@code CategoryPurpose} entity from the old
* {@code ccm-core module}.
- *
+ *
* A {@code Domain} can be mapped to multiple {@link CcmObject}s. Normally this
- * is used to make a {@code Domain} available in a application. The
- * {@link CcmObject}s to which a {@code Domain} is mapped are called
+ * is used to make a {@code Domain} available in a application. The
+ * {@link CcmObject}s to which a {@code Domain} is mapped are called
* owners of the domain.
*
* @author Jens Pelzetter
@@ -74,12 +75,12 @@ public class Domain extends CcmObject implements Serializable {
/**
* An unique URI identifying the domain. It is not required that this domain
- * points to a real resource, it primary purpose is provide a unique
+ * points to a real resource, it primary purpose is provide a unique
* identifier. for the domain. If you create your own category system you
* should use the top level domain of your organisation. Also the URI should
- * include the domain key in lower case letters. For example if the domain
- * key is {@code EXAMPLE-NAV}, than the URI can be
- *
+ * include the domain key in lower case letters. For example if the domain
+ * key is {@code EXAMPLE-NAV}, than the URI can be
+ *
*
* http://example.org/domains/example-nav
*
@@ -90,55 +91,62 @@ public class Domain extends CcmObject implements Serializable {
private URI uri;
/**
- * A human readable title for the {@code Domain}. The title can be
+ * A human readable title for the {@code Domain}. The title can be
* localised.
*/
@Embedded
@AssociationOverride(
- name = "values",
- joinTable = @JoinTable(name = "domain_titles",
- joinColumns = {
- @JoinColumn(name = "object_id")}))
+ name = "values",
+ joinTable = @JoinTable(name = "domain_titles",
+ joinColumns = {
+ @JoinColumn(name = "object_id")}))
private LocalizedString title;
-
+
/**
* A description of the domain. The description can be localised.
*/
@Embedded
@AssociationOverride(
- name = "values",
- joinTable = @JoinTable(name = "domain_descriptions",
- joinColumns = {
- @JoinColumn(name = "object_id")}))
+ name = "values",
+ joinTable = @JoinTable(name = "domain_descriptions",
+ joinColumns = {
+ @JoinColumn(name = "object_id")}))
private LocalizedString description;
-
+
/**
* A version string for the {@code Domain}.
*/
@Column(name = "version", nullable = false)
@NotBlank
private String version;
-
+
/**
* A timestamp for the release date of the {@code Domain}.
*/
@Column(name = "released")
@Temporal(TemporalType.TIMESTAMP)
private Date released;
-
+
/**
* The root category of the domain.
*/
@ManyToOne
@JoinColumn(name = "root_category_id")
private Category root;
-
+
/**
* The owners of the domain.
*/
@OneToMany(mappedBy = "domain")
private List owners;
+ public Domain() {
+ super();
+ title = new LocalizedString();
+ description = new LocalizedString();
+ owners = new ArrayList<>();
+ }
+
public String getDomainKey() {
return domainKey;
}
@@ -197,12 +205,12 @@ public class Domain extends CcmObject implements Serializable {
/**
* Returns an unmodifiable list of the owners of this
- * {@code Domain}. To add or remove owners use the methods provided
- * by the {@link DomainManager}.
- *
- * @return An unmodifiable list of the owners of this
- * {@Domain}
- *
+ * {@code Domain}. To add or remove owners use the methods provided by the
+ * {@link DomainManager}.
+ *
+ * @return An unmodifiable list of the owners of this {
+ * @Domain}
+ *
* @see #owners
*/
public List getOwners() {
@@ -211,29 +219,29 @@ public class Domain extends CcmObject implements Serializable {
/**
* Internal method for setting the list of owners.
- *
+ *
* @param owners A list of owners.
*/
protected void setOwners(final List owners) {
this.owners = owners;
}
-
+
/**
- * Internal method for adding a {@link DomainOwnership}.
- * To add or remove owners use the methods provided by the
+ * Internal method for adding a {@link DomainOwnership}. To
+ * add or remove owners use the methods provided by the
* {@link DomainManager}.
- *
+ *
* @param owner The domain ownership to add.
*/
protected void addOwner(final DomainOwnership owner) {
owners.add(owner);
}
-
+
/**
- * Internal method for removing a {@link DomainOwnership}.
- * To add or remove owners use the methods provided by the
+ * Internal method for removing a {@link DomainOwnership}.
+ * To add or remove owners use the methods provided by the
* {@link DomainManager}.
- *
+ *
* @param owner The domain ownership to add.
*/
protected void removeOwner(final DomainOwnership owner) {
@@ -269,8 +277,7 @@ public class Domain extends CcmObject implements Serializable {
if (!other.canEqual(this)) {
return false;
}
-
-
+
if (!Objects.equals(domainKey, other.getDomainKey())) {
return false;
}
@@ -291,28 +298,28 @@ public class Domain extends CcmObject implements Serializable {
}
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 %Jens Pelzetter
+ *
*/
@Entity
@Table(name = "ccm_objects")
diff --git a/ccm-core/src/main/java/org/libreccm/core/Group.java b/ccm-core/src/main/java/org/libreccm/core/Group.java
deleted file mode 100644
index 31c1f4c70..000000000
--- a/ccm-core/src/main/java/org/libreccm/core/Group.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.core;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.Table;
-
-/**
- *
- * @author Jens Pelzetter
- */
-@Entity
-@Table(name = "groups")
-public class Group extends Party implements Serializable {
-
- private static final long serialVersionUID = -5555063356689597270L;
-
-}
diff --git a/ccm-core/src/main/java/org/libreccm/core/Party.java b/ccm-core/src/main/java/org/libreccm/core/Party.java
index 50ced74df..748577747 100644
--- a/ccm-core/src/main/java/org/libreccm/core/Party.java
+++ b/ccm-core/src/main/java/org/libreccm/core/Party.java
@@ -69,6 +69,10 @@ public class Party extends CcmObject implements Serializable {
@Override
public boolean equals(final Object obj) {
+ if (!super.equals(obj)) {
+ return false;
+ }
+
if (obj == null) {
return false;
}
diff --git a/ccm-core/src/main/java/org/libreccm/categorization/PersonName.java b/ccm-core/src/main/java/org/libreccm/core/PersonName.java
similarity index 99%
rename from ccm-core/src/main/java/org/libreccm/categorization/PersonName.java
rename to ccm-core/src/main/java/org/libreccm/core/PersonName.java
index 69cb72843..cb130d92b 100644
--- a/ccm-core/src/main/java/org/libreccm/categorization/PersonName.java
+++ b/ccm-core/src/main/java/org/libreccm/core/PersonName.java
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
-package org.libreccm.categorization;
+package org.libreccm.core;
import org.hibernate.validator.constraints.NotBlank;
diff --git a/ccm-core/src/main/java/org/libreccm/core/User.java b/ccm-core/src/main/java/org/libreccm/core/User.java
index 60b55eefe..26167e4aa 100644
--- a/ccm-core/src/main/java/org/libreccm/core/User.java
+++ b/ccm-core/src/main/java/org/libreccm/core/User.java
@@ -19,9 +19,16 @@
package org.libreccm.core;
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.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.Table;
+import org.hibernate.validator.constraints.NotBlank;
/**
*
@@ -30,8 +37,174 @@ import javax.persistence.Table;
@Entity
@Table(name = "users")
public class User extends Party implements Serializable {
+
private static final long serialVersionUID = 892038270064849732L;
-
-
-
+
+ @Embedded
+ @AssociationOverride(
+ name = "user_names",
+ joinTable = @JoinTable(name = "user_names",
+ joinColumns = {
+ @JoinColumn(name = " user_id")}))
+ private PersonName name;
+
+ @Column(name = "screen_name", length = 255, nullable = false)
+ @NotBlank
+ private String screenName;
+
+ @Column(name = "banned")
+ private boolean banned;
+
+ @Column(name = "sso_login", length = 512)
+ private String ssoLogin;
+
+ @Column(name = "password", length = 2048)
+ private String password;
+
+ @Column(name = "salt", length = 2048)
+ private String salt;
+
+ @Column(name = "password_question", length = 2048)
+ private String passwordQuestion;
+
+ @Column(name = "password_answer", length = 2048)
+ private String passwordAnswer;
+
+ public PersonName getName() {
+ return name;
+ }
+
+ public void setName(final PersonName name) {
+ this.name = name;
+ }
+
+ public String getScreenName() {
+ return screenName;
+ }
+
+ public void setScreenName(final String screenName) {
+ this.screenName = screenName;
+ }
+
+ public boolean isBanned() {
+ return banned;
+ }
+
+ public void setBanned(final boolean banned) {
+ this.banned = banned;
+ }
+
+ public String getSsoLogin() {
+ return ssoLogin;
+ }
+
+ public void setSsoLogin(final String ssoLogin) {
+ this.ssoLogin = ssoLogin;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(final String password) {
+ this.password = password;
+ }
+
+ public String getSalt() {
+ return salt;
+ }
+
+ public void setSalt(final String salt) {
+ this.salt = salt;
+ }
+
+ public String getPasswordQuestion() {
+ return passwordQuestion;
+ }
+
+ public void setPasswordQuestion(final String passwordQuestion) {
+ this.passwordQuestion = passwordQuestion;
+ }
+
+ public String getPasswordAnswer() {
+ return passwordAnswer;
+ }
+
+ public void setPasswordAnswer(final String passwordAnswer) {
+ this.passwordAnswer = passwordAnswer;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = super.hashCode();
+ hash = 59 * hash + Objects.hashCode(this.name);
+ hash = 59 * hash + Objects.hashCode(this.screenName);
+ hash = 59 * hash + (this.banned ? 1 : 0);
+ hash = 59 * hash + Objects.hashCode(this.ssoLogin);
+ hash = 59 * hash + Objects.hashCode(this.password);
+ hash = 59 * hash + Objects.hashCode(this.salt);
+ hash = 59 * hash + Objects.hashCode(this.passwordQuestion);
+ hash = 59 * hash + Objects.hashCode(this.passwordAnswer);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (!super.equals(obj)) {
+ return false;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final User other = (User) obj;
+ if (!other.canEqual(this)) {
+ return false;
+ }
+
+ if (!Objects.equals(this.name, other.getName())) {
+ return false;
+ }
+ if (!Objects.equals(this.screenName, other.getScreenName())) {
+ return false;
+ }
+ if (this.banned != other.isBanned()) {
+ return false;
+ }
+ if (!Objects.equals(this.ssoLogin, other.getSsoLogin())) {
+ return false;
+ }
+ if (!Objects.equals(this.password, other.getPassword())) {
+ return false;
+ }
+ if (!Objects.equals(this.salt, other.getSalt())) {
+ return false;
+ }
+ if (!Objects.equals(this.passwordQuestion, other.getPasswordQuestion())) {
+ return false;
+ }
+ return Objects.equals(this.passwordAnswer, other.getPasswordAnswer());
+ }
+
+ @Override
+ public boolean canEqual(final Object obj) {
+ return obj instanceof User;
+ }
+
+ @Override
+ public String toString(final String data) {
+ return super.toString(String.format(", name = %s, "
+ + "screenName = \"%s\", "
+ + "banned = %b, "
+ + "ssoLogin = \"%s\"%s",
+ Objects.toString(name),
+ screenName,
+ banned,
+ ssoLogin,
+ data));
+ }
+
}
diff --git a/ccm-core/src/main/java/org/libreccm/core/UserGroup.java b/ccm-core/src/main/java/org/libreccm/core/UserGroup.java
new file mode 100644
index 000000000..3dcc9de83
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/core/UserGroup.java
@@ -0,0 +1,130 @@
+/*
+ * 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.core;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import javax.persistence.Column;
+
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import org.hibernate.validator.constraints.NotBlank;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@Entity
+@Table(name = "user_groups")
+public class UserGroup extends Party implements Serializable {
+
+ private static final long serialVersionUID = -5555063356689597270L;
+
+ @Column(name = "name", length = 512, nullable = false)
+ @NotBlank
+ private String name;
+
+ @OneToMany(mappedBy = "sourceGroup")
+ private List roles;
+
+ @OneToMany(mappedBy = "group")
+ private List groupMemberships;
+
+ public UserGroup() {
+ super();
+
+ roles = new ArrayList<>();
+ groupMemberships = new ArrayList<>();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public List getRoles() {
+ return Collections.unmodifiableList(roles);
+ }
+
+ protected void setRoles(final List roles) {
+ this.roles = roles;
+ }
+
+ protected void addRole(final Role role) {
+ roles.add(role);
+ }
+
+ protected void removeRole(final Role role) {
+ roles.remove(role);
+ }
+
+ public List getGroupMembership() {
+ return Collections.unmodifiableList(groupMemberships);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 83 * hash + Objects.hashCode(this.name);
+ hash = 83 * hash + Objects.hashCode(this.roles);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (!super.equals(obj)) {
+ return false;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final UserGroup other = (UserGroup) obj;
+ if (!other.canEqual(this)) {
+ return false;
+ }
+
+ if (!Objects.equals(this.name, other.name)) {
+ return false;
+ }
+ return Objects.equals(this.roles, other.roles);
+ }
+
+ public boolean canEquals(final Object obj) {
+ return obj instanceof UserGroup;
+ }
+
+ @Override
+ public String toString(final String data) {
+ return super.toString(String.format(", name = \"%s\"%s",
+ name,
+ data));
+ }
+
+}