Mapping of classes N to 1 [message #1704230] |
Sun, 09 August 2015 11:01 |
Abhishek Kappattanavar Messages: 4 Registered: August 2015 |
Junior Member |
|
|
Hello,
I am still new to QVTo and learning.
I am trying to transform a model SRC to DST.
Description of the mapping:
The attributes from SRC:Block are being mapped to the DST:Blocks, DST:Diagram and DST:Props
While trying to map SRC class 'Block' to DST classes Blocks I have tried to constructors and intermediate classes (I have attached the ecore diagrams). However, I am getting errors while doing so. Kindly help.
The code I tried:
-- Declaration with a condition: the instance may differ from the metamodel,
-- but should have exactly one Project object. Location specific reference.
modeltype SRC uses "com.example.src" where
{ self.objectsOfType(Model)->size() = 1 };
-- Strict declaration, using a package namespace URI
modeltype DST "strict" uses "com.example.dst";
transformation SRCTransformation(in Source: SRC, out Target: DST);
main() {
Source.rootObjects()[Model] -> map ModelToSciMod();
}
constructor Props::Props (id:String,val: String) { Id:=id; Value:=val; }
mapping Model::ModelToSciMod(): SciMod {
Name := self.Name;
Version := "4.4";
-- objects:=self.newEReference ->new(x) Props(x.id, P()) ;
var s := self.newEReference ->map ObjToSys();
}
mapping Systems::ObjToSys(): Objects {
blocks:=self.blocks -> map BlkToBlk();
links:=self.links -> map LnToLn();
}
--constructor Props::Props (id:String,val: String) { Id:=id; Value:=val; }
constructor Diagram::Diagram (d:Props) { P:=d }
constructor Graphs::Graphs (att:Sequence(Props)) { }
mapping Block:: BlkToBlk(): Blocks {
Name:=self.Name;
var type:= self.BlockType;
var sid:= self.SID;
var ports:=self.Ports;
var prop1:= new Props("BlockType", type);
var prop2:= new Props("SID", sid);
var prop3:= new Props("Ports", ports);
var di := new Diagram(prop1) ;
dia:=intermediateDia -> map BlkToDia() ; -- ERROR showing here
}
intermediate class IntermediateBlk2 {
vars: OrderedSet(Block);
}
intermediate class IntermediateDia {
vars: OrderedSet(Block);
}
intermediate property IntermediateBlk2::intermediateDia :IntermediateDia ;
intermediate property IntermediateDia::intermediateP :Block ;
mapping IntermediateBlk2:: BlkToDia(): Diagram {
intermediateP
}
mapping Line:: LnToLn(): Links {
}
Kindly help.
Also, kindly let me know if there are any tutorials/reference documents explaining the keywords.
Thank you,
Abhishek
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04610 seconds