Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
7 replies Latest Post - ‏2014-03-24T18:09:57Z by llandale
CMusicFan
CMusicFan
17 Posts
ACCEPTED ANSWER

Pinned topic How to save an arbitrary filter to a view?

‏2014-03-21T13:57:36Z |

Greetings! Although I have been working with dxl for some time, this is my first post on this site.

I need to be able to define a filter in dxl that can show/hide objects based on the Object Number. More specifically, the dxl code needs to create the 4 views described below:

- Document View: A view which displays all objects

- Volume 1: A view which displays only objects whose object numbers begin with 1,2 or 3.

- Volume 2: A view which displays only objects whose object numbers do NOT begin with 1,2 or 3.

- DD View: A view which displays only objects whose object numbers begin with 4 and only display objects with heading text

I have attempted to do this by creating an arbitrary filter using the accept and reject functions, And it seems like it works. the filter displays properly at first, but when I leave the view I have just created to go to a different view, the filter settings disappear and do not reappear after I go back to it. My code for Volume 1 view is displayed below. The other views function in a similar fashion.

// Create the view
create_view("Volume 1", attributeNames, columnNames, widths)

// Enable saved filter settings for views
View v = view "Volume 1"
useFiltering(get(v), true)

// Declare the filter for volume 1 and display it
Regexp LessThan4 = regexp2 "^[123]"
filtering on
for o in SDDModule do
{
    // If the first digit of the current object number is less than 4, accept it as part of the filter
        if (LessThan4 number(o))
        {
                accept o
        }
        else
        {
                reject o
        }
}

refresh current
save v

Is this the correct way to do what I am trying to do? If not, what is? If so, what am I missing?

Thanks!

Updated on 2014-03-21T13:59:21Z at 2014-03-21T13:59:21Z by CMusicFan
  • Pekka_Makinen
    Pekka_Makinen
    15 Posts
    ACCEPTED ANSWER

    Re: How to save an arbitrary filter to a view?

    ‏2014-03-21T14:55:50Z  in response to CMusicFan

    You can not save a filter created with accept/reject into a view. How about if you tried to filter based on the Object Number?

    • CMusicFan
      CMusicFan
      17 Posts
      ACCEPTED ANSWER

      Re: How to save an arbitrary filter to a view?

      ‏2014-03-21T15:00:08Z  in response to Pekka_Makinen

      That's what I would really like to do, but for some reason DOORS does not allow you to filter on that attribute. It is considered "virtual" so you can only access it via the number() function. If you know of a way to get around this, please let me know because that would solve my problem!

  • llandale
    llandale
    2943 Posts
    ACCEPTED ANSWER

    Re: How to save an arbitrary filter to a view?

    ‏2014-03-21T16:04:20Z  in response to CMusicFan

    Yes, accept/reject filters do not save in views.

    In this case I think you can define a filter such that "Object Number" is

    • less than 4
    • greater than or equal to 4
    • greater than or equal to 4 AND less than 5 AND not null Object Heading

    For your general problem, such as if your "accept" and 'reject" is rather complicated, you can create an Attribute DXL that does the calculation and display some meaningful result, then perform a natural filter based on the value of the attr-DXL.

    -Louie

    • CMusicFan
      CMusicFan
      17 Posts
      ACCEPTED ANSWER

      Re: How to save an arbitrary filter to a view?

      ‏2014-03-21T16:19:46Z  in response to llandale

      As I said before, you CANNOT create a filter based on the "Object Number" attribute. DOORS WILL NOT LET YOU. It is considered a "virtual" attribute, so if you try to create a filter with it DOORS says that it doesn't recognize that attribute. The only way to create such a filter that I have found is to use accept/reject. I know that you can create such a filter using the GUI, so it seems like there should be a way to do it from a dxl script.

      As for your suggestion regarding attribute dxl, I appreciate the general solution, but I don't think this is a workable solution for the modules I am working with.

      I suppose I could create a whole new attribute that does nothing but reflect the object number, and then I could filter on that. If there is no other option then I may have to do just that, but we are talking about a module with 60k+ objects in it. it takes awhile to save a value to an attribute for each and every one of those objects. I would like to think there is a better way to accomplish what I am trying to do, but I have not been able to find it.

      • llandale
        llandale
        2943 Posts
        ACCEPTED ANSWER

        Re: How to save an arbitrary filter to a view?

        ‏2014-03-21T19:43:02Z  in response to CMusicFan

        Well, you can use "Object Number" for a Filter using the GUI as I described.

        This works in DXL

        • string NameAttr = "Object Number"
        • print name(current Module) "\n"
        • filtering off
        • set(attribute NameAttr > "1.2")
        • filtering on

        -Louie

        Updated on 2014-03-21T19:43:14Z at 2014-03-21T19:43:14Z by llandale
        • CMusicFan
          CMusicFan
          17 Posts
          ACCEPTED ANSWER

          Re: How to save an arbitrary filter to a view?

          ‏2014-03-21T20:10:36Z  in response to llandale

          My apologies for my skepticism! It works perfectly! For some reason, every time I have tried to do what you described above, I got an error from doors. maybe it has something to do with saving the attribute name as a string first, but whenever I tried this:

          filtering off

          set(attribute "Object Number" > 1.2)

          filtering on

          It would refuse to work, claiming the "Object number" was not an attribute. Well, it works now so I'm content. Thank you very much!

          • llandale
            llandale
            2943 Posts
            ACCEPTED ANSWER

            Re: How to save an arbitrary filter to a view?

            ‏2014-03-24T18:09:57Z  in response to CMusicFan

            This also works:

            • filtering off
            • set(attribute "Object Number" > "1.2")
            • filtering on

            "Object number" is not an attribute; but it works with a capital "N".  I think you misspelled it.

            -Louie