Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to use java( or ocl if is possible) for a link constraint in gmfmap
how to use java( or ocl if is possible) for a link constraint in gmfmap [message #209532] Sun, 26 October 2008 16:05 Go to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

Hi,

I have an Element TProcessor and an element that rappresent a link
TEdge. TProcessor have an attribute type and depending on the value of
type the number of outgoing and ingoing edge( of type TEdge) is different.
How can i write a link constraint that solve my problem?
Re: how to use java( or ocl if is possible) for a link constraint ingmfmap [message #209595 is a reply to message #209532] Mon, 27 October 2008 11:52 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mattia,

Try link source(/target) constraint (OCL) like:

self.outgoing->size() < (if self.type = <desiredType1> then <x> else if self.type
= <desiredType2> then <y> else <z> endif)

-----------------
Alex Shatalin
Re: how to use java( or ocl if is possible) for a link constraint ingmfmap [message #209652 is a reply to message #209595] Mon, 27 October 2008 21:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

Thank a lot Alex! That's what I need! But know I have another problem.
The TProcessor's type is not a simple type but a complex TProcessorType
type. How can I specify the desiredType?
I don't understand how I can do something like self.type =
TProcessorType.Start

I tried: self.type = 'Start' and self.type = 0 but they don't work.

If help I post two little piece of my ecore.

This is the attribute type of TProcessor in the ecore file:

<eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
eType="#//TProcessorType"
unsettable="true">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="type"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>


And this is the TProcessorType in the ecore:

<eClassifiers xsi:type="ecore:EEnum" name="TProcessorType">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="TProcessorType"/>
</eAnnotations>
<eLiterals name="Start"/>
<eLiterals name="Simple" value="1"/>
<eLiterals name="Par" value="2"/>
<eLiterals name="Join" value="3"/>
<eLiterals name="JoinWT" value="4"/>
<eLiterals name="And" value="5"/>
<eLiterals name="JoinPar" value="6"/>
<eLiterals name="JoinWTPar" value="7"/>
<eLiterals name="AndPar" value="8"/>
<eLiterals name="SimplePar" value="9"/>
<eLiterals name="JoinSimplePar" value="10"/>
<eLiterals name="JoinWTSimplePar" value="11"/>
<eLiterals name="AndSimplePar" value="12"/>
<eLiterals name="Incoming" value="14"/>
<eLiterals name="End" value="15"/>
</eClassifiers>

Alex Shatalin wrote:
> Hello Mattia,
>
> Try link source(/target) constraint (OCL) like:
> self.outgoing->size() < (if self.type = <desiredType1> then <x> else if
> self.type = <desiredType2> then <y> else <z> endif)
>
> -----------------
> Alex Shatalin
>
>
Re: how to use java( or ocl if is possible) for a link constraint ingmfmap [message #209660 is a reply to message #209652] Tue, 28 October 2008 03:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Mattia,

The syntax for enumeration literals is like this:

self.type = TProcessorType::Start

Cheers,

Christian

Mattia Lambertini wrote:
> Thank a lot Alex! That's what I need! But know I have another problem.
> The TProcessor's type is not a simple type but a complex TProcessorType
> type. How can I specify the desiredType?
> I don't understand how I can do something like self.type =
> TProcessorType.Start
>
> I tried: self.type = 'Start' and self.type = 0 but they don't work.
>
> If help I post two little piece of my ecore.
>
> This is the attribute type of TProcessor in the ecore file:
>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> eType="#//TProcessorType"
> unsettable="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="type"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
>
>
> And this is the TProcessorType in the ecore:
>
> <eClassifiers xsi:type="ecore:EEnum" name="TProcessorType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="TProcessorType"/>
> </eAnnotations>
> <eLiterals name="Start"/>
> <eLiterals name="Simple" value="1"/>
> <eLiterals name="Par" value="2"/>
> <eLiterals name="Join" value="3"/>
> <eLiterals name="JoinWT" value="4"/>
> <eLiterals name="And" value="5"/>
> <eLiterals name="JoinPar" value="6"/>
> <eLiterals name="JoinWTPar" value="7"/>
> <eLiterals name="AndPar" value="8"/>
> <eLiterals name="SimplePar" value="9"/>
> <eLiterals name="JoinSimplePar" value="10"/>
> <eLiterals name="JoinWTSimplePar" value="11"/>
> <eLiterals name="AndSimplePar" value="12"/>
> <eLiterals name="Incoming" value="14"/>
> <eLiterals name="End" value="15"/>
> </eClassifiers>
>
> Alex Shatalin wrote:
>> Hello Mattia,
>>
>> Try link source(/target) constraint (OCL) like:
>> self.outgoing->size() < (if self.type = <desiredType1> then <x> else
>> if self.type = <desiredType2> then <y> else <z> endif)
>>
>> -----------------
>> Alex Shatalin
>>
>>
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209693 is a reply to message #209652] Tue, 28 October 2008 10:40 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mattia,

> I don't understand how I can do something like self.type =
> TProcessorType.Start
try "TProcessorType::Start" or (even better) "<modelPackage>::TProcessorType::Start"

-----------------
Alex Shatalin
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209735 is a reply to message #209693] Tue, 28 October 2008 15:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

> try "TProcessorType::Start" or (even better)
> "<modelPackage>::TProcessorType::Start"

It doesn't work! If i only type this test: self.type =
TProcessorType::Start or self.type = process::TProcessorType::Start it's
always false.

Is there a way to see the value(what is) of self.type and
process::TProcessorType::Start on runtime? like a log.
Or something like an interpreter to use for testing my ocl code on my
model? Something that tell's what i am wrong.
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209743 is a reply to message #209735] Tue, 28 October 2008 16:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

I discovered the Error Log window :).

If i i write an ocl test like:

self.type = process::TProcessorType::Start


the error is:

Expression problem:Unrecognized variable: (type)body:self.type =
process::TProcessorType::Start


and for this test:

self.outgoing->size() < 5

the error is:

Expression problem:Unrecognized variable:
(outgoing)body:self.outgoing->size() < 5

it don't find type and outgoing, but i am sure that type exist. Any idea?


> Or something like an interpreter to use for testing my ocl code on my
> model? Something that tell's what i am wrong.
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209749 is a reply to message #209743] Tue, 28 October 2008 17:04 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mattia,

> it don't find type and outgoing, but i am sure that type exist. Any
> idea?
Is it a LinkMapping.creationConstraints.sourceEnd/targetEnd constraitn or
LinkMapping.DomainSpecialization ?
(first option is correct).

-----------------
Alex Shatalin
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209758 is a reply to message #209743] Tue, 28 October 2008 17:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Mattia,

Probably, then, the constraint is defined on the wrong EClass? What is
your context EClass? (the type of "self") It seems clear that the
context EClass does not have a "type" attribute.

To test OCL expressions on your Ecore model, you will find the
Interactive OCL Console example very helpful. Install it from the MDT
OCL component's examples feature. It adds a menu action to Ecore and
UML editors that opens the OCL console. A quick guide to using it is in
the OCL SDK help documentation.

MDT OCL also provides tracing options for parsing and evaluation; see
the Tracing tab in the Run launch configuration dialog.

HTH,

Christian

Mattia Lambertini wrote:
> I discovered the Error Log window :).
>
> If i i write an ocl test like:
>
> self.type = process::TProcessorType::Start
>
>
> the error is:
>
> Expression problem:Unrecognized variable: (type)body:self.type =
> process::TProcessorType::Start
>
>
> and for this test:
>
> self.outgoing->size() < 5
>
> the error is:
>
> Expression problem:Unrecognized variable:
> (outgoing)body:self.outgoing->size() < 5
>
> it don't find type and outgoing, but i am sure that type exist. Any idea?
>
>
>> Or something like an interpreter to use for testing my ocl code on my
>> model? Something that tell's what i am wrong.
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209771 is a reply to message #209749] Tue, 28 October 2008 17:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

Alex Shatalin wrote:
> Hello Mattia,
>
>> it don't find type and outgoing, but i am sure that type exist. Any
>> idea?
> Is it a LinkMapping.creationConstraints.sourceEnd/targetEnd constraitn
> or LinkMapping.DomainSpecialization ?
> (first option is correct).
>
> -----------------
> Alex Shatalin
>
>
I think the first but maybe i am wrong. I do link mapping -> link
constraint -> source end constraint.

If i write: self.name = 'zio'

and i set 'zio' as name in my element all work!
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209778 is a reply to message #209758] Tue, 28 October 2008 18:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

Hi Christian,

> Probably, then, the constraint is defined on the wrong EClass? What is
> your context EClass? (the type of "self") It seems clear that the
> context EClass does not have a "type" attribute.
>


My context Eclass is TProcessor class. surely there is an error in
something that i do but as you can see in this piece of my ecore there
is an attribute type in that class:


eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
eType="#//TProcessorType"
unsettable="true">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="type"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>



the whole TProcessor element in my ecore:

<eClassifiers xsi:type="ecore:EClass" name="TProcessor"
eSuperTypes="#//NodesType">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="TProcessor"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference"
name="cancellationArea" eType="#//TCancellationArea"
containment="true" resolveProxies="false">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="cancellationArea"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="processLogic" eType="ecore:EDataType
http://www.eclipse.org/emf/2003/XMLType#//String">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="processLogic"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="sourceAndEdgeId" eType="ecore:EDataType
http://www.eclipse.org/emf/2003/XMLType#//IDREF">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="sourceAndEdgeId"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="supportedEvents" eType="#//TEventType"
unsettable="true">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="supportedEvents"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="th"
eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//Integer">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="th"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
eType="#//TProcessorType"
unsettable="true">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="type"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>

> To test OCL expressions on your Ecore model, you will find the
> Interactive OCL Console example very helpful. Install it from the MDT
> OCL component's examples feature. It adds a menu action to Ecore and
> UML editors that opens the OCL console. A quick guide to using it is in
> the OCL SDK help documentation.
>
> MDT OCL also provides tracing options for parsing and evaluation; see
> the Tracing tab in the Run launch configuration dialog.

thank a lot for this information!
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209785 is a reply to message #209771] Tue, 28 October 2008 18:17 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mattia,

> I think the first but maybe i am wrong. I do link mapping -> link
> constraint -> source end constraint.
This is a right type of constraint.

> If i write: self.name = 'zio'
then try self.type = process::TProcessorType::Start

-----------------
Alex Shatalin
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209792 is a reply to message #209785] Tue, 28 October 2008 18:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

>> If i write: self.name = 'zio'
> then try self.type = process::TProcessorType::Start

it doesn' work. But maybe the problem is that in my link mapping the
source feature is a Connection.source:TProcess. Where TProcess is a
superclass for TProcessor. In TProcess there isn't the attribute type.
Is it the problem?
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209815 is a reply to message #209792] Wed, 29 October 2008 08:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

>
>>> If i write: self.name = 'zio'
>> then try self.type = process::TProcessorType::Start
>
> it doesn' work. But maybe the problem is that in my link mapping the
> source feature is a Connection.source:TProcess. Where TProcess is a
> superclass for TProcessor. In TProcess there isn't the attribute type.
> Is it the problem?

I saw that self is considered only a TProcess and so i can access only
its attribute.
There's a way to cast self into another type in ocl? If there isn't, I
can write the constraint in java, right? Optionally i can do this into
the java classes. Which classes i have to touch?
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209820 is a reply to message #209815] Wed, 29 October 2008 09:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

> There's a way to cast self into another type in ocl?

I solved using

self.oclAsType(TProcessor).type = process::TProcessorType::Start


Thank for the precious help till now!!

I have another problem, if i want to set the max number of link that an
element can have i have to write:

self.oclAsType(TProcessor).outgoing->size() < 2

but outgoing doesn't exist. What's outgoing?
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209821 is a reply to message #209820] Wed, 29 October 2008 09:32 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mattia,

> self.oclAsType(TProcessor).outgoing->size() < 2
> but outgoing doesn't exist. What's outgoing?
I suppose TProcessor has a back reference enumerating all the outgoing links.
So, "outgoing" in my sample was just an EReference name pointing from TProcessor
to link element - there is no special "artificial variable" pointing to the
outgoing links.

-----------------
Alex Shatalin
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209844 is a reply to message #209821] Wed, 29 October 2008 12:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

> I suppose TProcessor has a back reference enumerating all the outgoing
> links. So, "outgoing" in my sample was just an EReference name pointing
> from TProcessor to link element

How can i do a back reference like that? With an association and the
Eopposite attribute?

thank for the help, Alex
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209846 is a reply to message #209844] Wed, 29 October 2008 13:19 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mattia,

> How can i do a back reference like that? With an association and the
> Eopposite attribute?
right.

-----------------
Alex Shatalin
Re: how to use java( or ocl if is possible) for a link constraintingmfmap [message #209924 is a reply to message #209846] Thu, 30 October 2008 08:27 Go to previous message
Eclipse UserFriend
Originally posted by: mattia.lambertini.studio.unibo.it

>> How can i do a back reference like that? With an association and the
>> Eopposite attribute?
> right.

perfectly! All works now! thank a lot Alex!


best regards,

Mattia
Previous Topic:Mapping in XML Schema.
Next Topic:Regarding Drag and Drop in GMF
Goto Forum:
  


Current Time: Fri Mar 29 11:39:08 GMT 2024

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

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

Back to the top