Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to inherit/override one enumeration from another
xomega
#1 Posted : Thursday, October 25, 2012 7:02:09 PM(UTC)
xomega



When modeling your business domain, you may sometimes run into a situation, where two or more fields have different but very similar lists of possible values with a lot of values in common. Another scenario is when you may want to tweak different values in a certain list for different installations of your system. You can potentially model such scenarios by creating one all-inclusive list of possible values and then use additional properties to control what appears in each list, but Xomega provides a more simple and powerful solution to that.

To address these and other types of scenarios, Xomega allows you to inherit one enumeration from another and then add or override any items or properties as needed. Here are the steps that will let you achieve that.
  1. Define a base static enumeration in the model, which you want to inherit from.
  2. For the enumeration that you want to inherit from the base enumeration, add an enum element to the enums grouping element in the most appropriate file. Typically it's recommended to declare the enumerations in the file where they are used the most often.
  3. Give the inherited enumeration a unique name by setting the name attribute.
  4. Set the base attribute to the name of the enumeration that you want to inherit from.
  5. To add a new item, a property value of a specific item or an additional property, add a corresponding element following the regular enumeration structure.
  6. To remove an item, a property value of a specific item or a property definition from the base enumeration, add a corresponding item, property value or property definition with the same identifying attribute(s) following the regular enumeration structure, and set the overrideAction attribute to delete. The identifying attributes for different types of elements are as follows: for an item and a property definition it is a name attribute; for item property values it is a ref attribute coupled with a value attribute for multi-value properties.
  7. To override an item, a property value of a specific item or a property definition from the base enumeration, add a corresponding item, property value or property definition with the same identifying attribute(s) following the regular enumeration structure, and set the attributes that you want to override or add. If you also want to remove the attributes that you don't include here, or if you want to override all the child elements, such as description stored in the doc > summary element, then you need to replace the whole base element with the current one by setting the overrideAction attribute to replace.
  8. To remove all additional properties, set the overrideAction attribute to delete on the properties element.
  9. To replace additional properties with a new set of properties, set the overrideAction attribute to replace on the properties element.
  10. Add enumeration's description inside the nested elements doc > summary of the enum element to provide more details about the enumeration for developers and users.

The following snippet demonstrates an enumeration that inherits from the standard operators enumeration, defines a new property, adds a new item, overrides the value of the existing Contains item, and adds a new property value, deletes an existing property value and overrides another property value (sort order) for that item.
Code:
<enum name="my operators" base="operators">
  <properties>
    <property name="new property"/>
    <property name="addl props" multi-value="true" overrideAction="replace"/>
  </properties>
  <item name="Contains" value="CONT">
    <prop ref="new property" value="abc"/>
    <prop ref="addl props" value="1" overrideAction="delete"/>
    <prop ref="sort order" value="20"/>
  </item>
  <item name="New Item" value="NEWVAL"/>
</enum>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Copyright © 2009-2022 Xomega.Net. All rights reserved.