QVT 1.0 NO IDEA Avatar
  1. OMG Issue

QVT — Relations language should support "default assignments"

  • Key: QVT-7
  • Legacy Issue Number: 10785
  • Status: closed  
  • Source: TCS ( Sreedhar Reddy)
  • Summary:

    Relations language should also support the 'default assignments' feature supported by
    the core language. This feature allows default values to be specified for the variables of
    an enforced target domain. Default assignments do not play a role in checking.

  • Reported: QVT 1.0b1 — Thu, 22 Feb 2007 05:00 GMT
  • Disposition: Resolved — QVT 1.0
  • Disposition Summary:

    Update the relations meta model in Fig 7.7 QVT Relation Package to add class 'RelationDomainAssignment'; class Assignment to have two associations to OclExpression - 'variable' and 'value'; class RelationDomain to have the association 'defaultAssignment' with class Assignment. Add the following text description in section 7.11.3.

    Add the following to the description of class RelationDomain.
    In bidirectional relations, sometimes it is not be possible to automatically compute the values required to enforce a relation in the reverse direction. This can be addressed by allowing a domain to specify default value assignments for its variables. The default assignments are executed only during enforcement and the values they assign must be capable of satisfying the relationship condition. Default assignments do not play a role in checking.

    Associations
    defaultAssignment : RelationDomainAssignment [0..*] Composes - the assignments that set default values for the variables of the domain that are required for its enforcement.

    Class RelationDomainAssignment
    A relation domain assignment sets the value of a domain variable by evaluating the associated expression in the context of a relation.

    Associations
    variable : Variable [1] - the variable being assigned
    valueExp : OclExpression [1] Composes - the expression that provides the value of the variable.

    Concrete syntax:
    Extend the production of <domain> with ['default_values' '

    {' (<assignmentExp>)+ '}

    ']
    <assignmentExp> ::= <identifier> '=' <OclExpressionCS> ';'

    The updated grammar is given in Appendix A of this report. This should replace the grammar given in section 7.13.

    Discussion:

    To see how this feature helps, let's consider the following bi-directional relation:

    top relation AttributeToColumn
    {
    n,utyp,rtyp : String;

    enforce domain uml
    a:Attribute

    { name = n, type = utyp }

    default_values

    { utyp = SqlToUmlDataType(rtyp); }

    ;

    enforce domain rdbms
    c:Column

    { name = n, dataType = rtyp }

    ;

    where

    { rtyp = UmlToSqlDataType(utyp); }

    }

    This relation uses a function in its where clause to compute a database type from an uml type. This works fine when the relation is enforced in the direction of 'rdbms'. It also works fine in 'checkonly' mode. However it does not work when the relation is enforced in the direction of 'uml' as the function 'UmlToSqlDataType' cannot be used to compute the uml type from the database type. We can solve this problem by using the default values section where we put an assignment that computes the required value for the uml domain.

  • Updated: Fri, 6 Mar 2015 20:53 GMT