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 ff2730b7d..59a94ff14 100644 --- a/ccm-core/src/main/java/org/libreccm/core/User.java +++ b/ccm-core/src/main/java/org/libreccm/core/User.java @@ -183,6 +183,18 @@ public class User extends Subject implements Serializable { @XmlElement(name = "group-membership", namespace = CORE_XML_NS) private List groupMemberships; + /** + * The {@link Resource}s created by the {@code User}. + */ + @OneToMany(mappedBy = "creationUser") + private List createdResources; + + /** + * The {@link Resource}s modified by the {@code User}. + */ + @OneToMany(mappedBy = "lastModifiedUser") + private List modifiedResources; + public User() { super(); @@ -310,6 +322,22 @@ public class User extends Subject implements Serializable { groupMemberships.remove(groupMembership); } + public List getCreatedResources() { + return createdResources; + } + + public void setCreatedResources(List createdResources) { + this.createdResources = createdResources; + } + + public List getModifiedResources() { + return modifiedResources; + } + + public void setModifiedResources(List modifiedResources) { + this.modifiedResources = modifiedResources; + } + @Override public int hashCode() { int hash = super.hashCode(); @@ -404,5 +432,4 @@ public class User extends Subject implements Serializable { passwordResetRequired, data)); } - } diff --git a/ccm-docrepo/src/main/java/org/libreccm/docrepo/BlobObject.java b/ccm-docrepo/src/main/java/org/libreccm/docrepo/BlobObject.java index d3baca439..d0d691bad 100644 --- a/ccm-docrepo/src/main/java/org/libreccm/docrepo/BlobObject.java +++ b/ccm-docrepo/src/main/java/org/libreccm/docrepo/BlobObject.java @@ -21,7 +21,13 @@ package org.libreccm.docrepo; import org.hibernate.validator.constraints.NotEmpty; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToOne; +import javax.persistence.Table; import java.io.Serializable; import java.sql.Blob; import java.util.Objects; @@ -48,12 +54,24 @@ public class BlobObject implements Serializable { private long blobObjectId; /** - * The Content of the blob-object. + * The Content of the {@code BlobObject}. */ @Column(name = "CONTENT") @NotEmpty private Blob content; + /** + * The {@link Resource} assigned to the {@code BlobObject}. + */ + @OneToOne(mappedBy = "content") + @NotEmpty + private Resource resource; + + /** + * Constructor. + */ + public BlobObject() {} + //> Begin GETTER & SETTER public long getBlobObjectId() { @@ -72,6 +90,14 @@ public class BlobObject implements Serializable { this.content = content; } + public Resource getResource() { + return resource; + } + + public void setResource(Resource resource) { + this.resource = resource; + } + //< End GETTER & SETTER @Override @@ -114,4 +140,6 @@ public class BlobObject implements Serializable { blobObjectId, content.toString()); } + + } diff --git a/ccm-docrepo/src/main/java/org/libreccm/docrepo/File.java b/ccm-docrepo/src/main/java/org/libreccm/docrepo/File.java index ae3ad8bdd..3e76a090c 100644 --- a/ccm-docrepo/src/main/java/org/libreccm/docrepo/File.java +++ b/ccm-docrepo/src/main/java/org/libreccm/docrepo/File.java @@ -33,6 +33,9 @@ public class File extends Resource { private static final long serialVersionUID = -504220783419811504L; + /** + * Constructor calls the super-class-constructor of {@link Resource}. + */ public File() { super(); } diff --git a/ccm-docrepo/src/main/java/org/libreccm/docrepo/Folder.java b/ccm-docrepo/src/main/java/org/libreccm/docrepo/Folder.java index 5dd17c5a6..cba686d18 100644 --- a/ccm-docrepo/src/main/java/org/libreccm/docrepo/Folder.java +++ b/ccm-docrepo/src/main/java/org/libreccm/docrepo/Folder.java @@ -33,6 +33,9 @@ public class Folder extends Resource { private static final long serialVersionUID = 1561466556458872622L; + /** + * Constructor calls the super-class-constructor of {@link Resource}. + */ public Folder() { super(); } diff --git a/ccm-docrepo/src/main/java/org/libreccm/docrepo/RecUpdDocsPortlet.java b/ccm-docrepo/src/main/java/org/libreccm/docrepo/RecUpdDocsPortlet.java index 95e019bc4..529e16dc8 100644 --- a/ccm-docrepo/src/main/java/org/libreccm/docrepo/RecUpdDocsPortlet.java +++ b/ccm-docrepo/src/main/java/org/libreccm/docrepo/RecUpdDocsPortlet.java @@ -36,6 +36,9 @@ public class RecUpdDocsPortlet extends Portlet { private static final long serialVersionUID = -4091024367070127101L; + /** + * Constructor calls the super-class-constructor of {@link Portlet}. + */ public RecUpdDocsPortlet() { super(); } diff --git a/ccm-docrepo/src/main/java/org/libreccm/docrepo/Repository.java b/ccm-docrepo/src/main/java/org/libreccm/docrepo/Repository.java index 66d376f87..3f56162d7 100644 --- a/ccm-docrepo/src/main/java/org/libreccm/docrepo/Repository.java +++ b/ccm-docrepo/src/main/java/org/libreccm/docrepo/Repository.java @@ -48,6 +48,9 @@ public class Repository extends Application { @Column(name = "OWNER_ID") private long ownerId; + /** + * Constructor calls the super-class-constructor of {@link Application}. + */ public Repository() { super(); } diff --git a/ccm-docrepo/src/main/java/org/libreccm/docrepo/Resource.java b/ccm-docrepo/src/main/java/org/libreccm/docrepo/Resource.java index 1407b784c..91fb77df6 100644 --- a/ccm-docrepo/src/main/java/org/libreccm/docrepo/Resource.java +++ b/ccm-docrepo/src/main/java/org/libreccm/docrepo/Resource.java @@ -20,15 +20,19 @@ package org.libreccm.docrepo; import org.hibernate.validator.constraints.NotBlank; import org.libreccm.core.CcmObject; +import org.libreccm.core.User; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import java.util.Date; +import java.util.List; /** @@ -47,46 +51,53 @@ public abstract class Resource extends CcmObject { private static final long serialVersionUID = -910317798106611214L; /** - * Name of the resource. + * Name of the {@code Resource}. */ @Column(name = "NAME") @NotBlank private String name; /** - * Description of the resource. + * Description of the {@code Resource}. */ @Column(name = "DESCRIPTION") private String description; /** - * Flag, wheather the resource is a folder or not. + * Flag, wheather the {@code Resource} is a {@link Folder} or not. */ @Column(name = "IS_FOLDER") @NotBlank private boolean isFolder; /** - * Path to the resource + * Path to the {@code Resource}. */ @Column(name = "PATH") @NotBlank private String path; /** - * Mime-type of the resource + * Mime-type of the {@code Resource}. */ @Column(name = "MIME_TYPE") private String mimeType; /** - * Size of the resource. + * Size of the {@code Resource}. */ @Column(name = "SIZE") private long size; /** - * Creation date of the resource. + * Content of the {@code Resource} as a {@link BlobObject}. + */ + @OneToOne + @JoinColumn(name = "CONTENT_ID") + private BlobObject content; + + /** + * Creation date of the {@code Resource}. */ @Column(name = "CREATION_DATE") @NotBlank @@ -94,13 +105,7 @@ public abstract class Resource extends CcmObject { private Date creationDate; /** - * Creation ip of the resource. - */ - @Column(name = "CREATION_IP") - private String creationIp; - - /** - * Date of the latest modification of the resource. + * Date of the latest modification of the {@code Resource}. */ @Column(name = "LAST_MODIFIED_DATE") @NotBlank @@ -108,18 +113,47 @@ public abstract class Resource extends CcmObject { private Date lastModifiedDate; /** - * Ip of the latest modification of the resource. + * Creation ip of the {@code Resource}. + */ + @Column(name = "CREATION_IP") + private String creationIp; + + /** + * Ip of the latest modification of the {@code Resource}. */ @Column(name = "LAST_MODIFIED_IP") private String lastModifiedIp; - @OneToOne - @JoinColumn(name = "CONTENT_RESOURCE_ID") - private Resource contentResource; + /** + * The {@link User}, who created the {@code Resource}. + */ + @ManyToOne + @JoinColumn(name = "CREATION_USER_ID") + private User creationUser; + /** + * The {@link User}, who last modified the {@code Resource}. + */ + @ManyToOne + @JoinColumn(name = "LAST_MODIFIED_USER_ID") + private User lastModifiedUser; + /** + * The parent-{@code Resource} of the {@code Resource}. + */ + @ManyToOne + @JoinColumn(name = "PARENT_ID") + private Resource parent; + /** + * The child-{@code Resource}s of the {@code Resource}. + */ + @OneToMany(mappedBy = "parent") + private List immediateChildren; + /** + * Constructor calls the super-class-constructor of {@link CcmObject}. + */ public Resource() { super(); } @@ -174,6 +208,14 @@ public abstract class Resource extends CcmObject { this.size = size; } + public BlobObject getContent() { + return content; + } + + public void setContent(BlobObject content) { + this.content = content; + } + public Date getCreationDate() { return creationDate; } @@ -182,14 +224,6 @@ public abstract class Resource extends CcmObject { this.creationDate = creationDate; } - public String getCreationIp() { - return creationIp; - } - - public void setCreationIp(String creationIp) { - this.creationIp = creationIp; - } - public Date getLastModifiedDate() { return lastModifiedDate; } @@ -198,6 +232,14 @@ public abstract class Resource extends CcmObject { this.lastModifiedDate = lastModifiedDate; } + public String getCreationIp() { + return creationIp; + } + + public void setCreationIp(String creationIp) { + this.creationIp = creationIp; + } + public String getLastModifiedIp() { return lastModifiedIp; } @@ -206,5 +248,37 @@ public abstract class Resource extends CcmObject { this.lastModifiedIp = lastModifiedIp; } + public User getCreationUser() { + return creationUser; + } + + public void setCreationUser(User creationUser) { + this.creationUser = creationUser; + } + + public User getLastModifiedUser() { + return lastModifiedUser; + } + + public void setLastModifiedUser(User lastModifiedUser) { + this.lastModifiedUser = lastModifiedUser; + } + + public Resource getParent() { + return parent; + } + + public void setParent(Resource parent) { + this.parent = parent; + } + + public List getImmediateChildren() { + return immediateChildren; + } + + public void setImmediateChildren(List immediateChildren) { + this.immediateChildren = immediateChildren; + } + //< End GETTER & SETTER }