org.dspace.content
Class Community

java.lang.Object
  extended by org.dspace.content.DSpaceObject
      extended by org.dspace.content.Community

public class Community
extends DSpaceObject

Class representing a community

The community's metadata (name, introductory text etc.) is loaded into' memory. Changes to this metadata are only reflected in the database after update is called.

Version:
$Revision: 3036 $
Author:
Robert Tansley

Method Summary
 void addCollection(Collection c)
          Add an exisiting collection to the community
 void addSubcommunity(Community c)
          Add an exisiting community as a subcommunity to the community
 void canEdit()
           
 boolean canEditBoolean()
          return TRUE if context's user can edit community, false otherwise
 int countItems()
          counts items in this community
static Community create(Community parent, Context context)
          Create a new community, with a new ID.
 Collection createCollection()
          Create a new collection within this community.
 Community createSubcommunity()
          Create a new sub-community within this community.
 void delete()
          Delete the community, including the metadata and logo.
 boolean equals(Object other)
          Return true if other is the same Community as this object, false otherwise
static Community find(Context context, int id)
          Get a community from the database.
static Community[] findAll(Context context)
          Get a list of all communities in the system.
static Community[] findAllTop(Context context)
          Get a list of all top-level communities in the system.
 Community[] getAllParents()
          Return an array of parent communities of this community, in ascending order.
 Collection[] getCollections()
          Get the collections in this community.
 String getHandle()
          Get the Handle of the object.
 int getID()
          Get the internal ID of this collection
 Bitstream getLogo()
          Get the logo for the community.
 String getMetadata(String field)
          Get the value of a metadata field
 String getName()
          Get a proper name for the object.
 Community getParentCommunity()
          Return the parent community of this community, or null if the community is top-level
 Community[] getSubcommunities()
          Get the immediate sub-communities of this community.
 int getType()
          return type found in Constants
 void removeCollection(Collection c)
          Remove a collection.
 void removeSubcommunity(Community c)
          Remove a subcommunity.
 Bitstream setLogo(InputStream is)
          Give the community a logo.
 void setMetadata(String field, String value)
          Set a metadata value
 void update()
          Update the community metadata (including logo) to the database.
 
Methods inherited from class org.dspace.content.DSpaceObject
addDetails, clearDetails, find, getDetails
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

find

public static Community find(Context context,
                             int id)
                      throws SQLException
Get a community from the database. Loads in the metadata

Parameters:
context - DSpace context object
id - ID of the community
Returns:
the community, or null if the ID is invalid.
Throws:
SQLException

create

public static Community create(Community parent,
                               Context context)
                        throws SQLException,
                               AuthorizeException
Create a new community, with a new ID.

Parameters:
context - DSpace context object
Returns:
the newly created community
Throws:
SQLException
AuthorizeException

findAll

public static Community[] findAll(Context context)
                           throws SQLException
Get a list of all communities in the system. These are alphabetically sorted by community name.

Parameters:
context - DSpace context object
Returns:
the communities in the system
Throws:
SQLException

findAllTop

public static Community[] findAllTop(Context context)
                              throws SQLException
Get a list of all top-level communities in the system. These are alphabetically sorted by community name. A top-level community is one without a parent community.

Parameters:
context - DSpace context object
Returns:
the top-level communities in the system
Throws:
SQLException

getID

public int getID()
Get the internal ID of this collection

Specified by:
getID in class DSpaceObject
Returns:
the internal identifier

getHandle

public String getHandle()
Description copied from class: DSpaceObject
Get the Handle of the object. This may return null

Specified by:
getHandle in class DSpaceObject
Returns:
Handle of the object, or null if it doesn't have one
See Also:
DSpaceObject.getHandle()

getMetadata

public String getMetadata(String field)
Get the value of a metadata field

Parameters:
field - the name of the metadata field to get
Returns:
the value of the metadata field
Throws:
IllegalArgumentException - if the requested metadata field doesn't exist

setMetadata

public void setMetadata(String field,
                        String value)
                 throws MissingResourceException
Set a metadata value

Parameters:
field - the name of the metadata field to get
value - value to set the field to
Throws:
IllegalArgumentException - if the requested metadata field doesn't exist
MissingResourceException

getName

public String getName()
Description copied from class: DSpaceObject
Get a proper name for the object. This may return null. Name should be suitable for display in a user interface.

Specified by:
getName in class DSpaceObject
Returns:
Name for the object, or null if it doesn't have one

getLogo

public Bitstream getLogo()
Get the logo for the community. null is return if the community does not have a logo.

Returns:
the logo of the community, or null

setLogo

public Bitstream setLogo(InputStream is)
                  throws AuthorizeException,
                         IOException,
                         SQLException
Give the community a logo. Passing in null removes any existing logo. You will need to set the format of the new logo bitstream before it will work, for example to "JPEG". Note that update(/code> will need to be called for the change to take effect. Setting a logo and not calling update later may result in a previous logo lying around as an "orphaned" bitstream.

Parameters:
is - the stream to use as the new logo
Returns:
the new logo bitstream, or null if there is no logo (null was passed in)
Throws:
AuthorizeException
IOException
SQLException

update

public void update()
            throws SQLException,
                   IOException,
                   AuthorizeException
Update the community metadata (including logo) to the database.

Throws:
SQLException
IOException
AuthorizeException

getCollections

public Collection[] getCollections()
                            throws SQLException
Get the collections in this community. Throws an SQLException because creating a community object won't load in all collections.

Returns:
array of Collection objects
Throws:
SQLException

getSubcommunities

public Community[] getSubcommunities()
                              throws SQLException
Get the immediate sub-communities of this community. Throws an SQLException because creating a community object won't load in all collections.

Returns:
array of Community objects
Throws:
SQLException

getParentCommunity

public Community getParentCommunity()
                             throws SQLException
Return the parent community of this community, or null if the community is top-level

Returns:
the immediate parent community, or null if top-level
Throws:
SQLException

getAllParents

public Community[] getAllParents()
                          throws SQLException
Return an array of parent communities of this community, in ascending order. If community is top-level, return an empty array.

Returns:
an array of parent communities, empty if top-level
Throws:
SQLException

createCollection

public Collection createCollection()
                            throws SQLException,
                                   AuthorizeException
Create a new collection within this community. The collection is created without any workflow groups or default submitter group.

Returns:
the new collection
Throws:
SQLException
AuthorizeException

addCollection

public void addCollection(Collection c)
                   throws SQLException,
                          AuthorizeException
Add an exisiting collection to the community

Parameters:
c - collection to add
Throws:
SQLException
AuthorizeException

createSubcommunity

public Community createSubcommunity()
                             throws SQLException,
                                    AuthorizeException
Create a new sub-community within this community.

Returns:
the new community
Throws:
SQLException
AuthorizeException

addSubcommunity

public void addSubcommunity(Community c)
                     throws SQLException,
                            AuthorizeException
Add an exisiting community as a subcommunity to the community

Parameters:
c - subcommunity to add
Throws:
SQLException
AuthorizeException

removeCollection

public void removeCollection(Collection c)
                      throws SQLException,
                             AuthorizeException,
                             IOException
Remove a collection. Any items then orphaned are deleted.

Parameters:
c - collection to remove
Throws:
SQLException
AuthorizeException
IOException

removeSubcommunity

public void removeSubcommunity(Community c)
                        throws SQLException,
                               AuthorizeException,
                               IOException
Remove a subcommunity. Any substructure then orphaned is deleted.

Parameters:
c - subcommunity to remove
Throws:
SQLException
AuthorizeException
IOException

delete

public void delete()
            throws SQLException,
                   AuthorizeException,
                   IOException
Delete the community, including the metadata and logo. Collections and subcommunities that are then orphans are deleted.

Throws:
SQLException
AuthorizeException
IOException

equals

public boolean equals(Object other)
Return true if other is the same Community as this object, false otherwise

Overrides:
equals in class Object
Parameters:
other - object to compare to
Returns:
true if object passed in represents the same community as this object

getType

public int getType()
return type found in Constants

Specified by:
getType in class DSpaceObject
Returns:
type of the object

canEditBoolean

public boolean canEditBoolean()
                       throws SQLException
return TRUE if context's user can edit community, false otherwise

Returns:
boolean true = current user can edit community
Throws:
SQLException

canEdit

public void canEdit()
             throws AuthorizeException,
                    SQLException
Throws:
AuthorizeException
SQLException

countItems

public int countItems()
               throws SQLException
counts items in this community

Returns:
total items
Throws:
SQLException


Copyright © 2008 The DSpace Foundation. All Rights Reserved.