ch.sahits.codegen.java.model
Class HeadlessJavaModelFactory

java.lang.Object
  extended by ch.sahits.codegen.java.model.HeadlessJavaModelFactory
Direct Known Subclasses:
JavaModelFactory

public class HeadlessJavaModelFactory
extends java.lang.Object

This factory class provides a model for the class to be generated
In the model factory the monitor is processed according to the workload model generator. Generally the initialization takes up one 1/5 - 1/6 of the workload while the rest is taken up by the model generation. In the case of an XML file it is otherwise: The initialization takes two third since this includes the parsing of the XML file which can be expensive. This implementation is for the headless generation

Since:
2.1.0 TODO Replace IGeneratedJavaClass with IGeneratedJavaClass2 and IGeneratedJavaDBClass with IGeneratedJavaDBClass2
Author:
Andi Hotz

Field Summary
protected static IExtendedDBDefinitionPage page2
          Current dB connection definition page, needed for createModelWithDBConnection(String, String, String, String, String, String, String, String, String, String, IProgressMonitor, String)
 
Constructor Summary
protected HeadlessJavaModelFactory()
           
 
Method Summary
static IGeneratedJavaDBClass createModelWithDBConnection(JavaClassDefinition definition, java.lang.String dbProduct, java.lang.String host, java.lang.String port, java.lang.String dbName, java.lang.String userName, java.lang.String passWd, java.lang.String tableName, java.lang.String packageName, java.lang.String className, IProgressMonitor monitor, java.lang.String schema)
          Generates a model of a database table.
static IGeneratedJavaDBClass createModelWithDBConnection(java.lang.String typeName, java.lang.String dbProduct, java.lang.String host, java.lang.String port, java.lang.String dbName, java.lang.String userName, java.lang.String passWd, java.lang.String tableName, java.lang.String packageName, java.lang.String className, IProgressMonitor monitor, java.lang.String schema)
          Deprecated. This method is replaced by createModelWithDBConnection(JavaClassDefinition, String, String, String, String, String, String, String, String, String, IProgressMonitor, String)
static IGeneratedJavaClass createModelWithDBInputFile(JavaClassDefinition definition, java.lang.String dbProduct, java.lang.String inputFilePath, IJavaProject project, IProgressMonitor monitor)
          Generates the model based on the class name and the inputFilePath Data in the wizard provided but not contained in the inputfilePath must be added to the model by the caller
static IGeneratedJavaClass createModelWithDBInputFile(java.lang.String typeName, java.lang.String dbProduct, java.lang.String inputFilePath, IJavaProject project, IProgressMonitor monitor)
          Deprecated. This method is replaced by createModelWithDBInputFile(JavaClassDefinition, String, String, IJavaProject, IProgressMonitor)
static IGeneratedJavaClass createModelWithoutDB(JavaClassDefinition definition, java.lang.String inputFilePath, IProgressMonitor monitor)
          Generates a model for the class that is not based on a database table
static IGeneratedJavaClass createModelWithoutDB(java.lang.String typeName, java.lang.String inputFilePath, IProgressMonitor monitor)
          Deprecated. This method is replaced by createModelWithoutDB(JavaClassDefinition, String, IProgressMonitor)
static int getModelGenerationWorkload(int modelBase, java.lang.String inputFilePath, java.lang.String dbProduct)
          Compute the number of work units for the generation of the file
protected  int getModelWorkloadDBConnection(int modelBase, java.lang.String dbProduct)
          Compute the workcload if the database data is retrived from the db definition page
static void setCurrentDBDefinitionPage(IExtendedDBDefinitionPage page2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

page2

protected static IExtendedDBDefinitionPage page2
Current dB connection definition page, needed for createModelWithDBConnection(String, String, String, String, String, String, String, String, String, String, IProgressMonitor, String)

Constructor Detail

HeadlessJavaModelFactory

protected HeadlessJavaModelFactory()
Method Detail

createModelWithDBInputFile

public static IGeneratedJavaClass createModelWithDBInputFile(JavaClassDefinition definition,
                                                             java.lang.String dbProduct,
                                                             java.lang.String inputFilePath,
                                                             IJavaProject project,
                                                             IProgressMonitor monitor)
                                                      throws java.io.FileNotFoundException,
                                                             java.io.IOException
Generates the model based on the class name and the inputFilePath Data in the wizard provided but not contained in the inputfilePath must be added to the model by the caller

Parameters:
definition - Java Class definition that encapsules the class informations
dbProduct - name of the database product
inputFilePath - path to the input file the model is based upon
project - java project to generate the class in
monitor - Progress monitor
Returns:
model of a subtype of IGeneratedJavaDBClass
Throws:
java.io.IOException - File could not be read
java.io.FileNotFoundException - File path incorrect

createModelWithDBConnection

public static IGeneratedJavaDBClass createModelWithDBConnection(JavaClassDefinition definition,
                                                                java.lang.String dbProduct,
                                                                java.lang.String host,
                                                                java.lang.String port,
                                                                java.lang.String dbName,
                                                                java.lang.String userName,
                                                                java.lang.String passWd,
                                                                java.lang.String tableName,
                                                                java.lang.String packageName,
                                                                java.lang.String className,
                                                                IProgressMonitor monitor,
                                                                java.lang.String schema)
Generates a model of a database table. The needed information for the table is retrieved over the database connection

Parameters:
definition - Java Class definition that encapsules the class informations
dbProduct - database product
host - name of the database
port - number of the database
dbName - name of the database
userName - name of the database user
passWd - password for the user
tableName - name of the database table
packageName - name of the package
className - name of the class
monitor - Progress monitor
schema - name
Returns:
DataBaseTable

createModelWithoutDB

public static IGeneratedJavaClass createModelWithoutDB(JavaClassDefinition definition,
                                                       java.lang.String inputFilePath,
                                                       IProgressMonitor monitor)
Generates a model for the class that is not based on a database table

Parameters:
definition - Java Class definition that encapsules the class informations
inputFilePath - path to the input file the model is based upon
monitor - Progress monitor
Returns:
generated model

getModelGenerationWorkload

public static int getModelGenerationWorkload(int modelBase,
                                             java.lang.String inputFilePath,
                                             java.lang.String dbProduct)
Compute the number of work units for the generation of the file

Parameters:
inputFilePath - path to the input file the model is based upon
modelBase - code for the generation
dbProduct - name of the database product my be null if the generation is not done with a database
Returns:
Number of work units for the model generation

getModelWorkloadDBConnection

protected int getModelWorkloadDBConnection(int modelBase,
                                           java.lang.String dbProduct)
Compute the workcload if the database data is retrived from the db definition page

Parameters:
modelBase -
dbProduct -
Returns:
workload

setCurrentDBDefinitionPage

public static void setCurrentDBDefinitionPage(IExtendedDBDefinitionPage page2)
Parameters:
page2 - the page2 to set

createModelWithDBInputFile

@Deprecated
public static IGeneratedJavaClass createModelWithDBInputFile(java.lang.String typeName,
                                                                        java.lang.String dbProduct,
                                                                        java.lang.String inputFilePath,
                                                                        IJavaProject project,
                                                                        IProgressMonitor monitor)
                                                      throws java.io.FileNotFoundException,
                                                             java.io.IOException
Deprecated. This method is replaced by createModelWithDBInputFile(JavaClassDefinition, String, String, IJavaProject, IProgressMonitor)

Generates the model based on the class name and the inputFilePath Data in the wizard provided but not contained in the inputfilePath must be added to the model by the caller

Parameters:
typeName - name of the class
dbProduct - name of the database product
inputFilePath - path to the input file the model is based upon
project - java project to generate the class in
monitor - Progress monitor
Returns:
model of a subtype of IGeneratedJavaDBClass
Throws:
java.io.IOException - File could not be read
java.io.FileNotFoundException - File path incorrect

createModelWithoutDB

@Deprecated
public static IGeneratedJavaClass createModelWithoutDB(java.lang.String typeName,
                                                                  java.lang.String inputFilePath,
                                                                  IProgressMonitor monitor)
Deprecated. This method is replaced by createModelWithoutDB(JavaClassDefinition, String, IProgressMonitor)

Generates a model for the class that is not based on a database table

Parameters:
typeName - name of the class
inputFilePath - path to the input file the model is based upon
monitor - Progress monitor
Returns:
generated model

createModelWithDBConnection

@Deprecated
public static IGeneratedJavaDBClass createModelWithDBConnection(java.lang.String typeName,
                                                                           java.lang.String dbProduct,
                                                                           java.lang.String host,
                                                                           java.lang.String port,
                                                                           java.lang.String dbName,
                                                                           java.lang.String userName,
                                                                           java.lang.String passWd,
                                                                           java.lang.String tableName,
                                                                           java.lang.String packageName,
                                                                           java.lang.String className,
                                                                           IProgressMonitor monitor,
                                                                           java.lang.String schema)
Deprecated. This method is replaced by createModelWithDBConnection(JavaClassDefinition, String, String, String, String, String, String, String, String, String, IProgressMonitor, String)

Generates a model of a database table. The needed information for the table is retrieved over the database connection

Parameters:
typeName - name of the class
dbProduct - database product
host - name of the database
port - number of the database
dbName - name of the database
userName - name of the database user
passWd - password for the user
tableName - name of the database table
packageName - name of the package
className - name of the class
monitor - Progress monitor
schema - name
Returns:
DataBaseTable