No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
===== Checking if a collection includes a value ===== | ===== Checking if a collection includes a value ===== | ||
You can't user the includes operator on collections of enum. You have to select on the value and check if you get a "hit". | You can't user the [[OCLOperators includes|includes]] operator on collections of enum. You have to select on the value and check if you get a "hit". | ||
This works; | This works; | ||
SysSingleton.SO.ActiveUser.UserModes->select(x|x = #Consultant)->notEmpty | SysSingleton.SO.ActiveUser.UserModes->select(x|x = #Consultant)->notEmpty | ||
''This does not work''''':''' SysSingleton.SO.ActiveUser.UserModes->includes(#Consultant) | ''This does not work''''':''' SysSingleton.SO.ActiveUser.UserModes->includes(#Consultant) |
Revision as of 13:00, 6 July 2021
You edit enumerations by right-clicking on any model element in the "model content" window.
The enumeration editing window
The defined enumeration is a class in the model's typesystem.
For example, you can returning a list of the values. This return a collection of ImportColumn Tuples
ImportColumn.allInstances
Converting this to a list of strings for each Enum value (for example to be used in a list on screen)
ImportColumn.allInstances.asString
Select an enum value from the list, then getting the string value from that
ImportColumn.allInstances->select(ic|ic = #JournalName).asString
Getting the value of an Enum tuple
(#JournalName).toString
(note: asString don't work on enum tuples)
Checking if a collection includes a value
You can't user the includes operator on collections of enum. You have to select on the value and check if you get a "hit".
This works;
SysSingleton.SO.ActiveUser.UserModes->select(x|x = #Consultant)->notEmpty
This does not work: SysSingleton.SO.ActiveUser.UserModes->includes(#Consultant)