| Home » Modeling » OCL » OCL context for an attribute?
 Goto Forum:| 
| OCL context for an attribute? [message #56117] | Tue, 20 May 2008 17:08  |  | 
| Eclipse User  |  |  |  |  | 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] | Tue, 20 May 2008 22:54   |  | 
| Eclipse User  |  |  |  |  | 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 13:55   |  | 
| Eclipse User  |  |  |  |  | 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] | Thu, 29 May 2008 23:05  |  | 
| Eclipse User  |  |  |  |  | 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.  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>
     context Employee<BR>
     inv bonus_eligibility:<BR>
          self.bonus > 0.0 implies<BR>
              Date::today() - self.startDate > self.probationDays and<BR>
              self.perfomanceRating > 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.  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.<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">"Christian W. Damus" <<A HREF="mailto:cdamus@zeligsoft.com">cdamus@zeligsoft.com</A>> wrote in message </FONT>
 <FONT COLOR="#000000">news:<A HREF="mailto:nemoTue052008105051@news.eclipse.org">nemoTue052008105051@news.eclipse.org</A>...</FONT>
 <FONT COLOR="#000000">> Hi, Arvinder,</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">> OCL has a notion of attribute context, which is used for the</FONT>
 <FONT COLOR="#000000">> definition of initial-value constraints and derivation expressions of</FONT>
 <FONT COLOR="#000000">> attributes.</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">> e.g.,</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">>  context NamedElement::qualifiedName : String</FONT>
 <FONT COLOR="#000000">>  derive: if not namespace.oclIsUndefined() and</FONT>
 <FONT COLOR="#000000">>              not namespace.name.oclIsUndefined()</FONT>
 <FONT COLOR="#000000">>          then</FONT>
 <FONT COLOR="#000000">>              namespace.name.concat('::').concat(name)</FONT>
 <FONT COLOR="#000000">>          else</FONT>
 <FONT COLOR="#000000">>              null</FONT>
 <FONT COLOR="#000000">>          endif</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">> HTH,</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">> Christian</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">> On Tuesday 05-20-2008   (05:08), arvinder birdi wrote:</FONT>
 <FONT COLOR="#000000">>>  Hello,</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">>>  I'm an OCL newbie and wanted to find out if there is a context for</FONT>
 <FONT COLOR="#000000">>> Attributes. The context's I've seen so far are for classes and</FONT>
 <FONT COLOR="#000000">>>  operations.</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">>>  thanks,</FONT>
 <FONT COLOR="#000000">>>  Arvinder</FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">></FONT>
 <FONT COLOR="#000000">> -- </FONT>
 <FONT COLOR="#000000">> I'm trying a new usenet client for Mac, Nemo OS X.</FONT>
 <FONT COLOR="#000000">> You can download it at <A HREF="http://www.malcom-mac.com/nemo">http://www.malcom-mac.com/nemo</A></FONT>
 <FONT COLOR="#000000">> </FONT>
 
 
 </PRE>
 </BLOCKQUOTE>
 </BODY>
 </HTML>
 
 --=-FDwKg8MMAFmWfoMdqlWD--
 |  |  |  | 
 
 
 Current Time: Fri Oct 31 00:53:39 EDT 2025 
 Powered by FUDForum . Page generated in 0.04900 seconds |