Create column and populate via DXL

Hi,

I'm sorry if this has been answered before, but on a cursory search I did not find anything.

So, currently I have a Layout DXL code that resides in Doc1, and follows links this way: Doc1 (outlink) --> (1 or more objects in) Doc2 ---> (1 or more objects in) Doc3. Then it lists all unique object IDs found in Doc3, that are somehow in-linked from Doc1.

This being Layout DXL, the procedure is wasteful. For each object on display in Doc1, Do2 and Doc3 are loaded again and again and again.

I would like to convert this to a standalone script if possible, that does the following:

  • Creates a new column in the current view (in Doc1)
  • Iterates over all objects, and for each object applies the logic described above, populating the column in one "go".

Is there a way to do this dynamically without altering the document structure, or is going the Atttribute DXL way my only option?

Thank you!


chirila.alexandru - Thu May 25 08:25:00 EDT 2017

Re: Create column and populate via DXL
ChristopheP - Fri May 26 05:54:33 EDT 2017

Hello,

 

You're right, it is a big waste of time to open/close linked modules objects by objects.

I am not sure of the best solution, but I think you can do it with a script plus triggers.

 

1- Write a DXL script with two functions:

* A first function able to fill your target attribute for your entire module

* Another function able to fill your attribute for one object

2- Use an open module trigger to handle your module opening

Call your first function

This update all your objects attributes with fresh information

3- Use an edit object trigger to handle object modifications (if you update outlinks)

Call your second function

This update only the modified object when you modifiy its outlinks

 

I can't help you more because at this time I am not really experienced with triggers.

Perhaps somebody will have a better solution.

 

-Christophe-

Re: Create column and populate via DXL
Peter_Albert - Thu Nov 23 10:27:27 EST 2017

I am a bit late to this thread, and attribute DXL and Christophe's suggestions are two possible ways forward, but they both contain the need to modify the Module itself. If you want to stick to a solution you can apply also to Modules to which you only have read access, then a third solution is possible, namely an interactive layout DXL column which interacts with a dialogue box. The advantage of this solution is that it is very fast and very flexible, the disadvantage is that you can't save it in a view.

Credits for the original idea go to Mathias Mamsch (this is the link to the original post, but the URL seems to be broken now).

I have attached the necessary include file.

An example usage looks like this:

// Example code for the usage of the interactive layout DXL column
/*
*/

// Adjust as necessary
#include <../layout/include/interactiveLayout.inc>
// Optional: You can define and use additional dialogue box elements
DBE DBE_info
DBE DBE_bold
// =============================================================================
void interactiveLayout_additionalDBEs(){
  // Optional: You can define and use additional dialogue box elements
  DBE_info   = label ( gDB_interactiveLayout, "You can place additional DBEs here in case you\nwant to make your temporary column more interactive")
  DBE_bold = toggle ( gDB_interactiveLayout, "Bold", false )
}
// =============================================================================
void interactiveLayout_calculateResults( Object O_this ){
  /* Put your existing layout DXL here
  All you have to do at the end is to put the final result
  into the global Skip list 'gS_interactiveLayout_Skip' 
  using the Object's Absolute Number as key */
  int    i_absNum = O_this."Absolute Number"
  Buffer B_out  = create
  bool   b_bold = get DBE_bold
  B_out = "The Absolute Number of this Object is "
  B_out += ((b_bold) ? "{\\b " : "") i_absNum ((b_bold) ? "}" : "")
  B_out += "."
  B_out += "\nThis column value has been calculated on " ( dateOf intOf today ) ""
  put (gS_interactiveLayout_Skip , i_absNum, stringOf B_out, true )
  delete B_out
}
// =============================================================================
interactiveLayout_getColumCode_createTmpSkip()
interactiveLayout_addColumn("Test", 200)
interactiveLayout_createGUI(300, 300, "Test", "", false)
// ============================================================================

Basically, the dialogue box and the new column share a Skip list. The key is the Objects' Absolute Number, and the value is set by the code you can define in the routine 'interactiveLayout_calculateResults'. The actual layout DXL which is executed is limited to fetching the respective value from the Skip list, so regardless of how time consuming your actual code is, the display of its results is always fast.

Cheers,

     Peter

 

 


Attachments

interactiveLayout.inc

Re: Create column and populate via DXL
Mike.Scharnow - Thu Nov 23 12:01:11 EST 2017

Peter_Albert - Thu Nov 23 10:27:27 EST 2017

I am a bit late to this thread, and attribute DXL and Christophe's suggestions are two possible ways forward, but they both contain the need to modify the Module itself. If you want to stick to a solution you can apply also to Modules to which you only have read access, then a third solution is possible, namely an interactive layout DXL column which interacts with a dialogue box. The advantage of this solution is that it is very fast and very flexible, the disadvantage is that you can't save it in a view.

Credits for the original idea go to Mathias Mamsch (this is the link to the original post, but the URL seems to be broken now).

I have attached the necessary include file.

An example usage looks like this:

// Example code for the usage of the interactive layout DXL column
/*
*/

// Adjust as necessary
#include <../layout/include/interactiveLayout.inc>
// Optional: You can define and use additional dialogue box elements
DBE DBE_info
DBE DBE_bold
// =============================================================================
void interactiveLayout_additionalDBEs(){
  // Optional: You can define and use additional dialogue box elements
  DBE_info   = label ( gDB_interactiveLayout, "You can place additional DBEs here in case you\nwant to make your temporary column more interactive")
  DBE_bold = toggle ( gDB_interactiveLayout, "Bold", false )
}
// =============================================================================
void interactiveLayout_calculateResults( Object O_this ){
  /* Put your existing layout DXL here
  All you have to do at the end is to put the final result
  into the global Skip list 'gS_interactiveLayout_Skip' 
  using the Object's Absolute Number as key */
  int    i_absNum = O_this."Absolute Number"
  Buffer B_out  = create
  bool   b_bold = get DBE_bold
  B_out = "The Absolute Number of this Object is "
  B_out += ((b_bold) ? "{\\b " : "") i_absNum ((b_bold) ? "}" : "")
  B_out += "."
  B_out += "\nThis column value has been calculated on " ( dateOf intOf today ) ""
  put (gS_interactiveLayout_Skip , i_absNum, stringOf B_out, true )
  delete B_out
}
// =============================================================================
interactiveLayout_getColumCode_createTmpSkip()
interactiveLayout_addColumn("Test", 200)
interactiveLayout_createGUI(300, 300, "Test", "", false)
// ============================================================================

Basically, the dialogue box and the new column share a Skip list. The key is the Objects' Absolute Number, and the value is set by the code you can define in the routine 'interactiveLayout_calculateResults'. The actual layout DXL which is executed is limited to fetching the respective value from the Skip list, so regardless of how time consuming your actual code is, the display of its results is always fast.

Cheers,

     Peter

 

 

current link to original post: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014890784