Commit 7df659db authored by Martti Käärik's avatar Martti Käärik
Browse files

ReductionMembers constraints updated for DataUse and ParameterBinding...

ReductionMembers constraints updated for DataUse and ParameterBinding according to new requirement (MemberReference specifies either a member or a collectionIndex but not both)
parent a567afb5
Loading
Loading
Loading
Loading
+36 −43
Changes for plugins/org.etsi.mts.tdl.model/model/tdl-constraints.ocl: 36 added lines, 43 removed lines.
Original line number Diff line number Diff line
@@ -330,25 +330,25 @@ context DataUse
  

  -- Members in 'reduction' list
  inv ReductionMembers ('The \'Member\' referenced by the \'MemberReference\' at index i of a \'reduction\' shall be contained in or inherited by the \'StructuredDataType\' of the \'Member\' referenced by the \'MemberReference\' at index (i - 1) of that \'reduction\' or the \'StructuredDataType\' of this \'DataUse\' if the \'MemberReference\' is the first element of the \'reduction\'.' + self.toString()):
        self.reduction->forAll(mr | mr.member.oclIsUndefined() 
        	or self.reduction->indexOf(mr) = 1        	 
        	or (not self.reduction->at(self.reduction->indexOf(mr)-1).member.oclIsUndefined() 
        		and (let dataType = self.reduction->at(self.reduction->indexOf(mr)-1).member.dataType in 
        			((dataType.oclIsKindOf(StructuredDataType)
	        			and dataType.oclAsType(StructuredDataType).allMembers()->includes(mr.member))
	    			or (dataType.oclIsKindOf(CollectionDataType)
	    				and dataType.oclAsType(CollectionDataType).itemType.oclIsKindOf(StructuredDataType)
          				and dataType.oclAsType(CollectionDataType).itemType
                                      .oclAsType(StructuredDataType).allMembers()->includes(mr.member)))))
			or (self.reduction->at(self.reduction->indexOf(mr)-1).member.oclIsUndefined())
        )  

  -- Collection index of first 'reduction'
  inv ReductionMembersCollection ('If the \'member\' is not specified for the first element of the \'reduction\' then the type of this \'DataUse\' shall be \'CollectionDataType\'.' + self.toString()):
  inv ReductionMembers ('Each \'MemberReference\' of a \'reduction\' shall be applicable to the type reached by the preceding \'MemberReference\'s, starting from the resolved \'DataType\' of this \'DataUse\'. If a \'MemberReference\' specifies a \'member\' then the type from previous \'MemberReference\' shall be a \'StructuredDataType\' that contains or inherits that \'Member\' and the resulting type of this reference is the \'DataType\' of the \'Member\'. If a \'MemberReference\' specifies a \'collectionIndex\' then the type from previous \'MemberReference\' shall be a \'CollectionDataType\' and the resulting type of this reference is its \'itemType\'. ' + self.toString()):
        self.reduction->isEmpty()
              or not self.reduction->at(1).member.oclIsUndefined()
              or self. resolveBaseDataType().oclIsKindOf(CollectionDataType)
              or self.reduction->iterate(ref; types : Sequence(DataType) = Sequence{self.resolveBaseDataType()} |
                  if types->last().oclIsUndefined() then types
                  else
                      if ref.member.oclIsUndefined() then
                          if types->last().oclIsKindOf(CollectionDataType)
                              then types->including(types->last().oclAsType(CollectionDataType).itemType)
                              else types
                          endif
                      else
                          if types->last().oclIsKindOf(StructuredDataType)
                                  and types->last().oclAsType(StructuredDataType).allMembers()->includes(ref.member)
                              then types->including(ref.member.dataType)
                              else types
                          endif
                      endif
                  endif) 
      ->size() = self.reduction->size() + 1
  


@@ -359,25 +359,25 @@ context ParameterBinding
        error(self.dataUse.resolveDataType().conformsTo(self.resolveParameterType()))
        
  -- Members in 'reduction' list of parameter
  inv ReductionMembers ('The \'Member\' referenced by the \'MemberReference\' at index i of a \'reduction\' shall be contained in or inherited by the \'StructuredDataType\' of the \'Member\' referenced by the \'MemberReference\' at index (i - 1) of that \'reduction\' or the \'StructuredDataType\' of the \'parameter\' if the \'MemberReference\' is the first element of the \'reduction\'.' + self.toString()):
        self.reduction->isEmpty()
              or self.reduction->reject(r | self.reduction->indexOf(r) = 1) 
              ->iterate(r; acc = Sequence{Sequence{self.parameter.dataType, self.reduction->at(1)}} 
          	    | acc->including(Sequence{self.reduction->at(self.reduction->indexOf(r) - 1)->asSequence()
          		    ->reject(r|r.member.oclIsUndefined()).member.dataType->including(self.parameter.dataType)->at(1), r
          	    }))
              ->reject(tr | tr->at(1).oclIsUndefined() or tr->at(2).oclAsType(MemberReference).member.oclIsUndefined())
              ->iterate(tr; acc = Sequence{} | acc->including(Sequence{tr->at(1)->asSequence()
          	    ->select(t|t.oclIsKindOf(CollectionDataType)).oclAsType(CollectionDataType).itemType->including(tr->at(1))->at(1), tr->at(2) 
              }))
              ->forAll(tr | tr->at(1).oclAsType(StructuredDataType).allMembers()->includes(tr->at(2).oclAsType(MemberReference).member))
  

  -- Collection index of first 'reduction' of parameter
  inv ReductionMembersCollection ('If the \'member\' is not specified for the first element of the \'reduction\' then the type of the \'parameter\' shall be \'CollectionDataType\'.' + self.toString()):
  inv ReductionMembers ('Each \'MemberReference\' of a \'reduction\' shall be applicable to the type reached by the preceding \'MemberReference\'s, starting from the \'DataType\' of the \'parameter\'. If a \'MemberReference\' specifies a \'member\' then the type from previous \'MemberReference\' shall be a \'StructuredDataType\' that contains or inherits that \'Member\' and the resulting type of this reference is the \'DataType\' of the \'Member\'. If a \'MemberReference\' specifies a \'collectionIndex\' then the type from previous \'MemberReference\' shall be a \'CollectionDataType\' and the resulting type of this reference is its \'itemType\'. ' + self.toString()):
        self.reduction->isEmpty()
              or not self.reduction->at(1).member.oclIsUndefined()
              or self.parameter.dataType.oclIsKindOf(CollectionDataType)
              or self.reduction->iterate(ref; types : Sequence(DataType) = Sequence{self.parameter.dataType} |
                  if types->last().oclIsUndefined() then types
                  else
                      if ref.member.oclIsUndefined() then
                          if types->last().oclIsKindOf(CollectionDataType)
                              then types->including(types->last().oclAsType(CollectionDataType).itemType)
                              else types
                          endif
                      else
                          if types->last().oclIsKindOf(StructuredDataType)
                                  and types->last().oclAsType(StructuredDataType).allMembers()->includes(ref.member)
                              then types->including(ref.member.dataType)
                              else types
                          endif
                      endif
                  endif) 
      ->size() = self.reduction->size() + 1
  

  -- Use of a 'StructuredDataInstance' with non-optional 'Member's
@@ -389,13 +389,6 @@ context ParameterBinding


context MemberReference
  -- Collection index expressions for collections only
  inv CollectionIndex ('If the \'member\' is specified and the type of the \'member\' is not \'CollectionDataType\' then the collectionIndex shall be undefined. ' + self.toString()):
        self.collectionIndex.oclIsUndefined()
              or self.member.oclIsUndefined()
              or self.member.dataType.oclIsKindOf(CollectionDataType)
  

  -- Either member or collection index is required
  inv MemberOrIndex ('Either the member or collectionIndex shall be specified, but not both. ' + self.toString()):
        self.member.oclIsUndefined() <> self.collectionIndex.oclIsUndefined()