| Re: [m2m-dev] FW: Quality Assessment of QVTO Model Transformations |
From: m2m-dev-bounces@xxxxxxxxxxx [mailto:m2m-dev-bounces@xxxxxxxxxxx] On Behalf Of Phu H. Nguyen
Sent: Wednesday, September 22, 2010 19:16
To: M2M dev list
Subject: Re: [m2m-dev] FW: Quality Assessment of QVTO Model TransformationsHi Sergey,Yes, it is very easy to map the metamodels to the URIs via QVT Settings in Eclipse. However I am still not sure how to do it programmatically. I used EPackage.Registry as follows:static {class inputMMPackageImpl extends EPackageImpl {@Overrideprotected Resource createResource(String uri) {return super.createResource(uri);}}String inputNS_URI = "http:///BOOKS.ecore"; //$NON-NLS-1$inputMMPackageImpl qvtoPackage = new inputMMPackageImpl();qvtoPackage.setName("BOOKS"); //$NON-NLS-1$qvtoPackage.setNsPrefix("BOOKS"); //$NON-NLS-1$qvtoPackage.setNsURI(inputNS_URI); //$NON-NLS-1$qvtoPackage.createResource("file:///C:/temp/BOOKS.ecore");EPackage.Registry.INSTANCE.put(qvtoPackage.getNsURI(), qvtoPackage);}static {class outputMMPackageImpl extends EPackageImpl {@Overrideprotected Resource createResource(String uri) {return super.createResource(uri);}}String outputNS_URI = "http:///PUB.ecore"; //$NON-NLS-1$outputMMPackageImpl qvtoPackage = new outputMMPackageImpl();qvtoPackage.setName("PUB"); //$NON-NLS-1$qvtoPackage.setNsPrefix("PUB"); //$NON-NLS-1$qvtoPackage.setNsURI(outputNS_URI); //$NON-NLS-1$qvtoPackage.createResource("file:///C:/temp/PUB.ecore");EPackage.Registry.INSTANCE.put(qvtoPackage.getNsURI(), qvtoPackage);}InternalTransformationExecutor executor = new InternalTransformationExecutor(transformationURI, EPackage.Registry.INSTANCE);Diagnostic ERROR source=org.eclipse.m2m.qvt.oml.execution code=130 Compilation errors found in unit 'file:///C:/temp/SimpleBook2Publication.qvto' data="" [Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unknown type (Book) (at:12) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unknown type (Publication) (at:12) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unrecognized variable: (Book) (at:9) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Condition must be a TypeExp or Boolean! (at:9) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Cannot find operation (book2pub()) neither for the type (Set(Element)) nor for its element type (Element) (at:9) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Mapping operation expected (at:9) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unrecognized variable: (title) (at:13) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unrecognized variable: (title) (at:13) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unrecognized variable: (chapters) (at:14) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unrecognized variable: (nbPages) (at:14) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unrecognized variable: (chapters) (at:15) data="" Diagnostic ERROR source=file:///C:/temp/SimpleBook2Publication.qvto code=0 Unrecognized variable: (authors) (at:15) data="">Diagnostic diag = executor.loadTransformation();if (diag.getSeverity() == Diagnostic.ERROR || diag.getSeverity() == Diagnostic.CANCEL) {System.err.println(diag);return;}But there were still errors while compiling the qvto file:
I do not understand why type Book, Publication... still can not be recognized.Is there any better way to map the metamodels programmatically?Best regards,PhuOn Tue, Sep 21, 2010 at 8:53 PM, Sergey Boyko <Sergey.Boyko@xxxxxxxxxxx> wrote:
Hi Phu,Comments are in-lined below.Regards,Sergey
Sent: Tuesday, September 21, 2010 02:54
To: M2M dev list
Subject: Re: [m2m-dev] FW: Quality Assessment of QVTO Model TransformationsHi Sergey,
Thank you very much for your helpful example. So it is also quite convenient to save/load QVTo AST with full composition. I have been able to obtain the QVTo ASTs of tt1.qvto and tt4.qvto with full composition.
@ Ed Willink: I found out the reason why the QVTo AST I serialized before (qvtoAST.xmi) was not correct. It caused by the error - Failed to resolve metamodel 'file:///C:/temp/BOOK.ecore'.
I tried several ways to config the metamodel, i.e.:
modeltype BOOKS uses 'file:///C:/temp/BOOKS.ecore';
But it does not works. Could someone tell me what is wrong?The reason is that we allowed only .ecore model URI in metamodel definition.Usually it's "Ns URI" property of the model root package or package.uri element of the 'org.eclipse.emf.ecore.generated_package' extension point.In Eclipse workspace you can map arbitrary .ecore to some URI via "Project Properties/QVT Settings/Metamodel Mappings".Programmatically such arbitrary model can be specified using optional second parameter (of EPackage.Registry type) in InternalTransformationExecutor constructor.
Anyway, it is possible to serialize the QVTo AST. So, it is possible to extract metrics from QVTo model transformations to enable their quality measurement. We have got good results for ATL and Xtend. Hope that we can make it for QVTo soon. Thanks again for your kind helps.
Best regards,
PhuOn Mon, Sep 20, 2010 at 9:37 PM, Sergey Boyko <Sergey.Boyko@xxxxxxxxxxx> wrote:
Hi Phu,I've posted sample _javascript_ that shows how to save/load compiled qvto transformation (QVTo AST) with full information obtained from .qvto file (even token positions as well).Regards,Sergey
Sent: Monday, September 20, 2010 14:08
To: M2M dev list
Subject: Re: [m2m-dev] FW: Quality Assessment of QVTO Model TransformationsHello Ed Willink,Thank you. Now I know that it is not easy to obtain a QVTo AST with full composition. You are right about my problem. The serialized AST I got seems to be the wrong one. Please find the QVTo file and the corresponding xmi file in the attachmentsIs there any suggestion about obtaining a QVTo AST with full composition?Best regards,Phu
On Mon, Sep 20, 2010 at 10:56 AM, Ed Willink <ed@xxxxxxxxxxxxx> wrote:
Hi Phu
If you have a true QVTo AST then it should compose/share all the information you require.
When you invoke Resource.save to serialize, what is the URI in the XMI?
QVT 1.0 enabled at least three different interpreations of some AST definitions and in some cases all three were wrong with the result that not all child objects were composed and so those elements were omitted from a serialized AST. Perhaps your problem is that you do not have a QVTo AST with full composition.
Please post the XMI file resulting from Resource.save.
Regards
Ed Willink
On 20/09/2010 09:32, Phu H. Nguyen wrote:Hello,First I would like to thank for suggestions from Ed Willink and Sergey.I tried several ways and I have found out that it is possible to obtain AST of corresponding QVTo file by using the InternalTransformationExecutor:InternalTransformationExecutor executor = new InternalTransformationExecutor(transformationURI);CompiledUnit myCompiled = executor.getUnit();OperationalTransformation trans = executor.getTransformation();Resource res = trans.eResource();EObject qvtoModule = res.getContents().get(0);Via the OperationalTransformation object, generated AST can be accessed and it certainly conforms to the metamodels QVTOperational.ecore and ImperativeOCL.ecoreFor now it is possible to extract some information from the AST, i.e. names of modeltype, transformation, name of mapping operations. However I have not found out the way to access other parts, i.e. bodies of mapping operation. Are there any suggestions?Last but not least, it would be much better to access the AST if there is a way to serialize it. The ATL tool kit allows obtaining the file of ATL model (generated AST) quite easily. I was wondering if QVTO tool kit has a similar function?If you have any suggestions, please let me know. Thank you very much!Best regards,Phu
On Mon, Sep 13, 2010 at 11:25 PM, Sergey Boyko <Sergey.Boyko@xxxxxxxxxxx> wrote:
From: Sergey Boyko
Sent: Tuesday, September 14, 2010 01:24
To: 'nguyenhongphu@xxxxxxxxx'
Subject: RE: [m2m-dev] Quality Assessment of QVTO Model TransformationsHi Phu,QVTo engine is able to be launched outside Eclipse.This is described in our Wiki: http://wiki.eclipse.org/M2M/QVTO/New_and_Noteworthy/Helios#Enhancements_4Inside Eclipse you can obtain AST of corresponding .qvto by means of EMF Resource, i.e. some like follows:URI uri = URI.createURI("file:/.../my.qvto");
Resource res = new ResourceSetImpl().createResource(uri);
EObject qvtoModule = res.getContents().get(0);Generated AST is conformed to org.eclipse.m2m.qvt.oml/model/QVTOperational.ecore (for QVTOperational package) and org.eclipse.m2m.qvt.oml.ecore.imperativeocl/ImperativeOCL.ecore (for ImperativeOCL package). In fact that models have some (very minor) deviations from official OMG QVTO metamodels.Regards,Sergey
_______________________________________________
m2m-dev mailing list
m2m-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2m-devClick here to report this email as spam.
This message has been scanned for viruses by MailController.
_______________________________________________
m2m-dev mailing list
m2m-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2m-dev
_______________________________________________
m2m-dev mailing list
m2m-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2m-dev
Attachment:
tt4.qvto
Description: tt4.qvto
Attachment:
BOOKS.ecore
Description: BOOKS.ecore
Attachment:
PUB.ecore
Description: PUB.ecore
Attachment:
QvtoTransformationTest.java
Description: QvtoTransformationTest.java
Attachment:
tt1.qvto
Description: tt1.qvto