Book a Demo

Author Topic: Code generation again  (Read 4028 times)

Graham_Labdon

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Code generation again
« on: March 06, 2009, 06:54:11 pm »
Hi
Does anyone know if it is possible to get the code gen template to output the contents of the require tab on the class properties dialog

Thanks

Graham

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code generation again
« Reply #1 on: March 06, 2009, 10:35:17 pm »
Hi Graham,


Yes it is. In the help file Field Substitution Macros table, the requirement* macros are described as "Properties dialog: Properties tab: ..." This is incorrect, it should read "Properties dialog: Require tab: ...." and it's exactly what you're after.

Here's a way to access the data. I've done this in the Java code templates but the structure would be the same in any language, it's just that you might have to change the comment characters.

Modify your Class template, adding a line for the template we're about to create:
Code: [Select]
%ClassNotes%
%Class__Requirements%
%PI=" "%
%ClassDeclaration%
%ClassBody%
Create a new custom Class template named "Requirements". The actual name will be Class__Requirements (note the double underscore). Contents for this template:
Code: [Select]
%list="Requirement__Full" @separator="\n"%with no new-line at the end of the single line in the template.
Finally, create a custom Requirement template named "Full" with the contents:
Code: [Select]
// %requirementType% requirement: %qt%%requirementName%%qt%
// Status %requirementStatus%; Difficulty %requirementDifficulty%; Priority %requirementPriority%
// Last updated %requirementLastUpdated%
%WRAP_COMMENT(requirementNotes, "60", "", "//     ")%
Again, no new-line at the end of the last line of the template.

This will output all available requirement information as a //-style comment. Note that there is no macro to extract the requirement Stability, and note also that if you only change a requirement and then regenerate the code, EA won't pick up on the class being changed and will not actually regenerate the code. You'll need to delete the file in between.

Sample output from the above:
Code: [Select]
package Pack;

/**
 * @author sysadmin
 * @version 1.0
 * @created 06-mar-2009 12:32:40
 */
// Functional requirement: "Blarg"
// Status Mandatory; Difficulty High; Priority Medium
// Last updated 06-mar-2009 11:48:06
//     Dearie me oh dearie me. We'll never get this done. Oh my
//     paws and whiskers, etc etc.
//    
//    
//     Despair.

// Report requirement: "Honk"
// Status Proposed; Difficulty Low; Priority High
// Last updated 06-mar-2009 12:13:27
//     Important but trivial. I can take the afternoon off.
//     Wo-hoo!

public class Class1 {

      public Class1(){

      }

      public void finalize() throws Throwable {

      }

}//end Class1


Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

Graham_Labdon

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Code generation again
« Reply #2 on: March 06, 2009, 10:53:53 pm »
Hi Uffe
Thanks for the reply, I cannot get it to work!
When I  Add a New Custom Template I do not get a choice of Requirement for the Template Type so I used <none>.
Any Idea why I dont see Requirement in the Custom Template?

Graham

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code generation again
« Reply #3 on: March 07, 2009, 12:37:40 am »
Hi again Graham,

Only thing I can think of is that it's a version issue. I'm using EA 7.5 Beta 2. If you're on an older version perhaps Requirement isn't available in code templates.

/Uffe
My theories are always correct, just apply them to the right reality.

Graham_Labdon

  • EA User
  • **
  • Posts: 66
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Code generation again
« Reply #4 on: March 07, 2009, 12:49:48 am »
Thanks Uffe
I cannot use a Beta version so I will have to wait for the release!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation again
« Reply #5 on: March 10, 2009, 08:22:33 am »
Just to confirm.  Yes, access to the requirements (as well as files, constraints, scenarios and more) was added in beta 2.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Code generation again
« Reply #6 on: March 10, 2009, 09:33:16 am »
And I have corrected the tab label against the requirement* macros - thanks Uffe.
Best Regards, Roy