Home » Modeling » OCL » stereotype constraints
|
Re: stereotype constraints [message #70298 is a reply to message #70256] |
Wed, 06 May 2009 12:57 |
|
--=-dnIB1MNrZhoGwa8xFh5X
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi, Dennis,
You're collecting the associations of all attributes of the Agent
stereotype instance. If Agent doesn't have a property named 'attribute'
then this won't work. You need the attributes of the base class. Try
this:
context Agent
inv is_connected:
base_Class.attribute.association->excluding(null)->exists(
extension_Flow->notEmpty())
taking measures also to strip out the nulls for attributes that aren't
association ends. Also, note the lower case 'c' in the context
declaration and the single colon in the "inv [name]" syntax.
HTH,
Christian
On Wed, 2009-05-06 at 12:43 +0000, Dennis Sluijsmans wrote:
> Hi all,
>
> I couldn't find a complete answer to my problem so I post it here.
>
> I've build an UML profile with a stereotype called 'Flow' which extends
> Association and a stereotype called 'Agent' which extends Class.
> Now I want in a model with this profile applied to it, assure that every
> class of stereotype Agent have an association of stereotype Flow attached
> to it.
>
> Here is what I made up so far for the constraint of stereotype Agent, but
> on testing I still get an error.
> Context Agent
> inv: is_connected : attribute.association->exists(s |
> s.extension_Flow->notEmpty())
>
> Thanks in advance.
>
> Dennis
>
--=-dnIB1MNrZhoGwa8xFh5X
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.24.1.1">
</HEAD>
<BODY>
Hi, Dennis,<BR>
<BR>
You're collecting the associations of all attributes of the Agent stereotype instance. If Agent doesn't have a property named 'attribute' then this won't work. You need the attributes of the base class. Try this:<BR>
<BR>
context Agent<BR>
inv is_connected: base_Class.attribute.association->excluding(null)-&am p;gt;exists( <BR>
extension_Flow->notEmpty())<BR>
<BR>
taking measures also to strip out the nulls for attributes that aren't association ends. Also, note the lower case 'c' in the context declaration and the single colon in the "inv [name]" syntax.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
On Wed, 2009-05-06 at 12:43 +0000, Dennis Sluijsmans wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hi all,
I couldn't find a complete answer to my problem so I post it here.
I've build an UML profile with a stereotype called 'Flow' which extends
Association and a stereotype called 'Agent' which extends Class.
Now I want in a model with this profile applied to it, assure that every
class of stereotype Agent have an association of stereotype Flow attached
to it.
Here is what I made up so far for the constraint of stereotype Agent, but
on testing I still get an error.
Context Agent
inv: is_connected : attribute.association->exists(s |
s.extension_Flow->notEmpty())
Thanks in advance.
Dennis
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-dnIB1MNrZhoGwa8xFh5X--
|
|
| |
Re: stereotype constraints [message #70377 is a reply to message #70318] |
Wed, 06 May 2009 21:08 |
|
--=-7pXAuGFk2DahhTq7PdkT
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi, Dennis,
Which of your stereotypes Flow and Connection has the metaclass
extension relationship to uml::Association? If it is Connection, then
your constraint must use extension_Connection.
Keep in mind that these "extension_Xyz" role names are nothing more nor
less than owned (and non-navigable) ends of the metaclass extensions.
They are, from an OCL perspective, in every way like ordinary Property
ends of Associations. So, if you have this:
Stereotype Connection
extends uml::Association
Stereotype Flow
specializes Connection
Then, in an Association context, you can do "self.extension_Connection"
but not "self.extension_Flow" because the latter is not define. If you
need to test that, in particular, the applied stereotype is a Flow, then
do "self.extension_Connection->any(oclIsKindOf(myprofile::Flow)) ".
Note that if you have, instead, this situation:
Stereotype Connection
Stereotype Flow
specializes Connection
extends uml::Association
then it is awkward to test whether an Association has any Connection
stereotype applied, as you would have to enumerate all of the
specializing stereotypes (such as Flow) that have metaclass extensions
to Association.
HTH,
Christian
On Wed, 2009-05-06 at 15:38 +0000, Dennis Sluijsmans wrote:
> Hi Christian,
>
> Your solution works, thanks a lot!
>
> Another thing, if I construct a new stereotype 'Connection' (as an
> extension of Association) which is now a generalization of the stereotype
> 'Flow', the same constraint results in the following error:
> "Parsing Error: Unrecognized variable:(extension_Flow)"
>
> Any idea why?
>
--=-7pXAuGFk2DahhTq7PdkT
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.24.1.1">
</HEAD>
<BODY>
Hi, Dennis,<BR>
<BR>
Which of your stereotypes Flow and Connection has the metaclass extension relationship to uml::Association? If it is Connection, then your constraint must use extension_Connection.<BR>
<BR>
Keep in mind that these "extension_Xyz" role names are nothing more nor less than owned (and non-navigable) ends of the metaclass extensions. They are, from an OCL perspective, in every way like ordinary Property ends of Associations. So, if you have this:<BR>
<BR>
Stereotype Connection<BR>
extends uml::Association<BR>
<BR>
Stereotype Flow<BR>
specializes Connection<BR>
<BR>
Then, in an Association context, you can do "self.extension_Connection" but not "self.extension_Flow" because the latter is not define. If you need to test that, in particular, the applied stereotype is a Flow, then do "self.extension_Connection->any(oclIsKindOf( myprofile::Flow))". <BR>
<BR>
Note that if you have, instead, this situation:<BR>
<BR>
Stereotype Connection<BR>
<BR>
Stereotype Flow<BR>
specializes Connection<BR>
extends uml::Association<BR>
<BR>
then it is awkward to test whether an Association has any Connection stereotype applied, as you would have to enumerate all of the specializing stereotypes (such as Flow) that have metaclass extensions to Association.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Wed, 2009-05-06 at 15:38 +0000, Dennis Sluijsmans wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hi Christian,
Your solution works, thanks a lot!
Another thing, if I construct a new stereotype 'Connection' (as an
extension of Association) which is now a generalization of the stereotype
'Flow', the same constraint results in the following error:
"Parsing Error: Unrecognized variable:(extension_Flow)"
Any idea why?
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-7pXAuGFk2DahhTq7PdkT--
|
|
| |
Re: stereotype constraints [message #70520 is a reply to message #70478] |
Thu, 07 May 2009 12:55 |
|
--=-3msf/srw4/KW0f2oD0vD
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi, Dennis,
OCL is quite a small language, and has a very tiny library. So, there's
not much convenience. Nonetheless, it can express a very wide range of
constructs. It also allows you to develop your own library of helper
operations (so-called "def" expressions) to simplify the structure of
constraints and to reuse expressions. In the MDT implementation, you
can even extend the environment with Java-defined operations, that can
do more complex and meta-level computations than would even be feasible
with OCL. The OCL Developer Guide has an example of this, showing how
to add a regexp-matching operation to the String primitive type.
Some of the operations provided by the MDT implementation of UML may
also help. For example, I think there's an operation that gets all of
the Associations in which a Type (not just Classifiers, which I find
odd) participates. This may help to simplify your OCL.
Cheers,
Christian
On Thu, 2009-05-07 at 12:44 +0000, Dennis Sluijsmans wrote:
> Hi Christian,
>
> It is the myprofile::Connection stereotype that has the metaclass
> extension relationship to uml::Association.
>
> So the complete constraint for myprofile::Agent would be
> context Agent
> inv is_connected :
> base_Class.attribute.association->excluding(null)->exists(extension_SuperFlow- >any(oclIsKindOf(Profile::Flow)))
>
> Isn't there a much easier expression just for checking if a class has a
> stereotype of uml::Association attached to it?
>
> Thx,
> Dennis
>
--=-3msf/srw4/KW0f2oD0vD
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.24.1.1">
</HEAD>
<BODY>
Hi, Dennis,<BR>
<BR>
OCL is quite a small language, and has a very tiny library. So, there's not much convenience. Nonetheless, it can express a very wide range of constructs. It also allows you to develop your own library of helper operations (so-called "def" expressions) to simplify the structure of constraints and to reuse expressions. In the MDT implementation, you can even extend the environment with Java-defined operations, that can do more complex and meta-level computations than would even be feasible with OCL. The OCL Developer Guide has an example of this, showing how to add a regexp-matching operation to the String primitive type.<BR>
<BR>
Some of the operations provided by the MDT implementation of UML may also help. For example, I think there's an operation that gets all of the Associations in which a Type (not just Classifiers, which I find odd) participates. This may help to simplify your OCL.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
On Thu, 2009-05-07 at 12:44 +0000, Dennis Sluijsmans wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hi Christian,
It is the myprofile::Connection stereotype that has the metaclass
extension relationship to uml::Association.
So the complete constraint for myprofile::Agent would be
context Agent
inv is_connected :
base_Class.attribute.association->excluding(null)-&am p;gt;exists(extension_SuperFlow->any(oclIsKindOf(Prof ile::Flow)))
Isn't there a much easier expression just for checking if a class has a
stereotype of uml::Association attached to it?
Thx,
Dennis
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-3msf/srw4/KW0f2oD0vD--
|
|
|
Goto Forum:
Current Time: Sat Nov 09 02:12:33 GMT 2024
Powered by FUDForum. Page generated in 0.03049 seconds
|