Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL GMF LinkConstraint with Generalization
OCL GMF LinkConstraint with Generalization [message #59638] Tue, 22 July 2008 19:26 Go to next message
Peter  is currently offline Peter Friend
Messages: 85
Registered: July 2009
Member
Hello,
sorry for the Question, but I`m new in OCL.
I want to create a LinkConstraint for my GMF Editor.
My Model look like this:

Root
instances:Instance
links:Link
Instance
name:EString
Link
src:Instance
dst:Instance
Class1 -> Instance
Class2 -> Instance
Class3 -> Instance
....

I want to forbid special Links, for example between Class1 and 2.
It is possible?
Thanks for your Help.
Peter
Re: OCL GMF LinkConstraint with Generalization [message #59664 is a reply to message #59638] Tue, 22 July 2008 20:11 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-Q/kc/o882zK6oMMAmlTl
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Peter,

Apart from the mechanics of specifying link constraints in GMF (which
question would be better asked on the GMF newsgroup), I can possibly
help with the "pure OCL" aspect of your problem.

Do I read your syntax correctly, that Class1 and Class2 are model
elements that are instances of the Instance metaclass?

In that case, you could simply do:

context Link
inv: src->union(dst).name <> Set{'Class1', 'Class2'}

What I am doing here is creating a Set(Instance) containing the objects
referenced via the src and dst properties of the contextual Link object,
collecting the names of the Instances in this set, and ensuring that the
resulting set of names is different from the names that indicate
badness.

HTH,

Christian


On Tue, 2008-07-22 at 21:26 +0200, Peter wrote:

> Hello,
> sorry for the Question, but I`m new in OCL.
> I want to create a LinkConstraint for my GMF Editor.
> My Model look like this:
>
> Root
> instances:Instance
> links:Link
> Instance
> name:EString
> Link
> src:Instance
> dst:Instance
> Class1 -> Instance
> Class2 -> Instance
> Class3 -> Instance
> ...
>
> I want to forbid special Links, for example between Class1 and 2.
> It is possible?
> Thanks for your Help.
> Peter

--=-Q/kc/o882zK6oMMAmlTl
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Peter,<BR>
<BR>
Apart from the mechanics of specifying link constraints in GMF (which question would be better asked on the GMF newsgroup), I can possibly help with the &quot;pure OCL&quot; aspect of your problem.<BR>
<BR>
Do I read your syntax correctly, that Class1 and Class2 are model elements that are instances of the Instance metaclass?<BR>
<BR>
In that case, you could simply do:<BR>
<BR>
&nbsp;&nbsp; context Link<BR>
&nbsp;&nbsp; inv: src-&gt;union(dst).name &lt;&gt; Set{'Class1', 'Class2'}<BR>
<BR>
What I am doing here is creating a Set(Instance) containing the objects referenced via the src and dst properties of the contextual Link object, collecting the names of the Instances in this set, and ensuring that the resulting set of names is different from the names that indicate badness.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Tue, 2008-07-22 at 21:26 +0200, Peter wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hello,</FONT>
<FONT COLOR="#000000">sorry for the Question, but I`m new in OCL.</FONT>
<FONT COLOR="#000000">I want to create a LinkConstraint for my GMF Editor.</FONT>
<FONT COLOR="#000000">My Model look like this:</FONT>

<FONT COLOR="#000000">Root</FONT>
<FONT COLOR="#000000"> instances:Instance</FONT>
<FONT COLOR="#000000"> links:Link</FONT>
<FONT COLOR="#000000">Instance</FONT>
<FONT COLOR="#000000"> name:EString</FONT>
<FONT COLOR="#000000">Link</FONT>
<FONT COLOR="#000000"> src:Instance</FONT>
<FONT COLOR="#000000"> dst:Instance</FONT>
<FONT COLOR="#000000">Class1 -&gt; Instance</FONT>
<FONT COLOR="#000000">Class2 -&gt; Instance</FONT>
<FONT COLOR="#000000">Class3 -&gt; Instance</FONT>
<FONT COLOR="#000000">...</FONT>

<FONT COLOR="#000000">I want to forbid special Links, for example between Class1 and 2.</FONT>
<FONT COLOR="#000000">It is possible?</FONT>
<FONT COLOR="#000000">Thanks for your Help.</FONT>
<FONT COLOR="#000000">Peter</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-Q/kc/o882zK6oMMAmlTl--
Previous Topic:Question about <<definition>> stereotype
Next Topic:Parsing failed: ") unexpected token(s)" in helper.defineOperation(..) although number of p
Goto Forum:
  


Current Time: Thu Nov 27 00:31:05 GMT 2014

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

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