IBM Doors DXL: Useful incoming/outgoing Link-Loops and -iterations (inlinks / in-link / out-link / outlinks) and other Iterations through Doors collections

Loop all views in module

Module m=current;
string myView;

for myView in views m do 
{
   print myView "\n";
}

Example: Get all Filter Strings from all views in current Module

Module m=current;
string myView;

for myView in views m do 
{
   print myView "\t";
   View v=view(myView);
   load(m,v);
   Filter f=current;

   if(null f)
   {
	print "no filter\n"
   }
   else
   {
      string filterString=stringOf(m,f);
      print filterString "\n";
   }
}

Loop all attributes on module

Module m=current;
string attribute;
for attribute in m do {
	print attribute "\n";
}

Loop through all In-Links (with Baselines) of an Object

Object obj=current;

Link lnk;
LinkRef lnkRef;
ModName_ otherMod = null;
string linkModuleString;

// I.e. for different Projects with different
// Link-Module Locations
string projName = name(current Project);	
if(projName=="VarCo")
{
  // Links zu Change Request
  linkModuleString = "/VarCo/20 Sample Project/22 Links/Changes"; 
}
else
{
  // Links zu Change Request
  linkModuleString = "/Project/90 Administration/Changes"; 
}
	
int lnkCount=0;
	
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 
{
  // Get In-Link Object
  Object src = source lnk;
  if ( isDeleted(src) || null(src) ) continue;
	
  identifierCC =  identifier(src) "";
  lnkCount++;
}

Loop through out-links of an object


Object obj=current;

Link lnk;

for lnk in obj->"*" do
{
  string tmn=fullName target(lnk);

  if(!open module tmn)
  {
    read(tmn,false);
  }

  Object tgt = target(lnk);
  print identifier(tgt) "\n";
}

Loop through all (with baselines) out-links of an object

First Approach

Module baselineModul=current;                                         

string satisfiesModuleString = "/NDS/90 Administration/Satisfies";
int object_count=0;
int link_count=0;

Object blObject;    
for blObject in baselineModul do 
{
	// Laufe durch die gebaselinten Outlinks
	Link lnk;
	for lnk in all(blObject->satisfiesModuleString) do
	{
		ModuleVersion mvTarget=targetVersion(lnk);
		if(null data(mvTarget)) 
		{
			load(mvTarget,false);			
		}
		
		Object tgt=target(lnk);
		link_count++;
    }
	 
	 object_count++;
}

print "Link Count: " link_count "\nObject Count: "  object_count "";

Second Approach

Module baselineModul=current;

ModName_ otherMod=null;                                                

string satisfiesModuleString = "/NDS/90 Administration/Satisfies";
int object_count=0;
int link_count=0;

Object blObject;    
for blObject in baselineModul do 
{
    	
	// Laufe durch die gebaselinten Outlinks
	Link lnk;
	for lnk in all(blObject->satisfiesModuleString) do
	{
	  	string tmn=fullName target(lnk);
	  
	  	otherMod = module (targetVersion lnk);
	  	if (!null otherMod) 
	  	{
	   		if ((!isDeleted otherMod) &amp;&amp; (null data(targetVersion lnk))) 
			{
			
				load((targetVersion lnk),false);
			}
	  	}			  
	
	  	Object tgt = target(lnk);
	  	
	  	if(null tgt)
	  	{
		  	print "Is null das Teil!\n";
	  	}
	  	else
	  	{
		  	Baseline blI= baselineInfo(module tgt);
		  	print major(blI) " " minor (blI) "\n";
	  	}
	  	
  		link_count++;
	 }
	 
	 object_count++;
}

print "Link Count: " link_count "\nObject Count: "  object_count "";

Loop through all (with baselines) out-links without opening the target module

Object obj=current;

Link lnk;
for lnk in all(obj->"*") do
{
	ModuleVersion mvTarget=targetVersion(lnk);
	Baseline b = baseline(mvTarget);
	if(!null b)
      {
		// Wenn der Link nicht auf Current geht
		print major(b) "." minor(b) "\n";
      }
	print fullName(mvTarget) " " targetAbsNo(lnk) "\n";
}

Atlassian JIRA+MS SQL Server: Get selected custom field value for Issue from JIRA Database in SQL

Problem

A selected custom field value, that is in a MS SQL Server JIRA Database should be retrieved.

Ansatz – Approach

The tables project_key, jiraissue, CustomFieldValue, customfield and customfieldoption have to be joined

Lösung – Solution

SELECT pk.PROJECT_KEY+'-'+CAST(a.issuenum AS varchar(max)) as issue, c.cfname as field, d.customvalue 
FROM project_key pk
INNER JOIN jiraissue a ON pk.PROJECT_ID=a.PROJECT 
INNER JOIN CustomFieldValue b ON a.ID=b.ISSUE
INNER JOIN customfield c ON b.CUSTOMFIELD=c.id 
INNER JOIN customfieldoption d ON c.id=d.CUSTOMFIELD 
WHERE c.CFName = 'Requirements/Specifications affected?' 
AND   b.STRINGVALUE=CAST(d.id as varchar(max))

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

Problem

Es soll durch alle Module eines Ordners / Folders und deren Unterordner / Subfolders iteriert werden.
All modules of a folder in a project (not the project itself) shall be iterated:

Ansatz – Approach

Das Skript aus dem vorherigen Artikel „Iterate all modules“ wird um eine Rekursion erweitert
The script „Iterate all modules…“ will be extended with a recursive call.

Solution – Lösung

string startFolder="/Project/Folder/";
int moduleCount=0;

void forAllModulesInFolder(Folder f)
{
  Item itemRef;
  string shType;
  string sItemNameFull;
  string sItemName;
  Module moduleReference;

  for itemRef in f do
  {
    shType = type(itemRef);
    print shType "\t";

    sItemNameFull = fullName(itemRef);
    print sItemNameFull "\t";

    sItemName = name(itemRef);
    print sItemName "\n";

  if(shType=="Folder")
  {
    string selectedFolder = sItemNameFull;
    Folder f=folder selectedFolder;
    forAllModulesInFolder(f);
  }

  if(shType=="Formal")
  {
    moduleReference = read(sItemNameFull,false,true);
    filtering off;
    // do s.th. with the moduleReference
    close(moduleReference);
    moduleCount++;
  }
}

// Main-Method
void main(void)
{
  string selectedFolder = startFolder;
  Folder f=folder selectedFolder;
  forAllModulesInFolder(f);
  print "Affected Modules: " moduleCount "\n";
}

main();

Für das ganze Projekt siehe auch…
For the whole project also see…

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

IBM Doors DXL: get previous Baseline (not mostRecentBaseline) / vorherige Baseline ermitteln

Problem

Die Standardmethode gibt vom current die aktuelle Baseline zurück. Es soll aber die vorherige ermittelt warden.

Ansatz – Approach

Es wird durch die Baselines iteriert
Iterate through all baselines and get the previous (not the most recent) Baseline

Solution – Lösung

string getPreviousBaselineVersion(Module m)
{
	Baseline b;
	Module currentModule=current;
	int blCount=0;
	int minorVersion=0;
	int majorVersion=0;

	for b in currentModule do 
	{
		blCount++;
	}

	int bl2Count=0;
	for b in currentModule do 
	{
		if(bl2Count==blCount-2)
		{
		  minorVersion = (minor b);
		  majorVersion = (major b);
		}
		bl2Count++;
	}

	return majorVersion "." minorVersion "";	
}

print getPreviousBaselineVersion(current);

IBM Doors DXL: Remove all Triggers from a module

Problem

All triggers, that are on a module, shall be deleted.

Approach – Ansatz

  • Iterate trough all module triggers
  • Delete trigger by using trigger reference

Lösung – Solution

void removeAllTriggersOnModule(Module mod)
{
	Module oldCurrent = current;
	current=mod;
	
	  Trigger t;
	  for t in mod do 
	  {
		string triggerName=name(t) "";
		if( !matches("specific", triggerName) )
		{
			delete t;
		}
	  }
	
	current=oldCurrent;	
}

IBM Doors DXL: Check if Module/Object DataType or Attribute exists

Problem

The existence of DataTypes or Attributes shall be checked

Approach – Ansatz

  • The first function uses the find-function to check for attributes
  • The second uses a loop to check for datatypes

Solution – Lösung

bool attributeExists(Module tgt, string attributeName)
{
	AttrDef ad = find(tgt, attributeName) 
	
	if(null ad)
	{
		return false;
	}
	else
	{
		return true;
	}		
	return false;
}

// This example is done in a different way but works
// here for DataTypes (instead the find function can be used)
bool dataTypeExists(Module tgt, string dataTypeName)
{
	AttrType at;
	
	for at in tgt do 
	{
		if(at.name == dataTypeName)
		{
			return true;
		}
	}	
	
	return false;
}

IBM Doors DXL: Rename Module/Object DataType or Attribute

Problem

The name of a DataType or an attribute shall be changed.

Ansatz – Approach

The modify function can be used to rename the functions

Solution – Lösung

void renameDataType(Module mod, string oldString, string newString)
{
	AttrType at = find(mod, oldString);

	if(null at)
	{
		print(name(mod) ": RENAME-" oldString " existiert nicht";
	}
	string ErrMess = ""
	modify (at, newString, ErrMess)
}

void renameAttribute(Module mod, string oldString, string newString)
{
	AttrDef ad = find(mod, oldString);

	if(null ad)
	{
		print(name(mod) ": RENAME-" oldString " existiert nicht");
	}
	string ErrMess = "";
	AttrDef adNew = modify(ad, setName, newString) 
}

IBM Doors DXL: Rename/Replace Enumeration Value of a DataType – Enumerationswert ändern

Problem

An existing enumeration value should be renamed or replaced

Approach – Ansatz

We have to iterate through the Type-Array and repopulate new arrays, which will be used as parameters for the modify function

Solution – Lösung

//This program was intended to replace the values of an enumerated attribute
//The replace will not affect the current selected values, it will just change the value to the new one
 
pragma runLim, 0
 
void replaceAttributeTypeValue(Module m, string atName, string oldVal, string newVal){
    AttrType att = find(m, atName)
        //Declare Arrays Size
        int colores[att.size]
        int arrMap[att.size]
        string arr[att.size]
        int arrVal[att.size]
        
        int i
        //Populate Arrays
        for(i = 0; i < att.size; i++){ 
                arr[i] = att.strings[i]
                arrVal[i] = i
                colores[i] = -1
                arrMap[i] = i
        }
        //
        for(i = 0; i < sizeof(arr); i++){ 
                if(arr[i] == oldVal){
                        arr[i] = newVal
                }
        }
 
        string err = null
        AttrType at2 = modify(att, atName, arr, arrVal, colores, arrMap, err)
        if(!null err){
                print "Failed: " err"\n"
        }
        else{
                infoBox at2.name " - Modified Successfully"
        }
}

by Björn Karpenstein