|
||||||||||
| 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.
| Nested Class Summary | |
|---|---|
private class |
Entity.FieldConstraintInfo
constraints. |
| Field Summary | |
|---|---|
private java.util.Map<java.lang.String,Action> |
actionMap
action map. |
private java.util.Map<java.lang.String,java.lang.String> |
aliasByColumn
Alias by column map. |
private java.util.Map<java.lang.String,Attribute> |
attributeMap
Attribute map. |
private Cache |
cache
the cache. |
private int |
cachingMethod
the caching method. |
private java.util.Map<java.lang.String,java.lang.String> |
columnByAlias
Column by alias map. |
private java.util.List<java.lang.String> |
columns
Column names in natural order. |
private java.util.List<Entity.FieldConstraintInfo> |
constraints
Constraint by column name map. |
private Database |
db
the database connection. |
private java.lang.String |
fetchQuery
the SQL query used to fetch one instance of this entity. |
private java.lang.Class |
instanceClass
the java class to use to realize this instance. |
private boolean[] |
keyColObfuscated
Obfuscation status of key columns. |
private java.util.List<java.lang.String> |
keyCols
Key column names in natural order. |
private java.util.List |
localizedColumns
Localized columns. |
private static int |
MAX_DATA_DISPLAY_LENGTH
Truncate validation error messages to a maximum number of characters. |
private java.lang.String |
name
Name. |
private boolean |
obfuscate
Whether to obfuscate something. |
private java.util.List<java.lang.String> |
obfuscatedColumns
Names of obfuscated columns. |
private boolean |
readOnly
whether this entity is read-only or not. |
private 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)
Add an action. |
void |
addAlias(java.lang.String alias,
java.lang.String column)
Add a column alis. |
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. |
void |
addConstraint(java.lang.String column,
FieldConstraint constraint)
Add a constraint. |
void |
addPKColumn(java.lang.String colName)
Add a key column to the sequential list of the key columns. |
java.util.List<java.lang.String> |
aliasToColumn(java.util.List<java.lang.String> aliases)
Translate a list of aliases to a list of column names. |
java.lang.String |
aliasToColumn(java.lang.String alias)
Translates an alias to its column name. |
private void |
buildFetchQuery()
Build the SQL query used to fetch one instance of this query. |
private java.lang.Object |
buildKey(java.util.Map<java.lang.String,java.lang.Object> values)
Build the key for the Cache from a Map. |
void |
clearCache()
Clear the cache. |
java.lang.String |
columnToAlias(java.lang.String column)
Translate a column name to an alias. |
boolean |
delete(java.util.Map values)
Delete a row based on (key) values. |
java.lang.String |
deobfuscate(java.lang.Object value)
De-obfuscate given value. |
private void |
extractColumnValues(java.util.Map<java.lang.String,java.lang.Object> source,
java.util.Map<java.lang.String,java.lang.Object> target)
Extract column values from an input Map source and store result in target. |
Instance |
fetch(java.util.List<java.lang.Object> values)
Fetch an instance from key values stored in a List in natural order. |
Instance |
fetch(java.util.Map values)
Fetch an instance from key values stored in a Map. |
Instance |
fetch(java.lang.Number keyValue)
Fetch an instance from its key value specified as a Number. |
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)
Check for the existence of an exported key with the same columns. |
ImportedKey |
findImportedKey(Entity pkEntity,
java.util.List<java.lang.String> fkCols)
Check for the existence of an imported key with the same columns. |
Action |
getAction(java.lang.String property)
get an action. |
Attribute |
getAttribute(java.lang.String property)
Get a named attribute. |
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<java.lang.String,java.lang.Object> values)
Get an instance from its values contained in a Map 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(java.util.Map<java.lang.String,java.lang.Object> values)
Insert a new row based on values of a map. |
void |
invalidateInstance(java.util.Map<java.lang.String,java.lang.Object> instance)
Invalidate an instance in the cache. |
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<java.lang.String,java.lang.Object> values)
Build a new instance from a Map 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 |
reverseEnginered()
Used by the framework to notify this entity that its reverse enginering is over. |
void |
setCachingMethod(int caching)
Specify the caching method. |
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<java.lang.String> 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(java.util.Map<java.lang.String,java.lang.Object> values)
Update a row based on a set of values that must contain key values. |
boolean |
validate(java.util.Map<java.lang.String,java.lang.Object> row)
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 |
|---|
private static final int MAX_DATA_DISPLAY_LENGTH
private java.lang.String name
private java.lang.String table
private java.util.List<java.lang.String> columns
private java.util.List<java.lang.String> keyCols
private boolean obfuscate
private java.util.List<java.lang.String> obfuscatedColumns
private boolean[] keyColObfuscated
private java.util.List localizedColumns
private java.util.Map<java.lang.String,java.lang.String> aliasByColumn
private java.util.Map<java.lang.String,java.lang.String> columnByAlias
private java.util.Map<java.lang.String,Attribute> attributeMap
private java.util.Map<java.lang.String,Action> actionMap
private java.lang.Class instanceClass
private java.lang.String fetchQuery
private boolean readOnly
private Database db
private int cachingMethod
private 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)
alias - aliascolumn - columnpublic java.lang.String aliasToColumn(java.lang.String alias)
alias - alias
public java.util.List<java.lang.String> aliasToColumn(java.util.List<java.lang.String> aliases)
aliases - list of aliases
public java.lang.String columnToAlias(java.lang.String column)
column - column
public void addPKColumn(java.lang.String colName)
colName - name of the key columnpublic void addAttribute(Attribute attribute)
attribute - attributepublic Attribute getAttribute(java.lang.String property)
property - attribute name
public void addAction(Action action)
action - actionpublic 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)
column - column nameconstraint - constraintpublic void reverseEnginered()
public void clearCache()
public Instance newInstance()
public Instance newInstance(java.util.Map<java.lang.String,java.lang.Object> values)
values - the Map object containing the values
public Instance getInstance(java.util.Map<java.lang.String,java.lang.Object> values)
values - the Map object containing the values
public void invalidateInstance(java.util.Map<java.lang.String,java.lang.Object> instance)
throws java.sql.SQLException
instance - instance
java.sql.SQLException
private void extractColumnValues(java.util.Map<java.lang.String,java.lang.Object> source,
java.util.Map<java.lang.String,java.lang.Object> target)
throws java.sql.SQLException
source - Map source objecttarget - Map target object
java.sql.SQLException
private java.lang.Object buildKey(java.util.Map<java.lang.String,java.lang.Object> values)
throws java.sql.SQLException
values - the Map containing all values
java.sql.SQLException - the getter of the Map throws an
SQLExceptionpublic java.lang.String getName()
public java.util.List<java.lang.String> getPKCols()
public java.util.List<java.lang.String> getColumns()
public boolean insert(java.util.Map<java.lang.String,java.lang.Object> values)
throws java.sql.SQLException
values - the Map object containing the values
java.sql.SQLExceptionpublic boolean update(java.util.Map<java.lang.String,java.lang.Object> values)
values - the Map object containing the values
public boolean delete(java.util.Map values)
values - the Map containing the values
public Instance fetch(java.util.List<java.lang.Object> values)
throws java.sql.SQLException
values - the List containing the key values
java.sql.SQLException
public Instance fetch(java.util.Map 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()
private 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<java.lang.String> 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)
id - id value
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(java.util.Map<java.lang.String,java.lang.Object> row)
throws java.sql.SQLException
java.sql.SQLException
public ImportedKey findImportedKey(Entity pkEntity,
java.util.List<java.lang.String> fkCols)
pkEntity - primary key entityfkCols - foreign key columns
public ExportedKey findExportedKey(Entity fkEntity,
java.util.List<java.lang.String> fkCols)
fkEntity - foreign key entityfkCols - foreign key columns
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||