(DOORS / DXL)无需打开模块即可修改对象

时间:2018-08-24 07:39:44

标签: ibm-doors

我正在一个项目中,该项目包含大约50个模块和数千个模块对象。

我需要在每个模块的某些对象上修改“从父继承”字段。

我发现这样做的一种方法是打开每个模块并运行我执行的以下dxl脚本……显然,打开所有模块是一种疯狂的解决方案!!!

/*
** Set_Inherit_Attribute_FALSE ***
Remove flag from the attribute "Inherit from Parent"
on each object of each module of the project
*/

// Variable definition
Object o
Module m
string serr
// file name provided by DOORS containing the results
string filename = tempFileName
print "FILE CONTAINING RESULTS -  " filename "\n"
// open file in write mode
Stream outputLog = write filename
// Set current project
Project prj = current Project
print "PROJECT - "(name prj) "\n"
outputLog << "-------------------- PROJECT " (name prj) " --------------------\n\n"

//  Management of each module in the project
for m in prj do {
    // write in outputLog the MODULE name
    outputLog << "\n**************** MODULE " (name m) " ****************\n"
    // set the "inherited" to false
    for o in entire m do {
        // The "Inherited" has to be updated just for NOT LEAF object
        if (!leaf(o)){
            // write in outputLog the obj id modified
            outputLog << "OBJ ID " (identifier o) "\n"
            serr = specific(o)
            // Check if the set of "inherited" failed
            if (!null serr){
                // inform the user and stop the execution
                outputLog << "OBJECT ERROR"
                ack "ERROR INHERITED"
                // close outputLog
                close outputLog
                halt
            }
        }
    }

    // save modificiation on module m
    save m
}
// close outputLog
close outputLog
// Inform the user the execution is ended
ack "EXECTUTION COMPLETED"

是否可以在不打开所有模块的情况下进行相同的修改?

谢谢。

2 个答案:

答案 0 :(得分:1)

循环“ for do in prj do”将仅对您先前在DOORS图形用户界面中手动打开的模块起作用。

为解决这个问题,我对代码的修改(如下)遍历每个项目中的所有(文件夹,项目,正式和链接模块),并打开它自己找到的所有正式模块。在处理后关闭模块以释放内存很重要,因此我的修改也可以做到这一点。

/*
** Set_Inherit_Attribute_FALSE ***
Remove flag from the attribute "Inherit from Parent"
on each object of each module of the project
*/

// Variable definition
Item   i
Object o
Module m
string serr
// file name provided by DOORS containing the results
string filename = tempFileName
print "FILE CONTAINING RESULTS -  " filename "\n"
// open file in write mode
Stream outputLog = write filename
// Set current project
Project prj = current Project
print "PROJECT - "(name prj) "\n"
outputLog << "-------------------- PROJECT " (name prj) " --------------------\n\n"

//  Management of each module in the project
for i in prj do {
    if (type(i) == "Formal")
    {
        m = edit(fullName(i), false)
        // write in outputLog the MODULE name
        outputLog << "\n**************** MODULE " (name m) " ****************\n"
        // set the "inherited" to false
        for o in entire m do {
            // The "Inherited" has to be updated just for NOT LEAF object
            if (!leaf(o)){
                // write in outputLog the obj id modified
                outputLog << "OBJ ID " (identifier o) "\n"
                serr = specific(o)
                // Check if the set of "inherited" failed
                if (!null serr){
                    // inform the user and stop the execution
                    outputLog << "OBJECT ERROR: " serr 
                    ack "ERROR INHERITED"
                    // close outputLog
                    close outputLog
                    halt
                }
            }
        }
        // save modificiation on module m
        save(m)
        close(m)
    }
}

// close outputLog
close outputLog
// Inform the user the execution is ended
ack "EXECUTION COMPLETED"

另外,请注意,您的“整个m时间内为o”循环(引自DXL参考手册):

  

将变量o分配为模块中的每个后续对象,而不管其删除状态或当前显示集如何。它包括表和行标题对象以及单元格。

确定要这样做吗?

答案 1 :(得分:0)

要修改对象,必须打开模块。在这种情况下,我将集中精力在检查模块以最小化内存负载之后关闭它们。

def search_forward(searchList, key):
    for i, element in enumerate(searchList):
        if key in element:
            return i
    raise ValueError

def search_backward(searchList, key, start):
    for i in range(start - 1, -1, -1):
        if key in searchList[i]:
            return i
    raise ValueError

searchList = [['apple'], ['a criterion for'], 
['what Im looking for'], ['a criterion for what Im looking for   not what Im looking for'], 
['fish'], ['coffee'], ['oil']]

coffee_index = search_forward(searchList, 'coffee')
a_criterion_for_index = search_backward(searchList, 'a criterion for', coffee_index - 1)
saveInformation = searchList[a_criterion_for_index + 1]
print(saveInformation)

如果您在上方看,我添加了:

/*
** Set_Inherit_Attribute_FALSE ***
Remove flag from the attribute "Inherit from Parent"
on each object of each module of the project
*/

// Variable definition
Object o
Module m
string serr
// file name provided by DOORS containing the results
string filename = tempFileName
print "FILE CONTAINING RESULTS -  " filename "\n"
// open file in write mode
Stream outputLog = write filename
// Set current project
Project prj = current Project
print "PROJECT - "(name prj) "\n"
outputLog << "-------------------- PROJECT " (name prj) " --------------------\n\n"

//  Management of each module in the project
for m in prj do {
    // write in outputLog the MODULE name
    outputLog << "\n**************** MODULE " (name m) " ****************\n"
    // set the "inherited" to false
    for o in entire m do {
        // The "Inherited" has to be updated just for NOT LEAF object
        if (!leaf(o)){
            // write in outputLog the obj id modified
            outputLog << "OBJ ID " (identifier o) "\n"
            serr = specific(o)
            // Check if the set of "inherited" failed
            if (!null serr){
                // inform the user and stop the execution
                outputLog << "OBJECT ERROR"
                ack "ERROR INHERITED"
                // close outputLog
                close outputLog
                halt
            }
        }
    }

    // save modificiation on module m
    save m
    Module close_mod = m
    close ( close_mod )
}
// close outputLog
close outputLog
// Inform the user the execution is ended
ack "EXECTUTION COMPLETED"
在proj循环中的for m内的

。如果运行close(m),则DXL循环在下一次尝试分配'm'变量时将引发错误。因此,您最终不得不声明一个单独的模块句柄,然后针对该句柄运行。

这应该使您的内存更易于管理。我还考虑通过'eval_'语句运行整个程序,但这可能不是必需的。