derive Expression with stereotypes and tagged values [message #639185] |
Mon, 15 November 2010 14:50 |
Engin Deveci 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 |
Ed Willink Messages: 7655 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
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02073 seconds