biz.c24.io.api
Class Factory

java.lang.Object
  extended by biz.c24.io.api.Factory

public class Factory
extends Object

A factory to initalize and create classes in the API.

Instances of this class should be retrieved via the newInstance(java.io.File) method, passing in a project file. OR newInstance(java.net.URI) method, passing in a file based uri with or without query scheme e.g file://[path]?configuration= The project file is generated when a designer project is saved. The Factory instance has a default configuration selected based on the query parameter provided in the project uri or if the project file has only a single configuration element.


Field Summary
static int DATAMODEL
           
static int TRANSFORM
           
 
Method Summary
 Element createElement(String configName)
          Creates a new Element from the specified configuration in the project file.
 Properties createInputDatabaseProperties(String id, String configName)
          Creates a new input set of database properties from the configuration element for the given ID.
 Properties createOutputDatabaseProperties(String id, String configName)
          Creates a new output database properties from configuration element with the given ID.
 Sink createSink(String id, String configName)
          Creates a new Sink for the given ID from the configuration element.
 Source createSource(String id, String configName)
          Creates a new Source with the given ID from the configuration element.
 Transform createTransform(String configName)
          Creates a new Transform from the specified configuration in the project file.
 String[] getDatabaseInputIds(String configName)
          Returns the ids of all database inputs specified in the configuration element An id in the returned array can be used in the #createInputDatabaseProperties(String) method.
 String[] getDatabaseOutputIds(String configName)
          Returns the ids of all database outputs specified in the configuration element.
 String[] getSinkIds(String configName)
          Returns the ids of all Sinks specified in the configuration element.
 String[] getSourceIds(String configName)
          Returns the ids of all Sources specified in the configuration element.
 String getSourceSinkURI(String id, String configName)
          Returns the Source uri from the configuration element

 int getTargetType(String configName)
          Returns a int depending on the target element.
 void initDomainConstraints()
          Initializes the DomainConstraintManager from the project file, after clearing any current constraints.
 void initDomainConstraints(boolean clear)
          Initializes the DomainConstraintManager from the project file, possibly clearing any current constraints first.
 void initInputDatabaseProperties(String id, Properties properties, String configName)
          Initializes a set of input database properties for the specified configuration with the given ID.
 void initOutputDatabaseProperties(String id, Properties properties, String configName)
          Initializes a set of output database properties from configuration with the given ID.
static Object loadFromDatabase(Element element, org.hibernate.cfg.Configuration cfg, String primaryKey, String sqlQuery, String hqlQuery, String dialect, ClassLoader loader)
          Loads an object from the specified database configuration using either a primary key, SQL query or HQL query.
static ComplexDataObject loadFromSource(Element element, Source src)
          Loads an object from the specified source.
static Factory newInstance(File file)
          Creates a new instance of the factory from the specified project url using the default classloader.
static Factory newInstance(File file, ClassLoader loader)
          Creates a new instance of the factory from the specified project file using the specified classloader.
static Factory newInstance(URI uri)
          Creates a new instance of the factory from the specified project file based uri.
static Factory newInstance(URI uri, ClassLoader loader)
          Creates a new instance of the factory from the specified project file based uri using the specified classloader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATAMODEL

public static final int DATAMODEL
See Also:
Constant Field Values

TRANSFORM

public static final int TRANSFORM
See Also:
Constant Field Values
Method Detail

getDatabaseInputIds

public String[] getDatabaseInputIds(String configName)
                             throws FactoryException
Returns the ids of all database inputs specified in the configuration element An id in the returned array can be used in the #createInputDatabaseProperties(String) method.

Parameters:
configName - The name of the target configuration in the project file or null to use the default configuration.
Returns:
The ids.
Throws:
FactoryException

getDatabaseOutputIds

public String[] getDatabaseOutputIds(String configName)
                              throws FactoryException
Returns the ids of all database outputs specified in the configuration element. An id in the returned array can be used in the #createOutputDatabaseProperties(String) method.

Parameters:
configName - The name of the target configuration in the project file or null to use the default configuration.
Returns:
The ids.
Throws:
FactoryException

getSourceIds

public String[] getSourceIds(String configName)
                      throws FactoryException
Returns the ids of all Sources specified in the configuration element.

An id in the returned array can be used in the #createSource(String) method.

Parameters:
configName - The name of the target configuration in the project file or null to use the default configuration.
Returns:
The ids.
Throws:
FactoryException

getSinkIds

public String[] getSinkIds(String configName)
                    throws FactoryException
Returns the ids of all Sinks specified in the configuration element.

An id in the returned array can be used in the #createSink(String) method.

Parameters:
configName - The name of the target configuration in the project file or null to use the default configuration.
Returns:
The ids.
Throws:
FactoryException

createSource

public Source createSource(String id,
                           String configName)
                    throws FactoryException
Creates a new Source with the given ID from the configuration element.

To create a new database connection, use #createInputDatabaseProperties(String) instead of this method.

Parameters:
id - The id of the Source to create or null to create the first Source appearing in the configuration element.
configName - The name of the target configuration or null to use default configuration element.
Returns:
The newly created Source.
Throws:
FactoryException - If no Source can be found for the specified ID.

getSourceSinkURI

public String getSourceSinkURI(String id,
                               String configName)
                        throws FactoryException
Returns the Source uri from the configuration element

Parameters:
id - The id of the Source or null to select the first source from the configuration element.
configName - The name of the target configuration or null to use default configuration element.
Returns:
The Source URI.
Throws:
FactoryException - If no Source can be found for the specified ID.

createSink

public Sink createSink(String id,
                       String configName)
                throws FactoryException
Creates a new Sink for the given ID from the configuration element.

To create a new database connection, use #createOutputDatabaseProperties(String) instead of this method.

Parameters:
id - The id of the Sink to create or null to create the first Sink appearing in the default configuration.
configName - The name of the target configuration or null to use default configuration element. *
Returns:
The newley created Sink.
Throws:
FactoryException - If no Sink can be found for the specified ID.

createInputDatabaseProperties

public Properties createInputDatabaseProperties(String id,
                                                String configName)
                                         throws FactoryException
Creates a new input set of database properties from the configuration element for the given ID.

Parameters:
id - The id of the database input to create or null to create the first database input appearing in the specified configuration.
configName - The name of the target configuration or null to use default configuration element.
Returns:
The newly created configuration.
Throws:
FactoryException - If no database input can be found for the specified ID.

initInputDatabaseProperties

public void initInputDatabaseProperties(String id,
                                        Properties properties,
                                        String configName)
                                 throws FactoryException
Initializes a set of input database properties for the specified configuration with the given ID.

Parameters:
id - The id of the database input to create or null to create the first database input appearing in the specified configuration.
properties - The properties instance that will be populated with configuration.
Throws:
FactoryException - If no database input can be found for the specified ID.

createOutputDatabaseProperties

public Properties createOutputDatabaseProperties(String id,
                                                 String configName)
                                          throws FactoryException
Creates a new output database properties from configuration element with the given ID.

Parameters:
id - The id of the database output to create or null to create the first database output appearing in the specified configuration.
configName - The name of the target configuration or null to use default configuration element.
Returns:
The newly created configuration.
Throws:
FactoryException - If no database output can be found for the specified ID.

initOutputDatabaseProperties

public void initOutputDatabaseProperties(String id,
                                         Properties properties,
                                         String configName)
                                  throws FactoryException
Initializes a set of output database properties from configuration with the given ID.

Parameters:
id - The id of the database output to create or null to create the first database output appearing in the specified configuration.
properties - The properties instance that will be populated with configuration.
configName - The name of the target configuration or null to use default configuration element. *
Throws:
FactoryException - If no database output can be found for the specified ID.

initDomainConstraints

public void initDomainConstraints()
                           throws FactoryException
Initializes the DomainConstraintManager from the project file, after clearing any current constraints.

Throws:
FactoryException - If the domain constraints in the project file are invalid in any way.

initDomainConstraints

public void initDomainConstraints(boolean clear)
                           throws FactoryException
Initializes the DomainConstraintManager from the project file, possibly clearing any current constraints first.

If clear == false the new constraints will be added to those already defined in the DomainConstraintManager. Any identifiers already registered will be overwritten. NOTE: Please ensure that the c24-io-hibernate.jar and Hibernate with its dependant libraries are added to your classpath (hibernate3.jar etc.). For more information about the Hibernate please visit: http://www.hibernate.org/

Parameters:
clear - Whether to clear current domain constraints before re-initializing.
Throws:
FactoryException - If the domain constraints in the project file are invalid in any way.

loadFromSource

public static ComplexDataObject loadFromSource(Element element,
                                               Source src)
                                        throws FactoryException
Loads an object from the specified source.

Parameters:
element - The element to parse against.
src - The Source object.
Returns:
The parsed object or a new empty object if the supplied Source did not have an InputStream / Reader set up.
Throws:
FactoryException - If an error occours during parsing.

loadFromDatabase

public static Object loadFromDatabase(Element element,
                                      org.hibernate.cfg.Configuration cfg,
                                      String primaryKey,
                                      String sqlQuery,
                                      String hqlQuery,
                                      String dialect,
                                      ClassLoader loader)
                               throws FactoryException
Loads an object from the specified database configuration using either a primary key, SQL query or HQL query. NOTE: Please ensure that the artix-ds-hibremate.jar and Hibernate with its dependant libraries are added to your classpath (hibernate3.jar etc.). For more information about the Hibernate please visit: http://www.hibernate.org/

Parameters:
element - The element to parse against.
cfg - The Source database properties.
primaryKey - The optional primary key of the object to be loaded.
sqlQuery - An optional SQL query to select the object to be loaded.
hqlQuery - An optional HQL query to select the object to be loaded.
dialect - the Hibernate database Dialect
loader - The class loader to be used to load the data.
Returns:
The parsed object or a new empty object if the supplied Source did not have an InputStream / Reader set up.
Throws:
FactoryException - If an error occours during loading or if all primaryKey, sqlQuery and hqlQuery are null.

getTargetType

public int getTargetType(String configName)
                  throws FactoryException
Returns a int depending on the target element. returns a Factory.DATAMODEL for a dataModel based configuration , Factory.TRANSFORM for a transform based configuration. -1 if the target is not defined.

Parameters:
The - configuration name to be used from the project file.
Returns:
int.
Throws:
FactoryException - If the specified configuration element is not found.

createTransform

public Transform createTransform(String configName)
                          throws FactoryException
Creates a new Transform from the specified configuration in the project file. if the configuration is null then For multiple configuration based project file the configuration used is the one specified as a query parameter in the project uri during Factory instantiation. In case of a project file with one configuration it will be selected by default.

Parameters:
The - configuration name to be used from the project file.
Returns:
The new element.
Throws:
FactoryException - If there are any problems locating and instantiating the element class.

createElement

public Element createElement(String configName)
                      throws FactoryException
Creates a new Element from the specified configuration in the project file. If the configuration is null then for multiple configuration based project file, the configuration used is the one specified as a query parameter in the project uri during Factory instantiation. In case of a project file with one configuration it will be selected by default.

Parameters:
The - configuration name to be used from the project file.
Returns:
The new element.
Throws:
FactoryException - If there are any problems locating and instantiating the element class.

newInstance

public static Factory newInstance(URI uri)
                           throws FactoryException
Creates a new instance of the factory from the specified project file based uri.

Parameters:
file - The project file based uri is generated by the Designer.
Returns:
The Factory.
Throws:
FactoryException - If an error occours during the Factory's construction.

newInstance

public static Factory newInstance(URI uri,
                                  ClassLoader loader)
                           throws FactoryException
Creates a new instance of the factory from the specified project file based uri using the specified classloader.

Parameters:
file - The project file based url should have been generated by the Designer/
loader - The class loader to be used by the factory.
Returns:
The Factory.
Throws:
FactoryException - If an error occours during the Factory's construction.

newInstance

public static Factory newInstance(File file)
                           throws FactoryException
Creates a new instance of the factory from the specified project url using the default classloader.

Parameters:
file - The project file which is created when the designer project is saved.
Returns:
The Factory.
Throws:
FactoryException - If an error occours during the Factory's construction.

newInstance

public static Factory newInstance(File file,
                                  ClassLoader loader)
                           throws FactoryException
Creates a new instance of the factory from the specified project file using the specified classloader.

Parameters:
file - The project file which is created when the designer project is saved.
loader - The class loader to be used by the factory.
Returns:
The Factory.
Throws:
FactoryException - If an error occours during the Factory's construction.


C24 Technologies © 2002-2012: All Rights Reserved.