velosurf.model
Class Entity

java.lang.Object
  |
  +--velosurf.model.Entity

public class Entity
extends java.lang.Object

The Entity class represents an entity in the data model. It should not be constructed directly.

Author:
Claude Brisson

Field Summary
protected  java.util.Map mActionMap
          actions of this entity
protected  java.util.Map mAttributeMap
          attributes of this entity
protected  Cache mCache
          the cache
protected  int mCachingMethod
          the caching method
protected  java.util.List mColumns
          column names in natural order
protected  DBConnection mDB
          the database connection
protected  boolean mExplicit
          whether this entity is explicitely declared in the config file
protected  java.lang.String mFetchQuery
          the SQL query used to fetch one instance of this entity
protected  java.lang.Class mInstanceClass
          the java class to use to realize this instance
protected  boolean[] mKeyColObfuscated
          obfuscation status of key columns
protected  java.util.List mKeys
          key column names in natural order
protected  long mLastInsertID
          the last insert id
protected  java.lang.String mName
          name
protected  boolean mObfuscate
          whether to obfuscate something
protected  java.util.List mObfuscatedColumns
          names of obfuscated columns
protected  boolean mReadOnly
          whether this entity is read-only or not
protected  java.lang.String mTable
          table
 
Constructor Summary
Entity(DBConnection inDB, java.lang.String inName, boolean inAccess, int inCachingMethod)
          Constructor reserved for the framework
 
Method Summary
 void addColumn(java.lang.String inColName)
          add a column at the end of the sequential list of named columns (called during the reverse engeenering of the database)
 void addKey(java.lang.String inColName)
          adds a key column to the sequential list of the key columns (called during the reverse-engeenering of the database)
protected  void buildFetchQuery()
          build the SQL query used to fetch one instance of this query
protected  java.lang.Object buildKey(DataAccessor inValues)
          build the key for the Cache from a DataAccessor
protected  java.lang.Object buildKey(java.util.Map inValues)
          build the key for the Cache from a DataAccessor
 void clearCache()
          Clear the cache
 void defineAction(org.jdom.Element inJDOMAction)
          defines a new action in this entity (called during the reading of the config file)
 void defineAttribute(org.jdom.Element inJDOMAttribute)
          defines a new attribute in this entity (called during the reading of the config file)
 boolean delete(java.util.Map inValues)
          delete a row based on (key) values in a Map
 java.lang.String deobfuscate(java.lang.Object value)
          de-obfuscate given value
protected  void extractColumnValues(DataAccessor inSource, java.util.Map inTarget)
          extract column values from an input DataAccessor source and store result in inTarget
 Instance fetch(java.util.List inValues)
          fetch an instance from key values stored in a List in natural order
 Instance fetch(java.util.Map inValues)
          fetch an instance from key values stored in a Map
 Instance fetch(java.lang.Number inKeyValue)
          fetch an instance from its key value specified as a Number
 Instance fetch(java.lang.String inKeyValue)
          fetch an instance from its key value as a string
 Action getAction(java.lang.String inProperty)
          get the named action from this entity
 Attribute getAttribute(java.lang.String inProperty)
          Get a named attribute of this entity
 java.util.List getColumns()
          getter for the list of column names
 DBConnection getDB()
          get the database connection
 java.lang.String getFetchQuery()
          get the SQL query string used to fetch one instance of this query
 Instance getInstance(DataAccessor inValues)
          get an instance from its values contained in a DataAccessor object (by default, update all fields based on the values in the DataAccessor if the instance has been found in the cache)
 Instance getInstance(DataAccessor inValues, boolean inUpdateValues)
          get an instance from a DataAccessor object
 Instance getInstance(java.util.Map inValues)
          get an instance whose values are in a map (by default, do not update instance values with map values if the instance is found in the cache)
 Instance getInstance(java.util.Map inValues, boolean inUpdateValues)
          get an instance whose values are in a map
 java.util.List getKeys()
          getter for the list of key column names
 long getLastInsertID()
          get the last insert id
 java.lang.String getName()
          getter for the name of this entity
 java.lang.String getTable()
          get the name of the mapped table
 boolean insert(DataAccessor inValues)
          insert a new row based on values of a map
 boolean insert(java.util.Map inValues)
          insert a new row based on values of a map
 boolean isExplicit()
          checks wether or not this entity has been explicitely declared in the configuration file
 boolean isObfuscated(java.lang.String inColumn)
          returns whether the given column is obfuscated
 Instance newInstance()
          create a new realisation of this entity
 Instance newInstance(DataAccessor inValues)
          build a new instance from a DataAccessor object
 Instance newInstance(java.util.Map inValues)
          builds a new instance from values contained in a Map
 java.lang.String obfuscate(java.lang.Object value)
          obfuscate given value
 RowIterator query()
          issue a query to iterate though all instances of this entity
 RowIterator query(java.util.List inRefineCriteria, java.lang.String inOrder)
          issue a query to iterate thought instances of this entity, with a facultative refining criteria and a facultative order by clause
 void rename(java.lang.String inName)
          set the name of this entity ** DO NOT USE DIRECTLY **
 void setCachingMethod(int inCaching)
          Specify the caching method, see Cache for allowed constants.
 void setExplicit(boolean inExplicit)
          sets wether or not this entity has been explicitely declared in the configuration file
 void setInstanceClass(java.lang.String inClassName)
          Specify a custom class to use when instanciating this entity
 void setLastInsertID(long inLastInsertID)
          sets the last insert id (do not use directly !)
 void setObfuscated(java.util.List inColumns)
          indicates a column as being obfuscated
 void setReadOnly(boolean inReadOnly)
          set this entity to be read-only or read-write
 void setTable(java.lang.String inTable)
          set the name of the table mapped by this entity
 boolean update(java.util.Map inValues)
          update a row based on values of a Map
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

mName

protected java.lang.String mName
name

mTable

protected java.lang.String mTable
table

mColumns

protected java.util.List mColumns
column names in natural order

mKeys

protected java.util.List mKeys
key column names in natural order

mObfuscate

protected boolean mObfuscate
whether to obfuscate something

mObfuscatedColumns

protected java.util.List mObfuscatedColumns
names of obfuscated columns

mKeyColObfuscated

protected boolean[] mKeyColObfuscated
obfuscation status of key columns

mAttributeMap

protected java.util.Map mAttributeMap
attributes of this entity

mActionMap

protected java.util.Map mActionMap
actions of this entity

mInstanceClass

protected java.lang.Class mInstanceClass
the java class to use to realize this instance

mFetchQuery

protected java.lang.String mFetchQuery
the SQL query used to fetch one instance of this entity

mReadOnly

protected boolean mReadOnly
whether this entity is read-only or not

mDB

protected DBConnection mDB
the database connection

mLastInsertID

protected long mLastInsertID
the last insert id

mCachingMethod

protected int mCachingMethod
the caching method

mCache

protected Cache mCache
the cache

mExplicit

protected boolean mExplicit
whether this entity is explicitely declared in the config file
Constructor Detail

Entity

public Entity(DBConnection inDB,
              java.lang.String inName,
              boolean inAccess,
              int inCachingMethod)
Constructor reserved for the framework
Parameters:
inDB - database connection
inName - entity name
inAccess - access mode (read-write or read-only)
inCachingMethod - caching method to be used
Method Detail

addColumn

public void addColumn(java.lang.String inColName)
add a column at the end of the sequential list of named columns (called during the reverse engeenering of the database)
Parameters:
inColName - column name

addKey

public void addKey(java.lang.String inColName)
adds a key column to the sequential list of the key columns (called during the reverse-engeenering of the database)
Parameters:
inColName - name of the key column

getAttribute

public Attribute getAttribute(java.lang.String inProperty)
Get a named attribute of this entity
Parameters:
inProperty - attribute name
Returns:
the attribute

getAction

public Action getAction(java.lang.String inProperty)
get the named action from this entity
Parameters:
inProperty - action name
Returns:
the action

defineAction

public void defineAction(org.jdom.Element inJDOMAction)
defines a new action in this entity (called during the reading of the config file)
Parameters:
inJDOMAction - the xml tree for the new action

defineAttribute

public void defineAttribute(org.jdom.Element inJDOMAttribute)
defines a new attribute in this entity (called during the reading of the config file)
Parameters:
inJDOMAttribute - the XML tree for this attribute

setInstanceClass

public void setInstanceClass(java.lang.String inClassName)
Specify a custom class to use when instanciating this entity
Parameters:
inClassName - the java class name

setCachingMethod

public void setCachingMethod(int inCaching)
Specify the caching method, see Cache for allowed constants.
Parameters:
inCaching - Caching method

clearCache

public void clearCache()
Clear the cache

newInstance

public Instance newInstance()
create a new realisation of this entity
Returns:
the newly created instance

newInstance

public Instance newInstance(java.util.Map inValues)
builds a new instance from values contained in a Map
Parameters:
inValues - the Map containing the values
Returns:
the newly created instance

newInstance

public Instance newInstance(DataAccessor inValues)
build a new instance from a DataAccessor object
Parameters:
inValues - the DataAccessor object containing the values
Returns:
the newly created instance

getInstance

public Instance getInstance(java.util.Map inValues)
get an instance whose values are in a map (by default, do not update instance values with map values if the instance is found in the cache)
Parameters:
inValues - the map containing the key values
Returns:
the instance

getInstance

public Instance getInstance(java.util.Map inValues,
                            boolean inUpdateValues)
get an instance whose values are in a map
Parameters:
inValues - the map containing the values
inUpdateValues - whether the instance should be updated from the map if found in the cache
Returns:
the instance

getInstance

public Instance getInstance(DataAccessor inValues)
get an instance from its values contained in a DataAccessor object (by default, update all fields based on the values in the DataAccessor if the instance has been found in the cache)
Parameters:
inValues - the DataAccessor object containing the values
Returns:
the instance

getInstance

public Instance getInstance(DataAccessor inValues,
                            boolean inUpdateValues)
get an instance from a DataAccessor object
Parameters:
inValues - the DataAccessor object containing the values
inUpdateValues - whether all values are to be read from the DataAccessor if the instance has been found in the cache
Returns:
the instance

extractColumnValues

protected void extractColumnValues(DataAccessor inSource,
                                   java.util.Map inTarget)
                            throws java.sql.SQLException
extract column values from an input DataAccessor source and store result in inTarget
Parameters:
inSource - DataAccessor source object
inTarget - Map target object

buildKey

protected java.lang.Object buildKey(DataAccessor inValues)
                             throws java.sql.SQLException
build the key for the Cache from a DataAccessor
Parameters:
inValues - the DataAccessor containing all values
Returns:
an array containing all key values
Throws:
java.sql.SQLException - the getter of the DataAccessor throws an SQLException

buildKey

protected java.lang.Object buildKey(java.util.Map inValues)
                             throws java.sql.SQLException
build the key for the Cache from a DataAccessor
Parameters:
inValues - the DataAccessor containing all values
Returns:
an array containing all key values
Throws:
java.sql.SQLException - the getter of the DataAccessor throws an SQLException

getName

public java.lang.String getName()
getter for the name of this entity
Returns:
the name of the entity

rename

public void rename(java.lang.String inName)
set the name of this entity ** DO NOT USE DIRECTLY **
Parameters:
inName - new name

getKeys

public java.util.List getKeys()
getter for the list of key column names
Returns:
the list of key column names

getColumns

public java.util.List getColumns()
getter for the list of column names
Returns:
the list of column names

insert

public boolean insert(java.util.Map inValues)
insert a new row based on values of a map
Parameters:
inValues - the Map object containing the values
Returns:
success indicator

insert

public boolean insert(DataAccessor inValues)
               throws java.sql.SQLException
insert a new row based on values of a map
Parameters:
inValues - the Map object containing the values
Returns:
success indicator

setLastInsertID

public void setLastInsertID(long inLastInsertID)
sets the last insert id (do not use directly !)
Parameters:
inLastInsertID - the last insert id

getLastInsertID

public long getLastInsertID()
get the last insert id
Returns:
the last insert id

update

public boolean update(java.util.Map inValues)
update a row based on values of a Map
Parameters:
inValues - the Map object containing the values
Returns:
success indicator

delete

public boolean delete(java.util.Map inValues)
delete a row based on (key) values in a Map
Parameters:
inValues - the Map containing the values
Returns:
success indicator

fetch

public Instance fetch(java.util.List inValues)
fetch an instance from key values stored in a List in natural order
Parameters:
inValues - the List containing the key values
Returns:
the fetched instance

fetch

public Instance fetch(java.util.Map inValues)
fetch an instance from key values stored in a Map
Parameters:
inValues - the Map containing the key values
Returns:
the fetched instance

fetch

public Instance fetch(java.lang.String inKeyValue)
fetch an instance from its key value as a string
Parameters:
inKeyValue - the key
Returns:
the fetched instance

fetch

public Instance fetch(java.lang.Number inKeyValue)
fetch an instance from its key value specified as a Number
Parameters:
inKeyValue - the key
Returns:
the fetched instance

getFetchQuery

public java.lang.String getFetchQuery()
get the SQL query string used to fetch one instance of this query
Returns:
the SLQ query

buildFetchQuery

protected void buildFetchQuery()
build the SQL query used to fetch one instance of this query

query

public RowIterator query()
issue a query to iterate though all instances of this entity
Returns:
the resulting RowIterator

query

public RowIterator query(java.util.List inRefineCriteria,
                         java.lang.String inOrder)
issue a query to iterate thought instances of this entity, with a facultative refining criteria and a facultative order by clause
Parameters:
inRefineCriteria - a refining criteria or null to get all instances
inOrder - an 'order by' clause or null to get instances in their natural order
Returns:
the resulting RowIterator

getDB

public DBConnection getDB()
get the database connection
Returns:
the database connection

setReadOnly

public void setReadOnly(boolean inReadOnly)
set this entity to be read-only or read-write
Parameters:
inReadOnly - the mode to switch to : true for read-only, false for read-write

setTable

public void setTable(java.lang.String inTable)
set the name of the table mapped by this entity
Parameters:
inTable - the table mapped by this entity read-write

getTable

public java.lang.String getTable()
get the name of the mapped table
Returns:
name of the mapped table

setExplicit

public void setExplicit(boolean inExplicit)
sets wether or not this entity has been explicitely declared in the configuration file
Parameters:
inExplicit - value to set

isExplicit

public boolean isExplicit()
checks wether or not this entity has been explicitely declared in the configuration file
Returns:
true if explicitely declared in the configuration file

setObfuscated

public void setObfuscated(java.util.List inColumns)
indicates a column as being obfuscated
Parameters:
inColumns - list of obfuscated columns

isObfuscated

public boolean isObfuscated(java.lang.String inColumn)
returns whether the given column is obfuscated
Parameters:
inColumn - the name of the column
Returns:
a boolean indicating whether this column is obfuscated

obfuscate

public java.lang.String obfuscate(java.lang.Object value)
obfuscate given value
Parameters:
value - value to obfuscate
Returns:
obfuscated value

deobfuscate

public java.lang.String deobfuscate(java.lang.Object value)
de-obfuscate given value
Parameters:
value - value to de-obfuscate
Returns:
obfuscated value


ooOoo