Skip to content

Constraint DataInstanceOrArgumentsOrItemsInDataElementUse incorrect

Given:

	Structure msg (
		Integer id,
		Data data
	)
	Collection Data of msg

and

	Data d2 [
		new msg(id = 1)
	]
	Data d2a [ 
		d2[1] //TODO: constraint is messed up 
	]

A constraint violation is raised in d2[1] "If a 'dataElement' is not specified, or if the 'dataElement' is resolved to a 'StructuredDataType' or a 'CollectionDataType', either a non-empty 'argument' set or a non-empty 'item' set shall be specified"

The implementation of the constraint is:

  inv DataInstanceOrArgumentsOrItemsInDataElementUse ('If a \'dataElement\' is not specified, or if the \'dataElement\' is resolved to a \'StructuredDataType\' or a \'CollectionDataType\', either a non-empty \'argument\' set or a non-empty \'item\' set shall be specified.' + self.toString()):
        not (self.dataElement.oclIsUndefined() and self.argument->isEmpty() and self.item->isEmpty())
                and (self.dataElement.oclIsKindOf(StructuredDataInstance) 
                      or not (self.resolveDataType().oclIsKindOf(StructuredDataType) 
                          and self.argument->isEmpty()))
                and (self.dataElement.oclIsKindOf(CollectionDataInstance) 
                      or not (self.resolveDataType().oclIsKindOf(CollectionDataType) 
                          and self.item->isEmpty()))
Edited by Philip Makedonski
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information