[gme-users] OCL and GME Question

Kyle Zielinski zielins1 at seattleu.edu
Thu Jul 8 23:30:28 CDT 2010

I'm using XTeam (http://www-scf.usc.edu/~gedwards/xteam.html), and more 
specifically, extending the SafexADL paradigm on top of GME.  I'm trying 
to add some constraints with my models, but am having problems 
understanding just what OCL is capable of in GME.  (Not only that, but 
it's my first time attempting OCL.)

We're using SafexADL to model and then simulate system architectures.  I 
have a hierarchy (the general structure of which comes from XTeam) that 
goes like this:

Root Folder
     Architecture Folder (Type: Folder Kind: Architecture)
         Architecture Folder (Type: Folder Kind: Architecture)
             Architecture (Type: Model, Kind: Architecture)
                 Component1 (Type: Model, Kind: Component)
                 Component2 (Type: Model, Kind: Component)
         Elements Folder (Type: Folder, Kind: Elements)
         (more folders)

What I'm trying to do is simply ensure that two components in the same 
Architecture (that's of Type: Model, Kind: Architecture, not folders) 
can't have the same component name.  At first, I had:

let mySet = project.allInstancesOf( Component ) in
mySet->isUnique( c | c.name)

I realized though, that this wouldn't work with the above example, 
because it gets all the components, period.  So I tried this:

let archBag = project.allInstancesOf( Architecture )->collect( 
oclAsType( Model )) in
archBag->forAll( arch | let compSet = arch.models( Component ) in 
compSet->isUnique(v | v.name) )

Which would catch the constraint ... and then crash GME.

Any suggestions?

Kyle Zielinski

More information about the gme-users mailing list