Topic
  • 6 replies
  • Latest Post - ‏2013-07-24T05:58:16Z by eetze
eetze
eetze
3 Posts

Pinned topic Using Layout DXL to display module name and all its parent object headingss in a column

‏2013-07-10T02:22:51Z | concatenation

Hi,

This is the first time I post in this forum after found it yesterday and spending days trying to figure out how to concatenate module name and object heading.

 

I am trying to create a column in a view which will display the module name and all its parent object headings before I export it to Excel for me to import it into Quality Center.

 

The reason I am doing this manually instead of relying on the Quality Center Integration(QCI) module is because QCI will occasionally starts to act up and stop updating the requirement data in Quality Center when performing the synchronization task. Performing the upload manually will be my fall back plan should the synchronization task stop functioning as intended.

 

The content in the column should be able to display all the object headings(parent) so that the requirements is able to retain the requirement structure when I import the data into Quality Center.

For instance,

Module Name: XXX Requirement

Object Heading             Object Text             Desire Output

Section 1                                                      XXX Requirement

                                      requirement 1         XXX Requirement\Section 1

                                      requirement 2         XXX Requirement\Section 1

      Section 1.1                                            XXX Requirement\Section 1

                                      requirement 3         XXX Requirement\Section 1\Section 1.1

           Section 1.1.1                                    XXX Requirement\Section 1\Section 1.1

                                      requirement 4         XXX Requirement\Section 1\Section 1.1\Section 1.1.1

      Section 1.2                                            XXX Requirement\Section 1

                                                   requirement 5         XXX Requirement\Section 1\Section 1.2

 

After browsing this forum and found two closest post. I am only managed to come up with the script below.

Object GetParent(Object in_obj) 
{  
  if (null in_obj)  
      return(Object null) 
 
  string Head = probeAttr_(in_obj, "Object Heading")  
 
  if (!null Head) then    
     return(in_obj) 
  else 
     return(GetParent(parent(in_obj))) 
}
 
Object obj = current
 
if (null obj) then halt 
else {
Module m = current
Object oParent = GetParent(parent(obj))
Object oGrandParent = GetParent(parent(oParent))
string HeadParent = probeAttr_(oParent, "Object Heading")  
 
if (!null HeadParent) 
display (m."Name" "\\" HeadParent)
}

 

The issues that I am facing now are:

  • The above script is unable to display all its parent(multiple parent level). For instance, if I click on 'requirement 3' row, all the content in the column will just display as 'XXX Requirement\Section 1.1'. I am suspecting it is due to the fact that I assign obj=current but I don't know how to get around it.
  • I am unable to retrieve all the parents of the object heading as there will be more that 5 levels of the object heading that I may have to deal with.

 

Does anyone has any experience or success in performing the concatenation successfully? 

 

Thanks & Best Regards,

Ee Tze

Updated on 2013-07-10T02:24:02Z at 2013-07-10T02:24:02Z by eetze
  • MichaelGeorg
    MichaelGeorg
    53 Posts
    ACCEPTED ANSWER

    Re: Using Layout DXL to display module name and all its parent object headingss in a column

    ‏2013-07-16T10:52:00Z  
    • eetze
    • ‏2013-07-16T03:40:15Z

    Hi Michael & Chris,

     

    Thank very much for providing me with the pointers.

     

    I tried the above script and I noticed it only work when the requirements up to 2nd levels. Anything beyond that will display the object heading in reverse order. I am not sure if it is caused by setting the obj = current.

                                                                             Output            

                     Level 1                                              Module Name

                             Requirement 1.1                       Module Name\Level 1

                             Level 2                                     Module Name\Level 1

                                   Level 2.1                            Module Name\Level 2\Level 1

                                           Requirement 2.1        Module Name\Level 2.1\Level 2\Level 1

     

    Next, may I know if there is a way to prevent the data in the column from refreshing by the script  whenever I navigate to different row in the view? The reason I asked this is because the current script will always refreshes the data display in the column with the same value whenever I select a different record. This will not work if I will need to value to persist. For instance, selecting record 'Level 2' will cause the data in the entire column to refresh as 'Module Name\Level 1'

     

    Regards,

    Ee Tze

    Hi,

    sorry, the script I've posted above is neither compiling nor correct. Seems like I copied some intermediate version of the script to the forum
    @Chris: Thanks a lot for correcting at least the compilation error.

    @Ee Tze: You are absolutely correct about "object = current" and the order of the headings. Actually a statement that uses the current object is typically not a good idea for Layout DXL Columns and because the scripts starts with the lowest level of heading the resultStr must be extended to the front instead of the end.

    So correct (and this time tested) code is:

    //string to gather content that should be displayed
    string resultStr = ""

    //loop through all ancestors and add if they have a Object Heading add it to resultStr
    Object ancestorObj = parent(obj)
    while (!null ancestorObj) {
     if(ancestorObj."Object Heading" "" != "") {  //add Object Heading to resultStr if object has/is a heading
      resultStr =  "\\"   ancestorObj."Object Heading"  resultStr
     }
     ancestorObj = parent(ancestorObj)    //go to next ancestor
    }

    //put module name to resultStr
    Module m = current
    resultStr = m."Name" resultStr

    //display gather content
    display(resultStr)

     Regards,

    Michael

     

    Updated on 2013-07-16T10:52:40Z at 2013-07-16T10:52:40Z by MichaelGeorg
  • MichaelGeorg
    MichaelGeorg
    53 Posts

    Re: Using Layout DXL to display module name and all its parent object headingss in a column

    ‏2013-07-12T07:37:40Z  

    Hello Ee Tze,

    two remarks about the code above:

    • The code checks only the parent and grandparent of the current object. So it should be no surprise, that if you have more then 2 levels of headings above the current object you will not be able to see them in the output. If you want to be flexible about the number of headings above some objects you need to use some kind of condition controlled loop or recursive function, which in difference to the one in above code doesn't break recursion if it finds a heading.
    • Even so the code does fetch parent and grandparent of the current object it only uses the Object Heading of the parent.

    Code that should do want you want might look like:


    //string to gather content that should be displayed
    string resultStr

     
    //put module name to resultStr
    Module m = current
    resultStr = m."Name" "\\"
     
     
    //get current object
    Object obj = current
    if (null obj) {
     halt
    }

    //loop through all ancestors and add if they have a Object Heading add it to resultStr
    Object ancestorObj = parent(obj)
    while (!null ancestorObj) do {
     if(ancestorObj."Object Heading" "" != "") {  //add Object Heading to resultStr if object has/is a heading
      resultStr = resultStr ancestorObj."Object Heading" "\\"   
     }
     ancestorObj = parent(ancestorObj)    //go to next ancestor
    }

    //display gather content
    display(resultStr)
     

     - Michael

  • ChrisAnnal
    ChrisAnnal
    64 Posts

    Re: Using Layout DXL to display module name and all its parent object headingss in a column

    ‏2013-07-12T16:58:29Z  

    Hello Ee Tze,

    two remarks about the code above:

    • The code checks only the parent and grandparent of the current object. So it should be no surprise, that if you have more then 2 levels of headings above the current object you will not be able to see them in the output. If you want to be flexible about the number of headings above some objects you need to use some kind of condition controlled loop or recursive function, which in difference to the one in above code doesn't break recursion if it finds a heading.
    • Even so the code does fetch parent and grandparent of the current object it only uses the Object Heading of the parent.

    Code that should do want you want might look like:


    //string to gather content that should be displayed
    string resultStr

     
    //put module name to resultStr
    Module m = current
    resultStr = m."Name" "\\"
     
     
    //get current object
    Object obj = current
    if (null obj) {
     halt
    }

    //loop through all ancestors and add if they have a Object Heading add it to resultStr
    Object ancestorObj = parent(obj)
    while (!null ancestorObj) do {
     if(ancestorObj."Object Heading" "" != "") {  //add Object Heading to resultStr if object has/is a heading
      resultStr = resultStr ancestorObj."Object Heading" "\\"   
     }
     ancestorObj = parent(ancestorObj)    //go to next ancestor
    }

    //display gather content
    display(resultStr)
     

     - Michael

    Michael's script is almost perfect for the task. The only issue I ran into when I tested it was that the "while" loop doesn't require "do".

    In other words, that line should read:

    while (!null ancestorObj)  {
     

    If you remove "do" from the line, then the script works perfectly.

  • eetze
    eetze
    3 Posts

    Re: Using Layout DXL to display module name and all its parent object headingss in a column

    ‏2013-07-16T03:40:15Z  

    Michael's script is almost perfect for the task. The only issue I ran into when I tested it was that the "while" loop doesn't require "do".

    In other words, that line should read:

    while (!null ancestorObj)  {
     

    If you remove "do" from the line, then the script works perfectly.

    Hi Michael & Chris,

     

    Thank very much for providing me with the pointers.

     

    I tried the above script and I noticed it only work when the requirements up to 2nd levels. Anything beyond that will display the object heading in reverse order. I am not sure if it is caused by setting the obj = current.

                                                                             Output            

                     Level 1                                              Module Name

                             Requirement 1.1                       Module Name\Level 1

                             Level 2                                     Module Name\Level 1

                                   Level 2.1                            Module Name\Level 2\Level 1

                                           Requirement 2.1        Module Name\Level 2.1\Level 2\Level 1

     

    Next, may I know if there is a way to prevent the data in the column from refreshing by the script  whenever I navigate to different row in the view? The reason I asked this is because the current script will always refreshes the data display in the column with the same value whenever I select a different record. This will not work if I will need to value to persist. For instance, selecting record 'Level 2' will cause the data in the entire column to refresh as 'Module Name\Level 1'

     

    Regards,

    Ee Tze

  • MichaelGeorg
    MichaelGeorg
    53 Posts

    Re: Using Layout DXL to display module name and all its parent object headingss in a column

    ‏2013-07-16T10:52:00Z  
    • eetze
    • ‏2013-07-16T03:40:15Z

    Hi Michael & Chris,

     

    Thank very much for providing me with the pointers.

     

    I tried the above script and I noticed it only work when the requirements up to 2nd levels. Anything beyond that will display the object heading in reverse order. I am not sure if it is caused by setting the obj = current.

                                                                             Output            

                     Level 1                                              Module Name

                             Requirement 1.1                       Module Name\Level 1

                             Level 2                                     Module Name\Level 1

                                   Level 2.1                            Module Name\Level 2\Level 1

                                           Requirement 2.1        Module Name\Level 2.1\Level 2\Level 1

     

    Next, may I know if there is a way to prevent the data in the column from refreshing by the script  whenever I navigate to different row in the view? The reason I asked this is because the current script will always refreshes the data display in the column with the same value whenever I select a different record. This will not work if I will need to value to persist. For instance, selecting record 'Level 2' will cause the data in the entire column to refresh as 'Module Name\Level 1'

     

    Regards,

    Ee Tze

    Hi,

    sorry, the script I've posted above is neither compiling nor correct. Seems like I copied some intermediate version of the script to the forum
    @Chris: Thanks a lot for correcting at least the compilation error.

    @Ee Tze: You are absolutely correct about "object = current" and the order of the headings. Actually a statement that uses the current object is typically not a good idea for Layout DXL Columns and because the scripts starts with the lowest level of heading the resultStr must be extended to the front instead of the end.

    So correct (and this time tested) code is:

    //string to gather content that should be displayed
    string resultStr = ""

    //loop through all ancestors and add if they have a Object Heading add it to resultStr
    Object ancestorObj = parent(obj)
    while (!null ancestorObj) {
     if(ancestorObj."Object Heading" "" != "") {  //add Object Heading to resultStr if object has/is a heading
      resultStr =  "\\"   ancestorObj."Object Heading"  resultStr
     }
     ancestorObj = parent(ancestorObj)    //go to next ancestor
    }

    //put module name to resultStr
    Module m = current
    resultStr = m."Name" resultStr

    //display gather content
    display(resultStr)

     Regards,

    Michael

     

    Updated on 2013-07-16T10:52:40Z at 2013-07-16T10:52:40Z by MichaelGeorg
  • llandale
    llandale
    3035 Posts

    Re: Using Layout DXL to display module name and all its parent object headingss in a column

    ‏2013-07-16T19:07:24Z  

    Let me scribble a recursive function; maybe it will get you going.

    • void Get(Object o, Buffer buf)
    • {  // Put the Object Heading of this object and all ancestors in the buffer; Ancestors first.
    •    if (null o)  return
    •    Get(parent(o), buf)    // deal with ancestors first
    •  // deal with this object second:
    •    buf += "\\"       // in my opinion, a CR-TAB would be better; "\n\t" to get a deep rather than wide result
    •    buf += number(o)  // in my opinion, display the paragraph number of the heading is desirable.
    •    buf += " "
    •    buf += o."Object Heading"
    • }
    • Buffer bufResults = create()
    • bufResults += name(module(obj))
    • bufResults += "\\"
    • Get(obj, bufResults)
    • display(tempStringOf(bufResults)
    • delete(bufResults)

    -Louie

    The view containing this layout should specifically turn showing deleted objects off.  the paragraph "number" of an object can change when deletions are showing.

    Will someone please tell me how to "block" code?  had no luck so far.

  • eetze
    eetze
    3 Posts

    Re: Using Layout DXL to display module name and all its parent object headingss in a column

    ‏2013-07-24T05:58:16Z  

    Hi,

    sorry, the script I've posted above is neither compiling nor correct. Seems like I copied some intermediate version of the script to the forum
    @Chris: Thanks a lot for correcting at least the compilation error.

    @Ee Tze: You are absolutely correct about "object = current" and the order of the headings. Actually a statement that uses the current object is typically not a good idea for Layout DXL Columns and because the scripts starts with the lowest level of heading the resultStr must be extended to the front instead of the end.

    So correct (and this time tested) code is:

    //string to gather content that should be displayed
    string resultStr = ""

    //loop through all ancestors and add if they have a Object Heading add it to resultStr
    Object ancestorObj = parent(obj)
    while (!null ancestorObj) {
     if(ancestorObj."Object Heading" "" != "") {  //add Object Heading to resultStr if object has/is a heading
      resultStr =  "\\"   ancestorObj."Object Heading"  resultStr
     }
     ancestorObj = parent(ancestorObj)    //go to next ancestor
    }

    //put module name to resultStr
    Module m = current
    resultStr = m."Name" resultStr

    //display gather content
    display(resultStr)

     Regards,

    Michael

     

    Hi Michael,

     

    Thanks for the prompt reply. Your updated script works like a charm.

     

    Regards,

    Ee Tze