How to Identify a View With an Invalid Filter Rule Before Loading It

Hi everyone,
Does anyone know of a way to identify a view with invalid filter rules before programmatically loading the view?
Thanks!
-Bob3
SystemAdmin - Thu Mar 14 00:28:11 EDT 2013

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
SystemAdmin - Thu Mar 14 19:39:18 EDT 2013

Another way to approach the question is to ask:
Is there a way to access the filter saved in a view without actually loading the view?
For example, something along the lines of getViewDescription(ViewDef vd), which can be accessed without loading the view.

For the record, invalid filer rules cause a DOORS dialog to appear and halt DXL processing. An invalid filter rule becomes an issue when it is saved in a view and that view is loaded. Invalid filter rules are filters that depend on a particular attribute to be present that is no longer present.

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
llandale - Fri Mar 15 12:37:36 EDT 2013

I don't know of any way. You may need to override the native "warningBox" or "errorBox" or "messageBox" functions, using "print". Good luck with that.

I doubt it would work, but try loading the view in batch mode and see if you can detect any errors.

-Louie

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
SystemAdmin - Sat Mar 16 11:02:59 EDT 2013

In a script it may be a good solution to load the script in the standard view and then to create the view. Then you will geht the error message by creating an invalid column or an invalid filter?

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
llandale - Sat Mar 16 13:55:29 EDT 2013

SystemAdmin - Sat Mar 16 11:02:59 EDT 2013
In a script it may be a good solution to load the script in the standard view and then to create the view. Then you will geht the error message by creating an invalid column or an invalid filter?

If you save the view with a filter for attribute A, then delete attribute A, then the saved view's filter is now invalid and will generate errors when you load it.

I wonder if it possible to SAVE a view with an invalid "Filter", such as define a "Filter" for attribute A in module 2, and somehow save that filter in module 1 (that lacks attribute A).

-Louie

Back to the original problem; I wonder how the "Manage Views" dialog works; it sure seems to get at view information without loading the various views.

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
SystemAdmin - Mon Mar 18 00:33:20 EDT 2013

llandale - Fri Mar 15 12:37:36 EDT 2013
I don't know of any way. You may need to override the native "warningBox" or "errorBox" or "messageBox" functions, using "print". Good luck with that.

I doubt it would work, but try loading the view in batch mode and see if you can detect any errors.

-Louie

Thanks for the ideas, gentlemen!

llandale, I don't believe DOORS lets views be loaded in batch mode. I gave it a try, however, and confirmed the views won't load using "load(m, v)" unless the module is visible. Can you explain more about what you mean by overriding the native box functions using print()?

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
llandale - Mon Mar 18 10:58:10 EDT 2013

SystemAdmin - Mon Mar 18 00:33:20 EDT 2013
Thanks for the ideas, gentlemen!

llandale, I don't believe DOORS lets views be loaded in batch mode. I gave it a try, however, and confirmed the views won't load using "load(m, v)" unless the module is visible. Can you explain more about what you mean by overriding the native box functions using print()?

warningBox("This is the native warningBox")
 
void    warningBox(string Message)
{  print "warningBox override: " Message "\n"
}
 
warningBox("This is overridden")

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
SystemAdmin - Mon Mar 18 14:26:55 EDT 2013

llandale - Mon Mar 18 10:58:10 EDT 2013

warningBox("This is the native warningBox")
 
void    warningBox(string Message)
{  print "warningBox override: " Message "\n"
}
 
warningBox("This is overridden")

Interesting technique, llandale! Thanks for the explanation.

I tried this warningBox override approach but the "DOORS Report" dialog still appeared when I programmatically loaded the view with an invalid filter rule. I noticed that the dialog title for a truly DXL-generated "warning box" was simply "DOORS," whereas the dialog that is produced when loading a view with an invalid filter rule is "DOORS Report," which leads me to believe they are different types of dialogs.

Thanks again for all the helpful ideas... let me know if you have any other thoughts!

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
llandale - Mon Mar 18 17:23:40 EDT 2013

SystemAdmin - Mon Mar 18 14:26:55 EDT 2013
Interesting technique, llandale! Thanks for the explanation.

I tried this warningBox override approach but the "DOORS Report" dialog still appeared when I programmatically loaded the view with an invalid filter rule. I noticed that the dialog title for a truly DXL-generated "warning box" was simply "DOORS," whereas the dialog that is produced when loading a view with an invalid filter rule is "DOORS Report," which leads me to believe they are different types of dialogs.

Thanks again for all the helpful ideas... let me know if you have any other thoughts!

Yup could not reproduce it. Could not trap it either; neither with eval_ nor noError/lastError. Sorry.

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
Tony_Goodman - Tue Mar 19 07:02:53 EDT 2013

llandale - Mon Mar 18 17:23:40 EDT 2013
Yup could not reproduce it. Could not trap it either; neither with eval_ nor noError/lastError. Sorry.

The following is a cunning way to look for bad filters in views.
I am afraid that the bad views cannot be fixed without loading the view, but this will tell you where to look.

This script relies on the following assumptions:
When a module is opened, the default view is loaded. This is true even when the module is not visible.
When a view with a bad filter is loaded then the filtering property is set to true, but the filter itself is null.
 

// Check module for bad filters in views
 
/*
   Tony Goodman.
*/
 
Skip viewNames = createString
 
/******************************************************************************
    checkModuleForBadFilters
******************************************************************************/
string checkModuleForBadFilters(string modName)
{
        Module m = null
        Filter f = null
        string vn = ""
        string defViewUser    = ""
        
        m = read(modName, false)
        
        if (null m) return("Error opening module")
        
        // get the user's default view - we need to restore this later
        defViewUser = getDefaultViewForUser(m)
        
        // get list of views
        for vn in views(m) do
        {
                put(viewNames, vn, vn)
        }
        
        
        // set each view as default in turn and re-open the module
        for vn in viewNames do
        {
                print("Checking view \"" vn "\"\n")
                
                setDefaultViewForUser(m, vn)
                
                close(m)
                
                m = read(modName, false)
                
                // if filtering is ON, but the filter is null, then we have found a bad filter
                if (filtering(m))
                {
                        f = current
                        
                        if (null f)
                        {
                                print("**** View \"" vn "\" contains a bad filter\n")
                        }
                }
        }
        
        
        // reset the user's default view (if there was one)
        if (!null defViewUser)
        {
                setDefaultViewForUser(m, defViewUser)
        }
        
        return("")
}
 
string res = checkModuleForBadFilters("/AMG/RPE Test")
print(res)

 


Tony Goodman, www.smartdxl.com

 

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
llandale - Tue Mar 19 13:58:24 EDT 2013

Tony_Goodman - Tue Mar 19 07:02:53 EDT 2013

The following is a cunning way to look for bad filters in views.
I am afraid that the bad views cannot be fixed without loading the view, but this will tell you where to look.

This script relies on the following assumptions:
When a module is opened, the default view is loaded. This is true even when the module is not visible.
When a view with a bad filter is loaded then the filtering property is set to true, but the filter itself is null.
 

// Check module for bad filters in views
 
/*
   Tony Goodman.
*/
 
Skip viewNames = createString
 
/******************************************************************************
    checkModuleForBadFilters
******************************************************************************/
string checkModuleForBadFilters(string modName)
{
        Module m = null
        Filter f = null
        string vn = ""
        string defViewUser    = ""
        
        m = read(modName, false)
        
        if (null m) return("Error opening module")
        
        // get the user's default view - we need to restore this later
        defViewUser = getDefaultViewForUser(m)
        
        // get list of views
        for vn in views(m) do
        {
                put(viewNames, vn, vn)
        }
        
        
        // set each view as default in turn and re-open the module
        for vn in viewNames do
        {
                print("Checking view \"" vn "\"\n")
                
                setDefaultViewForUser(m, vn)
                
                close(m)
                
                m = read(modName, false)
                
                // if filtering is ON, but the filter is null, then we have found a bad filter
                if (filtering(m))
                {
                        f = current
                        
                        if (null f)
                        {
                                print("**** View \"" vn "\" contains a bad filter\n")
                        }
                }
        }
        
        
        // reset the user's default view (if there was one)
        if (!null defViewUser)
        {
                setDefaultViewForUser(m, defViewUser)
        }
        
        return("")
}
 
string res = checkModuleForBadFilters("/AMG/RPE Test")
print(res)

 


Tony Goodman, www.smartdxl.com

 

Great minds think alike. So do ours.
https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14776304&#14776304

I don't think you need to close the module and re-load it; issuing the "read" when it's aleady open is sufficient. However, you may need to turn filtering off first in order to use your "the filtering property is set to true, but the filter itself is null" algorithm. I didn't try it, but trapping with noError/lastError the "read" may also suffice.

-Louie

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
JSRowland - Thu Jan 05 16:27:06 EST 2017

From what I can tell, Tony's algorithm no longer works in the latest version of DOORS if the filter was defined with multiple rules and at least one is still applicable. The offending rule is removed from the filter, but the current Filter, rather than being null, still contains any valid rules. 

From some fiddling around, I do not believe that applying an invalid filter will put anything useful in lastError() either. I could really use a way to run through my database and look for bad views, but I am out of ideas.

Re: How to Identify a View With an Invalid Filter Rule Before Loading It
Bob3 - Sun Sep 17 23:14:44 EDT 2017

I can confirm that Tony's approach no longer works with DOORS 9.6.1.9 because his second assumption is no longer true: "When a view with a bad filter is loaded then the filtering property is set to true, but the filter itself is null."

When a view with a bad filter is loaded, the filtering property is not set to true. Tony, any new ideas on this subject?