【问题标题】:(DOORS/DXL) Modification of objects without open module(DOORS/DXL) 在没有打开模块的情况下修改对象
【发布时间】:2018-08-24 07:39:44
【问题描述】:

我正在处理一个包含或多或少 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"

有没有办法在不打开所有模块的情况下进行相同的修改?

谢谢。

【问题讨论】:

    标签: ibm-doors


    【解决方案1】:

    “for m 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"
    

    另外,请注意您的“for o in entire m do”循环(引自 DXL 参考手册):

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

    你确定这是你想要的吗?

    【讨论】:

    • 这是我的最佳解决方案。
    【解决方案2】:

    要修改对象,您必须打开模块。在这种情况下,我将专注于在检查模块后关闭模块以最小化内存负载。

    /*
    ** 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"
    

    如果你看上面,我补充说:

        Module close_mod = m
        close ( close_mod )
    

    在 for m in proj 循环中。如果您运行 close(m),则 DXL 循环将在下次尝试分配“m”变量时抛出错误。所以你最终不得不声明一个单独的模块句柄并关闭它。

    这应该使您的记忆更易于管理。我也会考虑通过 'eval_' 语句运行整个事情,但这可能不是必需的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      相关资源
      最近更新 更多