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

Quick Search    Search Deep

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

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

public class AuditedExtension
extends java.lang.Object
implements EntityBean

This Extension can be used to collect creation/lastModified user/date on any EntityBean.

To set audit data, simply user markAsCreated and markAsEdited.
To view the data, getFor() the extension, and use its properties.

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

Field Summary
protected  int beanId
          The id of the EntityBean this AuditedExtension is for.
protected  java.util.Date creationDate
          The creation date bean
protected  int creationUserId
          The creationUser.
static java.lang.String DATABASE_TABLE
           
private static java.lang.String DELETE_FROM
           
private static java.lang.String EMPTY_STRING
           
private static java.lang.String ESC
           
private static java.lang.String FIELD_BEAN_ID
           
private static java.lang.String FIELD_CREATION_DATE
           
private static java.lang.String FIELD_CREATION_USER
           
private static java.lang.String FIELD_LAST_MODIFIED_DATE
           
private static java.lang.String FIELD_LAST_MODIFIED_USER
           
protected  int id
          This bean's id
protected  java.util.Date lastModifiedDate
          The last modified date.
protected  int lastModifiedUserId
          The lastModifiedUser
private static java.lang.String SELECT_DATA
           
private static java.lang.String SELECT_ID
           
private static java.lang.String SPACE
           
private static java.lang.String UPDATE
           
private static java.lang.String WHERE_BEAN_ID
           
private static java.lang.String WHERE_ID
           
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
INTERFACE_BEAN, NULL_ID
 
Constructor Summary
AuditedExtension()
          Constructs a new blank bean with a unique id.
AuditedExtension(int id)
          Gets a bean from the RuntimeDataSource, given an id.
 
Method Summary
 void delete()
          Delete this bean from the database.
 java.util.Date getCreationDate()
          Get the creation date.
 User getCreationUser()
          Get the creationUser.
 EntityBean getEntityBean()
          Gets the bean.
static AuditedExtension getFor(EntityBean bean)
          Gets the AuditedExtension for a particular bean.
 int getId()
          Get the unique id of this bean instance.
 java.util.Date getLastModifiedDate()
          Get the last modified date.
 User getLastModifiedUser()
          Get the lastModifiedUser.
static AuditedExtension getOrCreateFor(EntityBean bean)
          Gets the AuditedExtension for a particular bean.
static void markAsCreated(EntityBean bean, User user)
          Get or create an AuditedExtension for the bean, sets the Creation data, and save the extension.
static void markAsCreated(EntityBean bean, User user, boolean createIfNecessary)
          Get an AuditedExtension for the bean, sets the Creation data, and save the extension.
static void markAsEdited(EntityBean bean, User user)
          Get or create an AuditedExtension for the bean, sets the LastModified data, and save the extension.
static void markAsEdited(EntityBean bean, User user, boolean createIfNecessary)
          Get an AuditedExtension for the bean, sets the LastModified data, and save the extension.
 void save()
          Save this bean in the database.
 void setCreationDate(java.util.Date date)
          Set the creation date.
 void setCreationUser(User creationUser)
          Set the creationUser.
 void setEntityBean(EntityBean bean)
          Sets the bean.
 void setId(int id)
          Set the unique id of this bean instance.
 void setLastModifiedDate(java.util.Date date)
          Set the last modified date bean
 void setLastModifiedUser(User user)
          Set the lastModifiedUser.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SELECT_ID

private static final java.lang.String SELECT_ID
See Also:
Constant Field Values

WHERE_BEAN_ID

private static final java.lang.String WHERE_BEAN_ID
See Also:
Constant Field Values

DELETE_FROM

private static final java.lang.String DELETE_FROM
See Also:
Constant Field Values

WHERE_ID

private static final java.lang.String WHERE_ID
See Also:
Constant Field Values

SELECT_DATA

private static final java.lang.String SELECT_DATA
See Also:
Constant Field Values

UPDATE

private static final java.lang.String UPDATE
See Also:
Constant Field Values

ESC

private static final java.lang.String ESC
See Also:
Constant Field Values

EMPTY_STRING

private static final java.lang.String EMPTY_STRING
See Also:
Constant Field Values

SPACE

private static final java.lang.String SPACE
See Also:
Constant Field Values

DATABASE_TABLE

public static final java.lang.String DATABASE_TABLE
See Also:
Constant Field Values

FIELD_BEAN_ID

private static final java.lang.String FIELD_BEAN_ID
See Also:
Constant Field Values

FIELD_CREATION_USER

private static final java.lang.String FIELD_CREATION_USER
See Also:
Constant Field Values

FIELD_CREATION_DATE

private static final java.lang.String FIELD_CREATION_DATE
See Also:
Constant Field Values

FIELD_LAST_MODIFIED_USER

private static final java.lang.String FIELD_LAST_MODIFIED_USER
See Also:
Constant Field Values

FIELD_LAST_MODIFIED_DATE

private static final java.lang.String FIELD_LAST_MODIFIED_DATE
See Also:
Constant Field Values

id

protected int id
This bean's id


beanId

protected int beanId
The id of the EntityBean this AuditedExtension is for.


creationUserId

protected int creationUserId
The creationUser.


creationDate

protected java.util.Date creationDate
The creation date bean


lastModifiedUserId

protected int lastModifiedUserId
The lastModifiedUser


lastModifiedDate

protected java.util.Date lastModifiedDate
The last modified date.

Constructor Detail

AuditedExtension

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


AuditedExtension

public AuditedExtension(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()
Save this bean in the database.

Specified by:
save in interface EntityBean

delete

public void delete()
Delete this bean from the database.

Specified by:
delete in interface EntityBean

getEntityBean

public EntityBean getEntityBean()
Gets the bean.


setEntityBean

public void setEntityBean(EntityBean bean)
Sets the bean.


setCreationUser

public void setCreationUser(User creationUser)
Set the creationUser.


getCreationUser

public User getCreationUser()
Get the creationUser.


setCreationDate

public void setCreationDate(java.util.Date date)
Set the creation date.


getCreationDate

public java.util.Date getCreationDate()
Get the creation date.


setLastModifiedUser

public void setLastModifiedUser(User user)
Set the lastModifiedUser.


getLastModifiedUser

public User getLastModifiedUser()
Get the lastModifiedUser.


setLastModifiedDate

public void setLastModifiedDate(java.util.Date date)
Set the last modified date bean


getLastModifiedDate

public java.util.Date getLastModifiedDate()
Get the last modified date.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


getFor

public static AuditedExtension getFor(EntityBean bean)
Gets the AuditedExtension for a particular bean.


getOrCreateFor

public static AuditedExtension getOrCreateFor(EntityBean bean)
Gets the AuditedExtension for a particular bean. Create (and save) it if necessary.


markAsCreated

public static void markAsCreated(EntityBean bean,
                                 User user)
Get or create an AuditedExtension for the bean, sets the Creation data, and save the extension. Assumes the bean has been saved at least once.


markAsCreated

public static void markAsCreated(EntityBean bean,
                                 User user,
                                 boolean createIfNecessary)
Get an AuditedExtension for the bean, sets the Creation data, and save the extension. Assumes the bean has been saved at least once. If createIfNecessary == false and the bean has no AuditedExtension, nothing happens.


markAsEdited

public static void markAsEdited(EntityBean bean,
                                User user)
Get or create an AuditedExtension for the bean, sets the LastModified data, and save the extension. Assumes the bean has been saved at least once.


markAsEdited

public static void markAsEdited(EntityBean bean,
                                User user,
                                boolean createIfNecessary)
Get an AuditedExtension for the bean, sets the LastModified data, and save the extension. Assumes the bean has been saved at least once. If createIfNecessary == false and the bean has no AuditedExtension, nothing happens.