Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Setting attribute with first literal of an enumeration
Setting attribute with first literal of an enumeration [message #1776988] Thu, 23 November 2017 12:49 Go to next message
Camilo Almendra is currently offline Camilo AlmendraFriend
Messages: 2
Registered: November 2017
Junior Member
Hello there,

I've noted a behavior of Sirius (Obeo Designer Community, Version 10.0.0) when trying to set an enumeration literal value to an attribute.

CONTEXT:
- There is a class "Relationship" that contains an enumeration literal as attribute, this enumeration has two literals:
...
<eClassifiers xsi:type="ecore:EClass" name="Relationship">
...
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//RelationshipType"/>
...
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EEnum" name="RelationshipType">
    <eLiterals name="OneToOne" value="1"/>
    <eLiterals name="OneToMany" value="2"/>
...

- Model operation: I've created two separated Edge (element-based) Creation tools, the main diference between them is the value set for "type" feature. Please see attached figurem that shows the "OneToMany" tool (the other tool is configured in similar fashion, just changing the literal value to OneToOne)
index.php/fa/31369/0/

PROBLEM:
- The first enumeration literal never makes to the model. See below an excerpt of the xmi file after using the edge creation tools:
<relations source="//@entities.2" target="//@entities.1" type="OneToMany" name="R2"/> // using set type to OneToMany
<relations source="//@entities.3" target="//@entities.0" name="R3"/> // using set type to OneToOne

- I've made some exploration, added more literals to the enumeration, and I've got same behavior: if the value is set with FIRST enumerarion literal, it is not registered in the underline model.

Is this an expected behavior? We should assume the first literal as default value for an enumeration attribute? Also, we should assume that this value will not be registered in the model file?

Thank you in advance.

Best regards,
Camilo.

Re: Setting attribute with first literal of an enumeration [message #1777301 is a reply to message #1776988] Tue, 28 November 2017 09:33 Go to previous messageGo to next message
Julien Dupont is currently offline Julien DupontFriend
Messages: 172
Registered: July 2009
Senior Member
Hi,

The enum is very complex to use with emf :/

To set your value you should use this expression
aql:javason::RelationshipType.getEEnumLiteralByLiteral('OneToMany').instance

You can find more informations here:https://www.eclipse.org/eef/#/documentation/2.0.0/language/widgets/radio

Regards,
Re: Setting attribute with first literal of an enumeration [message #1777346 is a reply to message #1777301] Tue, 28 November 2017 16:32 Go to previous messageGo to next message
Julien Dupont is currently offline Julien DupontFriend
Messages: 172
Registered: July 2009
Senior Member
Hi,

An other simpler solution consist to use
aql:javason::RelationshipType::OneToMany.

For work, this requires your metamodel was register in Sirius (representation, tab Metamodels).

Regards,
Re: Setting attribute with first literal of an enumeration [message #1777498 is a reply to message #1777346] Wed, 29 November 2017 17:31 Go to previous message
Camilo Almendra is currently offline Camilo AlmendraFriend
Messages: 2
Registered: November 2017
Junior Member
Hello Julien,

Thanks for you help. The metamodel is registered in the project, and the option with "aql:" works same way as using "[... /]" notation.

I have made some more testing, and it really seems that first literal of an enumeration is treated as a 'default' value. In fact, if the attribute is not filled in the model, the query
aql:self.target.type == javason::RelationshipType::OneToOne
returns true.

For my current needs, it is not a problem since the EAttribute is supposed to be assigned all times.

Thank you,

Camilo.
Previous Topic:EObject attributes
Next Topic:View Xtend Validation in the Sirius Editor
Goto Forum:
  


Current Time: Fri Apr 19 22:48:43 GMT 2024

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

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

Back to the top