Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Loop on all nodes to check if they are all connected together(GMF diagram elements)
Loop on all nodes to check if they are all connected together [message #635607] Wed, 27 October 2010 13:40 Go to next message
Mostafa ElShafei is currently offline Mostafa ElShafei
Messages: 39
Registered: October 2010
Member
Dear All,

Can anyone help me with the following, I need OCL code to loop on all elements in a GMF diagram to check if they are all connected together.

For example:

1-Select all elements in diagram
2-Select start node
3-Try to select outgoing nodes of each element till arriving to the end node. (and save all nodes)
4- If step1 == step 3 -----------> success
else
Error

Thank you in advance for your help. Smile
Re: Loop on all nodes to check if they are all connected together [message #635658 is a reply to message #635607] Wed, 27 October 2010 15:41 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Mostafa

You'll find the extra closure() iterator in MDT/OCL since 1.2 and
probably in OMG OCL 2.3 helpful for step three.

sef->closure(outgoing)

will return a set of

self.outgoing
self.outgoing.outgoing
self.outgoing.outgoing.outgoing
self.outgoing.outgoing.outgoing.outgoing

etc

Regards

Ed Willink

On 27/10/2010 14:40, Mostafa ElShafei wrote:
> Dear All,
>
> Can anyone help me with the following, I need OCL code to loop on all
> elements in a GMF diagram to check if they are all connected together.
>
> For example:
>
> 1-Select all elements in diagram
> 2-Select start node
> 3-Try to select outgoing nodes of each element till arriving to the
> end node. (and save all nodes)
> 4- If step1 == step 3 -----------> success
> else
> Error
>
> Thank you in advance for your help. :)
Re: Loop on all nodes to check if they are all connected together [message #635808 is a reply to message #635607] Thu, 28 October 2010 08:13 Go to previous messageGo to next message
Mostafa ElShafei is currently offline Mostafa ElShafei
Messages: 39
Registered: October 2010
Member
Hi Edward

I appreciate your fast reply. Smile

However, the result of the following:

start->closure(outgoingConnections)

returns

Usage of non-standard "closure" iterator Sad

Can you please provide me with more information?

Thank you in advance Smile
Re: Loop on all nodes to check if they are all connected together [message #635943 is a reply to message #635808] Thu, 28 October 2010 16:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi

It should only be a warning, which you can suppress by code such as

BasicEnvironment benv =
OCLUtil.getAdapter(ocl.getEnvironment(), BasicEnvironment.class);
benv.setOption(ProblemOption.CLOSURE_ITERATOR,
ProblemHandler.Severity.OK);

Regards

Ed Willink

On 28/10/2010 09:13, Mostafa ElShafei wrote:
> Hi Edward
>
> I appreciate your fast reply. :)
>
> However, the result of the following:
>
> start->closure(outgoingConnections)
>
> returns
>
> Usage of non-standard "closure" iterator :(
>
> Can you please provide me with more information?
>
> Thank you in advance :)
Re: Loop on all nodes to check if they are all connected together [message #635988 is a reply to message #635607] Thu, 28 October 2010 20:26 Go to previous messageGo to next message
Mostafa ElShafei is currently offline Mostafa ElShafei
Messages: 39
Registered: October 2010
Member
Hello Edward,

Can you please tell me where exactly do I have to add your mentioned code?

Best Regards.
Re: Loop on all nodes to check if they are all connected together [message #636035 is a reply to message #635988] Fri, 29 October 2010 06:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
On 28/10/2010 21:26, Mostafa ElShafei wrote:
> Hello Edward,
>
> Can you please tell me where exactly do I have to add your mentioned
> code?
>
> Best Regards.

Only if you tell me how you invoke your OCL in the first place.

I assumed you were using a Java API and so could add some Java code.

Regards

Ed Willink
Re: Loop on all nodes to check if they are all connected together [message #636047 is a reply to message #636035] Fri, 29 October 2010 07:21 Go to previous messageGo to next message
Mostafa ElShafei is currently offline Mostafa ElShafei
Messages: 39
Registered: October 2010
Member
Dear Edward,

I am invoking OCL from the GMFMAP of my EMF/GMF Diagram.

Thank you in advance.
Re: Loop on all nodes to check if they are all connected together [message #636051 is a reply to message #636047] Fri, 29 October 2010 07:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Mostafa

Mm. Difficult. https://bugs.eclipse.org/bugs/show_bug.cgi?id=329006 raised.

The message is a warning message that occurs during validation; it does
not inhibit OCL execution.

So you have one API problem with respect to OCL addressed by the above
bug. However this should only be an inelegance; a warning message that
you have to ignore.

Perhaps you have a further API problem with respect to GMF that does not
allow you to execute in the presence of validation warnings. I have not
tried using OCL from GMF, so if this is indeed a problem please raise a
GMF bug.

Regards

Ed Willink


On 29/10/2010 08:21, Mostafa ElShafei wrote:
> Dear Edward,
>
> I am invoking OCL from the GMFMAP of my EMF/GMF Diagram.
>
> Thank you in advance.
Re: Loop on all nodes to check if they are all connected together [message #636060 is a reply to message #636051] Fri, 29 October 2010 08:24 Go to previous messageGo to next message
Mostafa ElShafei is currently offline Mostafa ElShafei
Messages: 39
Registered: October 2010
Member
Dear Edward,

Unfortunately, I do not hove permission to enter a bug. Sad

But, is my dream over? Very Happy
Is there another solution?? Smile
Re: Loop on all nodes to check if they are all connected together [message #636074 is a reply to message #636060] Fri, 29 October 2010 08:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi Mostafa

Anyone can apply for a Bugzilla account, which will then allow you to
enter/comment on bugs.

You can ask on the GMF newsgroup for a solution.

One workaround would be to use a private version of org.eclipse.ocl iin
which you zap org.eclipse.ocl.options.ProblemOptions.CLOSURE_ITERATOR
from WARNING to OK.

Another is to include the

BasicEnvironment benv =
OCLUtil.getAdapter(ocl.getEnvironment(), BasicEnvironment.class);
benv.setOption(ProblemOption.CLOSURE_ITERATOR,
ProblemHandler.Severity.OK);

lines in the construction of a derived ValidationVisitor within your
generated GMF editor. I don't kwno how easy this is to do.

Another option is not to use closure(), in which case you have to code
your own recursive operation that uses iterate() to accumulate results
within a Set.

Regards

Ed Willink


On 29/10/2010 09:24, Mostafa ElShafei wrote:
> Dear Edward,
>
> Unfortunately, I do not hove permission to enter a bug. :(
>
> But, is my dream over? :d
> Is there another solution?? :)
Re: Loop on all nodes to check if they are all connected together [message #636109 is a reply to message #635607] Fri, 29 October 2010 10:40 Go to previous message
Mostafa ElShafei is currently offline Mostafa ElShafei
Messages: 39
Registered: October 2010
Member
Dear Edward,

I would like to thank you for all your help. I will try all your advices and If I come to a working solution I will post it here for everybody.

Best regards
Previous Topic:OCL Constraint: No two diagram elements can have the same name
Next Topic:check syntax of OCL query
Goto Forum:
  


Current Time: Sat Oct 25 11:24:32 GMT 2014

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

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