Holger's
Java API

com.antelmann.sql
Class UserImplMapper<T extends UserImpl>

java.lang.Object
  extended by com.antelmann.sql.BaseRowMapper<T>
      extended by com.antelmann.sql.UserImplMapper<T>
All Implemented Interfaces:
TransactionRequired, MappingInfo, ObjectRowMapper<T>, Converter<RowItem,T>

public class UserImplMapper<T extends UserImpl>
extends BaseRowMapper<T>

provides a base mapper implementation for storing a User. If accessTable is non-null, the corresponding JDBCRowStore must set JDBCRowStore.fastDelete to false.

Since:
21. September 2006, 18:26
Author:
Holger Antelmann

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.util.Converter
Converter.Adapter<T1,T2>
 
Field Summary
protected  String accessColumn
          the column containing the name of the right in the access table
protected  String accessTable
          the table name for the user access rights; if null, no access rights are initialized when mapping users
protected  String accessUserColumn
          the column in the access rights table holding the foreign key for the userID
protected  String descriptionColumn
          the column containing a user description
protected  String emailColumn
          the column containing the email of the user
protected  String enabledColumn
          the column that holds the boolean value for enabling a user
protected  String passwordColumn
          the column that stores the password hash value
 
Fields inherited from class com.antelmann.sql.BaseRowMapper
db, helper
 
Constructor Summary
UserImplMapper(Database<Connection> db, String tableName, String idColumn, String displayColumn, IDFactory idFactory, Class<T> userType)
           
 
Method Summary
protected  T createUser(UserImpl user)
          supports reflection-based instantiation with the user as the constructor parameter
protected  void deleteAccessRights(Object userID)
          deletes the rights of the given userID from the database; the user object remains untouched
 Object generateNewID()
          if no factory is given, getNextIntID is returned
protected  Map<String,Object> generateRowProperties(T user)
          generates a map that contains all columns mapped to their values, so that the map can be used to store the object into a row.
 Class<? extends Enum<?>> getRightsEnumClass()
           
 T getUserForName(String name)
          for use with an AbstractUserLoginStore
 AbstractUserLoginStore getUserLoginStore()
           
 Iterable<String> getUserNames()
          for use with an AbstractUserLoginStore
 void handleAfterStore(T entry, boolean isInsert)
          does nothing unless overridden
protected  void initUserRights(UserImpl user)
          reads the rights from the database and initializes the given user with it
 T instantiate(RowItem row)
          instantiates the DBEntry based on the properties in the given row.
 boolean isMapProperties()
           
protected  Object objectToRight(Object obj)
          allows to customize the way the right for the user is derived from the object stored in the database
protected  Object rightToObject(Object right)
          allows to customize the way the right is mapped to the object in the database
 void setMapProperties(boolean mapProperties)
           
 void setRightsEnumClass(Class<? extends Enum<?>> rightsEnumClass)
           
protected  void updateAccessRights(UserImpl user)
          writes the rights of the given user in the database; the user object remains untouched
 void verifyBeforeDelete(Object id)
          does nothing unless overridden
 
Methods inherited from class com.antelmann.sql.BaseRowMapper
addColumnsForTopic, applyFromMapping, checkExistence, convert, convertBack, convertTopicFilter, emptyStringsToNull, extractReference, extractStub, extractStub, getAll, getColumnDisplayMapping, getColumnNames, getColumnsForTopic, getColumnSize, getConnection, getConnectionHelper, getDisplayColumn, getDisplayNameForColumn, getEntryClass, getEntryClassMapper, getIDColumn, getIDFactory, getMappedValue, getMappingForTopic, getNextIntID, getNextIntIDFactory, getNextIntIDFactory, getPreStoreFilter, getReadOnlyColumns, getRestrictMappedColumns, getResultSet, getSQLTypeforColumn, getStubColumns, getStubQuery, getStubResultSet, getSupportedTopicColumns, getTableColumnNames, getTableName, getTableQuery, getTableQueryForComboFilter, getTransactionCounter, getUniqueRandomString, initMapping, isMappedTopic, isTranslate, javaToSql, javaToSql, lockTable, mapReference, mapReference, mapToRow, removeColumnTopic, setColumnsForTopic, setDisplayColumn, setEntryClass, setEntryClassMapper, setIDFactory, setMappedValue, setNextIntIdAsFactory, setPreStoreFilter, setReadOnlyColumns, setRestrictedMappedColumns, setStubQuery, setTableQuery, setTableQuery, setTopic, setTranslate, sqlToJava, toSQLMap, verifyBeforeStore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enabledColumn

protected String enabledColumn
the column that holds the boolean value for enabling a user


passwordColumn

protected String passwordColumn
the column that stores the password hash value


descriptionColumn

protected String descriptionColumn
the column containing a user description


emailColumn

protected String emailColumn
the column containing the email of the user


accessTable

protected String accessTable
the table name for the user access rights; if null, no access rights are initialized when mapping users


accessUserColumn

protected String accessUserColumn
the column in the access rights table holding the foreign key for the userID


accessColumn

protected String accessColumn
the column containing the name of the right in the access table

Constructor Detail

UserImplMapper

public UserImplMapper(Database<Connection> db,
                      String tableName,
                      String idColumn,
                      String displayColumn,
                      IDFactory idFactory,
                      Class<T> userType)
               throws DatabaseException
Throws:
DatabaseException
Method Detail

getUserLoginStore

public AbstractUserLoginStore getUserLoginStore()

getRightsEnumClass

public Class<? extends Enum<?>> getRightsEnumClass()

setRightsEnumClass

public void setRightsEnumClass(Class<? extends Enum<?>> rightsEnumClass)

isMapProperties

public boolean isMapProperties()

setMapProperties

public void setMapProperties(boolean mapProperties)

generateRowProperties

protected Map<String,Object> generateRowProperties(T user)
                                            throws WrongDataException
Description copied from class: BaseRowMapper
generates a map that contains all columns mapped to their values, so that the map can be used to store the object into a row. The ID column and the corresponding ID should not be put in there, as this will happen automatically later.

Specified by:
generateRowProperties in class BaseRowMapper<T extends UserImpl>
Throws:
WrongDataException

generateNewID

public Object generateNewID()
                     throws DatabaseException
if no factory is given, getNextIntID is returned

Specified by:
generateNewID in interface ObjectRowMapper<T extends UserImpl>
Overrides:
generateNewID in class BaseRowMapper<T extends UserImpl>
Throws:
DatabaseException
See Also:
DBClassStore.generateNewID(), SQLNumberGenerator, TransactionalNumberGenerator

instantiate

public T instantiate(RowItem row)
                               throws Exception
Description copied from interface: ObjectRowMapper
instantiates the DBEntry based on the properties in the given row. The given row contains all the columns of the queried ResultSet unless the columns to be retrieved are restricted by ObjectRowMapper.getRestrictMappedColumns().

Throws:
Exception

createUser

protected T createUser(UserImpl user)
                                 throws Exception
supports reflection-based instantiation with the user as the constructor parameter

Throws:
Exception

verifyBeforeDelete

public void verifyBeforeDelete(Object id)
                        throws DatabaseException,
                               SQLException
Description copied from class: BaseRowMapper
does nothing unless overridden

Specified by:
verifyBeforeDelete in interface ObjectRowMapper<T extends UserImpl>
Overrides:
verifyBeforeDelete in class BaseRowMapper<T extends UserImpl>
Throws:
WrongDataException - if the deletion is not allowed for semantical reasons
DatabaseException
SQLException

handleAfterStore

public void handleAfterStore(T entry,
                             boolean isInsert)
                      throws DatabaseException,
                             SQLException
Description copied from class: BaseRowMapper
does nothing unless overridden

Specified by:
handleAfterStore in interface ObjectRowMapper<T extends UserImpl>
Overrides:
handleAfterStore in class BaseRowMapper<T extends UserImpl>
isInsert - if true, the entry is about to be inserted; if false, it is an update
Throws:
DatabaseException
SQLException

initUserRights

protected void initUserRights(UserImpl user)
                       throws SQLException
reads the rights from the database and initializes the given user with it

Throws:
SQLException

objectToRight

protected Object objectToRight(Object obj)
allows to customize the way the right for the user is derived from the object stored in the database


deleteAccessRights

protected void deleteAccessRights(Object userID)
                           throws SQLException
deletes the rights of the given userID from the database; the user object remains untouched

Throws:
SQLException

updateAccessRights

protected void updateAccessRights(UserImpl user)
                           throws SQLException
writes the rights of the given user in the database; the user object remains untouched

Throws:
SQLException

rightToObject

protected Object rightToObject(Object right)
allows to customize the way the right is mapped to the object in the database


getUserNames

public Iterable<String> getUserNames()
                              throws DatabaseException
for use with an AbstractUserLoginStore

Throws:
DatabaseException
See Also:
AbstractUserLoginStore

getUserForName

public T getUserForName(String name)
                                  throws DatabaseException
for use with an AbstractUserLoginStore

Throws:
DatabaseException
See Also:
AbstractUserLoginStore


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads