IBM Doors DXL: Delete and Create Attributes for Doors Module

Problem

An Attribute shall be deleted and replaced (recreated) by the same attribute with another type.

Approach

– Delete old attribute
– Create new one
– Views will not get lost with this method!

Solution

void deleteAttrDef(Module m, string s)
{
  string err;
  AttrDef ad = find(m, s);
  err = delete(ad);
  if (err !="") ack err;
} 

void modifyAttributeType(Module m, string theAttribute, string newAttributType)
{
  current = m;
	
  // Delete Attribute attribute1 if exists
  if (exists(attribute(string theAttribute))) 
  {	
    deleteAttrDef(m, theAttribute);
  }
	
  // Create new attribute1 of type TEXT (not string)
  AttrDef ad = create object type newAttributType attribute theAttribute
		
  if (null ad)
  {
    print "attr didn't create for module " fullName(m) "\n";
    halt;
  }			
}

modifyAttributeType(current Module, "My_Attribut_To_Change_Type", "Text");

IBM Doors DXL: Attribut eines verlinkten Objektes Ausgeben

Problem

Es soll eine LayoutDXL Spalte erzeugt werden, die ein Attribut aus einem verlinktem Requirement (Im V-Model z.B. obendrüber also hier Outlink) ausgibt.

Ansatz

* Öffnen des Moduls
* Nutzen der obj Referenz für das Objekt in der aktuellen Zeile
* Link Modul spezifizieren

Lösung

Module rsModule = read("/pathTo/RS", false);

Link lnk;
Object trg;
string lnkMod;
string strSat = "/pathToLinkModules/Satisfies";

for lnk in obj->"*" do 
{
  lnkMod= fullName module(lnk);
  
  if(!null lnkMod)
  {
	  if(lnkMod == strSat)
	  {
	      Object trg = target(lnk);
	      display trg."BB_PlannedRelease" "";
	  }
  }
}

IBM Doors DXL: Import from Sparx Systems Enterprise Architect

Problem

To refresh all UML Diagrams within an Formal Doors Module, a script is needed that imports all actual versions of a UML Diagram.

Approach

* Copy the GUID of the Diagram / Note
** right-click the project menu on the right side.
** Select „Copy Reference -> Copy Node GUID to clipboard“
* If not done before, create an Module attribute (here ATTRIBUT_WITH_GUID)
* Paste the GUID to the place in your doors module, where the diagram should be created

Solution

// Recommended as module plugin
/**
 * Run through all objects of the current module 
 * and watch for the attribute ATTRIBUT_WITH_GUID.
 * If it is not empty, fetch the diagram/note
 * from this attribute an load it into the 
 * Object Text of Sparx Systems Enterprise Architect
 */

Object o
Filter currentFilter, f
Module m
DB updateWin

string guid
string projectPath = "DP_ENTARCHITECT --- DBType=1;" //-
"Connect=Provider=SQLOLEDB.1;Integrated Security=SSPI;" //-
"Persist Security Info=False;Initial Catalog=DBNAME;" //-
"Data Source=EA_DB_SERVER"

OleAutoObj eaProject, eaRepository, diaObj, actObj
OleAutoArgs autoArgs = create
string diagramName, elementNotes

void establishInterface()
{
 eaProject = oleGetAutoObject("EA.Project")
 if(null(eaProject))
 { 
   eaProject = oleCreateAutoObject("EA.Project")
 }

 if(null(eaProject))
 {
   ack "Creating OLE-Object 'EA.Project' not possible."
   progressStop
   halt
 }

 eaRepository = oleGetAutoObject("EA.Project")

 if(null(eaRepository))
 {
   eaRepository = oleCreateAutoObject("EA.Repository")
 }

 if(null(eaRepository))
 {
   ack "Creating OLE-Object 'EA.Repository' not possible."
  progressStop
  halt
 }

 put(autoArgs,projectPath)
 oleMethod(eaRepository,"OpenFile",autoArgs)
 clear(autoArgs)
}

void closeInterface()
{
  oleMethod(eaRepository,"CloseFile",autoArgs)
  oleMethod(eaRepository,"Exit",autoArgs)
	
  delete(autoArgs)
}

void updateObjects()
{
 int progessbarStep = 0
 bool diagramCopied
 string fileName

 for o in m do
 {
  guid = o."BB_ImageFileName"
  diagramCopied = false
	
  if(guid != "" && guid[0:0] == "{")
  {
   progressMessage("Updating " identifier(o))
   put(autoArgs, guid)
		
   /**************************************************
    * Gets a pointer to a diagram using an absolute 
    * reference number (local ID). This is usually 
    * found using the DiagramID property of an 
    * element, and stored for later use to open a diagram 
    * without using the 
    * collection GetAt() function.
    **************************************************/
    oleMethod(eaRepository, "GetDiagramByGuid", autoArgs, diaObj)
		
    /*************************************************
     * An Element is the main modeling unit. 
     * It corresponds to (for example) a Class, 
     * Use Case, Node or Component. 
     * You create new elements by adding to the 
     * Package Elements collection. 
     * Once you have created an element, you can add it
     * to the DiagramObject 
     * Class of a diagram to include it in the diagram.
     ****************************************************/
     oleMethod(eaRepository, "GetElementByGuid", autoArgs, actObj)
     clear(autoArgs)
		
     // Wenn das Diagramm mit der GUID nicht gefunden wurde
     if(null(diaObj))
     {
      // ... und auch kein Element mit der GUID gefunden wurde
      if(null(actObj))
      {
         ack "GUID " guid " of object " identifier(o) "" //-
            " not found in EA as diagram or element."
      }
      else
      {
        // Es wurde kein Diagramm, aber ein Element 
        // mit der GUID gefunden
        oleGet(actObj, "Notes", elementNotes)
        if(null(elementNotes))
        {
          ack "Getting Notes of GUID " guid " failed."
        }
        else
        {
	 o."Object Text" = elementNotes
	 progressStep(++progessbarStep)
        }
      }
    }
    else // Es wurde ein Diagramm mit der GUID gefunden
    {					
      /***************************************************
       *  EA.Project.PutDiagramImageOnClipboard: 
       *  ======================================
       *  Copies an image of the specified diagram to the 
       *  clipboard.
       *	
       *  Parameters:
       *	•	DiagramGUID: String - the GUID 
       *        (in XML format) 
       *        of the diagram 
       *        to copy
       *	•	Type: Long - the file type
       *		•	If Type = 0 then it is a metafile
       *		•	If Type = 1 then it is a Device 
       *            Independent Bitmap
       *
       *****************************************************/
       put(autoArgs, guid)
       put(autoArgs, 0)				
       oleMethod(eaProject, "PutDiagramImageOnClipboard", autoArgs, 
	             diagramCopied)
       clear(autoArgs)
		
       if(diagramCopied)
       {
         while(oleDelete(o));
         if(olePaste(o))					
         {
	       oleSetMaxWidth(o."Object Text", 400)
	        progressStep(++progessbarStep)
         }
         else
         {
	       ack "Pasting from clipboard of GUID " guid " failed."
         }
       }
       else
       {
         ack "Copying to clipboard of GUID " guid " failed."
       }
     }
	 diaObj = null
     actObj = null
   }
  }
}

void main(DB updateWin)
{
  int accepted, rejected

  currentFilter = current	
  f = contains(attribute("ATTRIBUT_WITH_GUID"),"{", false)
  set(m, f, accepted, rejected)
  unApplyFiltering(m)
  progressStart(updateWin, "Executing update", "Processing...", accepted)
  establishInterface()
  updateObjects()
  if(!null(currentFilter)) set(m, currentFilter, accepted, rejected)
  closeInterface()
  progressStop
  refresh(m)
  hide(updateWin)
  destroy(updateWin)
  updateWin = null
}

m = current
if(null(m))
{
  ack "Update can only be started within a module."
}
else
{
 if(isEdit(m))
 {
   updateWin = create("Update EA ", styleCentered|styleFloating)
   label(updateWin, "Do you wish to update?")
   ok(updateWin, main)
   show updateWin
 }
 else
 {
  ack "Module must be opend in 'Exclusive Edit'."
 }
}