Skip to main content



      Home
Home » Modeling » OCL » Executing "ClassName.allInstances()" query on instances created using InstanceSpecificatio
Executing "ClassName.allInstances()" query on instances created using InstanceSpecificatio [message #1717076] Wed, 09 December 2015 14:57 Go to next message
Eclipse UserFriend
Hi,

I am working with a simple UML model and I want to create dynamic instances of a class in my code and then execute query "ClassName.allInstances()" to select those instances. I have tried to create instances using InstanceSpecification (org.eclipse.uml2.uml) and then setting values of properties in Slots of those instances. This works fine in Classic OCL but it doesn't work in Pivot. However, it works if I convert my model to Ecore and then create instances using EFactory.create(EClass) method.
I have tried to convert this InstanceSpecification to org.eclipse.ocl.pivot.InstanceSpecification using UML2ASDeclarationSwitch but it still didn't work. I want to know if there is any way I can create those instances in Pivot as I did in Ecore using EFactory?
Also, is there any way to uniquely identify EObject created using EFactory on the basis of name or ID as it can be done in InstanceSpecification using name?

Thanks.
Re: Executing "ClassName.allInstances()" query on instances created using Instance [message #1717109 is a reply to message #1717076] Wed, 09 December 2015 18:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi

UML2ASDeclarationSwitch is intended to be used as part of a full UML2AS
conversion, not just as a one-off. Internally it keeps track of UML-AS
correspondences, which can be accessed by e.g.

@Override
public Object caseDataType(org.eclipse.uml2.uml.DataType umlDataType) {
assert umlDataType != null;
DataType pivotElement = converter.getCreated(DataType.class, umlDataType);

----

allInstances() on InstanceSpecifications is kind of interesting.

Could you raise a Bugzilla attaching your simple model as a repro?

Regards

Ed Willink


On 09/12/2015 12:59, Finn Taylor wrote:
> Hi,
>
> I am working with a simple UML model and I want to create dynamic
> instances of a class in my code and then execute query
> "ClassName.allInstances()" to select those instances. I have tried to
> create instances using InstanceSpecification (org.eclipse.uml2.uml) and
> then setting values of properties in Slots of those instances. This
> works fine in Classic OCL but it doesn't work in Pivot. However, it
> works if I convert my model to Ecore and then create instances using
> EFactory.create(EClass) method. I have tried to convert this
> InstanceSpecification to org.eclipse.ocl.pivot.InstanceSpecification
> using UML2ASDeclarationSwitch but it still didn't work. I want to know
> if there is any way I can create those instances in Pivot as I did in
> Ecore using EFactory? Also, is there any way to uniquely identify
> EObject created using EFactory on the basis of name or ID as it can be
> done in InstanceSpecification using name?
>
> Thanks.
Re: Executing "ClassName.allInstances()" query on instances created using Instance [message #1717113 is a reply to message #1717109] Wed, 09 December 2015 20:46 Go to previous message
Eclipse UserFriend
Hi,

Thanks for your reply. I have raised a Bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=484060) and I've also attached the UML Model that I am working with.
I have also tried to create InstanceSpecification using PivotFactory but after debugging ClassfierAllInstancesOperation.evaluate(@NonNull Executor executor, @NonNull TypeId returnTypeId, @Nullable Object sourceVal) method, I think this is not going to work.
So is there a way that I can create dynamic instances other than in Ecore using EFactory? Or is there anything that I am missing here?
P.S. I have attached the UML model that I am using with this message.

Thanks.
Previous Topic:[OCL] ClassCastException for constraint on static profile
Next Topic:UML-OCL : Inheriting operations from primitive types in standard UML library
Goto Forum:
  


Current Time: Sat Jul 12 15:56:37 EDT 2025

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

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

Back to the top