Filter istype drops elements that carry user metadata (table export)

Versions: Syside 0.11.0 (syside-modeler, build 18800c5), sensmetry-syside-views 0.11.0, macOS.

Summary: In syside-modeler table export, a view filter filter istype SysML::RequirementUsage excludes requirement usages that carry a prefix metadata annotation (#Tag requirement …). This happens even when the metadata def is plain, with no base type. Untagged requirements pass the same filter. Per SysML v2, istype in a filter tests the element’s own metaclass, so both requirements should be selected. The tagged element is exposed correctly: it appears when the filter is removed. Exposing it explicitly by name gives “no rows”.

Repro (syside-modeler check passes):
package IstypeFilterRepro {
private import SysideViews::TableViewDefinitions::*;

metadata def Tag;

requirement def Requirements {
    requirement <'R1'> untagged;
    #Tag requirement <'R2'> tagged;
}

view def RequirementTable specializes TableView {
    attribute redefines includeReferenceElements = true;
    view id subsets columnViews {
        attribute redefines featureRepresentation = Representation::declaredShortName;
    }
    view requirementName subsets columnViews {
        attribute redefines featureRepresentation = Representation::declaredName;
    }
}

view withoutFilter defined by RequirementTable {
    expose Requirements::**;
}

view withIstypeFilter defined by RequirementTable {
    expose Requirements::**;
    filter istype SysML::RequirementUsage;
}

}

Expected withIstypeFilter: rows R1 untagged and R2 tagged.
Actual: only R1 untagged. withoutFilter lists R2 tagged, so the element is exposed and only the filter drops it.

Impact: a common pattern breaks: classifying elements with semantic metadata and selecting them by metaclass, for example requirements tagged as needs in a requirements table. Combining a metaclass filter with metadata filters (istype X and @Tag) is affected the same way.

Hi Hugo,

That is expected according to the semantics of SysMLv2. isType says that all types on the element must match RequirementUsage, but an attached metadata has a type of MetadataUsage, which means the #Tag requirement no longer matches.

To fix this, you need to first cast the element to the type you want, by using (as SysML::RequirementUsage). If the element that is being evaluated is a plain RequirementUsage, it passes the filter. If the element has any metadata on it, it “drops” them during evaluation and passes through it. Other elements that have completely unrelated types, do not pass the cast, and thus the filter.

Thus, if you rewrite your withIsTypeFilter to have the following, it will work as you expect (as shown in the screenshot): filter (as SysML::RequirementUsage) istype SysML::RequirementUsage;

We have this behaviour documented in our documentation with a table showing how each filter syntax works on a small example, as quite a lot of people get caught out by it.

Kind regards,
Simonas

I noticed you also tried or want to achieve istype RequirementUsage and @Tag to only show R2. This is also possible with the following filter: (as SysML::RequirementUsage) istype SysML::RequirementUsage and @Tag:

Hi Simonas,
Thank you very much, it works perfectly now!