Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We create a model as the root node and then we create four two primitive types and store them in Groovy variables because we have to reference them later on.

...

We define an enumeration OrderStatus with three literals.

Code Block
                 def orderStatusEnumeration = Enumeration(name: 'OrderStatus') {
			ownedLiteral {
				EnumerationLiteral(name: 'Pending')
				EnumerationLiteral(name: 'Back Order')
				EnumerationLiteral(name: 'Complete')
			}
		}

The following code snippet shows the definition of the class classes Address and USAddress. All the attributes are defined as a Property. The primitive types stringPrimitiveType and intPrimitiveType defined above are used. The class USAddress is a subclass of the abstract class Address. This is expressed with the Generalization object.

Code Block
                def addressClass = Class(name: 'Address' ,isAbstract: true) {
			ownedAttribute {
				Property(name: 'name', type: stringPrimitiveType, lower: 0, upper: 1)
				Property(name: 'country', type: stringPrimitiveType, lower: 0, upper: 1)
			}
		}
		def usAddressClass = Class(name: 'USAddress') {
			generalization {
				Generalization(general: addressClass)
			}
			ownedAttribute {
				Property(name: 'street', type: stringPrimitiveType, lower: 0, upper: 1)
				Property(name: 'city', type: stringPrimitiveType, lower: 0, upper: 1)
				Property(name: 'state', type: stringPrimitiveType, lower: 0, upper: 1)
				Property(name: 'zip', type: intPrimitiveType, lower: 0, upper: 1)
			}
		}

...