Topic
10 replies Latest Post - ‏2010-04-07T10:23:40Z by ihasaherb
ihasaherb
ihasaherb
11 Posts
ACCEPTED ANSWER

Pinned topic Access custom property in imported DOORS requirement with TCL

‏2010-04-05T13:59:15Z |
Hi, everyone!

I'm stuck in writing a tcl script that needs accessing a custom property in imported DOORS requirement. I've created a custom attribute in DOORS and imported a requiremenet having this attribute into Tau 4.3 and now I can't access in with tcl means.

The imported requirement has a 'Class' meta-class name although it's icon is green in Tau 4.3. I've figured it out by running

set entits [u2::GetEntities $pack OwnedMember] foreach ent $entits 
{ std::Output 
"\nEntity of [u2::GetMetaClassName $ent]}


Running

[u2::GetEntities $ent 
"Attribute"]

and

[u2::GetEntities $ent OwnedMember]

gives me nothing inside the requirement object.
I can only access standard meta features like 'Visibility', 'Name', 'Virtuality' and so on.

Could anyone please give a hint how to get access to the custom attribute? I can see it and set it on the 'Properties' tab of the imported requirement object but cannot do it from tcl code.

Thanks in advance.

Best regards,
Dmitry
Updated on 2010-04-07T10:23:40Z at 2010-04-07T10:23:40Z by ihasaherb
  • SystemAdmin
    SystemAdmin
    147 Posts
    ACCEPTED ANSWER

    Re: Access custom property in imported DOORS requirement with TCL

    ‏2010-04-06T08:43:55Z  in response to ihasaherb
    Dmitry

    I haven't had chance to check this yet but the custom properties are almost certainly implemented as stereotype with attributes. The stereotype name is what is selected as Filter in the dropdown at the top of the property editor, and the attribute name is the label for the field in the property editor (see NOTE 2 below for exception). Say that the stereotype is <<requirement>>, and that the attribute label is "feature" then you would retrieve the value using tcl like this:
    
    set val [u2::GetTaggedValue $rqt 
    "'requirement' (. 'feature' .)"]
    


    NOTE 1 I have used single quotes ' ' around requirement and feature; for simple words these are not needed but if the word is a u2 keyword (do you know them all?) or there are spaces in the name or non-alphabetic characters then these would be required for GetTaggedValue to work; it is a good habit to always use them because this helps you avoid unexpected and irritatingly hard to diagnose failures of the GetTaggedValue call.

    NOTE 2 It is possible and not unusual for the label displayed in the property editor to be different from the actual stereotype attribute name in the model, but it is the name in the model which you must use in the GetTaggedValue call. You can check this by looking at the details of the stereotype in the profile it is loaded from - these should appear below Library in the model view, and will show the model names (the presentation name is in a stereotype applied to the attribute).

    HTH
    Ian
    • SystemAdmin
      SystemAdmin
      147 Posts
      ACCEPTED ANSWER

      Re: Access custom property in imported DOORS requirement with TCL

      ‏2010-04-06T10:13:32Z  in response to SystemAdmin
      Couple of additional things:

      1. For Tau 4.3, the correct stereotype is <<requirementAttributes>> and the attribute name is exactly as in DOORS. The stereotype is defined by the formal module importer and is defined locally in the package corresponding to the formal module.

      So for example if the module has a custom attribute isReqt which is a boolean then in Tau the expression containing the value of isReqt on an object imported from that module could be accessed using the following tcl:

      
      set isRqtExpr [u2::GetTaggedValue $reqt 
      "'requirementAttributes' (. 'isReqt' .)"]
      


      NOTE this returns an expression holding the value.

      2. u2::GetTaggedValue returns an expression which you have to decode to get the value. I generally use a routine like below instead of direct calls to u2::GetTaggedValue, because it evaluates the expression and returns the actual value:

      
      proc GetTagValue 
      { el tag 
      {
      
      default 
      ""
      } 
      } 
      { # DebugOutput 
      "GetTagValue [rep $el] $tag\n" set tv [u2::GetTaggedValue $el $tag] #    DebugOutput 
      "taggedvalue $el $tag =$tv\n" 
      
      if 
      { $tv == 0 
      } 
      { set infotext $default 
      } 
      
      else 
      { #          DebugOutput 
      "metaclass=[u2::GetMetaClassName $tv]\n" 
      
      if 
      { [u2::IsKindOf $tv Ident] 
      } 
      { set infotext [u2::GetValue $tv Name] 
      } elseif 
      { [u2::IsKindOf $tv ListExpr] 
      } 
      { # combine the list values with \n set infotext [list] foreach e [u2::GetEntities $tv Expression] 
      { lappend infotext 
      "[u2::GetValue $e ValueString]" 
      } 
      } elseif 
      { [u2::IsKindOf $tv CharstringValue] 
      } 
      { #                        DebugOutput 
      "CharstringValue\n" set infotext [u2::GetValue $tv Value] 
      } elseif 
      { [u2::IsKindOf $tv UnaryExpr]
      } 
      { #                       DebugOutput 
      "UnaryExpr\n" set infotext 
      "[u2::GetValue $tv Operator][u2::GetValue $tv Operand]" 
      } 
      
      else 
      { set infotext [u2::GetValue $tv ValueString] 
      } 
      } # Tau uses \r\n as line seperators, so remove all \r to get just \n line seperator regsub -all -- 
      {\r
      } $infotext 
      "" infotext #  DebugOutput 
      "tag value for $el $tag is $infotext\n" 
      
      return $infotext 
      }
      


      I left in the commented-out debugging print statements so you can see what is going on.

      If you know the expressions are always string literals - as in this case for isReqt - you could also use u2::GetValue directly, for example:
      
      set val [u2::GetValue [u2::GetTaggedValue $rqt 
      "'requirementAttributes' (. 'isReqt' .)"] Value]
      

      but personally I find writing this easier:
      
      set val [GetTagValue $rqt 
      "'requirementAttributes' (. 'isReqt' .)"]
      

      because it also deals with numbers and lists, and tidies up multi-line text to use \n line separators.

      HTH
      Ian
  • ihasaherb
    ihasaherb
    11 Posts
    ACCEPTED ANSWER

    Re: Access custom property in imported DOORS requirement with TCL

    ‏2010-04-06T10:42:28Z  in response to ihasaherb
    Thank you, Ian! This looks like an appropriate solution! Thanks a lot!

    I've got one more question. Synchronizing my model with DOORS results in creation of a Formal Module that contains objects corresponding to each model element. Suppose I create a custom attribute in this module in DOORS, but at this time I don't import this module into Tau. Do I have a possibility to access this attribute from Tau not having imported requirements package inside the model?

    Thanks in advance.

    Best regards,
    Dmitry
    • SystemAdmin
      SystemAdmin
      147 Posts
      ACCEPTED ANSWER

      Re: Access custom property in imported DOORS requirement with TCL

      ‏2010-04-06T11:07:17Z  in response to ihasaherb
      So you have exported a package of your Tau model into DOORS to create a formal module, and you want to add an attribute to that module? No Tau won't know about what you added in DOORS. And you should not re-export the formal module from DOORS back into Tau! That is just going to get things very confused I expect.

      What are you trying to achieve?
  • ihasaherb
    ihasaherb
    11 Posts
    ACCEPTED ANSWER

    Re: Access custom property in imported DOORS requirement with TCL

    ‏2010-04-06T11:23:50Z  in response to ihasaherb
    The customer wants to export and import models from and to xml via Tau add-ins and control exported/imported status of a particular element via a specific attribute in corresponding DOORS module. That's it. Maybe it would be more sensible to figure out another approach to this target. I think there's something should be done with the customer's idea.

    Nevertheless, Ian, I appreciate your competence and attention.

    May I ask you where to get a complete reference of Tau UML meta-classes and their features?

    Thbak you.

    Best regards,
    Dmitry
    • SystemAdmin
      SystemAdmin
      147 Posts
      ACCEPTED ANSWER

      Re: Access custom property in imported DOORS requirement with TCL

      ‏2010-04-06T13:42:47Z  in response to ihasaherb
      So you have developed a custom export/import to xml. The control of what gets exported should really be applied to the model not in DOORS - for example you could define a stereotype to apply to an element which prevents your addin exporting that element or anything below it. However it is implemented you will need to strictly control the organization of your model - best enforced using automated checking to flag errors - because you cannot allow the exporter to export references to elements you don't export.

      The model in the Library is fairly close, but doesn't go into detail of the structure of e.g. an expression. In the Telelogic days there used to be an unsupported free download - called the SDK - on the Tau support pages which provided a model of the metamodel and a utility - called the FIDebugger - to examine the detail in your model. This has not been released for Tau 4.3. You could try asking support or your account manager for help getting it, not sure how far you will get.

      Looking at the tcl scripts in the provided addins installed with Tau can be a good way of seeing what is possible, I think they aren't encrypted anymore.

      Regards
      Ian
  • ihasaherb
    ihasaherb
    11 Posts
    ACCEPTED ANSWER

    Re: Access custom property in imported DOORS requirement with TCL

    ‏2010-04-06T11:35:53Z  in response to ihasaherb
    One more question
  • ihasaherb
    ihasaherb
    11 Posts
    ACCEPTED ANSWER

    Re: Access custom property in imported DOORS requirement with TCL

    ‏2010-04-07T09:58:06Z  in response to ihasaherb
    Well, Ian, I guess we've run into a misunderstanding here. The customer wants to control just the import/export status of the TAU model element, not to restrict it from being imported or exported. And it's supposed that this attribute is applied to the corresponding DOORS objects but affected with TAU add-in not interfering with DOORS itself. Simply, a user does import/export via specific TAU add-in in TAU and corresponding DOORS objects change their import/export attribute. According to your replies it's not possible and I guess you're definitely right.

    Am I right saying that TAU and it's add-ins cannot affect any attributes of DOORS objects representing TAU model(and not only - any DOORS objects) without importing corresponding formal module into TAU and commiting changes to DOORS then?

    BTW, I managed to figure out what features there are in metaclasses by running
    
    [u2::XMLEncode [std::GetSelection]]
    


    Best regards,
    Dmitry
    • SystemAdmin
      SystemAdmin
      147 Posts
      ACCEPTED ANSWER

      Re: Access custom property in imported DOORS requirement with TCL

      ‏2010-04-07T10:17:45Z  in response to ihasaherb
      Dmitry

      Few things are impossible, but what you propose is certainly not part of the supported/documented functionality of the TauDOORS integration. It probably is technically doable - after all when a Tau model is pushed into DOORS the integration updates lots of object/attribute values with data from Tau - but it is risky and you would need to know a lot about accessing DOORS external APIs and how the TauDOORS integration works; I certainly can't help with this.

      Regards
      Ian
      • ihasaherb
        ihasaherb
        11 Posts
        ACCEPTED ANSWER

        Re: Access custom property in imported DOORS requirement with TCL

        ‏2010-04-07T10:23:40Z  in response to SystemAdmin
        Ian,

        I highly appreciate your flawless answers. Thank you very much for bringing a piece of disambiguation into the question.

        Closing the thread.

        Best regards,
        Dmitry