Calendar

May 2005
M T W T F S S
« Apr   Jun »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Tag Cloud

Categories

Archives

Highest Rated

Most Viewed

Recent Posts

Recent Comments


« Future of Flash/Flex | Main | Flex Style Explorer »

Installing AS2VOGenerator

By Rich Tretola | May 17, 2005Print This Post Print This Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
309 views

Open eclipse and go window -> preferences -> Hibernate Synchronizer -> Templates
Hit New and enter template name AS2VOGenerator
Click OK and paste the following into your editor:
/*
* This class has been automatically generated by the EverythingFlex ActionScipt 2 VO Generator template within Hibernate Synchronizer.
*
* For more information on ActionScipt 2 VO Generator template, visit The ActionScipt VO Builder page
* at http://www.everythingflex.com/blog/index.cfm?mode=cat&category_id=CD4144E7-C396-8BD0-C102F965E978CD19
* or contact Rich Tretola at rich@richtretola.com.
*
* This is the object class that relates to the ${class.AbsoluteValueObjectSignatureClassName} Java Class
* @ignore
*/
class ${class.AbsoluteValueObjectSignatureClassName}{
#if ($class.Id)
#if ($class.Id.hasExternalClass())
public var ${class.Id.Property.Name}:Number = undefined;
#else
#foreach ($prop in $class.Id.Properties)
#if (${prop.ClassName} == “Date”)
public var ${prop.Name}:Date = undefined;
#elseif (${prop.ClassName} == “String”)
public var ${prop.Name}:String = “”;
#elseif (${prop.ClassName} == “Boolean” || ${prop.ClassName} == “boolean”)
public var ${prop.Name}:Boolean = false;
#elseif (${prop.ClassName} == “Byte” || ${prop.ClassName} == “Short” || ${prop.ClassName} == “Integer” || ${prop.ClassName} == “Long” || ${prop.ClassName} == “Float” || ${prop.ClassName} == “Double” || ${prop.ClassName} == “byte” || ${prop.ClassName} == “short” || ${prop.ClassName} == “int” || ${prop.ClassName} == “long” || ${prop.ClassName} == “float” || ${prop.ClassName} == “double”)
public var ${prop.Name}:Number = undefined;
#else
// UNABLE TO MAP DATATYPE FOR CLASS ${prop.FullClassName} PLEASE TELL RICH TRETOLA (rich@richtretola.com) ABOUT THIS
public var ${prop.Name}:${prop.FullClassName};
#end
#end
#end
#end
#if ($class.Version)
public var ${class.Version.Name}:${class.Version.FullClassName};
#end
#if ($class.Timestamp)
public var ${class.Timestamp.Name}:Date = undefined;
#end
#if ($class.Properties.size() > 0)
#foreach ($prop in $class.Properties)
#if (${prop.ClassName} == “Date”)
public var ${prop.Name}:Date = undefined;
#elseif (${prop.ClassName} == “String”)
public var ${prop.Name}:String = “”;
#elseif (${prop.ClassName} == “Boolean” || ${prop.ClassName} == “boolean”)
public var ${prop.Name}:Boolean = false;
#elseif (${prop.ClassName} == “Byte” || ${prop.ClassName} == “Short” || ${prop.ClassName} == “Integer” || ${prop.ClassName} == “Long” || ${prop.ClassName} == “Float” || ${prop.ClassName} == “Double” || ${prop.ClassName} == “byte” || ${prop.ClassName} == “short” || ${prop.ClassName} == “int” || ${prop.ClassName} == “long” || ${prop.ClassName} == “float” || ${prop.ClassName} == “double”)
public var ${prop.Name}:Number = undefined;
#else
// UNABLE TO MAP DATATYPE FOR CLASS ${prop.FullClassName} PLEASE TELL RICH TRETOLA (rich@richtretola.com) ABOUT THIS
public var ${prop.Name}:${prop.FullClassName};
#end
#end
#end
#if ($class.Version)
public var ${class.Version.Name}:${class.Version.FullClassName};
#end
#if ($class.Timestamp)
public var ${class.Timestamp.Name}:Date = undefined;
#end
#if ($class.ComponentList.size() > 0)
#foreach ($component in $class.ComponentList)
public var ${component.Name}:${component.AbsoluteValueObjectClassName};
#end
#end
#if ($class.OneToOneList.size() > 0)
#foreach ($prop in $class.OneToOneList)
public var ${prop.Name}:${prop.AbsoluteSignatureClassName};
#end
#end
#if ($class.ManyToOneList.size() > 0)
#foreach ($prop in $class.ManyToOneList)
public var ${prop.Name}:${prop.AbsoluteSignatureClassName};
#end
#end
#if ($class.CollectionList.size() > 0)
#foreach ($prop in $class.CollectionList)
public var ${prop.Name}:Array;
#end
#end

public static var registered:Boolean = Object.registerClass( “${class.AbsoluteValueObjectSignatureClassName}”, ${class.ValueObjectSignatureClassName});

public function ${class.ValueObjectSignatureClassName}() {
}
}
Enter a description if you want and then save the file

Now right click on your project and click properties
Select Hibernate Synchronizer and click on Template and then new
Select the template from the list and paste ${class.ValueObjectClassName}.as as the Output name
Browse to the place you want the files created
Check the overwrite box and click save

Now when you synchronize your hbm.xml files you will get both java file and as file generation.

Share/Save/Bookmark

Topics: Eclipse, Flex Tools |

Comments