Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.webapps.bean
Class ModeratedExtension  view ModeratedExtension download ModeratedExtension.java

java.lang.Object
  extended bycom.RuntimeCollective.webapps.bean.ModeratedExtension
All Implemented Interfaces:
EntityBean, java.io.Serializable

public class ModeratedExtension
extends java.lang.Object
implements EntityBean

This is an extension which can be stuck to any EntityBean, and allows for the storage of moderation information for that bean.

Moderation is used as a mechanism for vetting content before it is displayed on the public site. This is different from the Publishable interface since there is no versioning or editing cycle involved. Once a moderator has approved a bean it will be public from there on.

Current moderation behaviour is based on UserGroups, i.e. beans are assigned moderators that belong to a specific group.

Version:
$Id: ModeratedExtension.java,v 1.8 2003/09/30 15:13:09 joe Exp $

Field Summary
static java.lang.String DATABASE_TABLE
          The name of the database table for this bean type.
private static java.lang.String DELETE_FROM
           
private static java.lang.String EMPTY_STRING
           
protected  int id
          This bean's id
protected  boolean isApproved
          Has the moderator approved the bean.
protected  boolean isModerated
          Is this bean moderated.
protected static java.util.HashMap mappingCache
           
protected  int moderatedBeanId
          The EntityBean id of the bean this bean is the moderator for.
protected  int moderatorUserId
          Id of the User bean acting as moderator of this bean.
private static java.lang.String SELECT_DATA
           
private static java.lang.String SELECT_MAPPINGS
           
private static java.lang.String SPACE
           
private static java.lang.String WHERE_EB_ID
           
private static java.lang.String WHERE_ID
           
private static java.lang.String WHERE_T_ID
           
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
INTERFACE_BEAN, NULL_ID
 
Constructor Summary
ModeratedExtension()
          Constructs a new blank bean with a unique id.
ModeratedExtension(int id)
          Gets a bean from the RuntimeDataSource, given an id.
 
Method Summary
 void delete()
          Delete this bean from the database.
static java.util.List filterModeratedBy(java.util.Iterator beans, User user)
          Filter and keep the EntityBeans which are moderated by the specific User.
static java.util.List filterNonApproved(java.util.Iterator beans)
          Filter and keep non-approved EntityBeans from an Iterator of EntityBean.
static java.util.List filterNonApproved(java.util.List beans)
          Filter and keep non-approved EntityBeans from a List of EntityBean.
static java.util.List filterOutNonApproved(java.util.Iterator beans)
          Filter out non-approved EntityBeans from an Iterator of EntityBean.
static java.util.List filterOutNonApproved(java.util.List beans)
          Filter out non-approved EntityBeans from a List of EntityBean.
 EntityBean getEntityBean()
          Gets themoderated bean.
static ModeratedExtension getFor(EntityBean eb)
          Gets the ModeratedExtension for a particular bean if one exists.
 int getId()
          Get the unique id of this bean instance.
 boolean getIsApproved()
          Gets approval status of this bean.
 boolean getIsModerated()
          Gets moderation status of this bean.
protected static java.util.HashMap getMappingCache()
           
static java.lang.String getModeratorName(EntityBean bean)
          Says who, if anybody, is moderating the bean.
 User getModeratorUser()
          Gets the User for this ModeratedExtension
static User getModeratorUser(EntityBean bean)
          Gets who, if anybody, is moderating the bean.
static ModeratedExtension getOrCreateFor(EntityBean eb)
          Gets or creates the ModeratedExtension for a particular bean.
protected static void initMappingCache()
           
static boolean isModerated(EntityBean bean)
          Says whether a given EntityBean is moderated.
static boolean needApproval(EntityBean bean)
          Says whether a given EntityBean requires approval.
 void save()
          Save this bean in the database.
 void setEntityBean(EntityBean bean)
          Sets the moderated bean.
 void setId(int id)
          Set the unique id of this bean instance.
 void setIsApproved(boolean approve)
          Sets approval status of this bean.
 void setIsModerated(boolean moderate)
          Sets moderation status of this bean.
 void setModeratorUser(User user)
          Sets the User for this ModeratedExtension
protected static void updateMapping(java.lang.Integer beanInt, java.lang.Integer extInt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELETE_FROM

private static java.lang.String DELETE_FROM

SELECT_DATA

private static java.lang.String SELECT_DATA

SELECT_MAPPINGS

private static java.lang.String SELECT_MAPPINGS

WHERE_ID

private static java.lang.String WHERE_ID

WHERE_T_ID

private static java.lang.String WHERE_T_ID

WHERE_EB_ID

private static java.lang.String WHERE_EB_ID

DATABASE_TABLE

public static final java.lang.String DATABASE_TABLE
The name of the database table for this bean type.

See Also:
Constant Field Values

id

protected int id
This bean's id


moderatedBeanId

protected int moderatedBeanId
The EntityBean id of the bean this bean is the moderator for.


isModerated

protected boolean isModerated
Is this bean moderated.


isApproved

protected boolean isApproved
Has the moderator approved the bean.


moderatorUserId

protected int moderatorUserId
Id of the User bean acting as moderator of this bean.


mappingCache

protected static java.util.HashMap mappingCache

EMPTY_STRING

private static java.lang.String EMPTY_STRING

SPACE

private static java.lang.String SPACE
Constructor Detail

ModeratedExtension

public ModeratedExtension()
                   throws java.sql.SQLException
Constructs a new blank bean with a unique id.


ModeratedExtension

public ModeratedExtension(int id)
                   throws java.sql.SQLException
Gets a bean from the RuntimeDataSource, given an id.

Method Detail

setId

public void setId(int id)
Set the unique id of this bean instance.

Specified by:
setId in interface EntityBean

getId

public int getId()
Get the unique id of this bean instance.

Specified by:
getId in interface EntityBean

save

public void save()
          throws java.sql.SQLException
Save this bean in the database.

Specified by:
save in interface EntityBean

delete

public void delete()
            throws java.sql.SQLException
Delete this bean from the database.

Specified by:
delete in interface EntityBean

getEntityBean

public EntityBean getEntityBean()
Gets themoderated bean.


setEntityBean

public void setEntityBean(EntityBean bean)
Sets the moderated bean.


getIsModerated

public boolean getIsModerated()
Gets moderation status of this bean.


setIsModerated

public void setIsModerated(boolean moderate)
Sets moderation status of this bean.


getIsApproved

public boolean getIsApproved()
Gets approval status of this bean.


setIsApproved

public void setIsApproved(boolean approve)
Sets approval status of this bean.


getModeratorUser

public User getModeratorUser()
Gets the User for this ModeratedExtension


setModeratorUser

public void setModeratorUser(User user)
Sets the User for this ModeratedExtension


getFor

public static ModeratedExtension getFor(EntityBean eb)
Gets the ModeratedExtension for a particular bean if one exists.


getMappingCache

protected static java.util.HashMap getMappingCache()

initMappingCache

protected static void initMappingCache()

updateMapping

protected static void updateMapping(java.lang.Integer beanInt,
                                    java.lang.Integer extInt)

getOrCreateFor

public static ModeratedExtension getOrCreateFor(EntityBean eb)
Gets or creates the ModeratedExtension for a particular bean.

NOTE: newly created ModeratedExtension objects are NOT saved - you'll need to do that.


filterOutNonApproved

public static java.util.List filterOutNonApproved(java.util.List beans)
Filter out non-approved EntityBeans from a List of EntityBean. Note this considers all the EntityBeans which don't have a ModeratedExtension as being approved (hence they *are* in the returned List).


filterOutNonApproved

public static java.util.List filterOutNonApproved(java.util.Iterator beans)
Filter out non-approved EntityBeans from an Iterator of EntityBean. Note this considers all the EntityBeans which don't have a ModeratedExtension as being approved (hence they *are* in the returned List).


filterNonApproved

public static java.util.List filterNonApproved(java.util.List beans)
Filter and keep non-approved EntityBeans from a List of EntityBean. Note this considers all the EntityBeans which don't have a ModeratedExtension as being approved (hence they are *not* in the returned List).


filterNonApproved

public static java.util.List filterNonApproved(java.util.Iterator beans)
Filter and keep non-approved EntityBeans from an Iterator of EntityBean. Note this considers all the EntityBeans which don't have a ModeratedExtension as being approved (hence they are *not* in the returned List).


needApproval

public static boolean needApproval(EntityBean bean)
Says whether a given EntityBean requires approval.


isModerated

public static boolean isModerated(EntityBean bean)
Says whether a given EntityBean is moderated.


filterModeratedBy

public static java.util.List filterModeratedBy(java.util.Iterator beans,
                                               User user)
Filter and keep the EntityBeans which are moderated by the specific User.


getModeratorUser

public static User getModeratorUser(EntityBean bean)
Gets who, if anybody, is moderating the bean. Note that if the bean is marked as not being moderated, this will return null regardless of the getModeratorUser property of the bean's ModeratedExtension.


getModeratorName

public static java.lang.String getModeratorName(EntityBean bean)
Says who, if anybody, is moderating the bean.