[FEATURE]

- provides the instance variables with jpa annotations replacing the associations in the ResourceImpl.pdl

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3636 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
tosmers 2015-09-22 14:29:35 +00:00
parent a3f58755bd
commit a14a30c688
7 changed files with 170 additions and 29 deletions

View File

@ -183,6 +183,18 @@ public class User extends Subject implements Serializable {
@XmlElement(name = "group-membership", namespace = CORE_XML_NS)
private List<GroupMembership> groupMemberships;
/**
* The {@link Resource}s created by the {@code User}.
*/
@OneToMany(mappedBy = "creationUser")
private List<Resource> createdResources;
/**
* The {@link Resource}s modified by the {@code User}.
*/
@OneToMany(mappedBy = "lastModifiedUser")
private List<Resource> modifiedResources;
public User() {
super();
@ -310,6 +322,22 @@ public class User extends Subject implements Serializable {
groupMemberships.remove(groupMembership);
}
public List<Resource> getCreatedResources() {
return createdResources;
}
public void setCreatedResources(List<Resource> createdResources) {
this.createdResources = createdResources;
}
public List<Resource> getModifiedResources() {
return modifiedResources;
}
public void setModifiedResources(List<Resource> 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));
}
}

View File

@ -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());
}
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<Resource> 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<Resource> getImmediateChildren() {
return immediateChildren;
}
public void setImmediateChildren(List<Resource> immediateChildren) {
this.immediateChildren = immediateChildren;
}
//< End GETTER & SETTER
}