Book a Demo

Author Topic: Code Gen: Adding Requirement info to Operations  (Read 5618 times)

ChrisDr

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Code Gen: Adding Requirement info to Operations
« on: April 06, 2009, 08:39:48 pm »
Hi all,
we have a rigorous tracing process and I need to trace hazard related requirements to the functions that implement the appropriate hazard mitigations. Now I'd like to add the requirement name to the documentation of the linked operations. But operations don't support direct links at all and the only think I found is this http://www.sparxsystems.com/uml_tool_guide/modeling_with_uml/create_object_from_attribute.html, but the resulting structure doesn't let me access the requirement text for source code doc generation.

Any ideas on how this can be done?

Thanks,
chris

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #1 on: April 09, 2009, 10:01:34 pm »
Hi!


Well I have an idea, but I'm not sure if it can be done.

EA allows multiple Realizations from one Class to the same Requirement.
It also allows you to link a Connector to an Element Feature. Right-click the Realization near the Class and you'll get the option. You can then select Feature Type: Operation, and the specific Operation which is to implement the Requirement.

But.

I haven't found a way to retrieve this information when generating the code. The Realization, when you look at its properties, is still connected to the Class, not the Operation. I can't find a Feature macro in the code generation template language.

Does anyone know of a way to get a hold of this?


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

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #2 on: April 09, 2009, 10:27:18 pm »
No idea off hand. If you do look around though, make sure you are using EA 7.5. Links to features (including operations) were weak or non-existent in EA 7.1 and earlier.

The documentation might not have caught up in this area (I simply have not had time to check). You might need to experiment on a trivial project.
No, you can't have it!

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #3 on: April 09, 2009, 10:30:07 pm »
Yeah, I tried a couple of variations on the %connectorSourceElemFeature% theme, but no luck. And I'm in 7.5.844.

It seems the Feature link is only skin deep, but clearly the information is in there somewhere...
My theories are always correct, just apply them to the right reality.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #4 on: April 09, 2009, 10:49:55 pm »
...else
No, you can't have it!

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #5 on: April 10, 2009, 03:13:51 am »
I wouldn't be surprised to hear that they did not extend the code generation template  language to support the new "connector to feature" thing. I wouldn't know, though, cause I'm not using EA's in-built code generation.

But those of you who do surely know whether tagged values are accessible within a code generation template. If they are, you may consider giving each operation a tagged value of type RefGUIDList to relate it to a set of requirements.

By the way, the API does not seem to have been extended either. I can find no new property of the EA.Connector class to return the attribute or operation related to a connector (unless it's hidden in something undocumented like the CustomProperties collection).

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #6 on: April 10, 2009, 03:40:20 pm »
OK, well if "connector to Feature" is new in 7.5 there's reason to believe it'll make its way into the code template framework as well.

Meantime, the RefGUIDList helps with the original question. Not quite there, but almost.

1) Create a Tagged Value Type (Settings -> UML) according to:
Tag Name: TracedReqs
Description: List of Requirements
Detail:
Type=RefGUIDList;
Values=Requirement;

(You could add a 'Stereotypes=' line as well if you want to restrict the types of requirements an operation can be traced to.)

2) Create a Profile with a <<metaclass>> Operation and a <<stereotype>> ReqTraced extending Operation.
In the ReqTraced stereotype, add an attribute called TracedReqs.
My naming is terrible, but the important thing is that the attribute in the stereotype has the exact same name as the tagged value type you created in step 1. It doesn't need a type, just the name. The rest is EA Magic[size=8]TM[/size].

3) In the code generation templates for the language of your choice, add a Stereotyped Override to the Operation Notes template. Using the suitable comment formatting macro, add
%opTag:"TracedReqs"%
to the output.

You will need to go back and mark all your requirement-traced operations with the stereotype, of course. Once you've done that, go into the profile (the imported profile, not the profile definition), right-click the ReqTraced stereotype and select Synch. This will add the tag to all the stereotyped operations.

Operation tags aren't visible in the diagrams, but you can see them in the Tagged Value window.

The problem with this solution is that you don't get the requirement names in the comments, you get the GUIDs which are meaningless.

So does anyone know how to get the name from a GUID in the code template framework?


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

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #7 on: April 10, 2009, 11:24:49 pm »
Quote
...But those of you who do surely know whether tagged values are accessible within a code generation template. If they are, you may consider giving each operation a tagged value of type RefGUIDList to relate it to a set of requirements...
Tagged value support for connectors seems to be a (persistent) weak point of EA's transformation and code generation frameworks. New 7.5 stuff would probably have to wait until these are beefed up a bit.
No, you can't have it!

ChrisDr

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #8 on: April 14, 2009, 05:06:55 pm »
Hi all,

thank you very much for all you input! The Trick with the RefGUIDList is pretty cool, although Uffe is right, the GUID list alone doesn't help much :(.
Hope that Sparx will look at this as well!

Chris

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #9 on: April 15, 2009, 03:32:03 pm »
Hi again,

Just a quick note for clarification: I've been working under the assumption that you don't want to do a Model Transform. I am not a large air movement device of these myself and I'm not brilliant at writing them, but it might be possible to construct one that will solve the problem.

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

ChrisDr

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: Code Gen: Adding Requirement info to Operation
« Reply #10 on: April 15, 2009, 04:28:18 pm »
Hi Uffe,

no, not really. I tried to stay out of the Model Transform business so far. But it's, again, a good hint and I'll have at least a look at this.

Thanks again!
Chris