|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvelosurf.model.Entity
public class Entity
The Entity class represents an entity in the data model. It should not be constructed directly.
| Nested Class Summary | |
|---|---|
private class |
Entity.FieldConstraintInfo
constraints |
| Field Summary | |
|---|---|
protected java.util.Map |
actionMap
actions of this entity |
protected java.util.Map<java.lang.String,java.lang.String> |
aliasByColumn
attributes of this entity |
protected java.util.Map |
attributeMap
|
protected Cache |
cache
the cache |
protected int |
cachingMethod
the caching method |
protected java.util.Map<java.lang.String,java.lang.String> |
columnByAlias
|
protected java.util.List<java.lang.String> |
columns
column names in natural order |
private java.util.List<Entity.FieldConstraintInfo> |
constraints
|
protected Database |
db
the database connection |
protected java.lang.String |
fetchQuery
the SQL query used to fetch one instance of this entity |
protected java.lang.Class |
instanceClass
the java class to use to realize this instance |
protected boolean[] |
keyColObfuscated
obfuscation status of key columns |
protected java.util.List<java.lang.String> |
keyCols
key column names in natural order |
protected java.util.List |
localizedColumns
localized columns |
protected java.lang.String |
name
name |
protected boolean |
obfuscate
whether to obfuscate something |
protected java.util.List<java.lang.String> |
obfuscatedColumns
names of obfuscated columns |
protected boolean |
readOnly
whether this entity is read-only or not |
protected java.lang.String |
table
table |
| Constructor Summary | |
|---|---|
Entity(Database db,
java.lang.String name,
boolean readOnly,
int cachingMethod)
Constructor reserved for the framework |
|
| Method Summary | |
|---|---|
void |
addAction(Action action)
|
void |
addAlias(java.lang.String alias,
java.lang.String column)
|
void |
addAttribute(Attribute attribute)
add a new attribute |
void |
addColumn(java.lang.String colName)
add a column at the end of the sequential list of named columns (called during the reverse engeenering of the database) |
void |
addConstraint(java.lang.String column,
FieldConstraint constraint)
|
void |
addPKColumn(java.lang.String colName)
adds a key column to the sequential list of the key columns (called during the reverse-engeenering of the database) |
java.util.List<java.lang.String> |
aliasToColumn(java.util.List<java.lang.String> aliases)
|
java.lang.String |
aliasToColumn(java.lang.String alias)
|
protected void |
buildFetchQuery()
build the SQL query used to fetch one instance of this query |
protected java.lang.Object |
buildKey(ReadOnlyMap values)
build the key for the Cache from a DataAccessor |
void |
clearCache()
Clear the cache |
java.lang.String |
columnToAlias(java.lang.String column)
|
boolean |
delete(ReadOnlyMap values)
delete a row based on (key) values |
java.lang.String |
deobfuscate(java.lang.Object value)
de-obfuscate given value |
protected void |
extractColumnValues(ReadOnlyMap source,
java.util.Map target)
extract column values from an input DataAccessor source and store result in target |
Instance |
fetch(java.util.List values)
fetch an instance from key values stored in a List in natural order |
Instance |
fetch(java.lang.Number keyValue)
fetch an instance from its key value specified as a Number |
Instance |
fetch(ReadOnlyMap values)
fetch an instance from key values stored in a Map |
Instance |
fetch(java.lang.String keyValue)
fetch an instance from its key value as a string |
java.lang.Object |
filterID(java.lang.Long id)
obfuscate this id value if needed |
ExportedKey |
findExportedKey(Entity fkEntity,
java.util.List<java.lang.String> fkCols)
|
ImportedKey |
findImportedKey(Entity pkEntity,
java.util.List<java.lang.String> fkCols)
|
Action |
getAction(java.lang.String property)
get the named action from this entity |
Attribute |
getAttribute(java.lang.String property)
Get a named attribute of this entity |
java.util.List<java.lang.String> |
getColumns()
getter for the list of column names |
Database |
getDB()
get the database connection |
java.lang.String |
getFetchQuery()
get the SQL query string used to fetch one instance of this query |
Instance |
getInstance(java.util.Map values)
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 values,
boolean updateValues)
get an instance whose values are in a map |
Instance |
getInstance(ReadOnlyMap values)
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(ReadOnlyMap values,
boolean updateValues)
get an instance from a DataAccessor object |
java.lang.String |
getName()
getter for the name of this entity |
java.util.List<java.lang.String> |
getPKCols()
getter for the list of key column names |
java.lang.String |
getTableName()
get the name of the mapped table |
boolean |
hasLocalizedColumns()
does this entity have localized columns ? |
boolean |
insert(ReadOnlyMap values)
insert a new row based on values of a map |
void |
invalidateInstance(ReadOnlyMap instance)
|
boolean |
isLocalized(java.lang.String column)
returns whether the given column is obfuscated |
boolean |
isObfuscated(java.lang.String column)
returns whether the given column is obfuscated |
boolean |
isReadOnly()
Is this entity read-only or read-write? |
Instance |
newInstance()
create a new realisation of this entity |
Instance |
newInstance(java.util.Map values)
builds a new instance from values contained in a Map |
Instance |
newInstance(ReadOnlyMap values)
build a new instance from a DataAccessor object |
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 refineCriteria,
java.lang.String order)
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 name)
set the name of this entity ** DO NOT USE DIRECTLY ** |
void |
reverseEnginered()
Used by the framework to notify this entity that its reverse enginering is over |
void |
setCachingMethod(int caching)
Specify the caching method, see Cache for allowed constants. |
void |
setInstanceClass(java.lang.String className)
Specify a custom class to use when instanciating this entity |
void |
setLocalized(java.util.List columns)
indicates a column as being localized |
void |
setObfuscated(java.util.List columns)
indicates a column as being obfuscated |
void |
setReadOnly(boolean readOnly)
set this entity to be read-only or read-write |
void |
setTableName(java.lang.String table)
set the name of the table mapped by this entity |
boolean |
update(ReadOnlyMap values)
update a row based on a set of values that must contain kety values |
boolean |
validate(ReadOnlyMap row,
UserContext userContext)
validate a set of values |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String name
protected java.lang.String table
protected java.util.List<java.lang.String> columns
protected java.util.List<java.lang.String> keyCols
protected boolean obfuscate
protected java.util.List<java.lang.String> obfuscatedColumns
protected boolean[] keyColObfuscated
protected java.util.List localizedColumns
protected java.util.Map<java.lang.String,java.lang.String> aliasByColumn
protected java.util.Map<java.lang.String,java.lang.String> columnByAlias
protected java.util.Map attributeMap
protected java.util.Map actionMap
protected java.lang.Class instanceClass
protected java.lang.String fetchQuery
protected boolean readOnly
protected Database db
protected int cachingMethod
protected Cache cache
private java.util.List<Entity.FieldConstraintInfo> constraints
| Constructor Detail |
|---|
public Entity(Database db,
java.lang.String name,
boolean readOnly,
int cachingMethod)
db - database connectionname - entity namereadOnly - access mode (read-write or read-only)cachingMethod - caching method to be used| Method Detail |
|---|
public void addColumn(java.lang.String colName)
colName - column name
public void addAlias(java.lang.String alias,
java.lang.String column)
public java.lang.String aliasToColumn(java.lang.String alias)
public java.util.List<java.lang.String> aliasToColumn(java.util.List<java.lang.String> aliases)
public java.lang.String columnToAlias(java.lang.String column)
public void addPKColumn(java.lang.String colName)
colName - name of the key columnpublic void addAttribute(Attribute attribute)
public Attribute getAttribute(java.lang.String property)
property - attribute name
public void addAction(Action action)
public Action getAction(java.lang.String property)
property - action name
public void setInstanceClass(java.lang.String className)
className - the java class namepublic void setCachingMethod(int caching)
Cache for allowed constants.
caching - Caching method
public void addConstraint(java.lang.String column,
FieldConstraint constraint)
public void reverseEnginered()
public void clearCache()
public Instance newInstance()
public Instance newInstance(java.util.Map values)
values - the Map containing the values
public Instance newInstance(ReadOnlyMap values)
values - the DataAccessor object containing the values
public Instance getInstance(java.util.Map values)
values - the map containing the key values
public Instance getInstance(java.util.Map values,
boolean updateValues)
values - the map containing the valuesupdateValues - whether the instance should be updated from the
map if found in the cache
public Instance getInstance(ReadOnlyMap values)
values - the DataAccessor object containing the values
public Instance getInstance(ReadOnlyMap values,
boolean updateValues)
values - the DataAccessor object containing the valuesupdateValues - whether all values are to be read from the
ReadOnlyMap if the instance has been found in the cache
public void invalidateInstance(ReadOnlyMap instance)
throws java.sql.SQLException
java.sql.SQLException
protected void extractColumnValues(ReadOnlyMap source,
java.util.Map target)
throws java.sql.SQLException
source - ReadOnlyMap source objecttarget - Map target object
java.sql.SQLException
protected java.lang.Object buildKey(ReadOnlyMap values)
throws java.sql.SQLException
values - the DataAccessor containing all values
java.sql.SQLException - the getter of the DataAccessor throws an
SQLExceptionpublic java.lang.String getName()
public void rename(java.lang.String name)
name - new namepublic java.util.List<java.lang.String> getPKCols()
public java.util.List<java.lang.String> getColumns()
public boolean insert(ReadOnlyMap values)
throws java.sql.SQLException
values - the Map object containing the values
java.sql.SQLExceptionpublic boolean update(ReadOnlyMap values)
values - the Map object containing the values
public boolean delete(ReadOnlyMap values)
values - the Map containing the values
public Instance fetch(java.util.List values)
throws java.sql.SQLException
values - the List containing the key values
java.sql.SQLException
public Instance fetch(ReadOnlyMap values)
throws java.sql.SQLException
values - the Map containing the key values
java.sql.SQLException
public Instance fetch(java.lang.String keyValue)
throws java.sql.SQLException
keyValue - the key
java.sql.SQLException
public Instance fetch(java.lang.Number keyValue)
throws java.sql.SQLException
keyValue - the key
java.sql.SQLExceptionpublic java.lang.String getFetchQuery()
protected void buildFetchQuery()
public RowIterator query()
throws java.sql.SQLException
java.sql.SQLException
public RowIterator query(java.util.List refineCriteria,
java.lang.String order)
throws java.sql.SQLException
refineCriteria - a refining criteria or null to get all instancesorder - an 'order by' clause or null to get instances in their
natural order
java.sql.SQLExceptionpublic Database getDB()
public boolean isReadOnly()
public void setReadOnly(boolean readOnly)
readOnly - the mode to switch to : true for read-only, false for
read-writepublic void setTableName(java.lang.String table)
table - the table mapped by this entity
read-writepublic java.lang.String getTableName()
public void setObfuscated(java.util.List columns)
columns - list of obfuscated columnspublic boolean isObfuscated(java.lang.String column)
column - the name of the column
public java.lang.String obfuscate(java.lang.Object value)
value - value to obfuscate
public java.lang.Object filterID(java.lang.Long id)
public java.lang.String deobfuscate(java.lang.Object value)
value - value to de-obfuscate
public void setLocalized(java.util.List columns)
columns - list of localized columnspublic boolean isLocalized(java.lang.String column)
column - the name of the column
public boolean hasLocalizedColumns()
public boolean validate(ReadOnlyMap row,
UserContext userContext)
throws java.sql.SQLException
java.sql.SQLException
public ImportedKey findImportedKey(Entity pkEntity,
java.util.List<java.lang.String> fkCols)
public ExportedKey findExportedKey(Entity fkEntity,
java.util.List<java.lang.String> fkCols)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||