Book a Demo

Author Topic: Profiles - associations  (Read 4142 times)

nraponi

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Profiles - associations
« on: March 05, 2006, 11:48:54 pm »
Hi,
I am creating a profile and would like to know if its possible to limit the associations between the various stereotypes.

For example stereotypeA can link to only one stereotypeB which can link to 1..n stereotypeC's and exactly one stereotypeD etc.

Thanks for any help!
cheers
Nick

thomaskilian

  • Guest
Re: Profiles - associations
« Reply #1 on: March 06, 2006, 01:07:40 am »
I don't know of any such possibility. The only one that comes to my mind would be to write a small add-in to check these constraints.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Profiles - associations
« Reply #2 on: March 06, 2006, 01:34:26 pm »
These sorts of constraints would usually be written in OCL.

If you place the constraint on the stereotype in your profile it will be copied when you apply the stereotype.  If you then configure the model validation (Project | Model Validation | Configure) to check OCL constraints. (Element: OCL Conformance, Relationship: OCL Conformance and Feature: OCL Conformance) then the model validation feature will evaluate the constraint and report if it is violated.

nraponi

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Profiles - associations
« Reply #3 on: March 06, 2006, 03:32:16 pm »
Thankyou for your help - I am looking into the OCL stuff.

There is very little available in the online help.  Do you know of a concise resource?  I am trying the following based on a page on google, but without success as it is always failing.

inv: self.LINKNAME=2

In order to try and determine that only 2 connections with LINKNAME exist.

cheers
Nick

thomaskilian

  • Guest
Re: Profiles - associations
« Reply #4 on: March 07, 2006, 01:31:25 am »
Google for "ocl omg" to find the complete specification. I was not able to find something useful in condensed format.
Edit:I'm not sure whether EA checks OCL only for having a valid syntax and leave the real constraint checking to someone else. Just a feeling I had after a few tests.
« Last Edit: March 07, 2006, 01:34:20 am by thomaskilian »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Profiles - associations
« Reply #5 on: March 07, 2006, 01:05:23 pm »
EA does actually check the validity of OCL constraints if the options I specified in my last post are turned on.

The simple case that I tried (see below) was identified by the model checker.

Code: [Select]
inv: 1 < 0

nraponi

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Profiles - associations
« Reply #6 on: March 07, 2006, 02:06:21 pm »
I too was able to use your OCL line to prove that it is performing validation.

No matter what I try I dont seem to be able to get it to use the link count in OCL though:

An example is "inv: self.LINKNAME->size()=1"

Where I have 2 classes initially not linked (expecting a failure) then creating an association between them with the end on the target class named "LINKNAME".  I've tried it with the association both ways around incase that was the issue.

Any ideas?

Cheers
Nick

SF_lt

  • EA User
  • **
  • Posts: 216
  • Karma: +1/-0
  • The Truth Is Out There
    • View Profile
Re: Profiles - associations
« Reply #7 on: March 08, 2006, 08:00:29 am »
There is quite good book on OCL 2 "The object constraint language 2.0"

I'm also not sure, if EA correctly validates OCL constraints :P
In 788 build I have a class, which has number : int = 3 atrribute (integer attribute with the default value of 3).
Constraints for number attribute:
inv: self.number < 1
inv: self.number > 1

And guess, what validation shows ;D ? both invariants are violated...
This was reported to Sparx, but nothing have changed...

Quote
Google for "ocl omg" to find the complete specification. I was not able to find something useful in condensed format.
Edit:I'm not sure whether EA checks OCL only for having a valid syntax and leave the real constraint checking to someone else. Just a feeling I had after a few tests.

registertm everything to SparX

thomaskilian

  • Guest
Re: Profiles - associations
« Reply #8 on: March 08, 2006, 12:12:35 pm »
Quote
inv: 1 < 0

I hope this is not the kind of test scenario used at Sparx in general :-X