|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthelma.objectmodel.db.DbMapping
public final class DbMapping
A DbMapping describes how a certain type of Nodes is to mapped to a relational database table. Basically it consists of a set of JavaScript property-to- Database row bindings which are represented by instances of the Relation class.
Field Summary | |
---|---|
protected Application |
app
|
protected Relation |
propRelation
|
protected Relation |
subRelation
|
Constructor Summary | |
---|---|
DbMapping(Application app,
java.lang.String parentTypeName)
Create an internal DbMapping used for "virtual" mappings aka collections, mountpoints etc. |
|
DbMapping(Application app,
java.lang.String typename,
ResourceProperties props)
Create a DbMapping from a type.properties property file |
Method Summary | |
---|---|
protected void |
addDependency(DbMapping dbmap)
Register a DbMapping that depends on this DbMapping, so that collections of other mapping should be reloaded if data on this mapping is updated. |
void |
addJoinConstraints(java.lang.StringBuffer s,
java.lang.String pre)
Add constraints to select query string to join object references |
protected void |
appendCondition(java.lang.StringBuffer q,
java.lang.String column,
java.lang.String val)
Append a sql-condition for the given column which must have the value given to the given StringBuffer. |
protected void |
appendCondition(java.lang.StringBuffer q,
java.lang.String column,
java.lang.String[] values)
Append a sql-condition for the given column which must have one of the values contained inside the given Set to the given StringBuffer. |
static boolean |
areStorageCompatible(DbMapping dbm1,
DbMapping dbm2)
Static utility method to check whether two DbMappings use the same storage. |
java.lang.String |
columnNameToProperty(java.lang.String columnName)
Translate a database column name to an object property name according to this mapping. |
Relation |
columnNameToRelation(java.lang.String columnName)
Translate a database column name to an object property name according to this mapping. |
boolean |
evictOnReplication()
Should objects of this type be evicted/discarded/reloaded when received via cache replication? |
Application |
getApplication()
Get the application this DbMapping belongs to. |
java.lang.String |
getAppName()
Get the name of this mapping's application |
DbColumn |
getColumn(java.lang.String columnName)
|
DbColumn[] |
getColumns()
Return an array of DbColumns for the relational table mapped by this DbMapping. |
java.sql.Connection |
getConnection()
Get a JDBC connection for this DbMapping. |
DbSource |
getDbSource()
Get the DbSource object for this DbMapping. |
java.lang.String |
getDbSourceName()
Get the dbsource name used for this type mapping. |
Relation |
getExactPropertyRelation(java.lang.String propname)
|
java.lang.String |
getExtends()
Get the name of this type's parent type, if any. |
java.lang.String |
getExtensionId()
get the id-value of this extension |
java.lang.String[] |
getExtensions()
Returns the Set of Prototypes extending this prototype |
DbMapping |
getGroupbyMapping()
If subnodes are grouped by one of their properties, return the db-mapping with the right relations to create the group-by nodes |
java.lang.String |
getIDField()
Get the primary key column name for objects using this mapping. |
java.lang.String |
getIDgen()
|
java.lang.String |
getInsert()
|
Relation[] |
getJoins()
Return the array of relations that are fetched with objects of this type. |
long |
getLastDataChange()
Get the last time something changed in our data |
long |
getLastTypeChange()
Get the last time something changed in the Mapping |
java.lang.String |
getNameField()
Get the column used for (internal) names of objects of this type. |
protected long |
getNewID(long dbmax)
Helper method to generate a new ID. |
ParentInfo[] |
getParentInfo()
|
DbMapping |
getParentMapping()
Get the mapping we inherit from, or null |
java.lang.String |
getParentSetting()
|
ResourceProperties |
getProperties()
Get our ResourceProperties |
java.util.Enumeration |
getPropertyEnumeration()
Return an enumeration of all properties defined by this db mapping. |
DbMapping |
getPropertyMapping(java.lang.String propname)
|
java.lang.String[] |
getPropertyNames()
Return the list of defined property names as String array. |
Relation |
getPropertyRelation(java.lang.String propname)
|
java.lang.String |
getPrototypeField()
Get the column used for names of prototype. |
java.lang.String |
getPrototypeName(java.lang.String id)
Looks up the prototype name identified by the given id, returing our own type name if it can't be resolved |
java.lang.StringBuffer |
getSelect(Relation rel)
Get a StringBuffer initialized to the first part of the select statement for objects defined by this DbMapping |
java.lang.String |
getStorageTypeName()
Return the name of the prototype which specifies the storage location (dbsource + tablename) for this type, or null if it is stored in the embedded db. |
java.lang.String |
getSubnodeGroupby()
|
DbMapping |
getSubnodeMapping()
|
Relation |
getSubnodeRelation()
|
java.lang.String |
getTableName()
Get the table name used for this type mapping. |
java.lang.String |
getTypeName()
Get the name of the object type this DbMapping belongs to. |
java.lang.StringBuffer |
getUpdate()
|
WrappedNodeManager |
getWrappedNodeManager()
|
protected boolean |
inheritsStorage()
Check whether this DbMapping inherits its storage location from its parent mapping. |
boolean |
isH2()
Is the database behind this a H2 db? |
boolean |
isInstanceOf(java.lang.String other)
Return true if this db mapping represents the prototype indicated by the string argument, either itself or via one of its parent prototypes. |
boolean |
isMySQL()
Is the database behind this a MySQL db? |
boolean |
isOracle()
Is the database behind this an Oracle db? |
boolean |
isPostgreSQL()
Is the database behind this a PostgreSQL db? |
boolean |
isRelational()
Tell whether this data mapping maps to a relational database table. |
boolean |
isStorageCompatible(DbMapping other)
Tell if this DbMapping uses the same storage as the given DbMapping. |
boolean |
isVirtual()
Find if this DbMapping describes a virtual node (collection, mountpoint, groupnode) |
boolean |
needsQuotes(java.lang.String columnName)
Return true if values for the column identified by the parameter need to be quoted in SQL queries. |
boolean |
needsUpdate()
Tell the type manager whether we need update() to be called |
java.lang.String |
propertyToColumnName(java.lang.String propName)
Translate an object property name to a database column name according to this mapping. |
Relation |
propertyToRelation(java.lang.String propName)
Translate an object property name to a database column name according to this mapping. |
void |
remove()
Method in interface Updatable. |
protected void |
setIndirectDataChange()
Set the last time something changed in the data. |
void |
setLastDataChange()
Set the last time something changed in the data, propagating the event to mappings that depend on us through an additionalTables switch. |
void |
setPropertyRelation(Relation rel)
|
java.lang.String |
toString()
Return a string representation for this DbMapping |
void |
update()
Read the mapping from the Properties. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Application app
protected Relation subRelation
protected Relation propRelation
Constructor Detail |
---|
public DbMapping(Application app, java.lang.String parentTypeName)
public DbMapping(Application app, java.lang.String typename, ResourceProperties props)
Method Detail |
---|
public boolean needsUpdate()
public void update()
public java.lang.String[] getExtensions()
public java.lang.String getPrototypeName(java.lang.String id)
id
- the id specified for the prototype
public java.lang.String getExtensionId()
public void remove()
public java.sql.Connection getConnection() throws java.lang.ClassNotFoundException, java.sql.SQLException
java.lang.ClassNotFoundException
java.sql.SQLException
public DbSource getDbSource()
public java.lang.String getDbSourceName()
public java.lang.String getTableName()
public Application getApplication()
public java.lang.String getAppName()
public java.lang.String getTypeName()
public java.lang.String getExtends()
public java.lang.String getIDField()
public java.lang.String getNameField()
public java.lang.String getPrototypeField()
public boolean evictOnReplication()
public java.lang.String columnNameToProperty(java.lang.String columnName)
public java.lang.String propertyToColumnName(java.lang.String propName)
public Relation columnNameToRelation(java.lang.String columnName)
public Relation propertyToRelation(java.lang.String propName)
public java.lang.String getParentSetting()
public ParentInfo[] getParentInfo()
public DbMapping getSubnodeMapping()
public DbMapping getPropertyMapping(java.lang.String propname)
propname
- ...
public DbMapping getGroupbyMapping()
public void setPropertyRelation(Relation rel)
rel
- ...public Relation getSubnodeRelation()
public java.lang.String[] getPropertyNames()
public Relation getPropertyRelation(java.lang.String propname)
propname
- ...
public Relation getExactPropertyRelation(java.lang.String propname)
propname
- ...
public java.lang.String getSubnodeGroupby()
public java.lang.String getIDgen()
public WrappedNodeManager getWrappedNodeManager()
public boolean isRelational()
public DbColumn[] getColumns() throws java.lang.ClassNotFoundException, java.sql.SQLException
java.lang.ClassNotFoundException
java.sql.SQLException
public Relation[] getJoins()
public DbColumn getColumn(java.lang.String columnName) throws java.lang.ClassNotFoundException, java.sql.SQLException
columnName
- ...
java.lang.ClassNotFoundException
- ...
java.sql.SQLException
- ...public java.lang.StringBuffer getSelect(Relation rel)
rel
- the Relation we use to select. Currently only used for optimizer hints.
Is null if selecting by primary key.
public java.lang.String getInsert() throws java.lang.ClassNotFoundException, java.sql.SQLException
java.lang.ClassNotFoundException
java.sql.SQLException
public java.lang.StringBuffer getUpdate()
public boolean needsQuotes(java.lang.String columnName) throws java.sql.SQLException, java.lang.ClassNotFoundException
java.sql.SQLException
java.lang.ClassNotFoundException
public void addJoinConstraints(java.lang.StringBuffer s, java.lang.String pre)
public boolean isOracle()
public boolean isMySQL()
public boolean isPostgreSQL()
public boolean isH2()
public java.lang.String toString()
toString
in class java.lang.Object
public long getLastTypeChange()
public long getLastDataChange()
public void setLastDataChange()
protected void setIndirectDataChange()
protected long getNewID(long dbmax)
dbmax
- the maximum value already stored in db
public java.util.Enumeration getPropertyEnumeration()
public java.lang.String getStorageTypeName()
protected boolean inheritsStorage()
public static boolean areStorageCompatible(DbMapping dbm1, DbMapping dbm2)
public boolean isStorageCompatible(DbMapping other)
public boolean isInstanceOf(java.lang.String other)
public DbMapping getParentMapping()
public ResourceProperties getProperties()
protected void addDependency(DbMapping dbmap)
dbmap
- the DbMapping that depends on usprotected void appendCondition(java.lang.StringBuffer q, java.lang.String column, java.lang.String[] values) throws java.sql.SQLException, java.lang.ClassNotFoundException
q
- the StringBuffer to append tocolumn
- the column which must match one of the valuesvalues
- the list of values
java.sql.SQLException
java.lang.ClassNotFoundException
protected void appendCondition(java.lang.StringBuffer q, java.lang.String column, java.lang.String val) throws java.sql.SQLException, java.lang.ClassNotFoundException
q
- the StringBuffer to append tocolumn
- the column which must match one of the valuesval
- the value
java.sql.SQLException
java.lang.ClassNotFoundException
public boolean isVirtual()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |