ThinkUI Data Generator 1.0.2 API

thinkui.datagen.ant
Class GenerateTask

java.lang.Object
  extended byTask
      extended bythinkui.datagen.ant.GenerateTask

public class GenerateTask
extends Task

Implements the ThinkUI Data Generator custom Ant Task. The following is an example of using the task to generate some random names:

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <project name="thinkui_datagen_first_name_sample" basedir="." default="gen.first_name_data">
 
     <!-- Configure classpath based on default installation folder for release. -->
     <path id="classpath.run">
         <path path="${java.class.path}"/>
 	    <path location="lib/apache-derby.jar"/>
 	    <path location="lib/velocity-dep.jar"/>
         <path location="thinkui_datagen.jar"/>
     </path>
 
     <!-- Define custom Data Generator Generate Task used to generate data. -->
     <target name="generate.init" description="Define the ThinkUI Data Generator GenerateTask">
         <taskdef name="datagen" classname="thinkui.datagen.ant.GenerateTask">
 	        <classpath refid="classpath.run"/>
 	    </taskdef>
     </target>
 
     <property name="target.output.dir" value="output"/>
     <property name="target.output.name" value="SAMPLE_FIRST_NAME"/>
 
     <!-- ########################################################################### -->
     <!-- Sample target for generating first names with random gender.                -->
     <!-- ########################################################################### -->
 
     <target name="gen.first_name_data" description="Use the GenerateTask to generate sample test data in CSV file format" depends="generate.init">
         <datagen name="${target.output.name}" mode="OVERWRITE" numRecords="100">
             <writer>
                 <param name="file_name" value="${target.output.dir}/${target.output.name}.csv"/>
                 <param name="uppercase" value="false"/>
                 <param name="header" value="true"/>
             </writer>
 
             <!-- The gender will be determined by the social_title. -->
             <attribute name="gender" caption="Gender" type="Character" required="true" access="R/W" computed="true"/>
 
             <attribute name="social_title" caption="Social Title" type="String" required="false" access="R/$" constraints="">
                 <generator class="SocialTitleGenerator" probabilityNull="20">
                     <param name="attribute_gender" value="gender"/>
                 </generator>
             </attribute>
 
             <!-- The first name will be dependent on the gender. -->
             <attribute name="first_name" caption="First Name" type="String" required="true" access="R/W">
                 <generator class="FirstNameGenerator">
                     <param name="attribute_gender" value="gender"/>
                 </generator>
             </attribute>
 
             <attribute name="last_name" caption="Last Name" type="String" required="true" access="R/W">
                 <generator class="LastNameGenerator"/>
             </attribute>
 
             <attribute name="day_of_week" caption="Day of Week" type="String" required="false" access="R/W">
                 <generator class="EnumGenerator">
                     <param name="values" value="MON, TUE, WED, THU, FRI, SAT, SUN"/>
                     <param name="indices" value="1, 2, 3, 4, 5, 6, 7"/>
                 </generator>
             </attribute>
 
             <attribute name="date" caption="Date" type="Date" required="false" access="R/W">
                 <generator class="EnumGenerator">
                     <param name="values" value="2000-01-01, 2001-04-07, 2002-07-09, 2003-10-15, 2004-11-18, 2005-12-23, 2006-01-31"/>
                     <param name="indices" value="1, 2, 3, 4, 5, 6, 7"/>
                 </generator>
             </attribute>
             <attribute name="password" caption="Password" type="Password" required="true" access="R/W" constraints="StringLengthConstraints(6,10)"/>
         </datagen>
     </target>
 </project>
 

See Also:
Serialized Form

Nested Class Summary
 class GenerateTask.AttributeGenData
          Encapsulate the information for an attribute.
 class GenerateTask.ChildData
          Encapsulate the child data and attribute information.
 class GenerateTask.DbConnectionData
          Encapsulate the database connection data.
 class GenerateTask.FormatData
          Encapsulate the format class and various input parameters.
 class GenerateTask.GeneratorData
          Encapsulate the generator class and various input parameters.
 class GenerateTask.Parameter
          Encapsulate a name value parameter (with support for nested parameters).
 class GenerateTask.ReaderData
          Encapsulate the data object reader and various parameters.
 class GenerateTask.WriterData
          Encapsulate the data object writer and various parameters.
 
Constructor Summary
GenerateTask()
           
 
Method Summary
 GenerateTask.AttributeGenData createAttribute()
           
 GenerateTask.ChildData createChild()
           
 GenerateTask.DbConnectionData createConnection()
           
static AttributeValueGenerator createGenerator(AttributeValueGeneratorParam generatorParam)
          Helper method to create an AttributeValueGenerator for the given generatorParam.
 GenerateTask.ReaderData createReader()
           
 GenerateTask.WriterData createWriter()
           
 void execute()
           
 void setMode(java.lang.String outputMode)
           
 void setName(java.lang.String outputName)
           
 void setNumRecords(int numRecords)
           
 void setTransaction(boolean transaction)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenerateTask

public GenerateTask()
Method Detail

createAttribute

public final GenerateTask.AttributeGenData createAttribute()

createChild

public final GenerateTask.ChildData createChild()

createConnection

public GenerateTask.DbConnectionData createConnection()

createGenerator

public static final AttributeValueGenerator createGenerator(AttributeValueGeneratorParam generatorParam)
                                                     throws java.lang.Exception
Helper method to create an AttributeValueGenerator for the given generatorParam.

Throws:
java.lang.Exception

createReader

public final GenerateTask.ReaderData createReader()

createWriter

public final GenerateTask.WriterData createWriter()

execute

public final void execute()
                   throws BuildException
Throws:
BuildException

setMode

public final void setMode(java.lang.String outputMode)

setName

public final void setName(java.lang.String outputName)

setNumRecords

public final void setNumRecords(int numRecords)

setTransaction

public final void setTransaction(boolean transaction)

ThinkUI Data Generator 1.0.2 API

Copyright © 2007-2009. ThinkUI Software Inc. All rights reserved.