Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Check] Using models referencing other models in OAW
[Check] Using models referencing other models in OAW [message #506329] Thu, 07 January 2010 02:22 Go to next message
Eclipse UserFriend
Originally posted by: m_lehmeier.gmx.de

Hello.
I have a problem that results in an exception while executing a Check in
an Openarchitectureware workflow, but I think the problem lies deeper.

I seem to have a problem using a model that references elements in
another model in OAW. I have not found a way to make it work.

I have two models, called visageModel and visageTextModel. Both models
have separate metamodels and visageModel references and element in
visageTextModel. All metamodels and models validate correctly in
Eclipse.
I created a genmodel file and created model code from it. I did not
encounter problems anywhere.

However, when I start the workflow, I get this exception:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'texts' not
found. (platform:/resource/VisageGenerator/src/model/VisageModel.xm i,
24, 29)

'texts' is a reference in visageModel that references an element in
visageTextModel.
Apparently the reader does not know that there is another model.

This happens while in check (I did not yet get beyond this point):

<component class="org.eclipse.mwe.emf.Reader">
<uri value="platform:/resource/${visageModel}" />
<modelSlot value="visageModel" />
</component>

<component class="org.eclipse.mwe.emf.Reader">
<uri value="platform:/resource/${visageTexts}" />
<modelSlot value="visageTextModel" />
</component>

<component class="oaw.check.CheckComponent">
<metaModel id="mmVisage"
class="org.openarchitectureware.type.emf.EmfMetaModel">
<metaModelPackage value="com.lm.visage.model.visage.VisagePackage"/>
</metaModel>
<metaModel id="mmVisagetexts"
class="org.openarchitectureware.type.emf.EmfMetaModel">
<metaModelPackage
value="com.lm.visage.model.visagetext.VisagetextPackage"/>
</metaModel>
<checkFile value="metamodel::VisageChecks" />
<emfAllChildrenSlot value="visageModel" />
</component>

The VisageChecks file is empty. I don't use Check yet, I just don't know
another way to register a metamodel in the workflow. The examples I
found always do it here.
I tried a lot, like modifying the order of the elements or use
visageTextModel in emfAllChildrenSlot. Nothing worked.

I there a way to use models that reference other models in OAW?

Thank you!
Re: [Check] Using models referencing other models in OAW [message #506358 is a reply to message #506329] Thu, 07 January 2010 09:20 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
The model uses a platform:/resource URI. You'll have to tell EMF where
the platform root (aka workspace is):

<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri=".."/>

(where '..' is the relative path to the workspace root)

Note, that the StandaloneSetup can also be used to register ecore models:

<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="..">
<registerGeneratedEPackage
value="com.lm.visage.model.visage.VisagePackage"/>
<registerGeneratedEPackage
value="com.lm.visage.model.visagetext.VisagetextPackage"/>
</bean>

Cheers,
Sven

Michael Lehmeier schrieb:
> Hello.
> I have a problem that results in an exception while executing a Check in
> an Openarchitectureware workflow, but I think the problem lies deeper.
>
> I seem to have a problem using a model that references elements in
> another model in OAW. I have not found a way to make it work.
>
> I have two models, called visageModel and visageTextModel. Both models
> have separate metamodels and visageModel references and element in
> visageTextModel. All metamodels and models validate correctly in
> Eclipse.
> I created a genmodel file and created model code from it. I did not
> encounter problems anywhere.
>
> However, when I start the workflow, I get this exception:
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'texts' not
> found. (platform:/resource/VisageGenerator/src/model/VisageModel.xm i,
> 24, 29)
>
> 'texts' is a reference in visageModel that references an element in
> visageTextModel.
> Apparently the reader does not know that there is another model.
>
> This happens while in check (I did not yet get beyond this point):
>
> <component class="org.eclipse.mwe.emf.Reader">
> <uri value="platform:/resource/${visageModel}" />
> <modelSlot value="visageModel" />
> </component>
>
> <component class="org.eclipse.mwe.emf.Reader">
> <uri value="platform:/resource/${visageTexts}" />
> <modelSlot value="visageTextModel" />
> </component>
>
> <component class="oaw.check.CheckComponent">
> <metaModel id="mmVisage"
> class="org.openarchitectureware.type.emf.EmfMetaModel">
> <metaModelPackage value="com.lm.visage.model.visage.VisagePackage"/>
> </metaModel>
> <metaModel id="mmVisagetexts"
> class="org.openarchitectureware.type.emf.EmfMetaModel">
> <metaModelPackage
> value="com.lm.visage.model.visagetext.VisagetextPackage"/>
> </metaModel>
> <checkFile value="metamodel::VisageChecks" />
> <emfAllChildrenSlot value="visageModel" />
> </component>
>
> The VisageChecks file is empty. I don't use Check yet, I just don't know
> another way to register a metamodel in the workflow. The examples I
> found always do it here.
> I tried a lot, like modifying the order of the elements or use
> visageTextModel in emfAllChildrenSlot. Nothing worked.
>
> I there a way to use models that reference other models in OAW?
>
> Thank you!


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Check] Using models referencing other models in OAW [message #506408 is a reply to message #506358] Thu, 07 January 2010 12:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: m_lehmeier.gmx.de

On 2010-01-07, Sven Efftinge <sven.efftinge@itemis.de> wrote:
> The model uses a platform:/resource URI. You'll have to tell EMF where
> the platform root (aka workspace is):
>
><bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri=".."/>

I already had that entry. I thought it didn't relate to my problem so
I didn't quote it here. Sorry.

> Note, that the StandaloneSetup can also be used to register ecore models:
>
><bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="..">
> <registerGeneratedEPackage
> value="com.lm.visage.model.visage.VisagePackage"/>
> <registerGeneratedEPackage
> value="com.lm.visage.model.visagetext.VisagetextPackage"/>
></bean>

Interesting, I did not know that. But it doesn't look like it isn't
assigned an Id, so can I actually reference that Metamodel in the
Generator?

Anyway, I still get the Exception. This didn't resolve my problem.
Any other ideas?

BTW, where do I learn this stuff?
Whenever I look for workflow features I find solutions either in
discussion forums or by simple tutorials. I have not yet found where I
could look it up myself. For example, that registerGeneratedEPackage
doesn't seem to be in any manual or API, as far as I can see.

There is so much about all of this that I don't understand, but I would
like to learn.
Re: [Check] Using models referencing other models in OAW [message #506610 is a reply to message #506408] Fri, 08 January 2010 05:36 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Michael Lehmeier schrieb:
> On 2010-01-07, Sven Efftinge <sven.efftinge@itemis.de> wrote:
>> The model uses a platform:/resource URI. You'll have to tell EMF where
>> the platform root (aka workspace is):
>>
>> <bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri=".."/>
>
> I already had that entry. I thought it didn't relate to my problem so
> I didn't quote it here. Sorry.
>
>> Note, that the StandaloneSetup can also be used to register ecore models:
>>
>> <bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="..">
>> <registerGeneratedEPackage
>> value="com.lm.visage.model.visage.VisagePackage"/>
>> <registerGeneratedEPackage
>> value="com.lm.visage.model.visagetext.VisagetextPackage"/>
>> </bean>
>
> Interesting, I did not know that. But it doesn't look like it isn't
> assigned an Id, so can I actually reference that Metamodel in the
> Generator?

It is not a meta model adapter to be used in an Xpand, Xtend or Check
komponent. All it does is initializing the EPackage, i.e. adding it to
the EPackage.Registry.INSTANCE.

>
> Anyway, I still get the Exception. This didn't resolve my problem.
> Any other ideas?

Is the meta model (ecore model) in your model referenced via resource
URI or via nsURI? It should be nsURI if you use the generated EPackage
and should be resource uri (i.e. path to the *.ecore file) if it's.

>
> BTW, where do I learn this stuff?

The workflow engine is based on just a few concepts. If you've
understoof that you'll know where to look.

Basically you can think of it as a dependency injection language.

If you write
<workflow>
<bean class="my.foo.Type" doStuff="true">
<child class="my.special.Child">
<anotherProperty value="some text"/>
</child>
</bean>
</workflow>

The engine creates an instanceof Workflow
(org.eclipse.emf.mwe.internal.core.Workflow). Note that <workflow> is
just a shortcut for <workflow
class="org.eclipse.emf.mwe.internal.core.Workflow">


For all attributes and elements in workflow there must be a setter or an
adder. In this case there's a method addBean(Object). So the element
<bean> is expected to create an instance of java.lang.Object.
Using the class attribute we define that it should be an instance of
my.foo.Type, which is constructed (using the default constructor).

Here again every property or element needs to correspond to a setter or
adder methos. So given the configuration above there should be a Java class

package my.foo;
public class Type {
public void setDoStuff(boolean isDoStuff) {...}
public void setAnotherProperty(Child child) {...}
}

That's the foundation and there are not that many addition concepts.

So if you want to know what configuration is available, we usually look
up the Java classes. Have a look at
org.eclipse.emf.mwe.utils.StandaloneSetup or open the type hierarchy for
IWorkflowComponent.

Hope that helps,
Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Check] Using models referencing other models in OAW [message #507568 is a reply to message #506610] Wed, 13 January 2010 15:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: m_lehmeier.gmx.de

On 2010-01-08, Sven Efftinge <sven.efftinge@itemis.de> wrote:
> > Anyway, I still get the Exception. This didn't resolve my problem.
> > Any other ideas?

> Is the meta model (ecore model) in your model referenced via resource
> URI or via nsURI? It should be nsURI if you use the generated EPackage
> and should be resource uri (i.e. path to the *.ecore file) if it's.

I think I created the reference from one model to the other by using the
"Load Resource" command in Eclipse.

The model contains the following line:
<visage:Framework xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:visage="visage"
xmlns:visageText="visageText"
xsi:schemaLocation="visage ../metamodel/visage.ecore visageText
../metamodel/visageText.ecore">

I don't know how to do it in a different way.
The nsURI in the metamodels is very simple, simply because I am not yet
sure how to work with those prefixes, URIs etc. It seems to be enough
for the Eclipse EMF tools.

This is in the ecore:EPackage element of my metamodel:
name="visage" nsURI="visage" nsPrefix="visage"

A reference to the second metamodel looks like this:
<eStructuralFeatures xsi:type="ecore:EReference" name="texts"
eType="ecore:EClass visageText.ecore#//TextReference"/>

> The workflow engine is based on just a few concepts. If you've
> understoof that you'll know where to look.
> Basically you can think of it as a dependency injection language.

Yes, I have figured that out already myself.
My problem is, that it does not always seem to be that easy and I don't
know when to look for what.
Your example for help, using registerGeneratedEPackage to instantiate an
EPackage. (thanks BTW)
I wouldn't know that I have to instantiate an EPackage to begin with.

Another example that I used to get a feeling for the workflow syntax:
<component class="oaw.check.CheckComponent">
<metaModel id="mmVisage"
class="org.openarchitectureware.type.emf.EmfMetaModel">
<metaModelPackage value="com.lm.visage.model.visage.VisagePackage"/>
</metaModel>
....

First, I looked up "Metamodel". It was an interface that doesn't let me
set metaModelPackage. However, with the class attribute I looked up
EmfMetaModel.
EmfMetaModel lets me set a number of metaModelPackage's, but not an id.
So what is the id attribute for?
And what does the id attribute mean? From the context of the examples I
have found I can guess, but I would like to know where to look it up and
where I can see that I have to set it at all.

Sorry for my late reply, but I was offline the last couple of days.


Michael Lehmeier
Re: [Check] Using models referencing other models in OAW [message #507617 is a reply to message #507568] Thu, 14 January 2010 05:35 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Michael Lehmeier schrieb:
> On 2010-01-08, Sven Efftinge <sven.efftinge@itemis.de> wrote:
>>> Anyway, I still get the Exception. This didn't resolve my problem.
>>> Any other ideas?
>
>> Is the meta model (ecore model) in your model referenced via resource
>> URI or via nsURI? It should be nsURI if you use the generated EPackage
>> and should be resource uri (i.e. path to the *.ecore file) if it's.
>
> I think I created the reference from one model to the other by using the
> "Load Resource" command in Eclipse.
>
> The model contains the following line:
> <visage:Framework xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:visage="visage"
> xmlns:visageText="visageText"
> xsi:schemaLocation="visage ../metamodel/visage.ecore visageText
> ../metamodel/visageText.ecore">
>
> I don't know how to do it in a different way.
> The nsURI in the metamodels is very simple, simply because I am not yet
> sure how to work with those prefixes, URIs etc. It seems to be enough
> for the Eclipse EMF tools.
>
> This is in the ecore:EPackage element of my metamodel:
> name="visage" nsURI="visage" nsPrefix="visage"
>
> A reference to the second metamodel looks like this:
> <eStructuralFeatures xsi:type="ecore:EReference" name="texts"
> eType="ecore:EClass visageText.ecore#//TextReference"/>

Yes it references the visage model using a resource uri.
In that case you'll have to register the ecore files, not the generated
EPackages. There's another setter in the standaloneserup class for that.

Another possibility would be to add a URI mapping from the resource URI
to the nsURI. Again there's a corresponding method in standalonesetup.

Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Previous Topic:JMerger Example and Standalone Use
Next Topic:[XTEND] [MWE] Error when running ProfilerComponent in 0.8.0M4 sample project
Goto Forum:
  


Current Time: Thu Mar 28 14:06:52 GMT 2024

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

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

Back to the top