Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » derive Expression with stereotypes and tagged values(Unable to write an OCL derive expression for tagged values)
derive Expression with stereotypes and tagged values [message #639185] Mon, 15 November 2010 14:50 Go to next message
Engin Deveci is currently offline Engin DeveciFriend
Messages: 7
Registered: November 2010
Junior Member
Hi,

I have defined a profile containing one stereotype : "SoftwareComponent". This stereotype has one tagged value: "TrustLevel".

Now, i'm trying to write a derive expression with OCL:

package ThreatAnalysis context SoftwareComponent::TrustLevel : Integer
derive: if self.oclAsType(uml::Property).owner.oclAsType(SoftwareCompon ent).base_Class.name='Client' then 1 else 2 endif
endpackage

In other words, above expression is supposed to set the TrustLevel tagged value to 1 if the class which has "SoftwareComponent" stereotype applied, has the name "Client".

However when i execute above OCL, i receive OCLInvalid as described below:

[OCL] Evaluate: self
[OCL] Result : org.eclipse.emf.ecore.impl.DynamicEObjectImpl@833813 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@12a2a50 (name: SoftwareComponent) (instanceClassName: null) (abstract: false, interface: false))
[OCL] Evaluate: uml::Property
[OCL] Result : org.eclipse.uml2.uml.internal.impl.ClassImpl@1a9ec16 (name: Property, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
[OCL] Evaluate: self.oclAsType(uml::Property)
[OCL] Result : OclInvalid

Any comment is highly appreciated.

BR,
Engin Deveci

[Updated on: Mon, 15 November 2010 16:45]

Report message to a moderator

Re: derive Expression with stereotypes and tagged values [message #639253 is a reply to message #639185] Mon, 15 November 2010 18:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4187
Registered: July 2009
Senior Member
Hi Engin

oclAsType should return invalid if the source is not the required type.

MDT/OCL 3.0.0 returns invalid in accordance with corrections in OCL 2.3,
whereas MDT/OCL 1.x returns OclInvalid which was one ambiguous
possibility for OCL 2.0, 2.2.

It looks as if you're using MDT/OCL 1.3 and the evaluatiioon is
complaining that self is not a uml::Property.

Regards

Ed Willink

On 15/11/2010 14:50, Engin Deveci wrote:
> I have defined a profile containing one stereotype :
> "SoftwareComponent". This stereotype has one tagged value: "TrustLevel".
>
> Now, i'm trying to write a derive expression with OCL:
>
> package ThreatAnalysis context SoftwareComponent::TrustLevel : Integer
> derive: if
> self.oclAsType(uml::Property).owner.oclAsType(SoftwareCompon
> ent).base_Class.name='Client' then 1 else 2 endif
> endpackage
>
> In other words, above expression sets the TrustLevel tagged value to 1
> if the class which has "SoftwareComponent" stereotype applied, has
> the name "Client".
>
> However when i execute above OCL, i receive OCLInvalid as described
> below:
>
> [OCL] Evaluate: self
> [OCL] Result :
> mailto:org.eclipse.emf.ecore.impl.DynamicEObjectImpl@833813 (eClass:
> mailto:org.eclipse.emf.ecore.impl.EClassImpl@12a2a50 (name:
> SoftwareComponent) (instanceClassName: null) (abstract: false,
> interface: false))
> [OCL] Evaluate: uml::Property
> [OCL] Result :
> mailto:org.eclipse.uml2.uml.internal.impl.ClassImpl@1a9ec16 (name:
> Property, visibility: <unset>) (isLeaf: false, isAbstract: false)
> (isActive: false)
> [OCL] Evaluate: self.oclAsType(uml::Property)
> [OCL] Result : OclInvalid
>
> Any comment is highly appreciated.
>
> BR,
> Engin Deveci
>
Re: derive Expression with stereotypes and tagged values [message #639254 is a reply to message #639253] Mon, 15 November 2010 18:24 Go to previous messageGo to next message
Engin Deveci is currently offline Engin DeveciFriend
Messages: 7
Registered: November 2010
Junior Member
Hi Ed,

Thanks for reply. Yes, evaluatiion is
complaining that self is not a uml::Property. Do you have any idea what' type self is in this context?

ThreatAnalysis is the name of the UML profile.
SoftwareComponent is the name of the stereotype.
TrustLevel is tagged value and it's Integer type.

package ThreatAnalysis context SoftwareComponent::TrustLevel : Integer
derive: if
self.oclAsType(uml::Property).owner.oclAsType(SoftwareCompon ent).base_Class.name='Client' then 1 else 2 endif
endpackage

BR;
Engin
Re: derive Expression with stereotypes and tagged values [message #639261 is a reply to message #639254] Mon, 15 November 2010 18:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4187
Registered: July 2009
Senior Member
Hi

The context is SoftwareComponent::TrustLevel so presumably self is
SoftwareComponent.

Regards

Ed Willink

On 15/11/2010 18:24, Engin Deveci wrote:
> Hi Ed,
>
> Thanks for reply. Yes, evaluatiion is complaining that self is not a
> uml::Property. Do you have any idea what' type self is in this context?
>
> ThreatAnalysis is the name of the UML profile.
> SoftwareComponent is the name of the stereotype.
> TrustLevel is tagged value and it's Integer type.
> package ThreatAnalysis context SoftwareComponent::TrustLevel : Integer
> derive: if
> self.oclAsType(uml::Property).owner.oclAsType(SoftwareCompon
> ent).base_Class.name='Client' then 1 else 2 endif
> endpackage
>
> BR;
> Engin
Re: derive Expression with stereotypes and tagged values [message #639266 is a reply to message #639261] Mon, 15 November 2010 19:28 Go to previous message
Engin Deveci is currently offline Engin DeveciFriend
Messages: 7
Registered: November 2010
Junior Member
Hi again,

Thanks for the help. It's working now.
BR,

Engin
Previous Topic:SemanticException
Next Topic:Extend OCL editor
Goto Forum:
  


Current Time: Fri Dec 19 10:11:00 GMT 2014

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

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