Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » getStereotype() always return "invariant"
getStereotype() always return "invariant" [message #1125521] Fri, 04 October 2013 16:00 Go to next message
John Guerson is currently offline John GuersonFriend
Messages: 51
Registered: August 2011
Member
Hi,
From what I have tested (kepler and the OCL 4.2.0 build) the method PivotUtil.getStereotype(constraint) is always returning "invariant".

OCL Document:
context RoadTrafficAccident::fatalvictims:Integer
derive: self.victims->select(d|d.oclIsKindOf(DeceasedPerson))->size()

getStereotype():
public static String getStereotype(@NonNull Constraint object) 
{
    EStructuralFeature eContainingFeature = object.eContainingFeature();
    System.out.println(eContainingFeature);
    if (eContainingFeature == PivotPackage.Literals.TYPE__OWNED_INVARIANT) return UMLReflection.INVARIANT;
    else if (eContainingFeature == PivotPackage.Literals.PROPERTY__DEFAULT_EXPRESSION) return UMLReflection.DERIVATION;
    ...
}

Constraint.toString():
context fatalvictims : ecore::EInt invariant: self.victims->select(d : EA_Model::Victim[?] | d.oclIsKindOf(EA_Model::DeceasedPerson))->size()

eContainingFeature:
org.eclipse.emf.ecore.impl.EReferenceImpl@244d9d89 (name: ownedInvariant) (ordered: false, unique: true, lowerBound: 0, upperBound: -1) 
(changeable: true, volatile: false, transient: false, defaultValueLiteral: null, unsettable: false, derived: false) (containment: true, resolveProxies: false)


Someone already came across with that?

Regards,
John
Re: getStereotype() always return "invariant" [message #1125533 is a reply to message #1125521] Fri, 04 October 2013 16:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

I am sorry, but I do not have time to try to turn your hints into a
repro. If you want help you need to provide a small zipped project.

Regards

Ed Willink

On 04/10/2013 12:00, John Guerson wrote:
> Hi,
> From what I have tested (kepler and the OCL 4.2.0 build) the method
> PivotUtil.getStereotype(constraint) is always returning "invariant".
>
> OCL Document:
>
> context RoadTrafficAccident::fatalvictims:Integer
> derive: self.victims->select(d|d.oclIsKindOf(DeceasedPerson))->size()
>
> getStereotype():
>
> public static String getStereotype(@NonNull Constraint object) {
> EStructuralFeature eContainingFeature = object.eContainingFeature();
> System.out.println(eContainingFeature);
> if (eContainingFeature ==
> PivotPackage.Literals.TYPE__OWNED_INVARIANT) return
> UMLReflection.INVARIANT;
> else if (eContainingFeature ==
> PivotPackage.Literals.PROPERTY__DEFAULT_EXPRESSION) return
> UMLReflection.DERIVATION;
> ...
> }
>
> Constraint.toString():
>
> context fatalvictims : ecore::EInt invariant: self.victims->select(d :
> EA_Model::Victim[?] | d.oclIsKindOf(EA_Model::DeceasedPerson))->size()
>
> eContainingFeature:
>
> org.eclipse.emf.ecore.impl.EReferenceImpl@244d9d89 (name:
> ownedInvariant) (ordered: false, unique: true, lowerBound: 0,
> upperBound: -1) (changeable: true, volatile: false, transient: false,
> defaultValueLiteral: null, unsettable: false, derived: false)
> (containment: true, resolveProxies: false)
>
>
> Someone already came across with that?
>
> Regards,
> John
>
Re: getStereotype() always return "invariant" [message #1125659 is a reply to message #1125533] Fri, 04 October 2013 19:10 Go to previous messageGo to next message
John Guerson is currently offline John GuersonFriend
Messages: 51
Registered: August 2011
Member
No Message Body
Re: getStereotype() always return "invariant" [message #1129443 is a reply to message #1125533] Tue, 08 October 2013 16:28 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi John

We were both equally confused by "getStereotype()".

In UML 1.x there was a Constraint::stereotype feature to distinguish
kinds of constraints. OCL 2.x has yet to properly align with UML 2.x and
so the OCL specification uses it and implementations have corresponding
'support'.

So "getStereotype" is getting the constraint kind:
<<invariant>>/<<postcondition>>/... etc

Needless to say this usage is being phased out. I hope that it only
exists as a kind of compatibility and for some diagnostics such as text
in the Outline View.

Regards

Ed Willink



On 04/10/2013 17:13, Ed Willink wrote:
> Hi
>
> I am sorry, but I do not have time to try to turn your hints into a
> repro. If you want help you need to provide a small zipped project.
>
> Regards
>
> Ed Willink
>
> On 04/10/2013 12:00, John Guerson wrote:
>> Hi,
>> From what I have tested (kepler and the OCL 4.2.0 build) the method
>> PivotUtil.getStereotype(constraint) is always returning "invariant".
>>
>> OCL Document:
>>
>> context RoadTrafficAccident::fatalvictims:Integer
>> derive: self.victims->select(d|d.oclIsKindOf(DeceasedPerson))->size()
>>
>> getStereotype():
>>
>> public static String getStereotype(@NonNull Constraint object) {
>> EStructuralFeature eContainingFeature = object.eContainingFeature();
>> System.out.println(eContainingFeature);
>> if (eContainingFeature ==
>> PivotPackage.Literals.TYPE__OWNED_INVARIANT) return
>> UMLReflection.INVARIANT;
>> else if (eContainingFeature ==
>> PivotPackage.Literals.PROPERTY__DEFAULT_EXPRESSION) return
>> UMLReflection.DERIVATION;
>> ...
>> }
>>
>> Constraint.toString():
>>
>> context fatalvictims : ecore::EInt invariant: self.victims->select(d
>> : EA_Model::Victim[?] | d.oclIsKindOf(EA_Model::DeceasedPerson))->size()
>>
>> eContainingFeature:
>>
>> org.eclipse.emf.ecore.impl.EReferenceImpl@244d9d89 (name:
>> ownedInvariant) (ordered: false, unique: true, lowerBound: 0,
>> upperBound: -1) (changeable: true, volatile: false, transient: false,
>> defaultValueLiteral: null, unsettable: false, derived: false)
>> (containment: true, resolveProxies: false)
>>
>>
>> Someone already came across with that?
>>
>> Regards,
>> John
>>
>
Previous Topic:Forum Netiquette
Next Topic:Checking an OCL constraint before actually setting the value
Goto Forum:
  


Current Time: Wed Nov 26 15:44:20 GMT 2014

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

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