🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
Qualified associations

Design Advanced UI with live data, Qualified Links now available, Wednesday with MDriven 2025 Feb

Qualified Associations in MDriven

Qualified associations in MDriven simplify access to multi-value associations by reducing them to a single result using qualifiers. This feature, part of the OCL standard, enhances model navigation and data retrieval in MDriven.

Understanding Qualified Associations

In MDriven, qualified associations let you access a specific element from a multi-value association using a qualifier. The syntax is:

SomeObject.SomeManyObjectsAssociation[someQualifier1, someQualifier2]

This expression returns a single object of the type associated with the many-end, filtered by the provided qualifiers.

Implementing Qualified Associations

To implement a qualified association, define a method named Qualify_<SomeManyObjectsAssociation> with qualifiers as parameters. For example:

Qualify_ThingWithQualifyTest(someQualifier: String): Thing

Within this method, use EAL or C# to define the logic for selecting the appropriate object. Here's an example using EAL:

self.ThingWithQualifyTest->select(a | a.Attribute1 = someQualifier)->first

Mark your Qualify_ method as a query by setting IsQuery=true if you intend to use the qualifier operator in OCL.

Using Qualified Associations

Qualified associations can be used throughout your application, including the UI, to streamline access to specific elements without manually filtering collections in OCL expressions. This feature aligns with the UML standard, ensuring consistency in model-driven development.

Default Implementations

MDriven provides a default implementation for qualified associations. If no custom method is defined, a generic operator that accepts an integer as a qualifier is used. This operator functions similarly to the at0 operator, allowing access to elements by their index in the collection.

Compatibility with Associations

Qualified associations work with both persisted and transient associations, offering flexibility in navigating and accessing associations. This makes them a valuable tool for developers working with complex models.

Qualified associations enhance data access and improve the efficiency of model-driven development in MDriven. By leveraging this feature, developers can create more intuitive and maintainable applications.

Source

Based on the MDriven video Design Advanced UI with live data, Qualified Links now available, Wednesday with MDriven 2025 Feb.