mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 12:03:09 +00:00
Fix dspace-api module per new code style
This commit is contained in:
@@ -7,46 +7,61 @@
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.comparator.NameAscendingComparator;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.core.*;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.proxy.HibernateProxyHelper;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Class representing a community
|
||||
* <P>
|
||||
* The community's metadata (name, introductory text etc.) is loaded into'
|
||||
* memory. Changes to this metadata are only reflected in the database after
|
||||
* <code>update</code> is called.
|
||||
*
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="community")
|
||||
@Table(name = "community")
|
||||
@Cacheable
|
||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
{
|
||||
/** log4j category */
|
||||
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger log = Logger.getLogger(Community.class);
|
||||
|
||||
@Column(name="community_id", insertable = false, updatable = false)
|
||||
@Column(name = "community_id", insertable = false, updatable = false)
|
||||
private Integer legacyId;
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(
|
||||
name = "community2community",
|
||||
joinColumns = {@JoinColumn(name = "parent_comm_id") },
|
||||
inverseJoinColumns = {@JoinColumn(name = "child_comm_id") }
|
||||
name = "community2community",
|
||||
joinColumns = {@JoinColumn(name = "parent_comm_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "child_comm_id")}
|
||||
)
|
||||
private Set<Community> subCommunities = new HashSet<>();
|
||||
|
||||
@@ -61,7 +76,9 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
/** The default group of administrators */
|
||||
private Group admins;
|
||||
|
||||
/** The logo bitstream */
|
||||
/**
|
||||
* The logo bitstream
|
||||
*/
|
||||
@OneToOne
|
||||
@JoinColumn(name = "logo_bitstream_id")
|
||||
private Bitstream logo = null;
|
||||
@@ -80,21 +97,17 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
* {@link org.dspace.content.service.CommunityService#create(Community, Context)}
|
||||
* or
|
||||
* {@link org.dspace.content.service.CommunityService#create(Community, Context, String)}
|
||||
*
|
||||
*/
|
||||
protected Community()
|
||||
{
|
||||
protected Community() {
|
||||
|
||||
}
|
||||
|
||||
void addSubCommunity(Community subCommunity)
|
||||
{
|
||||
void addSubCommunity(Community subCommunity) {
|
||||
subCommunities.add(subCommunity);
|
||||
setModified();
|
||||
}
|
||||
|
||||
void removeSubCommunity(Community subCommunity)
|
||||
{
|
||||
void removeSubCommunity(Community subCommunity) {
|
||||
subCommunities.remove(subCommunity);
|
||||
setModified();
|
||||
}
|
||||
@@ -102,11 +115,10 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
/**
|
||||
* Get the logo for the community. <code>null</code> is return if the
|
||||
* community does not have a logo.
|
||||
*
|
||||
*
|
||||
* @return the logo of the community, or <code>null</code>
|
||||
*/
|
||||
public Bitstream getLogo()
|
||||
{
|
||||
public Bitstream getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
@@ -122,12 +134,11 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
* <P>
|
||||
* The default group of administrators for community 100 is the one called
|
||||
* <code>community_100_admin</code>.
|
||||
*
|
||||
*
|
||||
* @return group of administrators, or <code>null</code> if there is no
|
||||
* default group.
|
||||
* default group.
|
||||
*/
|
||||
public Group getAdministrators()
|
||||
{
|
||||
public Group getAdministrators() {
|
||||
return admins;
|
||||
}
|
||||
|
||||
@@ -139,25 +150,22 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
/**
|
||||
* Get the collections in this community. Throws an SQLException because
|
||||
* creating a community object won't load in all collections.
|
||||
*
|
||||
*
|
||||
* @return array of Collection objects
|
||||
*/
|
||||
public List<Collection> getCollections()
|
||||
{
|
||||
public List<Collection> getCollections() {
|
||||
// We return a copy because we do not want people to add elements to this collection directly.
|
||||
// We return a list to maintain backwards compatibility
|
||||
Collection[] output = collections.toArray(new Collection[]{});
|
||||
Collection[] output = collections.toArray(new Collection[] {});
|
||||
Arrays.sort(output, new NameAscendingComparator());
|
||||
return Arrays.asList(output);
|
||||
}
|
||||
|
||||
void addCollection(Collection collection)
|
||||
{
|
||||
void addCollection(Collection collection) {
|
||||
collections.add(collection);
|
||||
}
|
||||
|
||||
void removeCollection(Collection collection)
|
||||
{
|
||||
void removeCollection(Collection collection) {
|
||||
collections.remove(collection);
|
||||
}
|
||||
|
||||
@@ -165,14 +173,13 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
* Get the immediate sub-communities of this community. Throws an
|
||||
* SQLException because creating a community object won't load in all
|
||||
* collections.
|
||||
*
|
||||
*
|
||||
* @return array of Community objects
|
||||
*/
|
||||
public List<Community> getSubcommunities()
|
||||
{
|
||||
public List<Community> getSubcommunities() {
|
||||
// We return a copy because we do not want people to add elements to this collection directly.
|
||||
// We return a list to maintain backwards compatibility
|
||||
Community[] output = subCommunities.toArray(new Community[]{});
|
||||
Community[] output = subCommunities.toArray(new Community[] {});
|
||||
Arrays.sort(output, new NameAscendingComparator());
|
||||
return Arrays.asList(output);
|
||||
}
|
||||
@@ -180,14 +187,13 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
/**
|
||||
* Return the parent community of this community, or null if the community
|
||||
* is top-level
|
||||
*
|
||||
*
|
||||
* @return the immediate parent community, or null if top-level
|
||||
*/
|
||||
public List<Community> getParentCommunities()
|
||||
{
|
||||
public List<Community> getParentCommunities() {
|
||||
// We return a copy because we do not want people to add elements to this collection directly.
|
||||
// We return a list to maintain backwards compatibility
|
||||
Community[] output = parentCommunities.toArray(new Community[]{});
|
||||
Community[] output = parentCommunities.toArray(new Community[] {});
|
||||
Arrays.sort(output, new NameAscendingComparator());
|
||||
return Arrays.asList(output);
|
||||
}
|
||||
@@ -196,12 +202,11 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
parentCommunities.add(parentCommunity);
|
||||
}
|
||||
|
||||
void clearParentCommunities(){
|
||||
void clearParentCommunities() {
|
||||
parentCommunities.clear();
|
||||
}
|
||||
|
||||
public void removeParentCommunity(Community parentCommunity)
|
||||
{
|
||||
public void removeParentCommunity(Community parentCommunity) {
|
||||
parentCommunities.remove(parentCommunity);
|
||||
setModified();
|
||||
}
|
||||
@@ -209,28 +214,22 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
/**
|
||||
* Return <code>true</code> if <code>other</code> is the same Community
|
||||
* as this object, <code>false</code> otherwise
|
||||
*
|
||||
* @param other
|
||||
* object to compare to
|
||||
*
|
||||
*
|
||||
* @param other object to compare to
|
||||
* @return <code>true</code> if object passed in represents the same
|
||||
* community as this object
|
||||
* community as this object
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other);
|
||||
if (this.getClass() != objClass)
|
||||
{
|
||||
if (this.getClass() != objClass) {
|
||||
return false;
|
||||
}
|
||||
final Community otherCommunity = (Community) other;
|
||||
if (!this.getID().equals(otherCommunity.getID() ))
|
||||
{
|
||||
if (!this.getID().equals(otherCommunity.getID())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -238,24 +237,24 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(getID()).toHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* return type found in Constants
|
||||
*
|
||||
* @return Community type
|
||||
*/
|
||||
@Override
|
||||
public int getType()
|
||||
{
|
||||
public int getType() {
|
||||
return Constants.COMMUNITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
String value = getCommunityService().getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||
String value = getCommunityService()
|
||||
.getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@@ -265,8 +264,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
}
|
||||
|
||||
private CommunityService getCommunityService() {
|
||||
if(communityService == null)
|
||||
{
|
||||
if (communityService == null) {
|
||||
communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||
}
|
||||
return communityService;
|
||||
|
Reference in New Issue
Block a user