Reference files parsing for Java code generation

Hi,
I am currently working on a project where I have to customize the Java code generation of Visual Paradigm.

I am confronted to this problem :

I am very interested in loading and parsing some Reference files in Java class operations. I don’t know if it is possible, but the following part of code in JavaOperation.vm makes me think it is :

 #if( $operation.hasReference() == true )
#parse("$template-dir/$operation.getReference().getRefTemplate()") 

By the way, I don’t understand this code. I put a referenced file to an operation but the following test fails :

 #if( $operation.hasReference() == true ) 

So, Is it possible to parse a referenced file added in an operation ? If yes, how ?

Best regards

Dear jm_fra,

Thank you for your post. The “reference” is created during code generation for generating operation body. It is not the referenced file.

We suppose code generation does not require the knowledge of referenced files. May I know why you have this need?

Best regards,
Jick

Hi Jick, thanks for the answer

Ok, so I misunderstood it.

Actually, we want to generate some specific Java code for operations, and then inject it in the operation bodies during the VP code generation. However, we are obliged to use class diagrams only. We thought we could generate oursleves this code in files which would be parsed during generation.

Anyway, as it seems we may have to look for another way, is there a possibility to access to fields of forms specificiations, such as “Comments” (not “Documentation”) or the tagged values ?

Regards

Hi jm_fra,

We’ve enhanced our template supported to allow you retrieve tagged value and comments. First, download the patch at:
http://files3.visual-paradigm.com/200708/Patch/6-1-0_20070830a/VP_Suite_Windows_3_1_20070830a.exe

Then, run it by overwriting the current installation. You will be able to access the following calls:

${object}.commentIterator() : Iterator
${object}.commentCount() : int
${object}.commentArray() : TemplateComment[]
${object}.commentAt(int) : TemplateComment

Here is the operations supported by TemplateComment:
getSummary() : String // Same as getName()
getAuthor() : String
getDateTime() : String
getContent() : String // Same as getDocumentation()

Tagged Value can be access by:
${object}.taggedValueIterator() : Iterator
${object}.taggedValueCount() : int
${object}.taggedValueArray() : TemplateTaggedValue[]
${object}.taggedValueAt(int) : TemplateTaggedValue
${object}.getTaggedValue(String) : TemplateTaggedValue
${object}.getTaggedValueIgnoreCase(String) : TemplateTaggedValue
${object}.hasTaggedValue(String) : boolean
${object}.hasTaggedValueIgnoreCase(String) : boolean

For IG-Java, those operation body is generated as below ===
[Normal operation]
JavaOperation.vm // This may forward the body generation to other .vm

[Association many side (Setter)]
JavaAssociation_Add.vm
JavaAssociation_Remove.vm

[Association many side (Getter)]
JavaAssociation_To.vm

[Association one side (Setter)]
JavaAssociation_Set.vm

[Association one side (Getter)]
JavaAssociation_Get.vm

[Association class (Setter)]
JavaAssociationClass_Set.vm

[Association class (Getter)]
JavaAssociationClass_Get.vm

[Attribute (Setter)]
JavaAttribute_Set.vm

[Attribute (Getter)]
JavaAttribute_Get.vm

Hope this helps. Feel free to contact us if there are any questions.

Best regards,
Jick

Jick,

Thanks a lot for this patch, this is exactly what we needed !
Speaking of which, the access to original documentation is ok too (see this topic).
Double thanks!

Best regards

My pleasure! :smiley: :smiley:

[quote=Jick]Hi jm_fra,

We’ve enhanced our template supported to allow you retrieve tagged value and comments. First, download the patch at:
http://files3.visual-paradigm.com/200708/Patch/6-1-0_20070830a/VP_Suite_Windows_3_1_20070830a.exe

Then, run it by overwriting the current installation. You will be able to access the following calls:

${object}.commentIterator() : Iterator
${object}.commentCount() : int
${object}.commentArray() : TemplateComment[]
${object}.commentAt(int) : TemplateComment

Here is the operations supported by TemplateComment:
getSummary() : String // Same as getName()
getAuthor() : String
getDateTime() : String
getContent() : String // Same as getDocumentation()

Tagged Value can be access by:
${object}.taggedValueIterator() : Iterator
${object}.taggedValueCount() : int
${object}.taggedValueArray() : TemplateTaggedValue[]
${object}.taggedValueAt(int) : TemplateTaggedValue
${object}.getTaggedValue(String) : TemplateTaggedValue
${object}.getTaggedValueIgnoreCase(String) : TemplateTaggedValue
${object}.hasTaggedValue(String) : boolean
${object}.hasTaggedValueIgnoreCase(String) : boolean

For IG-Java, those operation body is generated as below ===
[Normal operation]
JavaOperation.vm // This may forward the body generation to other .vm

[Association many side (Setter)]
JavaAssociation_Add.vm
JavaAssociation_Remove.vm

[Association many side (Getter)]
JavaAssociation_To.vm

[Association one side (Setter)]
JavaAssociation_Set.vm

[Association one side (Getter)]
JavaAssociation_Get.vm

[Association class (Setter)]
JavaAssociationClass_Set.vm

[Association class (Getter)]
JavaAssociationClass_Get.vm

[Attribute (Setter)]
JavaAttribute_Set.vm

[Attribute (Getter)]
JavaAttribute_Get.vm

Hope this helps. Feel free to contact us if there are any questions.

Best regards,
Jick[/quote]

Such a very amazing link!
Thanks you for the post.


You are welcome. Feel free to post again if you have any questions.