-- author: Nicolas.F.Rouquette@jpl.nasa.gov -- December 2010 -- This Complete OCL document is edited using an Eclipse XText-based OCL Editor in the UML-RTF project. -- The reference below corresponds to the Eclipse EMF-exported version of UML2.4 merged at L3. -- the uml.ecore file is not 100% accurate but it is adequate for defining the CMOF constraints for MOF2.4. import 'uml.ecore' package UML -- 14.3 [1] The multiplicity of Association::memberEnd is limited to 2 rather than 2..* (i.e., n-ary Associations are not supported); -- unlike EMOF, CMOF associations can have navigable association-owned ends. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/association-does-not-have-two-member-ends context Association inv CMOF_14_3_1: memberEnd->size() = 2 and ownedEnd->size() < 2 -- 14.3 [2] The type of Operation::raisedException is limited to be Class rather than Type. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/operation-has-non-class-exception context Operation inv CMOF_14_3_2: raisedException->forAll(e | e.oclIsTypeOf(Class)) -- 14.3 [6] Names are required for all NamedElements except for ValueSpecifications. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/named-element-has-no-name context NamedElement inv CMOF_14_3_6: not oclIsKindOf(ValueSpecification) implies (name <> null and name->notEmpty()) -- 14.3 [7] CMOF does not support visibilities. All property visibilities must be explicitly set to public where applicable, -- that is for all NamedElements, ElementImports and PackageImports. -- Furthermore, no alias is allowed for any ElementImport. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/named-element-is-not-public context NamedElement inv CMOF_14_3_7a: visibility = VisibilityKind::public -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/element-import-is-not-public -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/element-import-has-alias context ElementImport inv CMOF_14_3_7b: visibility = VisibilityKind::public and alias->isEmpty() -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/package-import-is-not-public context PackageImport inv CMOF_14_3_7c: visibility = VisibilityKind::public -- 14.3 [8] Enumerations may not have attributes or operations -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/enumeration-has-attributes -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/enumeration-has-operations context Enumeration inv CMOF_14_3_8: feature->isEmpty() -- 14.3 [9] A CMOF metamodel is restricted to use the concrete metaclasses from UMLÕs Kernel: context Element def: isWithinCMOFSubset() : Boolean = self.oclIsKindOf(Association) or self.oclIsKindOf(Class) or self.oclIsKindOf(Comment) or self.oclIsKindOf(Constraint) or self.oclIsKindOf(DataType) or self.oclIsKindOf(ElementImport) or self.oclIsKindOf(Enumeration) or self.oclIsKindOf(EnumerationLiteral) or self.oclIsKindOf(Generalization) or self.oclIsKindOf(InstanceValue) or self.oclIsKindOf(LiteralBoolean) or self.oclIsKindOf(LiteralInteger) or self.oclIsKindOf(LiteralNull) or self.oclIsKindOf(LiteralReal) or self.oclIsKindOf(LiteralString) or self.oclIsKindOf(LiteralUnlimitedNatural) or self.oclIsKindOf(OpaqueExpression) or self.oclIsKindOf(Operation) or self.oclIsKindOf(Package) or self.oclIsKindOf(PackageImport) or self.oclIsKindOf(PackageMerge) or self.oclIsKindOf(Parameter) or self.oclIsKindOf(PrimitiveType) or self.oclIsKindOf(Property) context Package inv CMOF_14_3_9: self->closure(ownedElement)->forAll(e | e.Element::isWithinCMOFSubset()) -- 14.3 [10] The following properties must be empty -- Class::nestedClassifier -- Property::qualifier -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/class-has-nested-classifier context Class inv CMOF_14_3_10a: nestedClassifier->isEmpty() -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/property-has-qualifier context Property inv CMOF_14_3_10b: qualifier->isEmpty() -- 14.3 [11] The value of Feature::isStatic must be false context Feature inv CMOF_14_3_11: not isStatic -- 14.3 [12] A multi-valued Property or Parameter cannot have a default value. -- The default value of a Property or Parameter typed by a PrimitiveType must be a kind of LiteralSpecification. -- The default value of a Property or Parameter typed by an Enumeration must be a kind of InstanceValue. -- A Property or Parameter typed by a Class cannot have a default value. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/parameter-has-invalid-default-value -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/property-has-invalid-default-value context Parameter inv CMOF_14_3_12a: (upperBound() > 1 or type.oclIsKindOf(Class) implies defaultValue->isEmpty()) inv CMOF_14_3_12b: defaultValue->notEmpty() implies (upperBound() <= 1 and ((type.oclIsKindOf(PrimitiveType) and defaultValue.oclIsKindOf(LiteralSpecification)) or (type.oclIsKindOf(Enumeration) and defaultValue.oclIsKindOf(InstanceValue)))) context Property inv CMOF_14_3_12c: (upperBound() > 1 or type.oclIsKindOf(Class) implies defaultValue->isEmpty()) inv CMOF_14_3_12d: defaultValue->notEmpty() implies (upperBound() <= 1 and ((type.oclIsKindOf(PrimitiveType) and defaultValue.oclIsKindOf(LiteralSpecification)) or (type.oclIsKindOf(Enumeration) and defaultValue.oclIsKindOf(InstanceValue)))) -- 14.3 [13] The values of MultiplicityElement::lowerValue and upperValue must be of kind LiteralInteger and LiteralUnlimitedNatural respectively -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/multiplicity-element-has-non-integer-lower-value -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/multiplicity-element-has-non-unlimited-natural-upper-value context MultiplicityElement inv CMOF_14_3_13: lowerValue.oclIsKindOf(LiteralInteger) and upperValue.oclIsKindOf(LiteralUnlimitedNatural) -- 14.3 [14] Generalization::isSubstitutable must be true context Generalization inv CMOF_14_3_14: isSubstitutable = true context Classifier def: allAttributes : Set(Property) = self->closure(general)->union(self)->attribute->asSet() -- 14.3 [15] Only one member attribute of a Class may have isId=true. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/class-has-more-than-one-id context Class inv CMOF_14_3_15: self->closure(general)->union(self)->attribute->asSet()->select(p:Property | p.isID)->size() < 2 --inv CMOF_14_3_15: self.Classifier::allAttributes->select(p:Property | p.isID)->size() < 2 -- 14.3 [16] Property::aggregation must be either ÔnoneÕ or ÔcompositeÕ -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/property-has-shared-aggregation context Property inv CMOF_14_3_16: aggregation = AggregationKind::composite or aggregation = AggregationKind::none -- 14.3 [17] BehavioralFeature must be sequential -- https://sites.google.com/site/metamodelingantipatterns/catalog/mof/behavioral-feature-is-not-sequential context BehavioralFeature inv CMOF_14_3_17: concurrency = CallConcurrencyKind::sequential -- 14.3 [18] Class must not be active -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/class-is-active context Class inv CMOF_14_3_18: not isActive -- 14.3 [17] An Operation can have up to one Parameter whose direction is ÔreturnÕ; furthermore, an Operation cannot have any ParameterSet per 12.4 [8]. context Operation inv CMOF_14_3_17: ownedParameter->select(direction = ParameterDirectionKind::return)->size() < 2 and ownedParameterSet->isEmpty() -- 14.3 [18] Comments may only annotate instances of NamedElement context Comment inv CMOF_14_3_18: annotatedElement->forAll(e | e.oclIsKindOf(NamedElement)) -- 14.3 [19] An EnumerationLiteral must not have a ValueSpecification -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/enumeration-literal-has-specification context EnumerationLiteral inv CMOF_14_3_19: specification->isEmpty() -- 14.3 [20] An Operation Parameter must have no effect, exception or streaming characteristics -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/parameter-has-effect -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/parameter-is-exception context Parameter inv CMOF_14_3_20: effect->isEmpty() and not (isException or isStream) -- 14.3 [21] A TypedElement cannot be typed by an Association -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/typed-element-has-association-type context TypedElement inv CMOF_14_3_21: not type.oclIsKindOf(Association) -- 14.3 [22] A TypedElement other than a LiteralSpecification or an OpaqueExpression must have a Type -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/typed-element-has-no-type context TypedElement inv CMOF_14_3_22: not (oclIsKindOf(LiteralSpecification) or oclIsKindOf(OpaqueExpression)) implies type->notEmpty() -- 14.3 [23] A TypedElement that is a kind of Parameter or Property typed by a Class cannot have a default value. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/typed-element-is-complex-with-default-value context Parameter inv CMOF_14_3_23a: type.oclIsKindOf(Class) implies defaultValue->isEmpty() context Property inv CMOF_14_3_23b: type.oclIsKindOf(Class) implies defaultValue->isEmpty() -- 14.3 [24] For a TypedElement that is a kind of Parameter or Property typed by an Enumeration, the defaultValue, if any, must be a kind of InstanceValue. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/typed-element-is-enumeration-with-non-instance-value-default context Parameter inv CMOF_14_3_24a: type.oclIsKindOf(Enumeration) and defaultValue->notEmpty() implies defaultValue.oclIsKindOf(InstanceValue) context Property inv CMOF_14_3_24b: type.oclIsKindOf(Enumeration) and defaultValue->notEmpty() implies defaultValue.oclIsKindOf(InstanceValue) -- 14.3 [25] For a TypedElement that is a kind of Parameter or Property typed by an PrimitiveType, the defaultValue, if any, must be a kind of LiteralSpecification. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/typed-element-is-primitive-with-non-literal-default context Parameter inv CMOF_14_3_25a: type.oclIsKindOf(PrimitiveType) and defaultValue->notEmpty() implies defaultValue.oclIsKindOf(LiteralSpecification) context Property inv CMOF_14_3_25b: type.oclIsKindOf(PrimitiveType) and defaultValue->notEmpty() implies defaultValue.oclIsKindOf(LiteralSpecification) -- 14.3 [26] A composite subsetting Property with mandatory multiplicity cannot subset another composite Property with mandatory multiplicity. context Property inv CMOF_14_3_26: isComposite and lowerBound() = 1 implies subsettedProperty->forAll(not (isComposite and lowerBound() = 1)) -- 14.3 [27] A Property typed by a kind of DataType must have aggregation = none. context Property inv CMOF_14_3_27: type.oclIsKindOf(DataType) implies aggregation = AggregationKind::none -- 14.3 [28] A Property owned by a DataType can only be typed by a DataType. context DataType inv CMOF_14_3_28: ownedAttribute.type.oclIsKindOf(DataType) -- 14.3 [29] Each Association memberEnd Property must be typed by a Class. context Association inv CMOF_14_3_29: memberEnd.type.oclIsKindOf(Class) -- 14.3 [30] A Constraint must constrain at least one element and must be specified via an OpaqueExpression. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/constraint-specification-is-not-opaque-expression context Constraint inv CMOF_14_3_30: constrainedElement->notEmpty() and specification.oclIsKindOf(OpaqueExpression) -- 14.3 [31] The body of an OpaqueExpression must not be empty. -- see also: https://sites.google.com/site/metamodelingantipatterns/catalog/mof/opaque-expression-has-no-or-empty-body context OpaqueExpression inv CMOF_14_3_31: body->notEmpty() and body <> '' endpackage