Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMT (Generative Modeling Technologies) » [MOFScript] loading Metamodel
[MOFScript] loading Metamodel [message #383892] Tue, 17 June 2008 22:23 Go to next message
neto  is currently offline neto
Messages: 31
Registered: July 2009
Member
Hi,

I'm defining some textual tranformations for models based on the
JavaAbstractSyntax metamodel. It works fine! However, when I try to
integrate my MOFScript transformation in a Java environment, using the
example given in the MOFScript User Guide v0.6, it doesn't work.

The following line
**int errorCount = ParserUtil.getModelChecker().getErrorCount();**
returns 85 erros. They are all concerning the lack of a metamodel
definition.

I see that the exemple in the User Guide doesn't present a means of
setting the metamodel before calling
**execMgr.executeTransformation();**
So, the errors are expected.

Although I've searched a lot, I have not found any way of setting the
metamodel, any kind of MOFScript API and any other kind of ducumentation.

Has anyone had the same problem? May someone help me?

Best regards!

---
The output I get from my Java program is this:
Parsing result: 85 errors
: Error: MTTParseError: Illegal/unknown context: jast, line: 484, column: 0
: Error: MTTParseError: Can't find feature 'interface' for type
'TypeDeclaration'., line: 28, column: 5
: Error: MTTParseError: Type not found: 'FieldDeclaration' in metamodel
'null', line: 0, column: 0
: Error: MTTParseError: Can't find feature 'bodyDeclarations' for type
'TypeDeclaration'., line: 31, column: 2
: Error: MTTParseError: Type not found: 'MethodDeclaration' in metamodel
'null', line: 0, column: 0
..
.
.
.
---
jast is a reference to the metamodel.
Re: [MOFScript] loading Metamodel [message #383895 is a reply to message #383892] Mon, 23 June 2008 06:28 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello Netuh,

Have you added your model plugin to the classpath?

Cheers,
G
Re: [MOFScript] loading Metamodel [message #383896 is a reply to message #383895] Mon, 23 June 2008 06:42 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello again,

And if this doesn't work have you added

//
//Change to your ovn metamodel
//
import org.eclipse.uml2.uml.UMLPackage;

public class TestAPI implements ExecutionMessageListener {

public TestAPI () {

//
//Maks MOFScript aware of your metamodel chenge to your own
//
UMLPackage lePackage = UMLPackage.eINSTANCE;


/G
Re: [MOFScript] loading Metamodel [message #383901 is a reply to message #383896] Tue, 24 June 2008 16:45 Go to previous messageGo to next message
neto  is currently offline neto
Messages: 31
Registered: July 2009
Member
Thanks Gøran,

i did it...

File metamodel = new File("Z:\\<<Filepath>>\\JavaAbstractSyntax.ecore");
ResourceSet rsSource = new
ResourceSetImpl(); rsSource.getResourceFactoryRegistry().getExtensionToFactoryM ap().put( "*",
new XMIResourceFactoryImpl());
Resource resSource = rsSource.getResource(
URI.createFileURI(metamodel.getAbsolutePath()), true);
EPackage package = (EPackage) resSource.getContents().get(0);
EPackage.Registry.INSTANCE.put("JavaAbstractSyntax", package);

But now i have other problem. When i load the model.

i m doing it:

execMgr.lookupAndAddSourceMetaModel("JavaAbstractSyntax","JavaAbstractSyntax "));
execMgr.loadSourceModel(new
File("Z:\\<<Filepath>>\\test.javaabstractsyntax"));

But a exception is thrown. The model test.javaabstractsyntax and the
transfomation works well on the eclipse plugin.

Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.mofscript.runtime.ExecutionManager.getSourceMeta ModelName(ExecutionManager.java:887)
at
org.eclipse.mofscript.runtime.ExecutionManager.loadSourceMod el(ExecutionManager.java:585)
at code.JavaCodeGeneration.test(JavaCodeGeneration.java:123)
at code.JavaCodeGeneration.main(JavaCodeGeneration.java:151)

Any ideia?

Thanks in advance

Gøran K. Olsen wrote:

> Hello again,

> And if this doesn't work have you added

> //
> //Change to your ovn metamodel
> //
> import org.eclipse.uml2.uml.UMLPackage;

> public class TestAPI implements ExecutionMessageListener {

> public TestAPI () {

> //
> //Maks MOFScript aware of your metamodel chenge to your own
> //
> UMLPackage lePackage = UMLPackage.eINSTANCE;


> /Gøran


> "Gøran K. Olsen" <Goran.K.Olsen@Sintef.no> wrote in message
> news:g3ntt1$qo5$1@build.eclipse.org...
>> Hello Netuh,
>>
>> Have you added your model plugin to the classpath?
>>
>> Cheers,
>> Gøran
>>
>> "Netuh" <waldemar.neto@gmail.com> wrote in message
>> news:8fc95745bbb80a8e313ec69317d7e804$1@www.eclipsecon.com...
>>> Hi,
>>>
>>> I'm defining some textual tranformations for models based on the
>>> JavaAbstractSyntax metamodel. It works fine! However, when I try to
>>> integrate my MOFScript transformation in a Java environment, using the
>>> example given in the MOFScript User Guide v0.6, it doesn't work.
>>>
>>> The following line
>>> **int errorCount = ParserUtil.getModelChecker().getErrorCount();**
>>> returns 85 erros. They are all concerning the lack of a metamodel
>>> definition.
>>>
>>> I see that the exemple in the User Guide doesn't present a means of
>>> setting the metamodel before calling **execMgr.executeTransformation();**
>>> So, the errors are expected.
>>>
>>> Although I've searched a lot, I have not found any way of setting the
>>> metamodel, any kind of MOFScript API and any other kind of ducumentation.
>>>
>>> Has anyone had the same problem? May someone help me?
>>>
>>> Best regards!
>>>
>>> ---
>>> The output I get from my Java program is this:
>>> Parsing result: 85 errors
>>> : Error: MTTParseError: Illegal/unknown context: jast, line: 484, column:
>>> 0
>>> : Error: MTTParseError: Can't find feature 'interface' for type
>>> 'TypeDeclaration'., line: 28, column: 5
>>> : Error: MTTParseError: Type not found: 'FieldDeclaration' in metamodel
>>> 'null', line: 0, column: 0
>>> : Error: MTTParseError: Can't find feature 'bodyDeclarations' for type
>>> 'TypeDeclaration'., line: 31, column: 2
>>> : Error: MTTParseError: Type not found: 'MethodDeclaration' in metamodel
>>> 'null', line: 0, column: 0
>>> .
>>> .
>>> .
>>> .
>>> ---
>>> jast is a reference to the metamodel.
>>>
>>
>>
Re: [MOFScript] loading Metamodel [message #383904 is a reply to message #383901] Fri, 27 June 2008 03:37 Go to previous messageGo to next message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello again,

I am not sure what is wrong, take a look at the example below. It works.


Cheers G
Re: [MOFScript] loading Metamodel [message #383918 is a reply to message #383904] Mon, 30 June 2008 14:12 Go to previous message
neto  is currently offline neto
Messages: 31
Registered: July 2009
Member
Thanks Goran,

i solve my problem making, lookUp my metamodel, registring the
ResourceFactory nad loading my model by archive.

execMgr.lookupAndAddSourceMetaModel("jast", "JavaAbstractSyntax");
execMgr.lookupAndAddSourceMetaModel("JavaAbstractSyntax","JavaAbstractSyntax ");

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "javaabstractsyntax",
new XMIResourceFactoryImpl()
{
public Resource createResource(URI uri)
{
XMIResource xmiResource = new XMIResourceImpl(uri);
return xmiResource;
}
});
execMgr.loadSourceModel(new File(inputPath));
Re: [MOFScript] loading Metamodel [message #617744 is a reply to message #383892] Mon, 23 June 2008 06:28 Go to previous message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello Netuh,

Have you added your model plugin to the classpath?

Cheers,
G
Re: [MOFScript] loading Metamodel [message #618081 is a reply to message #383895] Mon, 23 June 2008 06:42 Go to previous message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello again,

And if this doesn't work have you added

//
//Change to your ovn metamodel
//
import org.eclipse.uml2.uml.UMLPackage;

public class TestAPI implements ExecutionMessageListener {

public TestAPI () {

//
//Maks MOFScript aware of your metamodel chenge to your own
//
UMLPackage lePackage = UMLPackage.eINSTANCE;


/G
Re: [MOFScript] loading Metamodel [message #618091 is a reply to message #383896] Tue, 24 June 2008 16:45 Go to previous message
neto  is currently offline neto
Messages: 31
Registered: July 2009
Member
Thanks Gøran,

i did it...

File metamodel = new File("Z:\\<<Filepath>>\\JavaAbstractSyntax.ecore");
ResourceSet rsSource = new
ResourceSetImpl(); rsSource.getResourceFactoryRegistry().getExtensionToFactoryM ap().put( "*",
new XMIResourceFactoryImpl());
Resource resSource = rsSource.getResource(
URI.createFileURI(metamodel.getAbsolutePath()), true);
EPackage package = (EPackage) resSource.getContents().get(0);
EPackage.Registry.INSTANCE.put("JavaAbstractSyntax", package);

But now i have other problem. When i load the model.

i m doing it:

execMgr.lookupAndAddSourceMetaModel("JavaAbstractSyntax","JavaAbstractSyntax "));
execMgr.loadSourceModel(new
File("Z:\\<<Filepath>>\\test.javaabstractsyntax"));

But a exception is thrown. The model test.javaabstractsyntax and the
transfomation works well on the eclipse plugin.

Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.mofscript.runtime.ExecutionManager.getSourceMeta ModelName(ExecutionManager.java:887)
at
org.eclipse.mofscript.runtime.ExecutionManager.loadSourceMod el(ExecutionManager.java:585)
at code.JavaCodeGeneration.test(JavaCodeGeneration.java:123)
at code.JavaCodeGeneration.main(JavaCodeGeneration.java:151)

Any ideia?

Thanks in advance

Gøran K. Olsen wrote:

> Hello again,

> And if this doesn't work have you added

> //
> //Change to your ovn metamodel
> //
> import org.eclipse.uml2.uml.UMLPackage;

> public class TestAPI implements ExecutionMessageListener {

> public TestAPI () {

> //
> //Maks MOFScript aware of your metamodel chenge to your own
> //
> UMLPackage lePackage = UMLPackage.eINSTANCE;


> /Gøran


> "Gøran K. Olsen" <Goran.K.Olsen@Sintef.no> wrote in message
> news:g3ntt1$qo5$1@build.eclipse.org...
>> Hello Netuh,
>>
>> Have you added your model plugin to the classpath?
>>
>> Cheers,
>> Gøran
>>
>> "Netuh" <waldemar.neto@gmail.com> wrote in message
>> news:8fc95745bbb80a8e313ec69317d7e804$1@www.eclipsecon.com...
>>> Hi,
>>>
>>> I'm defining some textual tranformations for models based on the
>>> JavaAbstractSyntax metamodel. It works fine! However, when I try to
>>> integrate my MOFScript transformation in a Java environment, using the
>>> example given in the MOFScript User Guide v0.6, it doesn't work.
>>>
>>> The following line
>>> **int errorCount = ParserUtil.getModelChecker().getErrorCount();**
>>> returns 85 erros. They are all concerning the lack of a metamodel
>>> definition.
>>>
>>> I see that the exemple in the User Guide doesn't present a means of
>>> setting the metamodel before calling **execMgr.executeTransformation();**
>>> So, the errors are expected.
>>>
>>> Although I've searched a lot, I have not found any way of setting the
>>> metamodel, any kind of MOFScript API and any other kind of ducumentation.
>>>
>>> Has anyone had the same problem? May someone help me?
>>>
>>> Best regards!
>>>
>>> ---
>>> The output I get from my Java program is this:
>>> Parsing result: 85 errors
>>> : Error: MTTParseError: Illegal/unknown context: jast, line: 484, column:
>>> 0
>>> : Error: MTTParseError: Can't find feature 'interface' for type
>>> 'TypeDeclaration'., line: 28, column: 5
>>> : Error: MTTParseError: Type not found: 'FieldDeclaration' in metamodel
>>> 'null', line: 0, column: 0
>>> : Error: MTTParseError: Can't find feature 'bodyDeclarations' for type
>>> 'TypeDeclaration'., line: 31, column: 2
>>> : Error: MTTParseError: Type not found: 'MethodDeclaration' in metamodel
>>> 'null', line: 0, column: 0
>>> .
>>> .
>>> .
>>> .
>>> ---
>>> jast is a reference to the metamodel.
>>>
>>
>>
Re: [MOFScript] loading Metamodel [message #618096 is a reply to message #383901] Fri, 27 June 2008 03:37 Go to previous message
Gøran K. Olsen is currently offline Gøran K. Olsen
Messages: 184
Registered: July 2009
Senior Member
Hello again,

I am not sure what is wrong, take a look at the example below. It works.


Cheers G
Re: [MOFScript] loading Metamodel [message #618104 is a reply to message #383904] Mon, 30 June 2008 14:12 Go to previous message
neto  is currently offline neto
Messages: 31
Registered: July 2009
Member
Thanks Goran,

i solve my problem making, lookUp my metamodel, registring the
ResourceFactory nad loading my model by archive.

execMgr.lookupAndAddSourceMetaModel("jast", "JavaAbstractSyntax");
execMgr.lookupAndAddSourceMetaModel("JavaAbstractSyntax","JavaAbstractSyntax ");

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "javaabstractsyntax",
new XMIResourceFactoryImpl()
{
public Resource createResource(URI uri)
{
XMIResource xmiResource = new XMIResourceImpl(uri);
return xmiResource;
}
});
execMgr.loadSourceModel(new File(inputPath));
Previous Topic:[Epsilon] Configuring HUTN file
Next Topic:[Epsilon] Problems using HUTN with UML metamodel
Goto Forum:
  


Current Time: Fri Jul 25 03:14:20 EDT 2014

Powered by FUDForum. Page generated in 0.02440 seconds