IBM Doors DXL: Browse Triggers on module

Problem

When there are triggers on a module it often is not visible to administrators and other users that can perform DXL operations.

Approach

A menu point as module add in should be generated. Copy the following script to the moduleaddins directory of your doors installation.

Solution

// This is necessary that it works
/*******************************************************
 * Author: Björn Karpenstein
 * Date:   2014-10-01
 * 
 * This script lists all triggers of the module
 ******************************************************/
pragma runLim, 0;

string lstArray [] = {}; 
 
DB mainWindow;
DBE textBox;
DBE textList;

void listAllTriggerForMod (Module mod) 
{
  string theResult="";
  Trigger t;
  int i = 0;
  for t in mod do 
  {
    insert(textList, i, name(t) "", iconNone);
    i++;
  }
}

string getSourceForTriggerName (string theTrigger) 
{
  string sourceCode = "";
  Trigger t;
  for t in current Module do 
  {
    if(name(t) "" == theTrigger)
    {
      sourceCode = dxl(t) "";
    }		
  }
	
  return sourceCode;
}

void doDeselect(DBE dbe, int idx)
{
  //infoBox "You deselected " dbe[idx] "";
} 


void doActivate(DBE dbe, int idx)
{
  // infoBox "You activated " dbe[idx] "";	
}

void doSelect(DBE dbe, int idx)
{
  string triggerName = getColumnValue(textList,idx,0);
  set(textBox, getSourceForTriggerName(triggerName));	
} 

void main(void)
{
  User currentUser = find();
  bool mayDXL = currentUser.mayEditDXL;
  if (!mayDXL)
  {
   // Show error box and inform user. Stop execution of script.
   errorBox "You are not allowed to run/edit DXL code!";
   halt;
  }		
	
  mainWindow = create("List all triggers");
	
  textList = listView(mainWindow, 0, 310, 20, lstArray);		
  textBox = text(mainWindow, "", "", 400, false);
	
  textList->"right"->"unattached";
  textBox->"left"->"flush"->textList;
  textBox->"top"->"aligned"->textList;	

  realize(mainWindow);			
	
  insertColumn(textList, 0, "Trigger Name", 300, iconNone);
	
  set(textList,doSelect,doDeselect,doActivate);		
  listAllTriggerForMod(current);
	
  // set(textBox, listAllTriggerForMod(current));
  show(mainWindow);	
}

main();

IBM Doors DXL: Auslesen aller Module eines Projektes einer BaselineSetDefinition und eines BaselineSets in ihren jeweils gebaseline-ten Versionen

Problem

Alle Module eines Projektes, die in einem BaselineSet freigegeben wurden, sollen in Ihrer Version im BaselineSet ausgelesen werden.

Approach

  1. Generell auslesen der Module in einer BaselineSetDefinition
  2. Auslesen des BaselineSets der Version {baselineSetVersion}
  • Die BaselineSetDefinition beinhaltet die Module, die für ein BaselineSet (hier Release_Set) vorgesehen sind. Eine BaselineSetDefinition hat einen Namen, unter dem die BaselineSet-Versionen erzeugt werden.
  • Das BaselineSet ist eine Version einer BaselineSetDefinition und hat den Namen der BaselineSetDefinition. In einem BaselineSet befinden sich Baseline-Versionen der Module aus der BaselineSetDefinition;

Solution

string baselineSetDefinition="Release_Set";
string baselineSetVersion="5.0";

BaselineSetDefinition bsd;
Folder f = folder "/MyProject";
ModName_ modName;

for bsd in f do
{
  if(name(bsd) "" == baselineSetDefinition)
  {
    // 1.) Generell auslesen der Module in einer BaselineSetDefinition
    for modName in bsd do
    {
      print name(bsd) " " name(modName) "\n";
    }

    // 2.) Bsp: Auslesen des BaselineSets der Version {baselineSetVersion}
    BaselineSet bs;
    for bs in bsd do
    {
       if(versionID(bs) "" == baselineSetVersion)
       {
         ModuleVersion modver;
	for modver in all bs do 
         {
           string versionsString = versionString modver;
           if(versionsString=="") versionsString="N/A";
           print fullName(modver) "\t" versionsString "\n";
	} 
        }
     }
   }
}

IBM Doors DXL: A Layout DXL column that shows the differences to a previous baseline

Problem

A Layout DXL Column script should show the differences to another baseline

Approach

  • Right-click column header
  • Select „New“
  • Choose „Layout DXL“  radio button
  • Click on the browser button
  • Click on New
  • Insert the script below
  • Be aware to have all line breaks in the code like below

Replace {baselineToCompare} to the major version that you want to compare with the current version.

Solution

// This script shall be replace {baselineToCompare}
/**************************************************
 * Author: Björn Karpenstein
 * Date:   2014-10-09
 *
 * This is a layout DXL to show the differences from 
 * the current version to another baseline. 
 **************************************************/
Baseline oldBaseline = baseline({baselineToCompare}, 0,"");

Buffer bBefore = create;
Buffer bAfter = create;
Buffer result = create;
AttrDef ad;

Module oldModule = load(module(obj), oldBaseline, false)
Module currModule = current
showDeletedObjects(true)
int i = obj."Absolute Number"
Object oldObject = object(i, oldModule)

void compareColumn(string columnName)
{
  ad = find(oldModule, columnName);
		
  if(!null(ad) && !null(oldObject))
  {
    bBefore = oldObject.columnName;
  }
  else bBefore = "";
		
  ad = find(currModule, columnName)

  if(!null(ad))
  {
    bAfter = obj.columnName;
  }
  else bAfter = "";
		
  bAfter = obj.columnName;

  if( bBefore != bAfter )
  {
    diff(result, bBefore, bAfter);
    displayRichWithColor("{\\b " columnName " CHANGED}");
    displayRichWithColor(stringOf(result));
  }
}
				
if(null(oldObject))
{
  displayRichWithColor("{\\b NEW}");
  if(isDeleted(obj)) displayRichWithColor("{\\b DELETED}");
}
else
{			
  if(isDeleted(obj) && !isDeleted(oldObject))
  {
    displayRichWithColor("{\\b DELETED}");
  }
  else
  {
    if(!isDeleted(obj) && isDeleted(oldObject))
    {
      displayRichWithColor("{\\b UNDELETED}");
    }
  
    // Here you can add the 
    // module attributes to compare	
		
    /*** BB_ReqStatus ***/		
    compareColumn("BB_ReqStatus");
	
    /*** BB_Type ***/
    compareColumn("BB_Type");

    /*** Last Modified On ***/
    compareColumn("Last Modified On");
		
    /*** Object Heading ***/
    compareColumn("Object Heading");

    /*** Object Text ***/
    compareColumn("Object Text");
  }
}
		
delete bBefore;
delete bAfter;
delete result;

IBM Doors DXL: Filtern mit accept und reject

Problem

Ein Standard-Filter kann aus logischen Ausdrücke nach Spalten und Attributen bestehen. Möchte man einen Filter anhand komplexerer Strukturen aufbauen, stößt man bei den Möglichkeiten, die die Doors GUI bietet, an die Grenzen.

Approach

In solchen Fällen kann man die internen Funktionen benutzen, die bei einer Filterung verwendet werden.

  • Filtern ausschalten
  • Iteration über das Modul
  • Abfrage der komplexeren Bedingungen, die das Filtern tun sollen (hier einfache IF() Struktur)
  • accept(obj) <– diese Objekte kommen in den Filter
  • reject(obj) <– diese Object werden aus dem Filter entfernt
  • Filtern einschalten

Solution

Module m = current;
filtering off;	
Object anObject = null;
for anObject in m do
{
  if(anObject."BB_Type" "" != "Reviewer")
  {
    reject anObject;
  }
  else
  {
    accept anObject;
  }
}
filtering on;

IBM Doors DXL: How to create a new view with LayoutDXL, Object Text and Object Heading, several attributes

Problem

A new view with the Main-Column (Object Heading and Object Text), a LayoutDXL Attribute and any other attribute shall be created.

Approach

  • Create View from Default View (overwrite existing)
  • Delete all columns in the Default View
  • Insert Columns

Solution

With this script you can iterate over all Attributes you can select for the view:

Module m = current;
string attr;

for attr in m do
{
  print attr "\n";
}

The following script generates the view:

void createViewForModule(Module m, string viewName)
{	
  // construct view of attributes chosen
  Column c;
  int n = 0; // number of existing columns
  int i; // column index
	
  View v = view(viewName);
  bool isLoaded = load(m,v);

  if(!isLoaded)
  {
    // If the view is not existing
    // Save the view
    // Normally the default View 
    // is constructed 	
    // save(m,v) is not asking
    // if a view exists -&gt; it 
    // overwrites any view with
    // the same name	
    save(m,v);
   }		
	
   // count the columns
   for c in m do
   {
      n++; 
   }
	
   // Delete all columns that were
   // contained in the default View
   // used as template
   for(i=1;i&lt;=n;i++)
   {
     delete(column 0); 
   }
	
   // Add Object Identifier (i.e. CRS-CS-2)
   insert(column 0);
   attribute(column 0, "Object Identifier");
   width(column 0, 80);
   justify(column 0, left);
	
    // Add the main Column (Object Heading+
    // Object Text) to the View
    Column mainColumn = null;
    mainColumn = insert mainColumn;
    main mainColumn;
    width(mainColumn, 300);
	
    // Add Object Identifier (i.e. CRS-CS-2)
    insert(column 2);
    attribute(column 2, "BB_ReqStatus");
    width(column 2, 80);	
	
    // Create a LayoutDXL Column in a view
    insert(column 3);  
    // I would recommend to #include scripts
    dxl(column 3, "displayRich \"huhu\""); 
    width(column 3, 80);	

    // important! (last column does not appear
    // otherwise)
    refresh m; 
    save view viewName; 
}

IBM Doors DXL: Get last baseline version as String

Problem

The last version of a baseline shall be retrieved as String

Approach

With the usage of the standard methods, the string can be returned

  • Baseline=getMostRecentBaseline(Module) – Holt die letzte BL
  • bool=baselineExists(Module,Baseline) – Existiert die BL?
  • string=major(Baseline) – Versionsnummer VOR Komma
  • string=minor(Baseline) – Versionsnummer NACH Komma
  • string=suffix(Baseline) – Anhängsel sichtbar in BL Liste
  • string=dateOf(Baseline) – Datum der Baseline
  • string=annotation(Baseline) – Bemerkung zur Baseline

The version can be retrieved as string.

Solution

string getLastBaselineVersionString(Module ModRef)
{
  string myBase="N/A;" 
  Baseline b = getMostRecentBaseline(ModRef);
  if (b != null &amp;&amp; baselineExists(ModRef,b));
  {
    myBase = (major b) "." (minor b) "";
    if ((suffix b) != "")
    { 
      myBase = myBase "(" (suffix b) ")";
    }
		
    myBase = myBase " //" dateOf(b) "";
    if ((annotation b) != "")
    {
	myBase = myBase  " " (annotation b) "";
    }
  }
  return myBase
}

IBM Doors DXL: Durch alle Module eines Projektes Module iterieren/laufen / Iterate all modules in a project

Problem

In Doors DXL all modules of a project should be read.

Approach

It is possible to filter for the ItemRef-Type „Formal“ when iterating a project without using recursion.

Solution

// This is necessary that it works
/*******************************************************
 * Author: Björn Karpenstein
 * Date:   2014-10-08
 * 
 * This DXL script iterates through all formal modules
 ******************************************************/

void forAllModules(void)
{
  Item itemRef;
  string shType;
  string sItemNameFull;
  string sItemName;
  Module moduleReference;
	
  string projectName = "/" name(current Project);
  print projectName "\n";
	
  for itemRef in project projectName do 
  {
    shType = type(itemRef);
    print shType "\t";

    sItemNameFull = fullName(itemRef);
    print sItemNameFull "\t";
		
    sItemName = name(itemRef);
    print sItemName "\n";	
	
    if(shType=="Formal")
    {
      moduleReference = read(sItemNameFull,false);
    }
  }
}

// Main-Method
void main(void)
{
  forAllModules();
}

main();

Für alle Module eine Folders (rekursiv) siehe …
To get all modules from a folder also see …

IBM Doors DXL: Rekursiv durch alle Module eines Folders / Iterate recursive all formal modules of a folder