2.17.2: 2011-06-17

net.sf.basedb.core
Class ReporterType

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<ReporterTypeData>
      extended by net.sf.basedb.core.ReporterType
All Implemented Interfaces:
AccessControlled, Identifiable, Nameable, Registered, Removable

public class ReporterType
extends BasicItem<ReporterTypeData>
implements Nameable, Removable, Registered

This class holds reporter type information. A reporter may have, but is not required to have a type. The main reason for a reporter to have a type is to make it easier for client application to filter the reporter list.

Version:
2.0
Author:
Nicklas, Samuel
See Also:
ReporterData

Field Summary
private static Item TYPE
          The type of item represented by this class.
 
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
 
Constructor Summary
ReporterType(ReporterTypeData data)
          Constructor that sets reporter type data.
 
Method Summary
static ReporterType getById(DbControl dc, int id)
          Get a ReporterType object when you know the ID.
 String getDescription()
          Get the description for the item.
 Date getEntryDate()
          Get the date that the item was registered in the database.
 String getName()
          Get the name of the item.
static ReporterType getNew(DbControl dc)
          Create a new ReporterType item.
static ItemQuery<ReporterType> getQuery()
          Get a query configured to retrieve reporter types.
 Item getType()
          Get the type of item represented by the object.
 Set<ItemProxy> getUsingItems()
          Get all: Reporter:s of this type
 boolean isRemoved()
          Check if the removed flag is set for this item.
 boolean isUsed()
          Check if any reporters of this type exists.
 ReporterData newReporter(String externalId)
          Create a new ReporterData object of this type.
 void setDescription(String description)
          Set the description for the item.
 void setName(String name)
          Set the name of the item.
 void setRemoved(boolean removed)
          Set the removed flag for this item.
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, initPermissions, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
 
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
 

Field Detail

TYPE

private static final Item TYPE
The type of item represented by this class.

See Also:
Item.REPORTERTYPE, getType()
Constructor Detail

ReporterType

ReporterType(ReporterTypeData data)
Constructor that sets reporter type data.

Parameters:
data - A ReporterTypeData object.
Method Detail

getNew

public static ReporterType getNew(DbControl dc)
                           throws PermissionDeniedException,
                                  BaseException
Create a new ReporterType item.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
Returns:
The new ReporterType item.
Throws:
PermissionDeniedException - If the logged in user doesn't have CREATE permission for this type of item.
BaseException - If there is another error.

getById

public static ReporterType getById(DbControl dc,
                                   int id)
                            throws ItemNotFoundException,
                                   PermissionDeniedException,
                                   BaseException
Get a ReporterType object when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The ID of the item to load.
Returns:
The ReporterType item.
Throws:
ItemNotFoundException - This exception is thrown if an item with the specified ID is not found.
PermissionDeniedException - This exception is thrown if the logged in user doesn't have READ permission to the items.
BaseException - This exception is thrown if there is another error.

getQuery

public static ItemQuery<ReporterType> getQuery()
Get a query configured to retrieve reporter types.

Returns:
An ItemQuery object

getType

public Item getType()
Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.

Specified by:
getType in interface Identifiable
Returns:
A value indicating the type of item.

getName

public String getName()
Description copied from interface: Nameable
Get the name of the item.

Specified by:
getName in interface Nameable
Returns:
A String with the name of the item

setName

public void setName(String name)
             throws PermissionDeniedException,
                    InvalidDataException
Description copied from interface: Nameable
Set the name of the item. The name cannot be null and mustn't be longer than the value specified by the Nameable.MAX_NAME_LENGTH constant.

Specified by:
setName in interface Nameable
Parameters:
name - The new name for the item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the name is null or longer than specified by the Nameable.MAX_NAME_LENGTH constant

getDescription

public String getDescription()
Description copied from interface: Nameable
Get the description for the item.

Specified by:
getDescription in interface Nameable
Returns:
A String with a description of the item

setDescription

public void setDescription(String description)
                    throws PermissionDeniedException,
                           InvalidDataException
Description copied from interface: Nameable
Set the description for the item. The description can be null but mustn't be longer than the value specified by the Nameable.MAX_DESCRIPTION_LENGTH constant.

Specified by:
setDescription in interface Nameable
Parameters:
description - The new description for the item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the description longer than specified by the Nameable.MAX_DESCRIPTION_LENGTH constant

isRemoved

public boolean isRemoved()
Description copied from interface: Removable
Check if the removed flag is set for this item.

Specified by:
isRemoved in interface Removable
Returns:
TRUE if the item is flagged as removed, FALSE otherwise

setRemoved

public void setRemoved(boolean removed)
                throws PermissionDeniedException
Description copied from interface: Removable
Set the removed flag for this item.

Specified by:
setRemoved in interface Removable
Parameters:
removed - TRUE if the item should be flagged as removed, FALSE otherwise
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.DELETE permission for setting the flag to TRUE or Permission.WRITE permission for setting the flag to FALSE

getEntryDate

public Date getEntryDate()
Description copied from interface: Registered
Get the date that the item was registered in the database.

Specified by:
getEntryDate in interface Registered
Returns:
A date or null if this is not known

isUsed

public boolean isUsed()
               throws BaseException
Check if any reporters of this type exists.

Overrides:
isUsed in class BasicItem<ReporterTypeData>
Returns:
TRUE if this item is used, FALSE otherwise
Throws:
BaseException - If not able to tell if item is used or not.
See Also:
BasicItem.getUsingItems()

getUsingItems

public Set<ItemProxy> getUsingItems()
Get all:

newReporter

public ReporterData newReporter(String externalId)
                         throws PermissionDeniedException,
                                InvalidDataException,
                                BaseException
Create a new ReporterData object of this type.

Parameters:
externalId - The external id of the new reporter. Null is not allowed
Returns:
The new ReporterData object
Throws:
PermissionDeniedException - This exception is thrown if user doesn't have use permission for this reporter type.
InvalidDataException - If required argument is null.
BaseException - If there is another error.

2.17.2: 2011-06-17