Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL context for an attribute?
OCL context for an attribute? [message #56117] Tue, 20 May 2008 21:08 Go to next message
Eclipse UserFriend
Originally posted by: birar01.ca.com

Hello,

I'm an OCL newbie and wanted to find out if there is a context for
Attributes. The context's I've seen so far are for classes and operations.

thanks,
Arvinder
Re: OCL context for an attribute? [message #56143 is a reply to message #56117] Wed, 21 May 2008 02:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Arvinder,

OCL has a notion of attribute context, which is used for the
definition of initial-value constraints and derivation expressions of
attributes.

e.g.,

context NamedElement::qualifiedName : String
derive: if not namespace.oclIsUndefined() and
not namespace.name.oclIsUndefined()
then
namespace.name.concat('::').concat(name)
else
null
endif

HTH,

Christian

On Tuesday 05-20-2008 (05:08), arvinder birdi wrote:
> Hello,

> I'm an OCL newbie and wanted to find out if there is a context for
> Attributes. The context's I've seen so far are for classes and
> operations.

> thanks,
> Arvinder




--

I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo
Re: OCL context for an attribute? [message #57191 is a reply to message #56143] Thu, 29 May 2008 17:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: birar01.ca.com

Thanks for your reply. I wanted to provide some background information:

We have invariants, with a class context, on different attributes of the
class.

After the call to BatchValidator.validate(Object) we get AggregateStatus or
ConstraintStatus objects.

From the ConstraintStatus we want to figure out which attribute of an
eobject the constraint was related to.

The other option is to use a naming scheme for the invariants and parse the
name.

Arvinder

"Christian W. Damus" <cdamus@zeligsoft.com> wrote in message
news:nemoTue052008105051@news.eclipse.org...
> Hi, Arvinder,
>
> OCL has a notion of attribute context, which is used for the
> definition of initial-value constraints and derivation expressions of
> attributes.
>
> e.g.,
>
> context NamedElement::qualifiedName : String
> derive: if not namespace.oclIsUndefined() and
> not namespace.name.oclIsUndefined()
> then
> namespace.name.concat('::').concat(name)
> else
> null
> endif
>
> HTH,
>
> Christian
>
> On Tuesday 05-20-2008 (05:08), arvinder birdi wrote:
>> Hello,
>
>> I'm an OCL newbie and wanted to find out if there is a context for
>> Attributes. The context's I've seen so far are for classes and
>> operations.
>
>> thanks,
>> Arvinder
>
>
>
> --
> I'm trying a new usenet client for Mac, Nemo OS X.
> You can download it at http://www.malcom-mac.com/nemo
>
Re: OCL context for an attribute? [message #57270 is a reply to message #57191] Fri, 30 May 2008 03:05 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-FDwKg8MMAFmWfoMdqlWD
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Arvinder,

I see. Perhaps another approach that you could take, given that you are
specify your invariant constraints in OCL, is to analyze the constraint
expression on detection of a failure, to see which sub-expression (and
hence the attributes involved) caused the expression value to be false.

For example, suppose that in a model of employees, the following
constraint is violated:

context Employee
inv bonus_eligibility:
self.bonus > 0.0 implies
Date::today() - self.startDate > self.probationDays and
self.perfomanceRating > 3

Then, you can analyze the various boolean-valued sub-expressions to find
which attribute or group of attributes is at fault and needs to be
corrected. By the nature of the "implies" operation, a failure of this
constraint can always mean that the 'bonus' attribute value is incorrect
(because false can imply true or false but true can only imply true).
Next, consider the arguments to the "and" operator: if the first part
is false, then the problem attribute is one of 'startDate' or
'probationDays' (because today() is an absolute) or, as determined
already, 'bonus'. Otherwise, if this part of the 'and' expression is
true, then obviously the other part is false and either
'performanceRating' or 'bonus' is the problem.

This ability to analyze OCL expressions (because the language is so much
simpler than Java) is quite powerful.

HTH,

Christian

On Thu, 2008-05-29 at 12:55 -0500, arvinder birdi wrote:

> Thanks for your reply. I wanted to provide some background information:
>
> We have invariants, with a class context, on different attributes of the
> class.
>
> After the call to BatchValidator.validate(Object) we get AggregateStatus or
> ConstraintStatus objects.
>
> From the ConstraintStatus we want to figure out which attribute of an
> eobject the constraint was related to.
>
> The other option is to use a naming scheme for the invariants and parse the
> name.
>
> Arvinder
>
> "Christian W. Damus" <cdamus@zeligsoft.com> wrote in message
> news:nemoTue052008105051@news.eclipse.org...
> > Hi, Arvinder,
> >
> > OCL has a notion of attribute context, which is used for the
> > definition of initial-value constraints and derivation expressions of
> > attributes.
> >
> > e.g.,
> >
> > context NamedElement::qualifiedName : String
> > derive: if not namespace.oclIsUndefined() and
> > not namespace.name.oclIsUndefined()
> > then
> > namespace.name.concat('::').concat(name)
> > else
> > null
> > endif
> >
> > HTH,
> >
> > Christian
> >
> > On Tuesday 05-20-2008 (05:08), arvinder birdi wrote:
> >> Hello,
> >
> >> I'm an OCL newbie and wanted to find out if there is a context for
> >> Attributes. The context's I've seen so far are for classes and
> >> operations.
> >
> >> thanks,
> >> Arvinder
> >
> >
> >
> > --
> > I'm trying a new usenet client for Mac, Nemo OS X.
> > You can download it at http://www.malcom-mac.com/nemo
> >
>
>

--=-FDwKg8MMAFmWfoMdqlWD
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.16.0">
</HEAD>
<BODY>
Hi, Arvinder,<BR>
<BR>
I see.&nbsp; Perhaps another approach that you could take, given that you are specify your invariant constraints in OCL, is to analyze the constraint expression on detection of a failure, to see which sub-expression (and hence the attributes involved) caused the expression value to be false.<BR>
<BR>
For example, suppose that in a model of employees, the following constraint is violated:<BR>
<BR>
&nbsp;&nbsp;&nbsp; context Employee<BR>
&nbsp;&nbsp;&nbsp; inv bonus_eligibility:<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; self.bonus &gt; 0.0 implies<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Date::today() - self.startDate &gt; self.probationDays and<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.perfomanceRating &gt; 3<BR>
<BR>
Then, you can analyze the various boolean-valued sub-expressions to find which attribute or group of attributes is at fault and needs to be corrected.&nbsp; By the nature of the &quot;implies&quot; operation, a failure of this constraint can always mean that the 'bonus' attribute value is incorrect (because false can imply true or false but true can only imply true).&nbsp; Next, consider the arguments to the &quot;and&quot; operator:&nbsp; if the first part is false, then the problem attribute is one of 'startDate' or 'probationDays' (because today() is an absolute) or, as determined already, 'bonus'.&nbsp; Otherwise, if this part of the 'and' expression is true, then obviously the other part is false and either 'performanceRating' or 'bonus' is the problem.<BR>
<BR>
This ability to analyze OCL expressions (because the language is so much simpler than Java) is quite powerful.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
On Thu, 2008-05-29 at 12:55 -0500, arvinder birdi wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Thanks for your reply. I wanted to provide some background information:</FONT>

<FONT COLOR="#000000">We have invariants, with a class context, on different attributes of the </FONT>
<FONT COLOR="#000000">class.</FONT>

<FONT COLOR="#000000">After the call to BatchValidator.validate(Object) we get AggregateStatus or </FONT>
<FONT COLOR="#000000">ConstraintStatus objects.</FONT>

<FONT COLOR="#000000">From the ConstraintStatus we want to figure out which attribute of an </FONT>
<FONT COLOR="#000000">eobject the constraint was related to.</FONT>

<FONT COLOR="#000000">The other option is to use a naming scheme for the invariants and parse the </FONT>
<FONT COLOR="#000000">name.</FONT>

<FONT COLOR="#000000">Arvinder</FONT>

<FONT COLOR="#000000">&quot;Christian W. Damus&quot; &lt;<A HREF="mailto:cdamus@zeligsoft.com">cdamus@zeligsoft.com</A>&gt; wrote in message </FONT>
<FONT COLOR="#000000">news:<A HREF="mailto:nemoTue052008105051@news.eclipse.org">nemoTue052008105051@news.eclipse.org</A>...</FONT>
<FONT COLOR="#000000">&gt; Hi, Arvinder,</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt; OCL has a notion of attribute context, which is used for the</FONT>
<FONT COLOR="#000000">&gt; definition of initial-value constraints and derivation expressions of</FONT>
<FONT COLOR="#000000">&gt; attributes.</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt; e.g.,</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt; context NamedElement::qualifiedName : String</FONT>
<FONT COLOR="#000000">&gt; derive: if not namespace.oclIsUndefined() and</FONT>
<FONT COLOR="#000000">&gt; not namespace.name.oclIsUndefined()</FONT>
<FONT COLOR="#000000">&gt; then</FONT>
<FONT COLOR="#000000">&gt; namespace.name.concat('::').concat(name)</FONT>
<FONT COLOR="#000000">&gt; else</FONT>
<FONT COLOR="#000000">&gt; null</FONT>
<FONT COLOR="#000000">&gt; endif</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt; HTH,</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt; Christian</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt; On Tuesday 05-20-2008 (05:08), arvinder birdi wrote:</FONT>
<FONT COLOR="#000000">&gt;&gt; Hello,</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; I'm an OCL newbie and wanted to find out if there is a context for</FONT>
<FONT COLOR="#000000">&gt;&gt; Attributes. The context's I've seen so far are for classes and</FONT>
<FONT COLOR="#000000">&gt;&gt; operations.</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; thanks,</FONT>
<FONT COLOR="#000000">&gt;&gt; Arvinder</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt;</FONT>
<FONT COLOR="#000000">&gt; -- </FONT>
<FONT COLOR="#000000">&gt; I'm trying a new usenet client for Mac, Nemo OS X.</FONT>
<FONT COLOR="#000000">&gt; You can download it at <A HREF="http://www.malcom-mac.com/nemo">http://www.malcom-mac.com/nemo</A></FONT>
<FONT COLOR="#000000">&gt; </FONT>


</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-FDwKg8MMAFmWfoMdqlWD--
Previous Topic:use of OCL: implement functionality or validate implementation against specifications (GMF)
Next Topic:OCL for UML2
Goto Forum:
  


Current Time: Fri Apr 19 06:11:40 GMT 2024

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

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

Back to the top