Bug 475278 - [QVTm2QVTp] Primitive variables get lost.
Summary: [QVTm2QVTp] Primitive variables get lost.
Status: NEW
Alias: None
Product: QVTd
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-18 12:11 EDT by Ed Willink CLA
Modified: 2015-08-18 12:54 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2015-08-18 12:11:37 EDT
Using OCL master at M1 (commit 25c512430e5adee1015e45437504857245dcfbdd)
QVTd master (commit a655cb8f8e644db288f8fc436a6bdb541f692cdb)


/org.eclipse.qvtd.build.etl.tests/bin/org/eclipse/qvtd/build/etl/tests/UmlToRdbms/UmlToRdbms.qvtm.qvtcas

map attributeColumns in umlRdbms
{
	enforce rdbms(t : Table
	|) {
		realize c : Column
	|
		c.owner := t;
	}

	where(c2t : SimpleUMLtoRDBMS::ClassToTable,
		p2n : SimpleUMLtoRDBMS::PrimitiveToName
	|
		c2t.table = t;) {
		ct : String := p2n.typeName,
		realize a2c : SimpleUMLtoRDBMS::AttributeToColumn
	|
		a2c.column := c;
		default a2c.owner := c2t;
		a2c.type := p2n;
		c.type := ct;
		c.name := a2c.name;
		c.kind := a2c.kind;
		c2t.fromAttributes.leafs->includes(a2c);
	}
}

gives in /org.eclipse.qvtd.build.etl.tests/bin/org/eclipse/qvtd/build/etl/tests/UmlToRdbms/UmlToRdbms.qvtp.qvtias

map attributeColumns_MR in umlRdbms
{
	enforce rdbms(t : Table) {
		realize c : Column
	}
	check middle(c2t : ClassToTable,
		p2n : PrimitiveToName,
		a2c : AttributeToColumn) {}
	where (c2t.table = t;
		c2t.fromAttributes.leafs->includes(a2c);
		a2c.type = p2n;
		a2c.owner = c2t;) {
		c.type := ct;
		a2c.column := c;
		c.name := a2c.name;
		c.kind := a2c.kind;
		c.owner := t;
	}
}

for "ct" is undefined. Copying it across as a middle bottom variable solves the problem.

	where (
		c2t.table = t;
		c2t.fromAttributes.leafs->includes(a2c);
		a2c.type = p2n;
		a2c.owner = c2t;) {
		ct : String := p2n.typeName
	|
		c.type := ct;
		a2c.column := c;
		c.name := a2c.name;
		c.kind := a2c.kind;
		c.owner := t;
	}

Similarly:

map booleanToBoolean in umlRdbms refines primitiveToName
{
	check uml(p : Package
	|) {
		prim : PrimitiveDataType
	|
		prim.name = 'Boolean';
		prim.namespace = p;
	}
	enforce rdbms() {
		sqlType : String := 'BOOLEAN'
	|}

	where(p2s : SimpleUMLtoRDBMS::PackageToSchema
	|
		p2s.umlPackage = p;) {
		realize p2n : SimpleUMLtoRDBMS::BooleanToBoolean
	|
		p2n.owner := p2s;
		p2n.primitive := prim;
		p2n.typeName := sqlType;
		p2n.name := prim.name + '2' + 'BOOLEAN';
	}
}

leads to

map booleanToBoolean_MR in umlRdbms
{
	enforce rdbms() {}
	check middle(p2s : PackageToSchema,
		p2n : BooleanToBoolean) {}
	where (p2n.owner = p2s;) {
		p2n.typeName := sqlType;
	}
}

in which sqlType is undefined. Once again a middle bottom variable solves the problem.

map booleanToBoolean_MR in umlRdbms
{
	enforce rdbms() {}
	check middle(p2s : PackageToSchema,
		p2n : BooleanToBoolean) {}
	where (p2n.owner = p2s;) {
		sqlType : String := 'BOOLEAN'
	|
		p2n.typeName := sqlType;
	}
}

In both cases an alternative solution is to inline the primitive variable, which avoids the need for a primitive domain.
Comment 1 Ed Willink CLA 2015-08-18 12:54:06 EDT
I think that the variable has actually been preserved but it has been put in the source bottom rather than middle bottom area.