Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » duplicate classes in a single package
duplicate classes in a single package [message #537488] Wed, 02 June 2010 15:26 Go to next message
pkojo is currently offline pkojoFriend
Messages: 27
Registered: October 2009
Junior Member
Hi

I am trying to find duplicate classes in a package, when I run my query it provides all duplicate classes from all packages of the model.

My question is how can I find duplicate classes in a single package.

right now I am running following query by selecting Packages as a context in eclipse OCL Interpreter console.

Class.allInstances()->select(n1|Class.allInstances()->exists(n2|n1<>n2 and n1.name = n2.name))->asSet()->select(oclIsTypeOf(Class))


Thanks in advance,
Re: duplicate classes in a single package [message #537511 is a reply to message #537488] Wed, 02 June 2010 16:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4184
Registered: July 2009
Senior Member
Hi pkojo

If you require 'n1.package = n2.package', then 'and' it with your exists
predicate

Your search will go quicker if you do Package.allInstances, then
do subloops of the package classifiers thereby rendering the same
package test redundant and excluding interpackage explorations from
the search domain.

Regards

Ed Willink



On 02/06/2010 16:26, pkojo wrote:
> Hi
>
> I am trying to find duplicate classes in a package, when I run my query
> it provides all duplicate classes from all packages of the model.
>
> My question is how can I find duplicate classes in a single package.
>
> right now I am running following query by selecting Packages as a
> context in eclipse OCL Interpreter console.
>
>
> Class.allInstances()->select(n1|Class.allInstances()->exists(n2|n1 <>n2
> and n1.name = n2.name))->asSet()->select(oclIsTypeOf(Class))
>
>
> Thanks in advance,
Re: duplicate classes in a single package [message #537658 is a reply to message #537511] Thu, 03 June 2010 09:44 Go to previous messageGo to next message
pkojo is currently offline pkojoFriend
Messages: 27
Registered: October 2009
Junior Member
Hi Ed,
Thanks for the response but I did not get your point. can you please explain it with example query.
Quote:
If you require 'n1.package = n2.package', then 'and' it with your exists predicate

from this it looks that you are talking about duplicate packages. but I am looking for duplicate classes in a same package. I am running that query on a package.
Thanks,
pkojo
Re: duplicate classes in a single package [message #537672 is a reply to message #537658] Thu, 03 June 2010 10:15 Go to previous message
pkojo is currently offline pkojoFriend
Messages: 27
Registered: October 2009
Junior Member
Hi,

I rewrite my query like this and it works fine.
context Package

 self.member->select(n1| self.member->exists(n2| n2 <> n1 and n1.name = n2.name))->select(oclIsTypeOf(Class))->asSet()
Previous Topic:EConstraint in Ecore Model
Next Topic:how to attach ocl constraint to uml class
Goto Forum:
  


Current Time: Thu Dec 18 12:40:19 GMT 2014

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

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