Archiv der Kategorie: IBM DOORS

IBM Doors DXL: Simple String DIFF Comparation in Layout DXL

Problem

Two strings shall be compared with the DIFF function of Doors

Approach

Assign the string to a buffer using the += operator

Solution

void compareStrings(string string1, string string2)
{
	Buffer string1Buff = create;
	Buffer string2Buff = create;
	Buffer result = create;
	
	string1Buff+=string1;
	string2Buff+=string2;
	
	diff(result, string1Buff, string2Buff);
	
	displayRichWithColor(stringOf(result));
	
	delete string1Buff;
	delete string2Buff;
	delete result;	
}

IBM Doors DXL: Simple Incoming Links / In-Links / Input Links Layout DXL

string linkModuleString="/Product Lifecycle Management/10 Administration/Accords";

Link lnk;
LinkRef lnkRef;
ModName_ otherMod = null;
Item linkModItem = itemFromID(uniqueID(item(linkModuleString)));
linkModName = fullName(linkModItem);
     
for lnkRef in all(obj<-linkModName) do
{
  otherMod = module (sourceVersion lnkRef);
  if (!null otherMod) 
  {
    if ((!isDeleted otherMod) && (null data(sourceVersion lnkRef))) 
    {
      load((sourceVersion lnkRef),false);
    }
  }
}
     
for lnk in all(obj<-linkModName) do
{
  Object src = source lnk;
  if ( isDeleted(src) || null(src) ) continue;
     
	display src."Object Text" "";
}

IBM Doors DXL: Call REST Services / REST-Services aufrufen

Problem

Von Doors aus sollen REST Services aufgerufen werden.

REST Services shall be called within a DXL Script in IBM Doors

Approach – Ansatz

Usage of OLE Automization

Solution – Lösung

pragma runLim,0
OleAutoArgs args = create
OleAutoArgs args2 = create
OleAutoObj http = oleCreateAutoObject("WinHttp.WinHttpRequest.5.1")
void sendResult(string commandId, string result) {
	clear(args)
	clear(args2)
	put(args, "POST")
	put(args, "https://my.url.de/commands/" commandId "/result")
	OleAutoArgs args2 = create
	put(args2, result)
	oleMethod(http, "open", args)
	string res = oleMethod(http, "send", args2)
	if(!null(res)){
				print "\n" stringOf(dateAndTime(today)) ": Sending data data Failed"
				print "\n" res
	}
}
Regexp lines = regexp ".*"
bool connected = true
while(connected) {
	clear(args)
	put(args, "GET")
	put(args, "https://my.url.de/nextCommand")
	oleMethod(http, "open", args)
	oleMethod(http, "send")
	int status
	oleGet(http, "status", status)
	connected = status == 200
	string response
	oleGet(http, "responseText", response)
	print "RESPONSE:" response "\n"
	lines response
	string commandId = response[0:end 0]
	string resultUrl = "https://my.urld.de/rest/connections/107030b3-0a046c8d-7c2b9836-edaa752e/commands/" commandId "/result"
	string command = "pragma runLim,0\nstring resultUrl = \"" resultUrl "\"\n" response[end 0+2:]
	sendResult(commandId, eval_(command))
}

IBM Doors DXL: Send email via Doors Client

Problem

Emails should be send via DXL script.

Prerequirements

The Doors Client should have access to a SMTP Server on it’s configured port (normally 25)

Right-click the doors database icon in the database explorer and make the following setttings:

Solution

string smtpServer = getDatabaseMailServer();
string smtpFrom = "Superman";
string smtpFrom2 = getDatabaseMailServerAccount();
string smtpTo = "bjoern.karpenstein@test.com";
string smtpSubject = "test";
string smtpMessage = "this is a test";

print "Mail Server Name: " smtpServer "\n";
print "Mail from account: " smtpFrom2 "\n\n";
bool b = sendEMailNotification(smtpFrom, smtpTo, smtpSubject, smtpMessage);

if (b) {
   print "Message sent\n";
} else {
   print "Could not send message.\n";
}

IBM Doors DXL: Object creation

Create first object of module

// Get the current selected module
Module m = current;

// Create first object of module
Object firstObjectInModule = create(m);

Create hierarchically objects

// Create child object of firstObj
Object childObjOfFirst = create below(firstObj);

// Create last Object (this will generate an error
// if the object has no children present
Object lastChildObjOfFirst = create last(firstObj);

// Creates a new object on the same level as firstObj
Object newObjectOnSameLevel = create after(firstObj);

IBM Doors DXL: Object Selection

Current module selections

// Select the current Module
Module m = current; 

// Get first Object of Module
Object firstObject = first(m);

// Get last Object of Module
Object lastObject = last(m);


Selection on object children and parents (get parent / first / last child)

// Get current selected module (highlighted row in Module)
Object currObj = current

// Get first Child of the Object (which is below currObj - 
// i.e. whenn currObj is a Headline)
Object firstChild = first(currObj);

// Get last child of the objects below currObj
Object lastChild = last(currObj);

// Get the parent of currObj
Object parentObject = parent(currObj);

Selection of vertically arranged objects in the module (without considering the object hierarchy)

Object currObj = current;

// Select the previous object independent from the object hierarchy
Object previousObj = previous(lastChild);

// Select the next object independent from the object hierarchy
Object nextObj = next(lastChild);


Selection of siblings of the current object

Object currObj = current;

// Selection of the first sibling in the same hiararchy and hierarchy level
Object firstSibling = first sibling (currObj);

// Selection of the last sibling in the same hiararchy and hierarchy level
Object firstSibling = first sibling (currObj);

IBM Doors DXL: Recursively load formal module by name without knowing the path / Modul nach Name Laden (Folder bekannt)

Problem

A module should be loaded by name independend from the position in the Doors Project Structure.
Ein Modul soll nur anhand seines Namens geladen werden, ohne die genaue Position im Doors Projekt zu wissen.

Premise – Prerequirement – Voraussetzung

Start Folder is known. The doors module name is unique in the project, otherwise only the first found module with that name will be loaded.
Der Startordner ist bekannt. Der Doors Modulname ist im Projekt eindeutig. Ist dies nicht der Fall, wird nur das erste Modul mit diesem Namen geladen.

Lösung -Solution

Module getModule(Folder selectedFolder, string moduleNameToCompare)
{
 Item itm;
 Module moduleToReturn = null

 for itm in selectedFolder do 
 { 
  if(type(itm) "" == "Folder") 
  { 
   moduleToReturn = getModule(folder(itm), moduleNameToCompare);	
   if(moduleToReturn != null)
   {
    break
   } 
  } 
  else if(type(itm) "" == "Formal")
  {
   Module mod;		
   mod = edit(fullName(itm), false);
   if(!null mod)
   {
     if(name(mod) "" == moduleNameToCompare) 
     {  
      moduleToReturn = mod;
      objectFound = true
      break;
     }
   }
  }
  else if(type(itm) "" == "Link")
  {
  }
 }

 return moduleToReturn;
}

IBM Doors DXL: Error Handling / Exceptions: try/catch / On Error Goto … missing? Fehlerbehandlung in Doors / DXL Fehler unterdrücken

Problem

DXL windows are opening every time a DXL error occurs and the users are sick of it :-).
Es werden jedesmal DXL-Fenster angezeigt, wenn eine DXL Funktion nicht richtig ausgeführt wird.

Ansatz

Über die Funktionen
void noError()
string lastError()

lassen sich Fehlerbehandlungsroutinen erzeugen, die Ähnlich den JAVA-Exceptions und .NET-Errors sind.

Lösung-Solution

// Try-Block start
noError(); // Alle Fehler werden deaktiviert und die Ausgabe im DXL Fenster unterdrückt

// hier den Code hin, der Fehler werfen kann

string catchMsg=lastError(); // Beinhaltet den letzten Fehler zur Ausgabe

// catchMsg ist null wenn kein Fehler existierte
if(!null catchMsg)
{
   infoBox catchMsg;
   halt;
}

IBM Doors DXL: How to get the next major and minor baseline number in a copied module, that is not containing baselines

Problem

Copied modules do not have any baselines that can be read with the standard method getMostRecentBaseline(module m), although the last baseline number is copied. The method returns NULL when the module is copied because the baseline list in the module is empty, although the next major wouldn’t be 1.0 and the next minor wouldn’t be 0.1.

Example:

Ansatz – Approach

In this example a radioBox is populated with the next Major and next Minor Baseline number using the suffix(„“) method that returns a usable baseline instance for the use with the major- and minor function.

Solution – Lösung

pragma runLim, 0;

Module m=current;

DB mainDialog;
DBE radioBoxDBE;

string comboBoxAuswahl[2];
Baseline b = getMostRecentBaseline(m);

// Trick: Wenn b null ist probiere es nochmal 
// mit suffix("")
if(null b) b = suffix("");
		
// war keine Baseline vorhanden liefert major b und 
// minor b jew. 0 zurück
comboBoxAuswahl[0]= (major b) "." ((minor b)+1) "";
comboBoxAuswahl[1]= ((major b)+1) ".0";	

mainDialog = create("Baseline Change History");	
radioBoxDBE=radioBox (mainDialog, "Version", comboBoxAuswahl, -1);

realize(mainDialog);		
show(mainDialog);