CCM NG: Current status
git-svn-id: https://svn.libreccm.org/ccm/jpa@3388 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
4e98aa55af
commit
4d566410ab
|
|
@ -38,6 +38,8 @@ import java.util.Objects;
|
|||
* The methods provided by the {@link CategoryManager} take care of that.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*
|
||||
* @apiviz.has org.libreccm.core.CcmObject
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "categorizations")
|
||||
|
|
|
|||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*
|
||||
* @apiviz.composedOf org.libreccm.categorization.Categorization
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "categories")
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,9 +45,9 @@ 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
|
||||
|
|
@ -139,6 +140,13 @@ public class Domain extends CcmObject implements Serializable {
|
|||
@OneToMany(mappedBy = "domain")
|
||||
private List<DomainOwnership> owners;
|
||||
|
||||
public Domain() {
|
||||
super();
|
||||
title = new LocalizedString();
|
||||
description = new LocalizedString();
|
||||
owners = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getDomainKey() {
|
||||
return domainKey;
|
||||
}
|
||||
|
|
@ -197,11 +205,11 @@ public class Domain extends CcmObject implements Serializable {
|
|||
|
||||
/**
|
||||
* Returns an <strong>unmodifiable</strong> list of the owners of this
|
||||
* {@code Domain}. To add or remove owners use the methods provided
|
||||
* by the {@link DomainManager}.
|
||||
* {@code Domain}. To add or remove owners use the methods provided by the
|
||||
* {@link DomainManager}.
|
||||
*
|
||||
* @return An <strong>unmodifiable</strong> list of the owners of this
|
||||
* {@Domain}
|
||||
* @return An <strong>unmodifiable</strong> list of the owners of this {
|
||||
* @Domain}
|
||||
*
|
||||
* @see #owners
|
||||
*/
|
||||
|
|
@ -219,8 +227,8 @@ public class Domain extends CcmObject implements Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* <strong>Internal</strong> method for adding a {@link DomainOwnership}.
|
||||
* To add or remove owners use the methods provided by the
|
||||
* <strong>Internal</strong> 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.
|
||||
|
|
@ -270,7 +278,6 @@ public class Domain extends CcmObject implements Serializable {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!Objects.equals(domainKey, other.getDomainKey())) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import javax.persistence.Table;
|
|||
* in the database.
|
||||
*
|
||||
* @author <a href="jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "ccm_objects")
|
||||
|
|
|
|||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "groups")
|
||||
public class Group extends Party implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5555063356689597270L;
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@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<Role> roles;
|
||||
|
||||
@OneToMany(mappedBy = "group")
|
||||
private List<GroupMembership> 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<Role> getRoles() {
|
||||
return Collections.unmodifiableList(roles);
|
||||
}
|
||||
|
||||
protected void setRoles(final List<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
protected void addRole(final Role role) {
|
||||
roles.add(role);
|
||||
}
|
||||
|
||||
protected void removeRole(final Role role) {
|
||||
roles.remove(role);
|
||||
}
|
||||
|
||||
public List<GroupMembership> 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));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue