Keel 2.1RC2

org.keel.services.persist
Interface PersistentFactory

All Known Implementing Classes:
AbstractPersistentFactory

public interface PersistentFactory

A PersistentFactory is a class that generates new Persistent objects, Transactions, and Queries.


Field Summary
static java.lang.String ROLE
           
 
Method Summary
 void addInputs(ModelResponse res, Persistent p)
          Convenience method to add an Input ResponseElement to the specified ModelResponse for every field in the supplied Persistent.
 void addOutputs(ModelResponse res, Persistent p)
          Convenience method to add an Output ResponseElement to the specified ModelResponse for every field in the supplied Persistent.
 void addQuery(ModelResponse res, Persistent p, java.lang.String outputName)
          Convenience method to add a List of nested Output ResponseElements to the specified ModelRepsonse.
 void addQuery(ModelResponse res, Persistent p, java.lang.String outputName, java.lang.String[] fieldNames)
          Convenience method to add a List of nested Output ResponseElements to the specified ModelRepsonse.
 Transaction begin()
          Begin a new transaction and pass the transaction back to the caller.
 Persistent create(java.lang.String name)
          Create a new persistent object with the specified name.
 Persistent create(java.lang.String name, Transaction trx)
          Create a new Persistent which participates in a transaction.
 void createTables()
          Initialize all schemas defined in this persistent factory, creating all tables as required.
 void createTables(java.lang.String schemaName)
          Initialize the specified schema, creating all tables as required.
 PersistentFactory getFactory(java.lang.String factoryName)
          A convenience method which gets another factory (other than the current one).
 java.lang.String getName()
          A different factory is used to talk to each different database that the application requires.
 java.util.Set getPersistents(java.lang.String schemaName)
          Return a list of the names of all persistent object in the specified schema.
 Configuration getSchemaConfiguration(java.lang.String schemaName)
          Get the Configuration object for the specified schema, if this schema is defined in this PersistentFactory
 java.lang.String getSchemaDescription(java.lang.String schemaName)
          Get the human-readable description of the specified schema
 java.util.Set getSchemas()
          Return a set of Schema names this factory knows about.
 java.lang.String getSecurity()
          Return the name of an another persistent factory where we find the definitions of the Keel security persistent objects.
 

Field Detail

ROLE

public static final java.lang.String ROLE
See Also:
Constant Field Values
Method Detail

create

public Persistent create(java.lang.String name)
                  throws PersistenceException
Create a new persistent object with the specified name. The name must be of the form "schema.persistent".

Throws:
PersistenceException

create

public Persistent create(java.lang.String name,
                         Transaction trx)
                  throws PersistenceException
Create a new Persistent which participates in a transaction.

Throws:
PersistenceException

begin

public Transaction begin()
                  throws PersistenceException
Begin a new transaction and pass the transaction back to the caller. Used when we want a number of database operations to be processed in a single transaction.

Throws:
PersistenceException

getName

public java.lang.String getName()
A different factory is used to talk to each different database that the application requires. Each factory has a unique name.


createTables

public void createTables(java.lang.String schemaName)
                  throws PersistenceException
Initialize the specified schema, creating all tables as required. Logs any differences between existing tables and specified tables.

Throws:
PersistenceException

createTables

public void createTables()
                  throws PersistenceException
Initialize all schemas defined in this persistent factory, creating all tables as required. Logs any differences between existing tables and specified tables.

Throws:
PersistenceException

getSchemas

public java.util.Set getSchemas()
Return a set of Schema names this factory knows about.


getSchemaDescription

public java.lang.String getSchemaDescription(java.lang.String schemaName)
Get the human-readable description of the specified schema

Parameters:
schemaName - The name of the schema
Returns:
String The human-readable description of this schema

getSchemaConfiguration

public Configuration getSchemaConfiguration(java.lang.String schemaName)
Get the Configuration object for the specified schema, if this schema is defined in this PersistentFactory

Parameters:
schemaName - The name of the schema to retrieve configuration for
Returns:
A Configuration for the named schema, or null if no such schema exists
Throws:
PersistenceException - If a parameter error is made (e.g. null schema name), or an error occurrs retrieving the specified schema's configuration

getPersistents

public java.util.Set getPersistents(java.lang.String schemaName)
                             throws PersistenceException
Return a list of the names of all persistent object in the specified schema.

Throws:
PersistenceException

addInputs

public void addInputs(ModelResponse res,
                      Persistent p)
               throws PersistenceException,
                      ModelException
Convenience method to add an Input ResponseElement to the specified ModelResponse for every field in the supplied Persistent. Each Input will have a default value the same as the current value of the field in the Persistent, and the Input will have valid values if the field has a list of supplied valid values.

Parameters:
res - A ModelResponse object
p - A persistent to be used to create Inputs
Throws:
PersistenceException - If a problem occurs retrieving the fields
ModelException - If a problem occurs creating the Inputs

addOutputs

public void addOutputs(ModelResponse res,
                       Persistent p)
                throws PersistenceException,
                       ModelException
Convenience method to add an Output ResponseElement to the specified ModelResponse for every field in the supplied Persistent. Each output will be named according to the field name from the persistent, and the content of the output will be the value of the field.

Parameters:
res - A ModelResponse object
p - A persistent to be used to create Outputs
Throws:
PersistenceException - If an exception occurs retrieving the fields
ModelException - If an exception occurs creating the outputs.

addQuery

public void addQuery(ModelResponse res,
                     Persistent p,
                     java.lang.String outputName)
              throws PersistenceException,
                     ModelException
Convenience method to add a List of nested Output ResponseElements to the specified ModelRepsonse. Similiar to addOutputs, for the individiual rows. Each row is added to the "outer" Output as row # (useful for logic:iterate). Rows are added to the Output Response Element specified by outputName.

Parameters:
res - A ModelResponse object
p - A persistent to be used to create Outputs
outputName - Name of Output ResponseElement to add the List to.
Throws:
PersistenceException - If an exception occurs retrieving the fields
ModelException - If an exception occurs creating the outputs.
See Also:
#addOutputs(ModelReponse, Persistent)

addQuery

public void addQuery(ModelResponse res,
                     Persistent p,
                     java.lang.String outputName,
                     java.lang.String[] fieldNames)
              throws PersistenceException,
                     ModelException
Convenience method to add a List of nested Output ResponseElements to the specified ModelRepsonse. Similiar to addOutputs, for the individiual rows. Each row is added to the "outer" Output as row # (useful for logic:iterate). Rows are added to the Output Response Element specified by outputName.

Parameters:
res - A ModelResponse object
p - A persistent to be used to create Outputs
outputName - Name of Output ResponseElement to add the List to.
fieldNames - The fields to be added to the Output. Fields will be added in the same order as in the list.
Throws:
PersistenceException - If an exception occurs retrieving the fields
ModelException - If an exception occurs creating the outputs.
See Also:
#addOutputs(ModelReponse, Persistent)

getSecurity

public java.lang.String getSecurity()
Return the name of an another persistent factory where we find the definitions of the Keel security persistent objects. If we get null we find them here.


getFactory

public PersistentFactory getFactory(java.lang.String factoryName)
                             throws PersistenceException
A convenience method which gets another factory (other than the current one).

Parameters:
factoryName - The name of the factory being requested
Returns:
A new PersistentFactory
Throws:
PersistenceException - If the factory cannot be initialized, or there is no such factory configured

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.