Archiv der Kategorie: IBM DOORS

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

IBM Doors DXL: String auf ASCII analyisieren / get ASCII codes of string

Problem

A String should be analyzed for it’s ASCII codes. Sometimes this is helpful when you get import files from a foreign system.
Sometimes there are invisible signs that can only be shown in the ASCII Code.

Approach

A string will be generated that shows the sign (c) and the real ASCII Code in brackets c[ASCII]

Solution

// Zum analysieren eines Strings auf seine Ascii Zeichen
string giveMeAscii(string withoutAscii)
{
string myAsciiString = „“;

for (i=0; i

IBM Doors DXL: Analyze Module or String for HTML or XML Tags

Problem

A module or a string should be analyzed for HTML or XML Tags.

Approach

The tags withing a module attribute shall be counted and the output should be send to the DXL Interaction window.

By running through the whole string, opening and closing tags can be found.
Here the steps are the following:
1.) Create a Skip-List that counts all tags
2.) Create a loop over the current module
3.) Within the loop call the Method checkForTags and

Solution

pragma runLim, 0;

/********************************************************************
 * Author: 	Bjoern Karpenstein
 * Date: 	2014-09-16
 * Parameter: 
 * Skipliste tagCount (vorher mit Skip tagCount=create; erzeugen)
 * string textToCheck (der auf XML Tags zu prüfende Text)
 * string tag (nach welchen Tag sehen? Falls leer alle Tags sammeln
 ********************************************************************/
void checkForTags(Skip tagCount, string textToCheck, string tag)
{
   // init loop variables
 bool currentIsInTag = false;
 bool tagEnded = false;
 string tagBetweenBrackets = "";
 int x;
   	
 for (x=0; x<length(textToCheck)-1;x++)
 {
  if(textToCheck&#91;x:x&#93; "" == "<" "")
  {
    currentIsInTag = true;
    tagBetweenBrackets = "";
   }
           
   if(textToCheck&#91;x:x&#93; "" == ">" "" && currentIsInTag)
   {
     currentIsInTag = false;

     // Wenn der Tag schon vorhanden ... eins hochzählen
     int vorhanden = 0;

     if(find(tagCount, tagBetweenBrackets ">", vorhanden))
     {
       // nehmen und eins hochzählen
       if(matches(lower(tag), lower(tagBetweenBrackets)))
       {
	// Lösche den aktuellen Wert in Skip-Liste		   		   
	delete (tagCount, tagBetweenBrackets ">");
		   		   
	// Füge den aktuellen Wert inkrementiert in Stückliste ein
	put(tagCount, tagBetweenBrackets ">", vorhanden+1);
       }
    }
    else
    {
      // Wenn nicht vorhanden initial mit 1 einfügen
      if(matches(lower(tag), lower(tagBetweenBrackets)))
      {
         put(tagCount, tagBetweenBrackets ">", 1);
      }
     }  
    }
      
    if(currentIsInTag)
    {
       tagBetweenBrackets = tagBetweenBrackets textToCheck[x:x] "";
    }
  }   
}

void main()
{
  Object o;
  Module m = current;
  Filter off;
  Skip tagCount = create;
	
  for o in m do
  {		
    string engText = o."Text_english" "";
    string gerText = o."Text_german" "";
		
    checkForTags(tagCount, engText, "");
    checkForTags(tagCount, gerText, "");
  }
	
  for myIterator in tagCount do 
  {
    string keyValue = (string key(tagCount));
   
    int dasVorhandene=0;
	   
    if(find(tagCount, keyValue, dasVorhandene))
    {
      print keyValue " \t" dasVorhandene "\n";
    }
  }
	
  delete(tagCount);
}

main();

IBM Doors: Performance tests with DXL

Problem

Sometimes it is necesseray to benchmark DXL scripts for their execution time.

Approach

There is a basic function called getTickCount_() that gives the current milliseconds. When subtracting the time before and after the execution we can get the execution time that was needed for the script.

Solution

int measureStart = (getTickCount_());

sleep_(1240);

int measureEnd = (getTickCount_());

print "The doing took " (measureEnd - measureStart) " seconds";

IBM Doors DXL: Iteration über ein listView(…) Element / Iterate populated listView DBE

Problem

Ein mit …

DBE textList = listView (...);

… erstelltes UI Element, welches eine Tabelle / Liste (mit/ohne Checkboxen) präsentiert, soll durchlaufen werden ohne eine separate Datenstruktur befüllen zu müssen.

An iteration through a listView(…) UI element shall be performed without the need of an additional data structure.

Ansatz – Approach

The following functions can be used to perform an Iteration…
int noElems(DBE element) – liefert die Anzahl der Elemente in einer UI Liste (element: choice, tab strip, list, multi-list, combo box, or list view)
bool getCheck(DBE listView, index) – liefert einen BOOL ob die Checkbox (falls vorhanden) im Eintrag markiert ist
string getColumnValue(DBE listView, int row, int column) – liefert den Content der Spalte

Lösung – Solution

// Iteriere über eine Liste / Tabelle des Typs listView: Welche… Datenstruktur oder UI Element?
// textList = listView (…);
int i = 0;

for (i = 0; i < noElems(textList); i++) { // if the entry is checked (selected) ... if (getCheck(textList, i)) { string textID_StringValue = getColumnValue(textList,i,0); string currentDoors_StringValue = getColumnValue(textList,i,1); string currentWings_StringValue = getColumnValue(textList,i,2); string textFile_StringValue = getColumnValue(textList,i,3); string module_StringValue = getColumnValue(textList,i,4); } } [/javascript]

IBM Doors DXL: Alle eingeloggten User ausgeben

Aufgabe

Alle eingeloggten User eines Modules sollen ausgegeben werden / Alle User Sessions angzeigt werden

Ansatz

Auslesen der Session History

Lösung

Module m = read("/NDS/20 System/RS-System Requirements Specification");
HistorySession hs = null;


for hs in m do
{
	print number(hs) "," when(hs) "," who(hs) ",";

	string sBaseline=baseline(hs);
	if(sBaseline != null)
	{
		print sBaseline;
	}
	print "\n";
}