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

Helper methods for resolving contained behaviours and test configuration of test description.

Change-Id: I3448e9395a35c9f65a7ebd7683eee40af92b36ad
parent b972f9f4
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
            <color xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
          </style>
        </nodeMappings>
        <edgeMappings xsi:type="description_1:BasicMessageMapping" name="interaction" sourceMapping="//@ownedViewpoints[name='org.etsi.mts.tdl']/@ownedRepresentations[name='TestDescriptionDiagram']/@defaultLayer/@nodeMappings[name='gateReference']/@borderedNodeMappings[name='lifelineExecution']" targetMapping="//@ownedViewpoints[name='org.etsi.mts.tdl']/@ownedRepresentations[name='TestDescriptionDiagram']/@defaultLayer/@nodeMappings[name='gateReference']/@borderedNodeMappings[name='lifelineExecution']" targetFinderExpression="[diagram.diagramElements.target->select(e|e.oclIsKindOf(tdl::GateReference))->asSet().oclAsType(tdl::GateReference)->any(ref|ref.component = self.targetGate.component and ref.gate = self.targetGate.gate)/]" sourceFinderExpression="[diagram.diagramElements.target->select(e|e.oclIsKindOf(tdl::GateReference))->asSet().oclAsType(tdl::GateReference)->any(ref|ref.component = self.owner().oclAsType(tdl::Interaction).sourceGate.component and ref.gate = self.owner().oclAsType(tdl::Interaction).sourceGate.gate)/]" targetExpression="[self.owner()/]" domainClass="tdl.Target" useDomainElement="true" sendingEndFinderExpression="[self.owner()/]" receivingEndFinderExpression="[self.owner()/]">
        <edgeMappings xsi:type="description_1:BasicMessageMapping" name="interaction" semanticCandidatesExpression="[allBehaviours()/]" sourceMapping="//@ownedViewpoints[name='org.etsi.mts.tdl']/@ownedRepresentations[name='TestDescriptionDiagram']/@defaultLayer/@nodeMappings[name='gateReference']/@borderedNodeMappings[name='lifelineExecution']" targetMapping="//@ownedViewpoints[name='org.etsi.mts.tdl']/@ownedRepresentations[name='TestDescriptionDiagram']/@defaultLayer/@nodeMappings[name='gateReference']/@borderedNodeMappings[name='lifelineExecution']" targetFinderExpression="[diagram.diagramElements.target->select(e|e.oclIsKindOf(tdl::GateReference))->asSet().oclAsType(tdl::GateReference)->any(ref|ref.component = self.targetGate.component and ref.gate = self.targetGate.gate)/]" sourceFinderExpression="[diagram.diagramElements.target->select(e|e.oclIsKindOf(tdl::GateReference))->asSet().oclAsType(tdl::GateReference)->any(ref|ref.component = self.owner().oclAsType(tdl::Interaction).sourceGate.component and ref.gate = self.owner().oclAsType(tdl::Interaction).sourceGate.gate)/]" targetExpression="[self.owner()/]" domainClass="tdl.Target" useDomainElement="true" sendingEndFinderExpression="[self.owner()/]" receivingEndFinderExpression="[self.owner()/]">
          <style sizeComputationExpression="2">
            <strokeColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
            <centerLabelStyleDescription showIcon="false" labelExpression="[ serialise(self.owner().oclAsType(tdl::Interaction).argument) /]">
@@ -93,7 +93,7 @@
            </centerLabelStyleDescription>
          </style>
        </edgeMappings>
        <containerMappings xsi:type="description_1:CombinedFragmentMapping" name="combinedBehaviour" preconditionExpression="[oclIsKindOf(CombinedBehaviour) or oclIsKindOf(ExceptionalBehaviour) or oclIsKindOf(PeriodicBehaviour)/]" domainClass="tdl.Behaviour" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[tdl::GateReference.allInstances()/]">
        <containerMappings xsi:type="description_1:CombinedFragmentMapping" name="combinedBehaviour" preconditionExpression="[oclIsKindOf(CombinedBehaviour) or oclIsKindOf(ExceptionalBehaviour) or oclIsKindOf(PeriodicBehaviour)/]" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.Behaviour" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[getTestConfiguration().connection.endPoint/]">
          <subContainerMappings name="boundedLoopBehaviour" semanticCandidatesExpression="[self/]" domainClass="tdl.BoundedLoopBehaviour" childrenPresentation="List">
            <subNodeMappings name="boundedLoop.keyword" semanticCandidatesExpression="[self/]" domainClass="tdl.BoundedLoopBehaviour">
              <style xsi:type="style:SquareDescription" showIcon="false" labelExpression="iteration: " labelAlignment="LEFT" labelPosition="node" resizeKind="NSEW">
@@ -245,7 +245,7 @@
            </style>
          </conditionnalStyles>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="globalAction" preconditionExpression="[not oclIsKindOf(Assertion) and not oclIsKindOf(VerdictAssignment) and not oclIsKindOf(TimerOperation) and not oclIsKindOf(TimeOperation) and not oclIsKindOf(ActionBehaviour) and not oclIsKindOf(TestDescriptionReference) and not oclIsKindOf(Interaction)/]" domainClass="tdl.AtomicBehaviour" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[tdl::GateReference.allInstances()/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="globalAction" preconditionExpression="[not oclIsKindOf(Assertion) and not oclIsKindOf(VerdictAssignment) and not oclIsKindOf(TimerOperation) and not oclIsKindOf(TimeOperation) and not oclIsKindOf(ActionBehaviour) and not oclIsKindOf(TestDescriptionReference) and not oclIsKindOf(Interaction)/]" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.AtomicBehaviour" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[getTestConfiguration().connection.endPoint/]">
          <style xsi:type="style:FlatContainerStyleDescription" borderSizeComputationExpression="1" showIcon="false" labelExpression="[(if (self.oclIsKindOf(ActionReference)) then  'Action ' + self.oclAsType(ActionReference).action.name else if (self.oclIsKindOf(InlineAction))  then 'Inline Action ' + self.oclAsType(InlineAction)._body else if (self.oclIsKindOf(VerdictAssignment))  then 'Verdict ' + serialise(self.oclAsType(VerdictAssignment).verdict) else if (self.oclIsKindOf(TestDescriptionReference))  then 'Test Description ' + serialise(self.oclAsType(TestDescriptionReference)) else if (self.oclIsKindOf(Assertion)) then 'Assert '  + serialise(self.oclAsType(Assertion)) else self.name endif endif endif endif endif)/]">
            <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
            <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
@@ -271,7 +271,7 @@
            </style>
          </conditionnalStyles>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="assertion" domainClass="tdl.Assertion" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[tdl::GateReference.allInstances()/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="assertion" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.Assertion" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[getTestConfiguration().connection.endPoint/]">
          <subNodeMappings name="assertion.config" semanticCandidatesExpression="[self/]" domainClass="tdl.Assertion"/>
          <subNodeMappings name="assertion.condition" semanticCandidatesExpression="[self/]" domainClass="tdl.Assertion">
            <style xsi:type="style:SquareDescription" showIcon="false" labelExpression="['condition ' + serialise(self.condition)/]" labelPosition="node" resizeKind="NSEW">
@@ -293,14 +293,14 @@
            <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
          </style>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="verdictAssignment" domainClass="tdl.VerdictAssignment" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[tdl::GateReference.allInstances()/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="verdictAssignment" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.VerdictAssignment" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[getTestConfiguration().connection.endPoint/]">
          <subNodeMappings name="verdictAssignment.config" semanticCandidatesExpression="[self/]" domainClass="tdl.VerdictAssignment"/>
          <style xsi:type="style:WorkspaceImageDescription" borderSizeComputationExpression="1" showIcon="false" labelExpression="[serialise(self.verdict)/]" workspacePath="org.etsi.mts.tdl.graphical.viewpoint/images/Verdict.svg">
            <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
            <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='black']"/>
          </style>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="timerOperation" domainClass="tdl.TimerOperation" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[tdl::GateReference.allInstances()->select(ref|ref.component = self.componentInstance)/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="timerOperation" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.TimerOperation" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[getTestConfiguration().connection.endPoint->select(ref|ref.component = self.componentInstance)/]">
          <subNodeMappings name="timerOperation.config" semanticCandidatesExpression="[self/]" domainClass="tdl.TimerOperation"/>
          <conditionnalStyles predicateExpression="[oclIsTypeOf(TimerStart)/]">
            <style xsi:type="style:WorkspaceImageDescription" borderSizeComputationExpression="1" showIcon="false" labelExpression="[self.timer.name + '('+serialise(self.oclAsType(TimerStart).period)+')'/]" workspacePath="org.etsi.mts.tdl.graphical.viewpoint/images/TimerStart.svg">
@@ -321,7 +321,7 @@
            </style>
          </conditionnalStyles>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="assignment" domainClass="tdl.Assignment" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[tdl::GateReference.allInstances()->select(ref|ref.component = self.componentInstance)/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="assignment" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.Assignment" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[getTestConfiguration().connection.endPoint->select(ref|ref.component = self.componentInstance)/]">
          <subNodeMappings name="assignment.config" semanticCandidatesExpression="[self/]" domainClass="tdl.Assignment"/>
          <subNodeMappings name="assignment.assignment" semanticCandidatesExpression="[self/]" domainClass="tdl.Assignment">
            <style xsi:type="style:SquareDescription" showIcon="false" labelExpression="[self.variable.name + ' := ' + serialise(self.expression)/]" labelPosition="node" resizeKind="NSEW">
@@ -338,7 +338,7 @@
            <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
          </style>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="actionReference" domainClass="tdl.ActionReference" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[if (not self.componentInstance.oclIsUndefined()) then tdl::GateReference.allInstances()->select(ref|ref.component = self.componentInstance) else tdl::GateReference.allInstances() endif/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="actionReference" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.ActionReference" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[if (not self.componentInstance.oclIsUndefined()) then getTestConfiguration().connection.endPoint->select(ref|ref.component = self.componentInstance) else getTestConfiguration().connection.endPoint endif/]">
          <subNodeMappings name="actionReference.config" semanticCandidatesExpression="[self/]" domainClass="tdl.ActionReference"/>
          <subNodeMappings name="actionReference.action" semanticCandidatesExpression="[self/]" domainClass="tdl.ActionReference">
            <style xsi:type="style:SquareDescription" showIcon="false" labelExpression="[self.action.name/]" labelPosition="node" resizeKind="NSEW">
@@ -362,7 +362,7 @@
            <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
          </style>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="inlineAction" domainClass="tdl.InlineAction" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[if (not self.componentInstance.oclIsUndefined()) then tdl::GateReference.allInstances()->select(ref|ref.component = self.componentInstance) else tdl::GateReference.allInstances() endif/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="inlineAction" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.InlineAction" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[if (not self.componentInstance.oclIsUndefined()) then getTestConfiguration().connection.endPoint->select(ref|ref.component = self.componentInstance) else getTestConfiguration().connection.endPoint endif/]">
          <subNodeMappings name="inlineAction.config" semanticCandidatesExpression="[self/]" domainClass="tdl.InlineAction"/>
          <subNodeMappings name="inlineAction.Body" semanticCandidatesExpression="[self/]" domainClass="tdl.InlineAction">
            <style xsi:type="style:SquareDescription" showIcon="false" labelExpression="[self._body/]" labelPosition="node" resizeKind="NSEW">
@@ -379,7 +379,7 @@
            <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
          </style>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="testDescriptionReference" domainClass="tdl.TestDescriptionReference" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[tdl::GateReference.allInstances()/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="testDescriptionReference" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.TestDescriptionReference" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[getTestConfiguration().connection.endPoint/]">
          <subNodeMappings name="testDescriptionReference.config" semanticCandidatesExpression="[self/]" domainClass="tdl.TestDescriptionReference"/>
          <subNodeMappings name="testDescriptionReference.testDescription" semanticCandidatesExpression="[self/]" domainClass="tdl.TestDescriptionReference">
            <style xsi:type="style:SquareDescription" showIcon="false" labelExpression="[self.testDescription.name/]" labelPosition="node" resizeKind="NSEW">
@@ -410,7 +410,7 @@
            <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/>
          </style>
        </containerMappings>
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="timeOperation" domainClass="tdl.TimeOperation" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[if (not self.componentInstance.oclIsUndefined()) then tdl::GateReference.allInstances()->select(ref|ref.component = self.componentInstance) else if (self.oclIsTypeOf(Quiescence) and not self.oclAsType(Quiescence).gateReference.oclIsUndefined()) then tdl::GateReference.allInstances()->select(ref|ref = self.oclAsType(Quiescence).gateReference) else tdl::GateReference.allInstances() endif endif/]">
        <containerMappings xsi:type="description_1:InteractionUseMapping" name="timeOperation" semanticCandidatesExpression="[allBehaviours()/]" domainClass="tdl.TimeOperation" startingEndFinderExpression="[self/]" finishingEndFinderExpression="[getEnd()/]" coveredLifelinesExpression="[if (not self.componentInstance.oclIsUndefined()) then getTestConfiguration().connection.endPoint->select(ref|ref.component = self.componentInstance) else if (self.oclIsTypeOf(Quiescence) and not self.oclAsType(Quiescence).gateReference.oclIsUndefined()) then getTestConfiguration().connection.endPoint->select(ref|ref = self.oclAsType(Quiescence).gateReference) else getTestConfiguration().connection.endPoint endif endif/]">
          <subNodeMappings name="timeOperation.config" semanticCandidatesExpression="[self/]" domainClass="tdl.TimeOperation"/>
          <subNodeMappings name="timeOperation.period" semanticCandidatesExpression="[self/]" domainClass="tdl.TimeOperation">
            <style xsi:type="style:SquareDescription" showIcon="false" labelExpression="[serialise(self.period)/]" labelPosition="node" resizeKind="NSEW">
@@ -1198,5 +1198,6 @@
    </ownedRepresentations>
    <ownedJavaExtensions qualifiedClassName="org.etsi.mts.tdl.graphical.extensions.DataUseLabelProvider"/>
    <ownedJavaExtensions qualifiedClassName="org.etsi.mts.tdl.graphical.extensions.BehaviorProvider"/>
    <ownedJavaExtensions qualifiedClassName="org.etsi.mts.tdl.graphical.extensions.ModelHelper"/>
  </ownedViewpoints>
</description:Group>
+36 −0
Original line number Diff line number Diff line
package org.etsi.mts.tdl.graphical.extensions;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.etsi.mts.tdl.Behaviour;
import org.etsi.mts.tdl.Target;
import org.etsi.mts.tdl.TestConfiguration;
import org.etsi.mts.tdl.TestDescription;

public class ModelHelper {
	public TestConfiguration getTestConfiguration(Behaviour b) {
		EObject c = b;
		while (c != null) {
			if (c instanceof TestDescription)
				return ((TestDescription) c).getTestConfiguration();
			c = c.eContainer();
		}
		return null;
	}
	
	public List<EObject> allBehaviours(TestDescription e) {
		List<EObject> behaviours = new ArrayList<EObject>();
		TreeIterator<EObject> iter = e.eAllContents();
		while (iter.hasNext()) {
			EObject c = iter.next();
			if (c instanceof Behaviour)
				behaviours.add(c);
			else if (c instanceof Target) 
				behaviours.add(c);
		}
		return behaviours;
	}
}