jrunx.persistence.greylock
Class InstanceForge

java.lang.Object
  |
  +--jrunx.persistence.greylock.BaseDB
        |
        +--jrunx.persistence.greylock.DBStoreManager
              |
              +--jrunx.persistence.greylock.InstanceForge
All Implemented Interfaces:
Const, ObjectPersistence

public class InstanceForge
extends DBStoreManager
implements ObjectPersistence

Title: Description: Copyright: Copyright (c) Company:

Version:
1.0
Author:
 

Inner Class Summary
 class InstanceForge.DBPropertyNotFoundException
          Property not found Type: {typeName} Property: {propName}
 class InstanceForge.DeleteRequiredPropertyException
          Required property can not be deleted: {colName} Type: {typeName}
 class InstanceForge.EmbeddedInstanceNotFoundException
          Embedded instance not found: {id} Type: {typeName} Property: {propName}
static class InstanceForge.InvalidPrimaryKeyTypeException
          Invalid primary key type Type: {typeName} Column: {colName} Invalid Primary Key Type: {primaryKeyTypeName}
 class InstanceForge.InvalidPropertyTypeException
          Property expected {expected}, received {actual} Instance ID: {id} Type: {typeName} Property: {propName}
 
Inner classes inherited from class jrunx.persistence.greylock.DBStoreManager
DBStoreManager.DatasourceMappingException
 
Field Summary
static java.lang.String DELETE_INSTANCES_BY_TYPE_SQL
           
static java.lang.String GET_INSTANCE_ID_SQL
           
static java.lang.String GET_INSTANCE_NAME_BY_NAME_SQL
           
static java.lang.String GET_INSTANCE_NAME_SQL
           
 
Fields inherited from class jrunx.persistence.greylock.DBStoreManager
_dbmd, _dbMeta, _isInit, _tmd, driverMappingMetaData
 
Fields inherited from interface jrunx.persistence.greylock.Const
ARRAYED, BIGINT, BIT, BLOB, BYTE, CHAR, DOUBLE, FLOAT, ID, ID_TABLE, INCREMENT, INDEX, INSTANCE, INSTANCE_FORGE_IDS, INSTANCE_ID, INSTANCE_TABLE, INTEGER, INTERNALID, NAME, PARENT, PROPERTY_ID, PROPERTY_TABLE, RELATION_ID, SEARCHABLE, SEQUENCE_PROCEDURE, SHORT, SINK, SOURCE, TIMESTAMP, TYPE_FORGE_IDS, TYPE_ID, TYPE_TABLE, UNDERSCORE, VARCHAR, VIEW
 
Constructor Summary
protected InstanceForge(DBForgeFactory forgeFactory, java.sql.Connection con, java.lang.String typeName, CFODBMetaData metadata)
           
 
Method Summary
 void createInstance(java.util.Map mp, java.sql.Connection con)
          Creates COAPI Objects
protected  void createInstance(java.util.Map mp, DBInvoker invoker, java.sql.Connection con, long instanceID)
           
 void deleteInstance(InstancePK pk, java.sql.Connection con)
          To delete an instance supply either the GUID or the user supplied instance name used to store instance
protected  void deleteInstance(java.util.List ids, DBInvoker dbi, java.sql.Connection con)
          takes a list of internal int instanceID's and deletes them from the specified type.
protected  void deleteInstance(java.lang.Long id, DBInvoker dbi, java.sql.Connection con)
           
protected  java.util.List deleteInstanceJoins()
           
static void deleteInstances(DBInvoker dbi, DBTypeDef td)
          Delete all instances of a given type.
protected  void deleteParentInstances(Name parent, DBInvoker dbi, java.sql.Connection con)
           
 java.util.Collection findAll(java.sql.Connection con)
          Returns a list of instance names for the given InstanceForge.
 InstancePK findInstanceByPrimaryKey(InstancePK key, java.sql.Connection con)
          Finds the instance in the DB with the supplied Instance Primary Key
 java.util.Collection findInstances(Query query, java.sql.Connection con)
          The supplied SQL understood by Greylock that will be executed against the DB.
 java.util.Collection findInstances(Query query, java.lang.Object[] args, java.sql.Connection con)
          The name of the SQL query that will be executed against the DB.
static java.lang.String getID(java.util.Map mp)
          Returns the object in a map with a key value of "JRunID"
protected static java.util.List getIDS(java.lang.String column, java.lang.String typeName, java.sql.Connection con)
           
 java.util.Map getInstance(InstancePK arg, java.sql.Connection con)
          Retrieves an instance based on the instance name supplied.
protected  java.util.Map getInstance(java.lang.String arg, java.sql.Connection con)
          Returns a map populated with the data for a given named instance
protected  InstanceForge getInstanceForge(java.lang.String name, java.sql.Connection con)
           
protected  void getInstanceSql(java.lang.String arg, java.sql.Connection con, DBInvoker invoker, java.util.Map col, java.util.Map mp)
          for non-embedded instances
protected  CFODBMetaData getMetaData(java.lang.String name, java.sql.Connection con)
           
 java.lang.String getTypeName()
           
protected  void getUpdateSql(java.util.Map mp, DBInvoker dbi, java.sql.Connection con, int instanceID)
           
static java.lang.String setParameters(java.lang.String sql, java.lang.Object[] args)
           
 void updateInstance(java.util.Map mp, java.sql.Connection con)
          Put only the props to be updated in the map - update statements will be constructed to only include the props that exist in the map.
 
Methods inherited from class jrunx.persistence.greylock.DBStoreManager
getDatabaseMetaData, getDBInvoker, getDBSchema, getDBStoreMetaData, getDBVendor, getPackageDelimiter, getTypeMappingMetaData, init, initClassMappings, quoteIdentifier, setDBStoreMetaData, useQuotedIdentifiers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET_INSTANCE_ID_SQL

public static final java.lang.String GET_INSTANCE_ID_SQL

GET_INSTANCE_NAME_SQL

public static final java.lang.String GET_INSTANCE_NAME_SQL

GET_INSTANCE_NAME_BY_NAME_SQL

public static final java.lang.String GET_INSTANCE_NAME_BY_NAME_SQL

DELETE_INSTANCES_BY_TYPE_SQL

public static final java.lang.String DELETE_INSTANCES_BY_TYPE_SQL
Constructor Detail

InstanceForge

protected InstanceForge(DBForgeFactory forgeFactory,
                        java.sql.Connection con,
                        java.lang.String typeName,
                        CFODBMetaData metadata)
                 throws java.lang.Exception,
                        NoSuchTypeException
Method Detail

getInstanceForge

protected InstanceForge getInstanceForge(java.lang.String name,
                                         java.sql.Connection con)
                                  throws java.lang.Exception,
                                         NoSuchTypeException

getMetaData

protected CFODBMetaData getMetaData(java.lang.String name,
                                    java.sql.Connection con)
                             throws java.lang.Exception,
                                    NoSuchTypeException

getTypeName

public java.lang.String getTypeName()

createInstance

public void createInstance(java.util.Map mp,
                           java.sql.Connection con)
                    throws java.lang.Exception
Creates COAPI Objects
Specified by:
createInstance in interface ObjectPersistence
Parameters:
mp - This map is expected to match the graph of the Type
con -  
Throws:
InstanceForge.InvalidPropertyTypeException -  

createInstance

protected void createInstance(java.util.Map mp,
                              DBInvoker invoker,
                              java.sql.Connection con,
                              long instanceID)
                       throws java.lang.Exception

findAll

public java.util.Collection findAll(java.sql.Connection con)
                             throws java.lang.Exception
Returns a list of instance names for the given InstanceForge. Each instance of an InstanceForge is bound to a single COAPI Type namespace.
Specified by:
findAll in interface ObjectPersistence
Parameters:
con -  
Returns:
java.util.Collection
Throws:
InstanceForge.InvalidPropertyTypeException -  

findInstanceByPrimaryKey

public InstancePK findInstanceByPrimaryKey(InstancePK key,
                                           java.sql.Connection con)
                                    throws java.lang.Exception,
                                           NoSuchInstanceException
Finds the instance in the DB with the supplied Instance Primary Key
Specified by:
findInstanceByPrimaryKey in interface ObjectPersistence
Parameters:
key - InstancePK
con - java.sql.Connection
Returns:
InstancePK
Throws:
InstanceForge.InvalidPropertyTypeException -  

getInstance

public java.util.Map getInstance(InstancePK arg,
                                 java.sql.Connection con)
                          throws java.lang.Exception,
                                 NoSuchInstanceException
Description copied from interface: ObjectPersistence
Retrieves an instance based on the instance name supplied. This will either be a system supplied GUID or a user supplied name. If no instance is found a NoSuchInstanceException will be thrown.
Specified by:
getInstance in interface ObjectPersistence
Following copied from interface: jrunx.persistence.greylock.ObjectPersistence
Parameters:
name - java.lang.String
con - java.sql.Connection
Returns:
java.util.Map the instance
Throws:
java.lang.Exception -  
NoSuchInstanceException -  

getInstance

protected java.util.Map getInstance(java.lang.String arg,
                                    java.sql.Connection con)
                             throws java.lang.Exception,
                                    NoSuchInstanceException
Returns a map populated with the data for a given named instance
Parameters:
instanceName -  
con -  
Returns:
java.util.Map
Throws:
InstanceForge.InvalidPropertyTypeException -  
NoSuchInstanceException -  

getInstanceSql

protected void getInstanceSql(java.lang.String arg,
                              java.sql.Connection con,
                              DBInvoker invoker,
                              java.util.Map col,
                              java.util.Map mp)
                       throws java.lang.Exception
for non-embedded instances
Parameters:
arg -  
con -  
invoker -  
col -  
mp -  

updateInstance

public void updateInstance(java.util.Map mp,
                           java.sql.Connection con)
                    throws java.lang.Exception
Description copied from interface: ObjectPersistence
Put only the props to be updated in the map - update statements will be constructed to only include the props that exist in the map.
Specified by:
updateInstance in interface ObjectPersistence
Following copied from interface: jrunx.persistence.greylock.ObjectPersistence
Parameters:
props - java.util.Map
con - java.sql.Connection
Throws:
java.lang.Exception -  
NoSuchInstanceException -  

getUpdateSql

protected void getUpdateSql(java.util.Map mp,
                            DBInvoker dbi,
                            java.sql.Connection con,
                            int instanceID)
                     throws java.lang.Exception

findInstances

public java.util.Collection findInstances(Query query,
                                          java.sql.Connection con)
                                   throws java.lang.Exception
The supplied SQL understood by Greylock that will be executed against the DB. All instance names that return as a result of this query will be returned in Collection object.
Parameters:
sql - java.lang.String SQL
con - java.sql.Connection
Returns:
java.util.Collection
Throws:
InstanceForge.InvalidPropertyTypeException -  

findInstances

public java.util.Collection findInstances(Query query,
                                          java.lang.Object[] args,
                                          java.sql.Connection con)
                                   throws java.lang.Exception
The name of the SQL query that will be executed against the DB. All instance names that return as a result of this query will be returned in a Collection object.
Specified by:
findInstances in interface ObjectPersistence
Parameters:
query - Query
args - java.lang.Object[] Arguments passed to the query
con - java.sql.Connection
Returns:
java.util.Collection
Throws:
InstanceForge.InvalidPropertyTypeException -  

setParameters

public static java.lang.String setParameters(java.lang.String sql,
                                             java.lang.Object[] args)
                                      throws java.lang.Exception

deleteInstances

public static void deleteInstances(DBInvoker dbi,
                                   DBTypeDef td)
                            throws java.lang.Exception
Delete all instances of a given type.
Parameters:
dbi -  
td -  
Throws:
InstanceForge.InvalidPropertyTypeException -  

deleteInstance

public void deleteInstance(InstancePK pk,
                           java.sql.Connection con)
                    throws java.lang.Exception,
                           NoSuchInstanceException
Description copied from interface: ObjectPersistence
To delete an instance supply either the GUID or the user supplied instance name used to store instance
Specified by:
deleteInstance in interface ObjectPersistence
Following copied from interface: jrunx.persistence.greylock.ObjectPersistence
Parameters:
name - InstancePK instance primary key
con - java.sql.Connection
Throws:
java.lang.Exception -  
NoSuchInstanceException -  

deleteInstance

protected void deleteInstance(java.lang.Long id,
                              DBInvoker dbi,
                              java.sql.Connection con)
                       throws java.lang.Exception

deleteInstance

protected void deleteInstance(java.util.List ids,
                              DBInvoker dbi,
                              java.sql.Connection con)
                       throws java.lang.Exception
takes a list of internal int instanceID's and deletes them from the specified type. This method will resolve the graph of the instance to delete any embedded instances
Parameters:
ids - java.util.List of instanceID's to be deleted
dbi - DBInvoker to cache db calls
con - Connection object
Throws:
InstanceForge.InvalidPropertyTypeException -  

deleteInstanceJoins

protected java.util.List deleteInstanceJoins()
                                      throws java.lang.Exception

getIDS

protected static java.util.List getIDS(java.lang.String column,
                                       java.lang.String typeName,
                                       java.sql.Connection con)
                                throws java.lang.Exception

deleteParentInstances

protected void deleteParentInstances(Name parent,
                                     DBInvoker dbi,
                                     java.sql.Connection con)
                              throws java.lang.Exception

getID

public static java.lang.String getID(java.util.Map mp)
Returns the object in a map with a key value of "JRunID"
Parameters:
mp - the map that contains an id key


Copyright � 2002 Macromedia Corporation. All Rights Reserved.