Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Calling Java Code from QVTO 1.0.1
Calling Java Code from QVTO 1.0.1 [message #479644] Tue, 11 August 2009 20:29 Go to next message
mary is currently offline maryFriend
Messages: 22
Registered: July 2009
Junior Member
hello,

I am trying to call a java custom library from qvto.I followed the
instructions described in the following post :

http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg02375.html

Here is the steps i followed.
1. Created a plug-in with the java class which contain a public method
that i want to call from qvt

2. added the following metainfo method.
The function that i want to call from QVT has the following signature.
OclAny::getJP(String): Set(OclAny)

=============================
public static class Metainfo {
private static final String[] Get_JP = new String[] {
"OclAny", "String", "Set(OclAny)" };

public static String[] getJP(Object self,String oclExp)
{
return Get_JP;
}
}
=============================


3. Created an extention point in the plugin.xml file for
"org.eclipse.m2m.qvt.oml.ocl.emf.libraries" .and the metamodel set to UML
Here is a copy of the plugin.xml file:
=============================
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.m2m.qvt.oml.ocl.emf.libraries">
<library class="CheckOCLConstraint.getJP" id="CheckOCLConstraint.getJP">
<inMetamodel uri="http://www.eclipse.org/uml2/2.1.0/UML"/>
</library>
</extension>
</plugin>
=============================
However in the file it gives an error [unknown extension point
"org.eclipse.m2m.qvt.oml.ocl.emf.libraries"].
But i tried to ignore the error and export the plugin anyway.

4. exported the plug-in and deployed it .

5. from qvto code when i try to import the library it gives an error:
[cannot find imported module].

=============================
modeltype UML uses "http://www.eclipse.org/uml2/2.1.0/UML";
transformation Class(in a:UML,in b:UML,inout c:UML);
import CheckOCLConstraint.getJP;
=============================

Can someone please tell me how to fix this.
Re: Calling Java Code from QVTO 1.0.1 [message #479698 is a reply to message #479644] Wed, 12 August 2009 03:48 Go to previous messageGo to next message
mary is currently offline maryFriend
Messages: 22
Registered: July 2009
Junior Member
> 3. Created an extention point in the plugin.xml file for
> "org.eclipse.m2m.qvt.oml.ocl.emf.libraries" .and the metamodel set to UML
> Here is a copy of the plugin.xml file:
> =============================
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.4"?>
> <plugin>
> <extension point="org.eclipse.m2m.qvt.oml.ocl.emf.libraries">
> <library class="CheckOCLConstraint.getJP" id="CheckOCLConstraint.getJP">
> <inMetamodel uri="http://www.eclipse.org/uml2/2.1.0/UML"/>
> </library>
> </extension>
> </plugin>
> =============================
> However in the file it gives an error [unknown extension point
> "org.eclipse.m2m.qvt.oml.ocl.emf.libraries"].
> But i tried to ignore the error and export the plugin anyway.


For the extention point i solved the error.. instead of
having["org.eclipse.m2m.qvt.oml.ocl.emf.libraries"] I put
[org.eclipse.m2m.qvt.oml.ocl.libraries] and the error is gone.

However, still I cant access the library from qvt transformation..The
error is still [can not find imported module]

I 've looked in the web and tried a lot of examples. Like the
SampleLibrary example but yet it didn't work too..

I don't know what am I missing!! Any help Plz?

Thanks..
Re: Calling Java Code from QVTO 1.0.1 [message #479733 is a reply to message #479698] Wed, 12 August 2009 09:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Look in that post:
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg04540.html

Especially the described example wizard helps a lot.
Re: Calling Java Code from QVTO 1.0.1 [message #479798 is a reply to message #479698] Wed, 12 August 2009 14:31 Go to previous messageGo to next message
Sergey Boyko is currently offline Sergey BoykoFriend
Messages: 171
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040006040804040103080806
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi mary ,

You are using quite old version of QVTo. I advise you to switch on
recent 2.0.0 version (see
http://www.eclipse.org/modeling/m2m/downloads/index.php?proj ect=qvtoml).
It has many improvements over 1.0.1 also in area of black-box supporting.

Some replies in-line, below.

Regards,
Sergey

mary wrote:
>> 3. Created an extention point in the plugin.xml file for
>> "org.eclipse.m2m.qvt.oml.ocl.emf.libraries" .and the metamodel set to
>> UML Here is a copy of the plugin.xml file:
>> =============================
>> <?xml version="1.0" encoding="UTF-8"?>
>> <?eclipse version="3.4"?>
>> <plugin>
>> <extension point="org.eclipse.m2m.qvt.oml.ocl.emf.libraries">
>> <library class="CheckOCLConstraint.getJP"
>> id="CheckOCLConstraint.getJP">
>> <inMetamodel uri="http://www.eclipse.org/uml2/2.1.0/UML"/> </library>
>> </extension>
>> </plugin>
>> =============================
>> However in the file it gives an error [unknown extension point
>> "org.eclipse.m2m.qvt.oml.ocl.emf.libraries"]. But i tried to ignore
>> the error and export the plugin anyway.
>
>
> For the extention point i solved the error.. instead of
> having["org.eclipse.m2m.qvt.oml.ocl.emf.libraries"] I put
> [org.eclipse.m2m.qvt.oml.ocl.libraries] and the error is gone.
> However, still I cant access the library from qvt transformation..The
> error is still [can not find imported module]

It was mistake in earlier post. You're right, ext.point should be
"org.eclipse.m2m.qvt.oml.ocl.libraries".

Looking at posted library's registration in plugin.xml

<library class="CheckOCLConstraint.getJP" id="CheckOCLConstraint.getJP">

I can figure out that library class is named 'getJP' and it's located in
java package 'CheckOCLConstraint'. I think it's not true :)
You should specify fully qualified java class for 'class=' property.

I've attached java library sample (taken from
'org.eclipse.m2m.tests.qvt.oml' plug-in).
In plugin.xml it's registered as follows:
<extension point="org.eclipse.m2m.qvt.oml.ocl.libraries">
<library
class="org.eclipse.m2m.tests.qvt.oml.TestBlackboxLibrary"
id="TestBlackboxLibrary">
<inMetamodel uri="http://www.eclipse.org/emf/2002/Ecore"/>
<outMetamodel uri="http://www.eclipse.org/emf/2002/Ecore"/>
</library>
</extension>


Given it deployed the following script can test it:

import TestBlackboxLibrary;
modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
transformation testOldLib();
main() {
var v := object EClass{}.oclAnyMyOperation();
}


>
> I 've looked in the web and tried a lot of examples. Like the
> SampleLibrary example but yet it didn't work too..
> I don't know what am I missing!! Any help Plz?
>
> Thanks..
>


--------------040006040804040103080806
Content-Type: text/plain;
name="TestBlackboxLibrary.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="TestBlackboxLibrary.java"

/*********************************************************** ********************
* Copyright (c) 2008 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Borland Software Corporation - initial API and implementation
************************************************************ *******************/
package org.eclipse.m2m.tests.qvt.oml;

import java.util.Collections;
import java.util.Set;

import org.eclipse.emf.ecore.ENamedElement;

public class TestBlackboxLibrary {

public Set<ENamedElement> asRenamedSetSingleton(Object self, String newName) {
if(self instanceof ENamedElement) {
ENamedElement namedElement = (ENamedElement) self;
namedElement.setName(newName);
return Collections.singleton(namedElement);
}

return Collections.emptySet();
}

public final Set<Object> oclAnyMyOperation(Object self) {
return Collections.singleton(self);
}


/**
* Metainfo for the native methods should be accessible throu the static
* methods of inner class <code>Metainfo</code> with the same signature
* ant <code>String[]</code> return type. Returned array should contains
* string representation of OCL classifiers:
*
* array[0] - Context classifier
* array[n] - Classifier corresponds to the n-th operation parameter
* array[n+1] - Return type classifier
*/
public static class Metainfo {

private static final String[] RENAMED_SET_SINGLETON = new String[] {
"oclstdlib::OclVoid", // Void context -> module owned (context-less) operation
// imported library module is the implicit source object of the call
"oclstdlib::OclAny", // your argument1
"oclstdlib::String", // your argument2
"Set(ecore::ENamedElement)" // return type
};

private static final String[] OCLANY_MYOPERATION = new String[] {
"oclstdlib::OclAny",
"Set(oclstdlib::OclAny)"
};

public static final String[] asRenamedSetSingleton(Object arg, String newName) {
return RENAMED_SET_SINGLETON;
}

public static final String[] oclAnyMyOperation(Object arg) {
return OCLANY_MYOPERATION;
}
}
}

--------------040006040804040103080806--
Re: Calling Java Code from QVTO 1.0.1 [message #479803 is a reply to message #479733] Wed, 12 August 2009 14:59 Go to previous messageGo to next message
mary is currently offline maryFriend
Messages: 22
Registered: July 2009
Junior Member
Thank you Gilbert for your reply.. However, I have looked at this but it
is describing example for QVT 2.0 which is not the version i am using.
Re: Calling Java Code from QVTO 1.0.1 [message #479877 is a reply to message #479798] Wed, 12 August 2009 21:00 Go to previous messageGo to next message
mary is currently offline maryFriend
Messages: 22
Registered: July 2009
Junior Member
Hello Sergey,

Thanks a lot for your help. I tried to update to a newer version of QVT
but couldn't as the newer version require eclipse V.3.5 and I am using RSA
which is based on eclipse 3.4 . So unfortunately upgrading to qvt v.2
would be difficult. :(

Please see comments in-line..

Regards,


> Looking at posted library's registration in plugin.xml

> <library class="CheckOCLConstraint.getJP" id="CheckOCLConstraint.getJP">

> I can figure out that library class is named 'getJP' and it's located in
> java package 'CheckOCLConstraint'. I think it's not true :)
> You should specify fully qualified java class for 'class=' property.

Actually it was true. This was the fully qualified java class name. :(

> I've attached java library sample (taken from
> 'org.eclipse.m2m.tests.qvt.oml' plug-in).
> In plugin.xml it's registered as follows:
> <extension point="org.eclipse.m2m.qvt.oml.ocl.libraries">
> <library
> class="org.eclipse.m2m.tests.qvt.oml.TestBlackboxLibrary"
> id="TestBlackboxLibrary">
> <inMetamodel uri="http://www.eclipse.org/emf/2002/Ecore"/>
> <outMetamodel uri="http://www.eclipse.org/emf/2002/Ecore"/>
> </library>
> </extension>

> Given it deployed the following script can test it:

> import TestBlackboxLibrary;
> modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
> transformation testOldLib();
> main() {
> var v := object EClass{}.oclAnyMyOperation();
> }

I tried the library sample you sent and it worked from qvt and i had
access to it. Unfortunately, for my library still cant import it from qvt.

Can I send you my java plug-in project for you to see it and try importing
it from qvt? If thats Ok with you i will really appreciate it, and BTW I
have your email address..

Thanks Again..
Re: Calling Java Code from QVTO 1.0.1 [message #479881 is a reply to message #479877] Wed, 12 August 2009 21:26 Go to previous message
Sergey Boyko is currently offline Sergey BoykoFriend
Messages: 171
Registered: July 2009
Senior Member
Hi mary ,

Sure send me your library project. I'll check it.

Regards,
Sergey

mary wrote:
> Hello Sergey,
>
> Thanks a lot for your help. I tried to update to a newer version of QVT
> but couldn't as the newer version require eclipse V.3.5 and I am using
> RSA which is based on eclipse 3.4 . So unfortunately upgrading to qvt
> v.2 would be difficult. :(
>
> Please see comments in-line..
>
> Regards,
>
>
>> Looking at posted library's registration in plugin.xml
>
>> <library class="CheckOCLConstraint.getJP"
>> id="CheckOCLConstraint.getJP">
>
>> I can figure out that library class is named 'getJP' and it's located
>> in java package 'CheckOCLConstraint'. I think it's not true :)
>> You should specify fully qualified java class for 'class=' property.
>
> Actually it was true. This was the fully qualified java class name. :(
>
>> I've attached java library sample (taken from
>> 'org.eclipse.m2m.tests.qvt.oml' plug-in).
>> In plugin.xml it's registered as follows:
>> <extension point="org.eclipse.m2m.qvt.oml.ocl.libraries">
>> <library
>> class="org.eclipse.m2m.tests.qvt.oml.TestBlackboxLibrary"
>> id="TestBlackboxLibrary">
>> <inMetamodel uri="http://www.eclipse.org/emf/2002/Ecore"/>
>> <outMetamodel uri="http://www.eclipse.org/emf/2002/Ecore"/>
>> </library>
>> </extension>
>
>> Given it deployed the following script can test it:
>
>> import TestBlackboxLibrary;
>> modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
>> transformation testOldLib();
>> main() {
>> var v := object EClass{}.oclAnyMyOperation();
>> }
>
> I tried the library sample you sent and it worked from qvt and i had
> access to it. Unfortunately, for my library still cant import it from qvt.
> Can I send you my java plug-in project for you to see it and try
> importing it from qvt? If thats Ok with you i will really appreciate it,
> and BTW I have your email address..
>
> Thanks Again..
>
>
Previous Topic:QVTO- creating RDBMS view from UML PIM
Next Topic:[QVTO] Methode to create and open the QVT Editor
Goto Forum:
  


Current Time: Tue Apr 23 09:25:49 GMT 2024

Powered by FUDForum. Page generated in 0.03539 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top