How to get the link details of an object by DXL

Hi folks,

I have a new problem in getting the link details of an object from a formal module.

Description:

Select an object with links in a formal module,
Open 'Edit Links'. All the links of this object will be listed below Links tag.
Select one link and click on 'Details'
A dialog with Attributes and corresponding values will displayed.

My question is how to get these attributes and corresponding values by DXL.

I know we can get these attributes from the Link Module. But I have no idea to get the corresponding values. I tried to wrote down the code to do that, but the returned value is not the same as we see from link property dialog.
 

Module mod =current
Object obj =first mod
AttrDef ad
string as=""
 
for ad in mod do
{
 
    if(ad.object)
        {
                as=ad.name
                print ad.name obj.as "\n"    //Print out the incorrect values.
        }
}


The expected result, please see my attached screen shot.


Edward_Wang - Wed Mar 23 01:47:06 EDT 2011

Re: How to get the link details of an object by DXL
Edward_Wang - Wed Mar 23 01:48:21 EDT 2011

The Output result:
Absolute Number:1
Created By:sss
Created On:10 January 2011
Last Modified By: sss
Last Modified On:10 January 2011
LinkType:
Purpose:adadsf
Source:/ss/ss - User Requirements
Source Index:000002e0
Target:/ss/TRS - Architectural Requirements
Target Index:000002e1

Re: How to get the link details of an object by DXL
Reik_Schroeder - Wed Mar 23 02:02:30 EDT 2011

Hi Edward,

to access those values you will need to apply them on the link, not on the object:

Object o = current;
Link l;
AttrDef ad;
 
for l in all (o -> "*") do {
  Module mLink = load (linkVersion l, false);
  if (!null mLink) {
    print (identifier o) " -> "(fullName mLink)" -> "(fullName targetVersion l)"["(targetAbsNo l)"]\n";
    for ad in mLink do {
      if (ad.object) {
        print "\tl.\""(ad.name)"\" = \""(l.(ad.name)"")"\"\n";
      }
    }
  }
}

 


The example will print all information on outgoing links of currently selected object.
I hope this helps you.

Regards
Reik

_______________________Evosoft GmbH / Siemens AG

 

Re: How to get the link details of an object by DXL
Mathias Mamsch - Wed Mar 23 04:20:45 EDT 2011

It seems a bit that you are under the impression that the Link Module stores links. Lets sum up the facts really quick:
  • An outlink is stored together with its object in the module. You get iterate over the links using the for Link in Object->"*" do ... loop.
  • Links have attributes - which Attributes a link has is defined in the link module (object type attributes of the link module)
  • The attribute value of links can be read and write by ... = MyLink.MyAttributeName or MyLink.MyAttributeName = ... just like with objects of formal modules.
  • Link modules have module attributes like formal modules. They usually have nothing to do with the links,except the "Mapping" attribute which will define if it is a one/one one/many, etc. link module
  • Link modules have objects which are the "Linksets". Therefore for example "Create" Access on a link module allows you to create a linkset. A linkset must exist for a link to be created.

And now comes the confusing part:
  • Since the object of a linkmodule is a linkset, and in addition the attributes of all links using the link module are defined by the attributes of the link module, Linksets and Liks share their attributes definitions, although they are completly different things.

Hope that clear matters up a bit. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: How to get the link details of an object by DXL
llandale - Wed Mar 23 11:12:28 EDT 2011

Mathias Mamsch - Wed Mar 23 04:20:45 EDT 2011
It seems a bit that you are under the impression that the Link Module stores links. Lets sum up the facts really quick:

  • An outlink is stored together with its object in the module. You get iterate over the links using the for Link in Object->"*" do ... loop.
  • Links have attributes - which Attributes a link has is defined in the link module (object type attributes of the link module)
  • The attribute value of links can be read and write by ... = MyLink.MyAttributeName or MyLink.MyAttributeName = ... just like with objects of formal modules.
  • Link modules have module attributes like formal modules. They usually have nothing to do with the links,except the "Mapping" attribute which will define if it is a one/one one/many, etc. link module
  • Link modules have objects which are the "Linksets". Therefore for example "Create" Access on a link module allows you to create a linkset. A linkset must exist for a link to be created.

And now comes the confusing part:
  • Since the object of a linkmodule is a linkset, and in addition the attributes of all links using the link module are defined by the attributes of the link module, Linksets and Liks share their attributes definitions, although they are completly different things.

Hope that clear matters up a bit. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Linksets and Links share their attribute definitions, although they are completly different things.

That's the key; hard to believe I've not actually considered it that way before.


So for ...
... Object oLS // Object handle of LinkSet in the LinkModule
... Link lnk // Link handle retrieved from the formal Objects

oLS."Created On" // when the LinkSet was created
lnk."Created On" // when the Link was created

oLs."Source" // full name of Source module of the LinkSet
lnk."Source" // no meaning what so ever

oLS."Suspicion Cleared Forwards" // no meaning
lnk."Suspicion Cleared Forwards" // Suspect Link information

oLS."Absolute Number" // AbsNo of LinkSet
lnk."Absolute Number" // no meaning

oLS."Custom Severity" // Could have meaning, but probably not
lnk."Custom Severity" // Severity of Link

"No meaning" means its null.

 

 

  • Louie