Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Black-box support
[QVTO] Black-box support [message #97877] Tue, 20 January 2009 16:46 Go to next message
Hossam Karim is currently offline Hossam KarimFriend
Messages: 26
Registered: July 2009
Junior Member
Hello everyone,
I am not able to get the new annotation based black-box support to
work. I had a look at the documentation, the example and the test cases
but they seem inconsistent. The test case is referencing a library that
I can't find: library org.eclipse.m2m.tests.qvt.oml.bbox.SimpleJavaLibrary

Would someone who got this feature to work provide some guide please?

Thanks,
Hossam Karim
Re: [QVTO] Black-box support [message #97908 is a reply to message #97877] Tue, 20 January 2009 17:34 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Hossam Karim,

As for 'org.eclipse.m2m.tests.qvt.oml.bbox.SimpleJavaLibrary', it's a
library which is a
part of QVTO unittests. It does not aim to be an example, but only a test
for one of
the deployment variants.
Looks like you have not installed 'Automated tests'.

It's unrelated to the 'Blackbox Library Example'.
The documentation of the blackbox extension point just mentions that as an
example of a simple library class. It does not refer to the same namespace,
so it's unrelated too. Sorry, if it sounds confusing.

Anyway, thanks for pointing out there!
I have to update the documentation and the example as well, as the provided
'org.eclipse.m2m.qvt.oml.examples.blackbox.UtilitiesLibrary' class
does not represent a real world example too much.
Rather a quick way how to start.

Except us ;), GMF uses it.
Feel free to ask questions in this newsgroup.
Perhaps, you could come up with your particular
usecase to solve, which might become a good example.

Regards,
/Radek



On Tue, 20 Jan 2009 17:46:15 +0100, Hossam Karim <hossam.karim@gmail.com>
wrote:

> Hello everyone,
> I am not able to get the new annotation based black-box support to
> work. I had a look at the documentation, the example and the test cases
> but they seem inconsistent. The test case is referencing a library that
> I can't find: library
> org.eclipse.m2m.tests.qvt.oml.bbox.SimpleJavaLibrary
>
> Would someone who got this feature to work provide some guide please?
>
> Thanks,
> Hossam Karim
Re: [QVTO] Black-box support [message #97922 is a reply to message #97908] Wed, 21 January 2009 07:00 Go to previous messageGo to next message
Hossam Karim is currently offline Hossam KarimFriend
Messages: 26
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.
--------------050309030607090502040705
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Thanks Radek for the answer.

Here is what I am trying to do:

I need to map the UML primitive types to Ecore primitive types before
starting the actual model instances mapping.
Currently this is what I have done to get it to work:
- Created a class in the top UML input model package as follows:
class PrimitiveTypes {
integer : UML::Integer;
string : UML::String;
boolean : UML::Boolean;
unlimitedNatural: UML::UnlimitedNatural;
}

- BTW, I couldn't create such class dynamically using QVTO syntax, I
couldn't manage to declare the attributes as primitive types.

- Using the attached use case, I was able to make the early binding,
then remove the 'PrimitiveTypes' class

This is basically a work around, I believe there is a better way to do
it. What I have in mind is to use the black-box support to load the
UMLPrimitiveTypes model library and do the early mapping through Java
calls without the 'PrimitiveTypes' class hack.

I failed to get the Java black-box unit support to work. Here is my
scenario:
- Created a Plug-in with the attached plugin.xml
- Added a dependency in my transformation project on the created plug-in
- Tried to import the library as:
import org.thinkmeta.qvt.uml.ThinkMetaLibrary;
, but it is not resolved.

I appreciate if you can point out the problem with my approach, or
suggest a better one.


Thanks,
Hossam Karim


Radek Dvorak wrote:
> Hi Hossam Karim,
>
> As for 'org.eclipse.m2m.tests.qvt.oml.bbox.SimpleJavaLibrary', it's a
> library which is a
> part of QVTO unittests. It does not aim to be an example, but only a
> test for one of
> the deployment variants.
> Looks like you have not installed 'Automated tests'.
>
> It's unrelated to the 'Blackbox Library Example'.
> The documentation of the blackbox extension point just mentions that as an
> example of a simple library class. It does not refer to the same namespace,
> so it's unrelated too. Sorry, if it sounds confusing.
>
> Anyway, thanks for pointing out there!
> I have to update the documentation and the example as well, as the provided
> 'org.eclipse.m2m.qvt.oml.examples.blackbox.UtilitiesLibrary' class
> does not represent a real world example too much.
> Rather a quick way how to start.
>
> Except us ;), GMF uses it.
> Feel free to ask questions in this newsgroup.
> Perhaps, you could come up with your particular
> usecase to solve, which might become a good example.
>
> Regards,
> /Radek
>
>
>
> On Tue, 20 Jan 2009 17:46:15 +0100, Hossam Karim
> <hossam.karim@gmail.com> wrote:
>
>> Hello everyone,
>> I am not able to get the new annotation based black-box support to
>> work. I had a look at the documentation, the example and the test
>> cases but they seem inconsistent. The test case is referencing a
>> library that I can't find: library
>> org.eclipse.m2m.tests.qvt.oml.bbox.SimpleJavaLibrary
>>
>> Would someone who got this feature to work provide some guide please?
>>
>> Thanks,
>> Hossam Karim
>


--------------050309030607090502040705
Content-Type: text/plain;
name="usecase.qvto"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="usecase.qvto"

aW1wb3J0IGVtZi50b29sczsgCgoKbW9kZWx0eXBlIFVNTCB1c2VzICdodHRw Oi8vd3d3LmVj
bGlwc2Uub3JnL3VtbDIvMy4wLjAvVU1MJzsKbW9kZWx0eXBlIEVjb3JlIHVz ZXMgJ2h0dHA6
Ly93d3cuZWNsaXBzZS5vcmcvZW1mLzIwMDIvRWNvcmUnOwoJCgp0cmFuc2Zv cm1hdGlvbiB1
bWwyZWNvcmUoaW4gdW1sOlVNTCwgb3V0IGVjb3JlOkVjb3JlKTsKCmhlbHBl ciBlRGF0YVR5
cGVJbnN0YW5jZShuYW1lIDogU3RyaW5nKSA6IEVjb3JlOjpFRGF0YVR5cGUg ewogIHJldHVy
biBnZXREYXRhVHlwZUluc3RhbmNlKCdodHRwOi8vd3d3LmVjbGlwc2Uub3Jn L2VtZi8yMDAy
L0Vjb3JlJywgbmFtZSk7CQp9CgpoZWxwZXIgZUludCgpIDogRWNvcmU6OkVE YXRhVHlwZSB7
CglyZXR1cm4gZURhdGFUeXBlSW5zdGFuY2UoJ0VJbnQnKTsKfQoKaGVscGVy IGVCb29sZWFu
KCkgOiBFY29yZTo6RURhdGFUeXBlIHsKCXJldHVybiBlRGF0YVR5cGVJbnN0 YW5jZSgnRUJv
b2xlYW4nKTsKfQoKaGVscGVyIGVTdHJpbmcoKSA6IEVjb3J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JdmFyIGVjb3JlVW5saW1pdGVkTmF0dXJhbCA6IEVjb3JlOjpF RGF0YVR5cGUg
Oj0gdW1sVW5saW1pdGVkTmF0dXJhbC5tYXAgc3BlY2lhbFByaW1pdGl2ZVR5 cGUyRURhdGFU
eXBlKCk7CgkKCXJldHVybiBwcmltaXRpdmVUeXBlc0NsYXNzOwkKfQoKCm1h aW4oKSB7Cgl1
bWwucmVtb3ZlRWxlbWVudChwZXJmb3JtUHJpbWl0aXZlVHlwZU1hcHBpbmco KSk7CgktLXVt
bC5vYmplY3RzKClbVU1MOjpQYWNrYWdlXS0+bWFwIHBhY2thZ2UyRVBhY2th Z2UoKTsKfQo=
--------------050309030607090502040705
Content-Type: text/xml;
name="plugin.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="plugin.xml"

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.m2m.qvt.oml.javaBlackboxUnits">
<unit
name="ThinkMetaLibrary"
namespace="org.thinkmeta.qvt.uml">
<library
class="org.thinkmeta.qvt.uml.ThinkMetaLibrary"
name="ThinkMetaLibrary">
<metamodel
nsURI="http://www.eclipse.org/uml2/3.0.0/UML">
</metamodel>
</library>
</unit>
</extension>

</plugin>

--------------050309030607090502040705--
Re: [QVTO] Black-box support [message #98015 is a reply to message #97922] Wed, 21 January 2009 13:12 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
See inlined responses bellow.

> - Created a class in the top UML input model package as follows:
> class PrimitiveTypes {
> integer : UML::Integer;
> string : UML::String;
> boolean : UML::Boolean;
> unlimitedNatural: UML::UnlimitedNatural;
> }
>
> - BTW, I couldn't create such class dynamically using QVTO syntax, I
> couldn't manage to declare the attributes as primitive types.

So far, we have only implemented intermediate classes and properties.
A regular EMF based metamodel can be defined outside QVTo, so we focus
on other features first.

> This is basically a work around, I believe there is a better way to do
> it. What I have in mind is to use the black-box support to load the
> UMLPrimitiveTypes model library and do the early mapping through Java
> calls without the 'PrimitiveTypes' class hack.

You can take a look at my response to "[QVTO] Early mapping of metamodel
elements".
It shows how to get access to the EcorePackage instance programmatically
in QVTo.
The crucial part is actually getting access to the EcorePackage instance
as an ECORE model
in QVTo, in which you can look for the predefined types.
The access you could get also via a blackbox library and do the
actual mapping in QVT source code, if a more flexible decision making is
needed there.

> I failed to get the Java black-box unit support to work. Here is my
> scenario:
> - Created a Plug-in with the attached plugin.xml
> - Added a dependency in my transformation project on the created plug-in
> - Tried to import the library as:
> import org.thinkmeta.qvt.uml.ThinkMetaLibrary;
> , but it is not resolved.

Check please the compilation error message on the import.
It might also be:
"Failed to load black-box library
'org.thinkmeta.qvt.uml.ThinkMetaLibrary'. See error log for details"

which means it has been resolved but some operations may have failed to
load.
It depends on how you define your library java class.

I have just tried that and all works fine.

plugin.xml:
<plugin>
<extension point="org.eclipse.m2m.qvt.oml.javaBlackboxUnits">
<unit name="ThinkMetaLibrary" namespace="org.thinkmeta.qvt.uml">

<library name="ThinkMetaLibrary"
class="org.thinkmeta.qvt.uml.ThinkMetaLibrary">
<metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/>
<metamodel nsURI="http://www.eclipse.org/uml2/3.0.0/UML"/>
</library>
</unit>
</extension>
</plugin>

ThinkMetaLibrary.java:
package org.thinkmeta.qvt.uml;

import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
import org.eclipse.uml2.uml.PrimitiveType;

public class ThinkMetaLibrary {

public ThinkMetaLibrary() {
super();
}

/*
* non-contextual operation variant
*/
public EClassifier getEPrimitiveType(PrimitiveType umlType) {
if("String".equals(umlType.getName())) {
return EcorePackage.eINSTANCE.getEString();
}
// other cases
return null;
}

/*
* contextual operation variant
*/
@Operation(contextual=true)
public EClassifier getEPrimitiveType2(PrimitiveType self) {
return getEPrimitiveType2(self);
}
}


In QVT importing compilation unit you can refer to it as the following:

main() {
var umlType : UML::PrimitiveType;
--
getEPrimitiveType(umlType);
umlType.getEPrimitiveType2();
}

Regards,
/Radek
Re: [QVTO] Black-box support [message #689293 is a reply to message #98015] Mon, 27 June 2011 11:13 Go to previous message
Tom2000  is currently offline Tom2000 Friend
Messages: 6
Registered: May 2011
Junior Member
Hi at all,

(Step 1)
i tried to implement these example but i get the following error (Log):
- Failed to load java black-box unit 'org.thinkmeta.qvt.uml.ThinkMetaLibrary'
-- Loading Java module diagnostics 'ThinkMetaLibrary, javaClass: org.thinkmeta.qvt.uml.ThinkMetaLibrary, bundle:
--- Can't resolve 'interface org.eclipse.uml2.uml.PrimitiveType' as OCL type in java method 'public
-- Can't resolve metamodel nsURI='...www.eclipse.org/uml2/3.0.0/UML"'
so i checked my MetamodelExplorer and the plugin.xml, discovered some typing error and corrected it.

(Step 2)
But after plugin exportation, copying it into Eclipse/plugin folder (replacing the plugin from step 1) and restart the IDE, suprisingly i got the same Error Message with a current Date. I repeat this Process again and again but the Error occurs , as recently as i shut down my pc and restartet the whole System it works (with out changing the Code in Step 2). In an other project i got the same message Can't resolve metamodel nsURI='someMetamodel' before and after deleting it in plugin.xml.

Could anybody tell me how to avoid it, is there an internal memory in QVTO or something?

Thanks a lot Tom
(Eclipse Helios Version: 3.6.2,
Operational QVT 3.0.1)
Previous Topic:ATL error
Next Topic:[ATL]Inter Model References
Goto Forum:
  


Current Time: Mon Dec 22 10:01:28 GMT 2014

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

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