can't extract module's Version DXL IBM DOORS - ibm-doors

I'm working on a DXL program in Doors which supposed to output to a csv file all of source module, target, linkset and version of each (source/target) modules. I've succeed to output "source module, target, linkset but I couldn't extract the version of modules. Does anyone know how to do it ?
Here is my code bellow:

The following uses an output file which is in C:\Temp, but you can easily change that.
it works by matching modules using a grep string, again which you can change to suit.
I have different module types, and therefore I can just get the results on the prefix 'STR' in this case. I decided to have multiple scripts for different prefix modules, rather than dynamically pass the STR keyword.
You need to enter your folder and subfolders for the "modPathname"
then adjust the Regexp "GrepString" to suit your naming convention
alternatively you can bypass all this by hardcoding the values.
string filename = "C:\\TEMP\\STR_Baseline_Info.txt"
Stream outFile = write filename
string Modtype = "STR"
void PrintAndOutput ( string s)
{
// print (s) // Enable if you want output
outFile << s
}
void DisplayResults( string Modtype )
{
Item modItem
Module mName
Regexp GrepString = regexp2 "^" Modtype "-[0-8][0-9][0-9]"
Folder modPathname = folder "/EnterYourFolderHere/AnySubFolders/" Modtype ""
string fullModuleName , CommentStr , moduleName
Baseline b
PrintAndOutput "------------------------------------------------------------------------------\n"
CommentStr = "This File is automatically produced via the " Modtype " Baseline Info.dxl script. \n" Modtype " Versions as of : " dateAndTime(today) "\n"
PrintAndOutput CommentStr
PrintAndOutput "-------------------------------------------------------------------------------\n\n"
for modItem in modPathname do
{
if (type (modItem ) == "Formal")
{
moduleName = (name modItem)
if (GrepString moduleName)
{
fullModuleName = (fullName(modItem))
mName = read(fullName modItem , false)
b= getMostRecentBaseline (mName)
if (b != null )
{
PrintAndOutput moduleName " -\tBaseline : "(major b)"."(minor b)(suffix b) " \t " (dateOf b) "\n"
}
else
{
PrintAndOutput moduleName " \t### No Baseline Information ### \t" " \n"
}
}
}
}
}
DisplayResults ( Modtype)

Related

Checking if a String container any of a set of Symbols in Dart

I would like to check if a string contains any of the following symbols ^ $ * . [ ] { } ( ) ? - " ! # # % & / \ , > < ' : ; | _ ~ ` + =
I tried using the following
string.contains(RegExp(r'[^$*.[]{}()?-"!##%&/\,><:;_~`+=]'))
But that does not seem to do anything. I am also not able to add the ' symbol.
Questions:
How do I check if a string contains any one of a set of symbols?
How do I add the ' symbol in my regex collection?
When writing such a RegExp pattern, you should escape the special symbols (if you want to search specifically by them).
Also, to add the ' to the RegExp, there is no straightforward way, but you could use String concatenation to work around this.
This is what the final result could look like:
void main() {
final regExp = RegExp(
r'[\^$*.\[\]{}()?\-"!##%&/\,><:;_~`+=' // <-- Notice the escaped symbols
"'" // <-- ' is added to the expression
']'
);
final string1 = 'abc';
final string2 = 'abc[';
final string3 = "'";
print(string1.contains(regExp)); // false
print(string2.contains(regExp)); // true
print(string3.contains(regExp)); // true
}
To ad both ' an " to the same string literal, you can use a multiline (triple-quoted) string.
string.contains(RegExp(r'''[^$*.[\]{}()?\-"'!##%&/\\,><:;_~`+=]'''))
You also need to escape characters which have meaning inside a RegExp character class (], - and \ in particular).
Another approach is to create a set of character codes, and check if the string's characters are in that set:
var chars = r'''^$*.[]{}()?-"'!##%&/\,><:;_~`+=''';
var charSet = {...chars.codeUnits};
var containsSpecialChar = string.codeUnits.any(charSet.contains);

DXL error not undestood :DXL: <D:\XXXX.dxl:1234> Un module en cours est requis pour lopération => US traduction = operation requires a current module

I have following error message :
DEBUG: isBaseline(spec_produit) = true -R-E- DXL: <D:\XXXX.dxl:1234> Un module en cours est requis pour lopération
US traduction = operation requires a current module
line 1234 is the following : print "DEBUG: baseline loaded for " name(module_in_database) " = " major(baseline_open) "." minor(baseline_open) suffix(baseline_open) "\n"
With : baseline_open = baselineInfo(module_in_database) (=true)
I don't understand why I have this message as I already use this kind of coding elsewhere with success.
Here I have the message in a loop that I use to detect if I have still open module after having close all open modules (I don't know why I still have open module but it is another subject)
the loop is :
// display list of open module at then end of the script
for module_in_database in database do
{
logResult = logResult "INFO: open modules at the end the script are " fullName(module_in_database) "\n"
// display more information on open modules : (DEBUG) :
print "DEBUG: isBaseline(" name(module_in_database) ") = " isBaseline(module_in_database) "\n"
baseline_open = baselineInfo(module_in_database)
if (baseline_open != null) {
print "DEBUG: baseline loaded for" name(module_in_database) " = " major(baseline_open) "." minor(baseline_open) suffix(baseline_open) "\n"
} else {
print "DEBUG: " name(module_in_database) " = CURRENT \n"
}
}
Version 1:
Module module_in_database
Baseline baseline_open
string logResult = ""
// display list of open module at then end of the script
for module_in_database in database do
{
logResult = logResult "INFO: open modules at the end the script are " fullName(module_in_database) "\n"
if type (module_in_database) == "Formal" then {
// display more information on open modules : (DEBUG) :
print "DEBUG: isBaseline(" name(module_in_database) ") = " isBaseline(module_in_database) "\n"
baseline_open = baselineInfo(module_in_database)
if (baseline_open != null) {
current = module_in_database // <------ set current module so that the next line works!
print "DEBUG: baseline loaded for" name(module_in_database) " = " major(baseline_open) "." minor(baseline_open) suffix(baseline_open) "\n"
} else {
print "DEBUG: " name(module_in_database) " = CURRENT \n"
}
} else {
print fullName(module_in_database) " is a Link Module. No baselineInfo available\n"
}
}
Version 2:
Module module_in_database
Baseline baseline_open
string logResult = ""
ModuleVersion mv
string version_string
// display list of open module at then end of the script
for module_in_database in database do
{
logResult = logResult "INFO: open modules at the end the script are " fullName(module_in_database) "\n"
if type (module_in_database) == "Formal" then {
// display more information on open modules : (DEBUG) :
print "DEBUG: isBaseline(" name(module_in_database) ") = " isBaseline(module_in_database) "\n"
mv = moduleVersion (module_in_database)
version_string = versionString (mv) // <---- don't use "major" and "minor", instead use version_string, which does not require a "current" module
if (version_string != "") {
print "DEBUG: baseline loaded for" name(module_in_database) " = " version_string "\n"
} else {
print "DEBUG: " name(module_in_database) " = CURRENT \n"
}
} else {
print fullName(module_in_database) " is a Link Module. No baselineInfo available\n"
}
}
P.S: Having read through our thread again, I think that the misunderstanding stems from DOORS' inconsistency when naming things. a "current version" is a Module which is not a baseline. A "current module" in DOORS-speak is a module version that is "the one '''module''' that the user currently interacts with". When you have opened five windows with modules (either current version or baselines or link modules), only one of these windows is at the front - only one of these windows catches your keyboard input - and that window contains the "current" Module. If you have a one-liner like print fullName (current Module) and you open the database explorer (main window), click on Tools->Edit DXL… and paste the code, it will complain that no Module is current. if you then click on one window and in this window click on Tools->Edit DXL…, you will get the SAME DXL window, but now the code will run, because now DOORS knows which Module is the one that you mean when you say fullName (current Module).
Unfortunately, that's still not correctly said: the current Module is not directly related to the window at the front - you might even have opened Modules invisibly. And using DXL you can say "this invisible Module is the current one" although there is a window at the front showing a different Module.
It's complicated but I hope that I explained it correctly now.
Strange.
I have been able to run the script with the following declarations
Module module_in_database
Baseline baseline_open
string logResult = ""
and I got the expected results.
I remember some problems with perms that expect a current module even though they shouldn't.
Perhaps you just need to add some lines to your loop
if type (module_in_database) == "Formal" then {
current = module_in_database
} else {
continue
}
but still, that should not be necessary

checking an object in a nested link via dxl

I have the following situation.
I want to count in Module 1, how many objects are having links in links from Module 3.
example:
Module 1 Obj1 <- Module 2 Obj1 <- Module 3.Obj1
Module 1 Obj2 <- Module 2 Obj1 <- Module 3.Obj1
Module 1 Obj3 <- Module 2 Obj1 <- Module 3.Obj1
Module 1 Obj4 <- Module 2 Obj1
Module 1 Obj5 <- Module 2 Obj1
The count should return 3, in the above case.
Is it possible via DXL to follow a link, and then follow another link?
(not using the Wizard or DXL attributes)
Most important for me: knowing if somebody else did this and it's possible to do.
Please try the following DXL from within the module that has the incoming links. Before running the code:
make sure that you open the 'Edit DXL' window from the relevant module
set the string values assigned to global constant STR_LINK_MOD_FULLNAME (line 17) to the full pathname of the link module whose links you are interested in
set the string values assigned to global constant STR_SRC_MOD_FULLNAME (line 18) to the full pathname of the source formal module (Module 3, in your example) whose links you are interested in
You shouldn't need to change anything else to make it work.
N.B. I have not considered the implications of analysing links in all link modules by using the string "*" in place of a specific link module name in line 17 (see point 2, above).
I also haven't gone out of my way to explain the code, though I have tried to be nice and tidy up after myself where DOORS and DXL require it. Please feel free to reply with any questions on what I have done.
Kind regards,
Richard
//<CheckObjectInNestedLink.dxl>
/*
*/
///////////////
// Sanity check
if (null (current Module))
{
print "ERROR: this script must be run from a Formal Module."
}
///////////////////
// Global Constants
const string STR_LINK_MOD_FULLNAME = "/New Family Car Project/Admin/Satisfies" // the fullName of a single link module - results of using "*" have not been considered/tested
const string STR_SRC_MOD_FULLNAME = "/New Family Car Project/Architecture/Architectural Design" // The fullName of the desired source Formal Module
///////////////////
// Global Variables
Module modSource = null
Object objTarget = null
Object objSource = null
Link lkIn = null
Skip skLinkedMods = create()
Skip skObjsWithDesiredSource = create()
int intNoOfLinked = 0
//////////////////////
// Auxiliary Functions
void closeSourceMods ()
{
Module srcMod
for srcMod in skLinkedMods do
{
close(srcMod)
}
}
void openSourceMods (Object objWithLinks)
{
ModName_ srcModRef
Module srcMod
for srcModRef in (objWithLinks <- STR_LINK_MOD_FULLNAME) do
{
srcMod = read(fullName(srcModRef), false)
put(skLinkedMods, srcMod, srcMod)
}
}
void recurseFollowInLinks (Object objWithLinks)
{
openSourceMods(objWithLinks)
for lkIn in objWithLinks <- STR_LINK_MOD_FULLNAME do
{
openSourceMods(objWithLinks)
objSource = source(lkIn)
string strSrcModName = fullName(module(objSource))
if (strSrcModName == STR_SRC_MOD_FULLNAME)
{
bool blNewEntry = put(skObjsWithDesiredSource, objTarget, objTarget)
if (blNewEntry)
{
intNoOfLinked++
}
//print "put(skObjsWithDesiredSource, " identifier(objTarget) ", " identifier(objTarget) ")\n"
}
recurseFollowInLinks(objSource)
}
}
void checkObjectInNestedLink (Module modThis, string strSourceModuleFullname, string strLinkModuleFullName)
{
intNoOfLinked = 0
for objTarget in modThis do
{
recurseFollowInLinks(objTarget)
}
print "The following " intNoOfLinked " objects have direct or indirect links of type " STR_LINK_MOD_FULLNAME " from formal module " STR_SRC_MOD_FULLNAME ":\n"
for objTarget in skObjsWithDesiredSource do
{
print identifier(objTarget)
print "\n"
}
}
///////////////
// Main Program
checkObjectInNestedLink ((current Module), STR_SRC_MOD_FULLNAME, STR_LINK_MOD_FULLNAME)
closeSourceMods()
delete(skLinkedMods)
delete(skObjsWithDesiredSource)

DXL in batch mode

I am facing issues with running DXL in batch mode
doors: assertion failed, line 3173, document.cpp: !nls_("unexpected: tree root does not have a name attribute") stack:
my batch file is as below
set arg1=%1
set arg2=%2
set arg1=%arg1:"=%
set arg2=%arg2:"=%
start "DOORS" "C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -d ABCD -u xxxxx -P xxxx -b "C:\\doNothing.dxl" -dxl "string s_ModListPath = \"%arg1%\";string CRNUM = \"%arg2%\";#include <C:\\Users\\ObjectsList.dxl>"
I run this batch file from command line by passing arguments as below
C:\Users\ObjectsCmnd.bat C:\\TEMP\\ModulesSelected.txt 12345
Please suggest me what wrong I am doing and why I am getting the error
OBjectList.dxl
pragma encoding, "UTF-8"
pragma runLim,0
Buffer b_ModPath
string s_ModPath
string s_Log = "C:\\TEMP\\ObjectList.txt"
string s_OutPutLog = "C:\\TEMP\\MDPRLog.txt"
Object o
bool b1 = canOpenFile(s_ModListPath,false)
bool b2 = canOpenFile(s_Log,true)
bool b3 = canOpenFile(s_OutPutLog,true)
if(!b1)
{
print "cannot open file to read the module list \n"
}
if(!b2)
{
print "cannot open file to write the objectlist \n"
}
if(!b3)
{
print "cannot open file to write the MDPRlog under temp"
}
Stream st = read s_ModListPath
Stream Output = write s_Log
Stream Log = write s_OutPutLog
void fn_Main()
{
while(!end st)
{
b_ModPath = create
st >= b_ModPath
s_ModPath = stringOf(b_ModPath)
Module m = read(s_ModPath,false)
if(null m)
{
Log << "null module path " s_ModPath "\n"
continue
}
//noError()
current = m
if(!exists(attribute("Change_Request_ID")))
{
Log << "Attr Change_Request_ID doesnt exist in module " s_ModPath "\n"
continue
}
if(!null m)
{
//current = m
Filter CRObjects = contains(attribute "Change_Request_ID",CRNUM,false) && attribute "CC_Status" == "Frozen"
set (m, CRObjects, acceptedObjs, rejectedObjs)
filtering on
if (acceptedObjs <= 0)
{
Log << "No objects that contain CR and CC_Staus frozen \n"
}
for o in m do
{
Output << fullName(m) ";" identifier(o) "\n"
}
filtering off
}
else
{
Log << "Null module " s_ModPath "\n"
}
close m
}
delete b_ModPath
}
fn_Main()
Log << "-------- ObjectList Completed ------------- \n"
close st
close Log
close Output

Display exact Requirement IDs using dxl in Doors

i am parsing a requirement Module in Doors and i want to get the outlinked requirements so i did that :
Stream outfile= write("D:\\Users\\iiii\\" reportName ".txt")
outfile << "Spec Report Requirement IDs\n-----------------------------\n"
Object o
Module m = read(planSpecReportPath_inDoors)
Link outLink
ModName_ parentModName
for o in m do
{
for outLink in o -> "*" do
{
parentModName = target(outLink)
string h = fullName(parentModName) "\n\n"
outfile << h
}
}
however i ONLY get the linked requirement documents paths and can't get exact Req ID .
My question is if i want to get all outlinks to specific Requirement Module with Requirement IDs not just Requirement Document path , what shall i do , any help ?
you will need the perm
int targetAbsNo (Link)
So, in your example something like
parentModName = target(outLink)
int iTarget = targetAbsNo(outLink)
string h = fullName(parentModName) " (" iTarget ")" "\n\n"

Resources