|
Re: QVTO- creating RDBMS view from UML PIM [message #479492 is a reply to message #478760] |
Tue, 11 August 2009 10:25 |
Sergey Boyko Messages: 171 Registered: July 2009 |
Senior Member |
|
|
Hi Omran ,
See some replies in-line, below.
Regards,
Sergey
Omran wrote:
> Dear All,
> I want to create a view in RDBMS PSM; I looked to class2table mapping
> and tried to do some thing similare but i found the following
>
> 1-rdm metmodel view has the following
> attributes(name,columns,ddl,referencedTablesAndViews)but the
> pim.simpluml source model has only the following properties for its
> classes(abstract,name,stereotype);
You listed only EAttribute-based properties. There are also
EReference-based properties (attributes, generalizations, taggedValue)
in SimpleUML classes.
> "How can we make pim.simppleuml has new properties such as ddl to map
> to rdb target metamodel??"
You can copy SimpleUML.ecore and rdb.ecore into workspace. When copied
these models can be referenced from Simpleuml_To_Rdb.qvto script as
descripbed in
http://www.eclipse.org/newsportal/article.php?id=4592&gr oup=eclipse.modeling.m2m#4592
After that you can change these workspace metamodels using for example
Ecore editor. All modifications made to them (after model saving) will
be immediately available in QVTo script.
> "what are the chnages that we have to do in rdb metamodel and simpuml
> metamodel if needed???"
>
> 2-I made a simple try to create a view by addin a class "myview" with
> stereotype "view" then updating Simpleuml_To_Rdb.qvto using the code
> below; but the view has not been created(WITH NO errORS);
>
> mapping UML::Class::viewClass2viewtable() : RDB::view::View
> when { self.isview() }
> {
> name := self.name;
> columns := self.map class2vcolumns(self) ->sortedBy(name);
> ddl := "aaaaa";
> referencedTablesAndViews := null;
>
> }
>
>
> mapping UML::Class::class2vcolumns(targetClass: UML::Class) :
> OrderedSet(RDB::view::ViewColumn) {
> init {
> result := self.map dataType2columns(targetClass)->
> union(self.map
> generalizations2columns(targetClass))->asOrderedSet()
> }
> }
>
>
> query UML::ModelElement::isview() : Boolean {
> return self.stereotype->includes('view')
> }
There's some inconsistent type checking in QVTo. Main problem is that
mapping dataType2columns() returns collection of type RDB::TableColumn
while mapping class2viewColumns() declares result to be collection of
type RDB::view::ViewColumn.
I'll file that bug.
However in any case you can't reuse existing mappings (since they are
results in collections of type RDB::TableColumn) and provide your own
mappings for type RDB::view::ViewColumn.
It may look like follows:
mapping UML::Class::class2vcolumns(targetClass: UML::Class) :
OrderedSet(RDB::view::ViewColumn) {
init {
result := self.map generalizations2viewColumns(targetClass)->
union(self.attributes->collect(i|object
RDB::view::ReferencedViewColumn{name := i.name})->asSet())->asOrderedSet()
}
}
mapping UML::Class::generalizations2viewColumns(targetClass :
UML::Class) : OrderedSet(RDB::view::ViewColumn) {
init {
result := self.generalizations.general->map
class2vcolumns(targetClass)->flatten()->asOrderedSet();
}
}
>
>
> Any help is highly appreciated
>
> regards,
> Omran
|
|
|
Powered by
FUDForum. Page generated in 0.03467 seconds