Skip to content

Adding and accessing additional data to the input of a translation #1084

@SimonCockx

Description

@SimonCockx

See parent issue: #1077

When extending the input schema, a modeller may require to access additional information in an overridden function which did not exist in the original translation. An example: suppose we have an existing translation from Document.

type Document:
  tradeInformation TradeInformation (1..1)

func MapDocument:
  inputs:
    document Document (1..1)
  output:
    result Foo (1..1)
  
  set result:
    MapTradeInformation(document -> tradeInformation)

We decide to extend TradeInformation with a default currency.

type ExtendedTradeInformation extends TradeInformation:
  defaultCurrency CurrencyCode (1..1)

Now, if we want to access this property when extending the translation, we need a way to assert that the tradeInformation present in the passed document is indeed of type ExtendedTradeInformation. For this we introduce a new operation, as <type>, which allows us to access extended attributes:

(tradeInformation as ExtendedTradeInformation) -> defaultCurrency

In object oriented languages, this is often referred to as downcasting. Invalid casts result in empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsubject: code generationThis issue is about code generationsubject: model validationThis issue is about validation of Rosetta models, such as the type systemsubject: syntaxThis issue is about the syntax of Rosetta

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions