eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[pivot] Support non-String defaults for Stereotype properties #1422

Open eclipse-ocl-bot opened 1 month ago

eclipse-ocl-bot commented 1 month ago

| --- | --- | | Bugzilla Link | 455704 | | Status | NEW | | Importance | P3 normal | | Reported | Dec 19, 2014 03:06 EDT | | Modified | Oct 29, 2015 09:02 EDT | | Reporter | Ed Willink |

Description

The "problem in evaluating the UML model with OCL API" thread on the OCL newsgroup provides an example where a user has a Stereotype property with an Object-valued default.

This fails because Stereotype Properties are realised by regular properties for which "default" is a String.

The limitation comes from UML 2.0 Basic where Property.default was a String and from Ecore where EStructuralFeature.defaultValueLiteral is an EString.

UML 2.5 non-Basic has evolved. Property.defaultValue is a ValueSpecification allowing OpaqueExpression/ExpressionInOCL for derived computation, or LiteralXXX or InstanceValue for known values.

Suggest change the Pivot Property.default:String to Property.defaultValue:Object for any known boxed value, retaining Property.defaultExpression renamed to Property.ownedExpression for derived computations.

context Property\ inv DerivedHasNoDefaultValue: isDerived implies defaultValue = null\ inv NonDerivedHasNoDefaultExpression: not isDerived implies ownedExpression = null

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Dec 19, 2014 11:42

Created attachment 249554 Tidied up attachment to newsgroup message

(In reply to Ed Willink from comment #0)

Suggest change the Pivot Property.default:String to Property.defaultValue:Object for any known boxed value

In order to be serializeable without string syntax knowledge in the serializer there must be a defaultValueString whose content is type-specific. For internal purposes defaultValue can be derived to have any Object value.

Attached, tidied up user project. Console output now gives:

startMain expression:self.Attribute1>5 sa: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@5273a5d3 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@7ce1eae7 (name: Stereotype1) (instanceClassName: null) (abstract: false, interface: false)) psa: class1$Stereotype1 context class1$Stereotype1 create Query: self.Attribute1.>(5) result: false expression:self.stereotype2.Attribute2>5 sa: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@5273a5d3 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@7ce1eae7 (name: Stereotype1) (instanceClassName: null) (abstract: false, interface: false)) psa: class1$Stereotype1 context class1$Stereotype1 create Query: self.stereotype2.Attribute2.>(5) result: false

an no exception stack trace.

:compression: TestValidation.zip