mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 03:53:07 +00:00
Fix dspace-api module per new code style
This commit is contained in:
@@ -7,27 +7,36 @@
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderBy;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.core.ReloadableEntity;
|
||||
import org.dspace.handle.Handle;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Abstract base class for DSpace objects
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy= InheritanceType.JOINED)
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Table(name = "dspaceobject")
|
||||
public abstract class DSpaceObject implements Serializable, ReloadableEntity<java.util.UUID>
|
||||
{
|
||||
public abstract class DSpaceObject implements Serializable, ReloadableEntity<java.util.UUID> {
|
||||
@Id
|
||||
@GeneratedValue(generator = "system-uuid")
|
||||
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
|
||||
@@ -38,14 +47,15 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
// e.g. to document metadata fields touched, etc.
|
||||
@Transient
|
||||
private StringBuffer eventDetails = null;
|
||||
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dSpaceObject", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@OrderBy("metadataField, place")
|
||||
private List<MetadataValue> metadata = new ArrayList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dso")
|
||||
// Order by is here to ensure that the oldest handle is retrieved first,
|
||||
// multiple handles are assigned to the latest version of an item the original handle will have the lowest identifier
|
||||
// multiple handles are assigned to the latest version of an item the original handle will have the lowest
|
||||
// identifier
|
||||
// This handle is the preferred handle.
|
||||
@OrderBy("id ASC")
|
||||
private List<Handle> handles = new ArrayList<>();
|
||||
@@ -60,20 +70,20 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
@Transient
|
||||
private boolean modifiedMetadata = false;
|
||||
|
||||
/** Flag set when data is modified, for events */
|
||||
/**
|
||||
* Flag set when data is modified, for events
|
||||
*/
|
||||
@Transient
|
||||
private boolean modified = false;
|
||||
|
||||
protected DSpaceObject()
|
||||
{
|
||||
protected DSpaceObject() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the cache of event details.
|
||||
*/
|
||||
public void clearDetails()
|
||||
{
|
||||
public void clearDetails() {
|
||||
eventDetails = null;
|
||||
}
|
||||
|
||||
@@ -82,16 +92,13 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
* separates entries with a comma.
|
||||
* Subclass can just start calling addDetails, since it creates
|
||||
* the cache if it needs to.
|
||||
*
|
||||
* @param d detail string to add.
|
||||
*/
|
||||
protected void addDetails(String d)
|
||||
{
|
||||
if (eventDetails == null)
|
||||
{
|
||||
protected void addDetails(String d) {
|
||||
if (eventDetails == null) {
|
||||
eventDetails = new StringBuffer(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
eventDetails.append(", ").append(d);
|
||||
}
|
||||
}
|
||||
@@ -99,24 +106,23 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
/**
|
||||
* @return summary of event details, or null if there are none.
|
||||
*/
|
||||
public String getDetails()
|
||||
{
|
||||
public String getDetails() {
|
||||
return (eventDetails == null ? null : eventDetails.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of this object, found in Constants
|
||||
*
|
||||
*
|
||||
* @return type of the object
|
||||
*/
|
||||
public abstract int getType();
|
||||
|
||||
/**
|
||||
* Get the internal ID (database primary key) of this object
|
||||
*
|
||||
*
|
||||
* @return internal ID of object
|
||||
*/
|
||||
public UUID getID(){
|
||||
public UUID getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -124,22 +130,19 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
|
||||
/**
|
||||
* Get the Handle of the object. This may return <code>null</code>
|
||||
*
|
||||
*
|
||||
* @return Handle of the object, or <code>null</code> if it doesn't have
|
||||
* one
|
||||
* one
|
||||
*/
|
||||
public String getHandle()
|
||||
{
|
||||
public String getHandle() {
|
||||
return (CollectionUtils.isNotEmpty(handles) ? handles.get(0).getHandle() : null);
|
||||
}
|
||||
|
||||
void setHandle(List<Handle> handle)
|
||||
{
|
||||
void setHandle(List<Handle> handle) {
|
||||
this.handles = handle;
|
||||
}
|
||||
|
||||
public void addHandle(Handle handle)
|
||||
{
|
||||
public void addHandle(Handle handle) {
|
||||
this.handles.add(handle);
|
||||
}
|
||||
|
||||
@@ -155,14 +158,12 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
protected void removeMetadata(MetadataValue metadataValue)
|
||||
{
|
||||
protected void removeMetadata(MetadataValue metadataValue) {
|
||||
setMetadataModified();
|
||||
getMetadata().remove(metadataValue);
|
||||
}
|
||||
|
||||
protected void removeMetadata(List<MetadataValue> metadataValues)
|
||||
{
|
||||
protected void removeMetadata(List<MetadataValue> metadataValues) {
|
||||
setMetadataModified();
|
||||
getMetadata().removeAll(metadataValues);
|
||||
}
|
||||
@@ -189,11 +190,13 @@ public abstract class DSpaceObject implements Serializable, ReloadableEntity<jav
|
||||
public boolean isModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void clearModified() {
|
||||
this.modified = false;
|
||||
}
|
||||
|
||||
protected void setModified() {
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user