General (#1) - Find only ? (#17) - Message List

Find only ?
 unsolved

Hi QVT-ers,

As part of a bigger QVT relations pattern I try to find certain classes in the target model and if found, relate them to other existing classes in that model. To do that I use a pattern like this:

transformation findMom (model : carel) {
key carel::Parent { name };
key carel::Child { name };
	top relation findOrphan {
		checkonly domain model orphan : carel::Child {
			name = 'Romy'
		};
		where {
			relateToMom (orphan, 'Mom');
		}
	}
	relation relateToMom {
		ns : String;
		checkonly domain model child : carel::Child {
			parent = ec : carel::Parent {
				name = ns
			}
		};
		primitive domain aaa : String ;
		when {
			aaa = ns;
		}
	}
}

To my surprise an Orphan class named 'Romy' is created even if it did not exist in the model. Shouldn't a checkonly domain never result in an automatic instantiation? What am i doing wrong?

Greetings,

-- Carel

  • Message #38

    Hi Carel,

    Note that "checkonly" has no influence on the transformation itself. Defining "checkonly" may generate some static warning message that some element could be created, but however think of it as if you have written "enforce".

    You have to define at least one source and one target direction. Using only one direction, it will be interpreted as target direction. The reason is because the QVT transformation needs at least one target direction. So this is a current restriction, which I guess is not difficult to overcome. So if you feel that a transformation should be possible without having a target direction, let me know and I will see how fast I can implement it.

    • Message #40

      Hi,

      I do not agree on the semantics of checkonly. In paragraph 7.2.3 of the QVT specification, it is clearly stated that checkonly *only* reports inconsistencies and does not enforce any missing elements.

      Interpreting the only direction as the target direction is OK. But even if my example is executed in this (only) target direction, the checkonly relations should not have any side-effects.

      Grtz,

      -- Carel

      • Message #41

        Hi Carel,

        Jörg's suggestion is a workaround for your problem: You should add a simple (senseless) additional domain to your transformation, which will be the target direction when execution the transformation. Since the execution demands (currently) to always define a target domain! Using an additional domain ensured that all your source domain models keep untouched!

        The checkonly mode - same as not defining any target domain - is currently not directly supported. We will check, what is necessary to enable it. (see ticket #12)

        But, we suggest to use OCL constraints for consistency checks directly! Thus, the ticket has a low priority.

        Best regards,

        Hajo

        • Message #42

          Hi Hajo and Jörg,

          Such a workaround will not work for me because I use the checkonly relations as part of a bigger transformation. This transformation translates a source model into a target model in which some classes are already present. My intention is to, based on the source model, create new classes in the target model that have relations to the existing classes in the target model. These classes can not be created by the pattern because they have attribute values that are not derived from the source model nor from the transformation pattern.

          So one transformation can have checkonly and enforce relations to the same (target) domain. In that case this is not a 'execution mode', but an attribute of a specific relation.

          Greetings,

          -- Carel

          • Message #43

            I think one solution is using three directions.

            transformation findMom (s1: carel, s2: carel, t2:carel ) {
            


            .. , where s1 is a "source direction" with the source model m1 as input, s2 is another "source direction" with the target model m2 as input and t2 is the "target direction" with the target model m2 as input.

            Next, "checking relations" in the target model can be coded that way:

            top relation findOrphan {
            		checkonly domain s2 orphan : carel::Child {
            			name = 'Romy'
            		};
            		where {
            			relateToMom (orphan, 'Mom');
            		}
            	}
            


            And "transforming relations" can be encoded that way:

            	top relation myRelation{
            		checkonly domain s1 orphan : carel::Child {
            			name = 'Romy'
            		};
            		checkonly domain t2 orphan : carel::Child {
            			name = 'Romy'
            		};
            	}
            





            The only drawback with this solution is currently: you can define only two directions in the launch configuration.
            However, do you agree that this would be a solution for your problem?

Attachments

No attachments created.