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

Quick Search    Search Deep

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

java.lang.Object
  extended bycom.RuntimeCollective.webapps.bean.SimpleUser
All Implemented Interfaces:
EntityBean, java.io.Serializable, User
Direct Known Subclasses:
SimpleTrackedUser

public class SimpleUser
extends java.lang.Object
implements User

Simple implementation of the User interface representing a user that has an address.

Version:
$Id: SimpleUser.java,v 1.32 2003/09/30 15:13:10 joe Exp $

Field Summary
protected  Address address
          The address object of this user.
private static java.lang.String ADDRESS_ID
           
private static java.lang.String ADDRESS_JOIN
           
private static java.lang.String ADDRESS_TABLE
           
private static java.lang.String AND
           
private static java.lang.String ARCHIVE_DATE_NULL
           
 java.util.Hashtable attributes
          The attributes of this user.
private static java.lang.String CITY_LIKE
           
private static java.lang.String COMMA
           
private static java.lang.String COUNTRY_LIKE
           
private static java.lang.String CREATE_DATE
           
protected  java.util.Date createDate
          The date that the user was registered onto the system.
static java.lang.String DATABASE_TABLE
          The name of the database table for this bean type.
private static java.lang.String DELETE_ROLES
           
private static java.lang.String DELETE_WHERE
           
protected  java.lang.String email
          Email address -- used as a unique identifier when logging in.
private static java.lang.String EMAIL
           
private static java.lang.String EMAIL_LIKE
           
private static java.lang.String END_PAR
           
private static java.lang.String ESC
           
private static java.lang.String FIRST
           
private static java.lang.String FIRST_LIKE
           
protected  java.lang.String firstName
          First name
private static java.lang.String FROM
           
protected  int id
          ID
private static java.lang.String INSERT_ROLE
           
static java.lang.String INTERFACE_BEAN
          name of interface used to identify this bean
protected  java.lang.String lastName
          Last name
private static java.lang.String LIKE_AND
           
private static java.lang.String NATIONALITY_LIKE
           
private static java.lang.String NOT_ARCHIVED_CONDITION
           
private static java.lang.String NOTHING
           
private static java.lang.String ORDER_BY
           
protected  java.lang.String password
          Password.
private static java.lang.String PASSWORD
           
private static java.lang.String POSTCODE_LIKE
           
private static java.lang.String RESULTS
           
private static java.lang.String ROLE_JOIN
           
private static java.lang.String ROLE_TABLE
           
protected  int[] roles
           
private static java.lang.String SELECT
           
private static java.lang.String SELECT_DATE
           
private static java.lang.String SELECT_ID_WHERE_EMAIL
           
private static java.lang.String SELECT_ROLES
           
private static java.lang.String SET_ARCHIVE_DATE
           
private static java.lang.String SET_ARCHIVE_DATE_NULL
           
private static java.lang.String SURNAME
           
private static java.lang.String SURNAME_LIKE
           
private static java.lang.String UPDATE
           
private static java.lang.String USER_TABLE
           
private static java.lang.String WHERE
           
private static java.lang.String WHERE_ID
           
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
NULL_ID
 
Constructor Summary
SimpleUser()
          Construct a new blank user, giving it a new unique ID.
SimpleUser(int id)
          Get a current user from the RuntimeDataSource, given an id.
 
Method Summary
 void addRole(int role)
           
 void archive()
          Archive this bean.
 void delete()
          Delete this bean from the database.
static int findByEmail(java.lang.String email, boolean current)
          Get the id of a user from the RuntimeDataSource, given an email address.
 Address getAddress()
          Get the address object of this user.
 java.lang.Object getAttribute(java.lang.String name)
          Get the value of an attribute.
 java.util.Date getCreateDate()
          Get the date that the user was registered onto the system.
 java.lang.String getEmail()
          Get the user's email address -- used as a unique identifier when logging in.
 java.lang.String getFirstName()
          Get first name
 int getId()
          Get the user's ID.
 java.lang.String getLastName()
          Get last name
static java.lang.String getName(int id)
          Get the name (first surname) of a user for a particular id.
 java.lang.String getPassword()
          Get the user's password.
static java.lang.String getProperty(int id, java.lang.String propertyName)
          Get a named property of a user for a particular id.
 int[] getRoles()
           
 boolean hasRole(int role)
           
 void removeRole(int role)
           
 void save()
          Save this user to the RuntimeDataSource.
static com.RuntimeCollective.webapps.SearchResults searchUsers(com.RuntimeCollective.webapps.form.SearchUserForm form)
          Search for current users that match the parameters on the UserSearchForm.
 void setAddress(Address address)
          Set the address object of this user.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set the value of an attribute.
 void setCreateDate(java.util.Date createDate)
          Set the date that the user was registered onto the system.
 void setEmail(java.lang.String email)
          Set the user's email address -- used as a unique identifier when logging in.
 void setFirstName(java.lang.String firstName)
          Set first name
 void setId(int id)
          Set the user's ID.
 void setLastName(java.lang.String lastName)
          Set last name
 void setPassword(java.lang.String password)
          Set the user's password.
 void setRoles(int[] roles)
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void unArchive()
          Unarchive this bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INTERFACE_BEAN

public static final java.lang.String INTERFACE_BEAN
name of interface used to identify this bean

See Also:
Constant Field Values

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

SELECT_DATE

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

ARCHIVE_DATE_NULL

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

SELECT_ROLES

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

EMAIL

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

PASSWORD

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

FIRST

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

SURNAME

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

ADDRESS_ID

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

CREATE_DATE

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

DELETE_ROLES

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

INSERT_ROLE

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

COMMA

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

END_PAR

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

UPDATE

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

SET_ARCHIVE_DATE

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

SET_ARCHIVE_DATE_NULL

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

WHERE_ID

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

DELETE_WHERE

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

SELECT_ID_WHERE_EMAIL

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

RESULTS

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

USER_TABLE

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

ROLE_TABLE

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

ADDRESS_TABLE

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

ROLE_JOIN

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

ADDRESS_JOIN

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

NOT_ARCHIVED_CONDITION

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

FIRST_LIKE

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

SURNAME_LIKE

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

CITY_LIKE

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

COUNTRY_LIKE

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

NATIONALITY_LIKE

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

EMAIL_LIKE

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

POSTCODE_LIKE

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

SELECT

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

FROM

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

WHERE

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

ORDER_BY

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

LIKE_AND

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

AND

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

NOTHING

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

ESC

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

id

protected int id
ID


email

protected java.lang.String email
Email address -- used as a unique identifier when logging in.


password

protected java.lang.String password
Password.


createDate

protected java.util.Date createDate
The date that the user was registered onto the system.


roles

protected int[] roles

firstName

protected java.lang.String firstName
First name


lastName

protected java.lang.String lastName
Last name


address

protected Address address
The address object of this user.


attributes

public java.util.Hashtable attributes
The attributes of this user.

Constructor Detail

SimpleUser

public SimpleUser()
           throws java.sql.SQLException
Construct a new blank user, giving it a new unique ID. This will also create a new Address object for this user.


SimpleUser

public SimpleUser(int id)
           throws java.sql.SQLException
Get a current user from the RuntimeDataSource, given an id.

Method Detail

save

public void save()
          throws java.sql.SQLException
Save this user to the RuntimeDataSource.

Specified by:
save in interface EntityBean

archive

public void archive()
             throws java.sql.SQLException
Archive this bean.


unArchive

public void unArchive()
               throws java.sql.SQLException
Unarchive this bean.


delete

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

Specified by:
delete in interface EntityBean

getId

public int getId()
Get the user's ID.

Specified by:
getId in interface EntityBean

setId

public void setId(int id)
Set the user's ID.

Specified by:
setId in interface EntityBean

getEmail

public java.lang.String getEmail()
Get the user's email address -- used as a unique identifier when logging in.

Specified by:
getEmail in interface User

setEmail

public void setEmail(java.lang.String email)
Set the user's email address -- used as a unique identifier when logging in.

Specified by:
setEmail in interface User

getPassword

public java.lang.String getPassword()
Get the user's password.

Specified by:
getPassword in interface User

setPassword

public void setPassword(java.lang.String password)
Set the user's password.

Specified by:
setPassword in interface User

setCreateDate

public void setCreateDate(java.util.Date createDate)
Set the date that the user was registered onto the system.

Specified by:
setCreateDate in interface User

getCreateDate

public java.util.Date getCreateDate()
Get the date that the user was registered onto the system.

Specified by:
getCreateDate in interface User

getRoles

public int[] getRoles()
Specified by:
getRoles in interface User

setRoles

public void setRoles(int[] roles)
Specified by:
setRoles in interface User

hasRole

public boolean hasRole(int role)
Specified by:
hasRole in interface User

getFirstName

public java.lang.String getFirstName()
Get first name

Specified by:
getFirstName in interface User

setFirstName

public void setFirstName(java.lang.String firstName)
Set first name

Specified by:
setFirstName in interface User

getLastName

public java.lang.String getLastName()
Get last name

Specified by:
getLastName in interface User

setLastName

public void setLastName(java.lang.String lastName)
Set last name

Specified by:
setLastName in interface User

getAddress

public Address getAddress()
Get the address object of this user.

Specified by:
getAddress in interface User

setAddress

public void setAddress(Address address)
Set the address object of this user.

Specified by:
setAddress in interface User

searchUsers

public static com.RuntimeCollective.webapps.SearchResults searchUsers(com.RuntimeCollective.webapps.form.SearchUserForm form)
                                                               throws java.sql.SQLException
Search for current users that match the parameters on the UserSearchForm. The search form must be validated before this method is called.


addRole

public void addRole(int role)
             throws java.sql.SQLException
Specified by:
addRole in interface User

removeRole

public void removeRole(int role)
                throws java.sql.SQLException
Specified by:
removeRole in interface User

findByEmail

public static int findByEmail(java.lang.String email,
                              boolean current)
                       throws java.sql.SQLException
Get the id of a user from the RuntimeDataSource, given an email address.


getName

public static java.lang.String getName(int id)
                                throws java.sql.SQLException
Get the name (first surname) of a user for a particular id.


getProperty

public static java.lang.String getProperty(int id,
                                           java.lang.String propertyName)
                                    throws java.sql.SQLException
Get a named property of a user for a particular id.


getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Get the value of an attribute.
These attributes are *not* saved.
Null is returned if the attribute for this name has not been. Note that these attributes held on here should be relevant to all users of the system, such as bookmarks or webfolders. If there is an attribute that is specific to a particular type of user, or actor, then it should be held on the relevant Actor object.

Specified by:
getAttribute in interface User

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Set the value of an attribute.
These attributes are *not* saved.
Note that these attributes held on here should be relevant to all users of the system, such as bookmarks or webfolders. If there is an attribute that is specific to a particular type of user, or actor, then it should be held on the relevant Actor object.

Specified by:
setAttribute in interface User

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()).