SCHEMA QUERY

You can use this operator to introspect a Data Model.

This page discusses:

See Also
Expression Language
Defining and Managing Data Queries

Configuration

The configuration requires:

  • The schema you want to introspect.
  • The element type you want to stream. For example, a class definition or an attribute definition. For more information, see Attribute Definition.
  • The variable name.
  • A potential predicate to filter returned elements.

Output

This operator has one output that streams multiple elements. The element type depends on the configuration. The output stream is not ordered.

Element Types

The SCHEMA QUERY operator can stream 6 different element types.

Type Description
Class Definition The class definition represents the definition of a class. For example:
class Person {
    name: String
    age: Integer
}
With this element type, the operator streams all class definitions in your Data Model, using the Item<schema.ClassDefinition>.
Attribute Definition The attribute definition represents the definition of a reusable attribute. For example:
attribute Age : Integer {
    @Positive
}
With this element type, the operator streams all attribute definitions in your Data Model, using the Item<schema.AttributeDefinition>.
Attribute An attribute represents a class attribute. For example:
class Person {
    name: String // <-- a class attribute
    age: Integer // <-- another class attribute
}
With this element type, the operator streams all annotation definitions in your Data Model, using the Item<schema.AnnotationDefintion>.
Class definition Annotation and Attribute Annotation An annotation represents an annotation instance linked to a class or an attribute. For example:
class Person {
    @AnAnnotation // <-- annotation instance linked to a class definition

    name: String
    age: Integer {
        @DefaultValue(value: 12) // <-- annotation instance linked to an attribute         
    }
}
If you choose class definition annotation or attribute annotation, the operator streams all annotations, either linked to a class definition or to an attribute in your Data Model, using the Item<schema.Annotation>.

Example

To get all class definitions with a numerical attribute, you need two operators:

  • SCHEMA QUERY of Attribute with the predicate
    attribute->parentAttributes.anyMatch((attr) -> attr.fqName =
          "core.Integer")
  • MAP attribute->declarationClass