Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Get all class attributes, including those from association ends
Get all class attributes, including those from association ends [message #1803541] Sun, 03 March 2019 21:52 Go to next message
Thomas Pusztai is currently offline Thomas PusztaiFriend
Messages: 27
Registered: September 2018
Junior Member
Hi,

I'm working on a code generator and I'm having problems getting all attributes of a class in my UML2 model. If I have an object of type org.eclipse.uml2.uml.Class, the following methods do not return attributes that come from association ends:

  • allAttributes()
  • getOwnedAttributes()
  • getAllAttributes()


For example:
index.php/fa/35001/0/
For the "Car" class in this class diagram, I would get the attribute "doors", but not the attribute "engine".

How can I get the attributes from association ends as well?
  • Attachment: Example.png
    (Size: 47.43KB, Downloaded 136 times)

[Updated on: Sun, 03 March 2019 21:56]

Report message to a moderator

Re: Get all class attributes, including those from association ends [message #1803548 is a reply to message #1803541] Mon, 04 March 2019 06:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6614
Registered: July 2009
Senior Member
Hi

You are obviously not doing what you think you are. and not providing a repro to enable us to understand.

If you add
		EList<Property> allAttributes = purchaseOrderClass.getAllAttributes();

to the GettingStartedWithUML2 example, you can use the debugger to confirm that AssociationEnds do contribute.

Regards

Ed Willink
Re: Get all class attributes, including those from association ends [message #1803632 is a reply to message #1803548] Tue, 05 March 2019 19:53 Go to previous messageGo to next message
Thomas Pusztai is currently offline Thomas PusztaiFriend
Messages: 27
Registered: September 2018
Junior Member
Hi,

Thank you for your response. I tried getAllAttributes() and it doesn't work.

The concrete problem is this method. If I obtain the attributes using classifier.getAllAttributes(), I don't get those from association ends.

As a workaround I'm now passing in the list of attributes obtained by combining getAllAttributes() with the results of these OCL queries from UML Designer.

This works fine, so I'm happy with that.
Re: Get all class attributes, including those from association ends [message #1803660 is a reply to message #1803632] Wed, 06 March 2019 10:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6614
Registered: July 2009
Senior Member
Hi

You may be happy now, but in my experience you are avoiding solving a reproducible problem now. It will come back to bite you later, quite possibly in an obscure intermittent form.

From what little you have told us it seems that you have written a toUML generator that doesn't work. That is, the UML2 project's expectations on consistent model elements differs from yours/your generator's. IIRC the first time I tried to generate UML, I made a mess of it and it was a while before I appreciated how to get Associations just right.

Eclipse UML2 has been in use for many years so it is very unikely that your problem is a defect in Eclipse UML2.

Regards

Ed Willink
Re: Get all class attributes, including those from association ends [message #1803684 is a reply to message #1803660] Wed, 06 March 2019 18:11 Go to previous messageGo to next message
Thomas Pusztai is currently offline Thomas PusztaiFriend
Messages: 27
Registered: September 2018
Junior Member
Hi,

I agree with you that my workaround isn't an ideal solution, but since it is a research prototype I can live with that. Also, at the moment I don't have time to find a proper solution (as you know, I also have to deal with this problem: https://www.eclipse.org/forums/index.php/t/1097919/ )

By the way, I'm not generating any UML, I'm generating C and Java code from the UML model. The UML model was created with UML Designer.
Re: Get all class attributes, including those from association ends [message #1803704 is a reply to message #1803684] Thu, 07 March 2019 08:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6614
Registered: July 2009
Senior Member
HI

OK. I am not familiar with UML Designer so it may have a bug in its UML generation, or rather some wizard may fail to ensure the creation of a valid Association + Properties.

More likely, some wizard fails to help, so that what you treat as UML is actually a UML-like model with variant semantics. This could be fine so long as the only consumer is yours and it consistently uses the variant semantics. It may not bite until a next research activity wants to exploit your 'UML' models only to discover that they are variant UML.

If you shared your broken model, you might get some help in understanding the breakage.

Regards

Ed Willink
Re: Get all class attributes, including those from association ends [message #1803714 is a reply to message #1803704] Thu, 07 March 2019 12:54 Go to previous messageGo to next message
Thomas Pusztai is currently offline Thomas PusztaiFriend
Messages: 27
Registered: September 2018
Junior Member
Hi,

The model that is causing the problems can be found here. The Fog UML profile is here.
Re: Get all class attributes, including those from association ends [message #1803725 is a reply to message #1803714] Thu, 07 March 2019 16:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6614
Registered: July 2009
Senior Member
Hi

If you Validate your model you will see that you have 34 errors:

Description Resource Path Location Type
The required feature 'base_Class' of 'Activity Realization -> <<ActivityRealization, FogDevice>> <Package> Monitoring' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Class' of 'Data Model -> <<DataModel>> <Package> Models' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Class' of 'Fog Device ARM_32bit -> <<FogDevice>> <Interface> BloodPressureSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Class' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> BloodSugarSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Class' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> HeartRateSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Class' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> InsulinPump' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Class' of 'Fog Device MIPS_32bit -> <<FogDevice>> <Interface> TemperatureSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Class' of 'Fog Device x86_32bit -> <<ActivityRealization, FogDevice>> <Package> Monitoring' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Device' of 'Fog Device ARM_32bit -> <<FogDevice>> <Interface> BloodPressureSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Device' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> BloodSugarSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Device' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> HeartRateSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Device' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> InsulinPump' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Device' of 'Fog Device MIPS_32bit -> <<FogDevice>> <Interface> TemperatureSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Device' of 'Fog Device x86_32bit -> <<ActivityRealization, FogDevice>> <Package> Monitoring' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Interface' of 'Activity Realization -> <<ActivityRealization, FogDevice>> <Package> Monitoring' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Interface' of 'Fog Device x86_32bit -> <<ActivityRealization, FogDevice>> <Package> Monitoring' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Package' of 'Data Model -> <<DataModel>> <Class> TreatmentPlan' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Package' of 'Fog Device ARM_32bit -> <<FogDevice>> <Interface> BloodPressureSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Package' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> BloodSugarSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Package' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> HeartRateSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Package' of 'Fog Device AVR_8bit -> <<FogDevice>> <Interface> InsulinPump' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'base_Package' of 'Fog Device MIPS_32bit -> <<FogDevice>> <Interface> TemperatureSensor' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'changeExpression' of '<Change Event> ChangeEvent1' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> callAmbulance_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> checkForTreatmentUpdates_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> getHeartRate_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> measureBloodPressureEmergency_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> measureBloodPressureStd_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> measureBloodSugar_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> measureTemperature_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> sendAggregatedDataToDoctor_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'target' of '<Call Operation Action> storeHeartRate_call' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'when' of '<Time Event> TimeEvent1' must be set model.uml /USER Pusztai/model Unknown EMF Problem
The required feature 'when' of '<Time Event> TimeEvent2' must be set model.uml /USER Pusztai/model Unknown EMF Problem

Once you have errors, expecting everything to work perfectly is a bit naive,.

If you tunnel down on e.g.The required feature 'base_Class' of 'Fog Device ARM_32bit -> <<FogDevice>> <Interface> BloodPressureSensor' must be set and look at FogDevice, each of base_Class, base_Device and base_Package has a non-zero lower bound mandating that the stereotype is applied to something that is a Class+Device+Package; unlikely.

20 of the errors are bad stereotype multiplicities.

The remaining 14 are incomplete models.

You haven't identified which Class is Attribute deficient, so I cannot tell whether fixuing the above fixes the problem.

Regards

Ed Willink
Re: Get all class attributes, including those from association ends [message #1803730 is a reply to message #1803725] Thu, 07 March 2019 18:15 Go to previous messageGo to next message
Thomas Pusztai is currently offline Thomas PusztaiFriend
Messages: 27
Registered: September 2018
Junior Member
Thanks for the hints. I've modified the Fog profile to allow a lower bound of 0 for the base_* that caused problems. I wanted these stereotypes to be applicable e.g., to classes, interfaces, and packages, but of course one stereotype application can't be made to all three at once. It clearly shows that this is my first custom UML profile :)

I've also corrected the other errors in the HealthCare model itself. I've pushed updates to both repositories. The validation now only has one warning about an interface having a non-public property, which shouldn't cause a problem here.

The problem with association ends not being included in getAllAttributes however, still remains. For example I tried running
[self.getAllAttributes()/]
in the Acceleo interpreter on the Treatment::TreatmentPlan class and the resulting list does not include "basalRate" and "bolus", which should come from the associations.

[Updated on: Thu, 07 March 2019 18:16]

Report message to a moderator

Re: Get all class attributes, including those from association ends [message #1803735 is a reply to message #1803730] Thu, 07 March 2019 20:15 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6614
Registered: July 2009
Senior Member
Hi

Yopu seem to have chnaged your complaint.

Originaly you calimed Java was broken but Acceleo was ok. Now you complain that Acceleo is broken.

When I run your query in th OCl Console, I indeed see no "bolus" or "basalRate". 100% correct.

If you want Properties to be part of a Class they should be owned by the Class not the Association. (Association owned Properties are a secret way of immutable extending - NB secret.)

Regards

Ed Willink
Re: Get all class attributes, including those from association ends [message #1803760 is a reply to message #1803735] Fri, 08 March 2019 13:20 Go to previous message
Thomas Pusztai is currently offline Thomas PusztaiFriend
Messages: 27
Registered: September 2018
Junior Member
Now I understand. Thanks for your help.
Previous Topic:Ecore to UML
Next Topic:Tag elements of a sequence diagram in an emx file (UML2)
Goto Forum:
  


Current Time: Sat Mar 28 21:17:08 GMT 2020

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

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

Back to the top