Conditional Expression

<DefaultValueChecker>

The <DefaultValueChecker> element evaluates the querying element to check if the property stated by the @property attribute equals to its default value. If the result of evaluation matches with the result stated by the attribute @flag, the child elements of <DefaultValueChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <DefaultValueChecker> in a template.

<IterationBlock modelType="Class">
    <DefaultValueChecker property="root" flag="false">
        <Text>The root property has been modified.</Text>
    </DefaultValueChecker>
</IterationBlock>

The following table lists the available attributes of <DefaultValueChecker>.

Name Description/Usage Required?
property : string The property to check. Required
flag : boolean = false The expected result of checking. If the actual result matches the value specified by @flag, the child elements will be processed. Optional
Attributes of <DefaultConditionChecker>

<ValueChecker>

The <ValueChecker> element evaluates the querying element to check if the value of the property stated by the @property attribute equals to the value stated by the @value attribute. If the result of evaluation is true, the child elements of <ValueChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <ValueChecker> in a template.

<IterationBlock modelType="Class">
    <ValueChecker property="name" value="ShapeCreator">
        <Text>ShapeCreator class found!</Text>
    </ValueChecker>
    <ValueChecker property="description" operator="not equals" value="">
        <Text>Description: </Text>
        <Property property="description"/>
    </ValueChecker>
</IterationBlock>

The following table lists the available attributes of <ValueChecker>.

Name Description/Usage Required?
property : string The property to check. Optional
operator : string

{equals | not equals | less than | equals or less than | greater than | equals or greater than | like | not like | equal | not equal}
Specify the way to compare the property value of model against your expectation.

equals - The value of property must be the same as the expected value
not equals - The value of property must be different from the expected value
less than - The value of property must be smaller than the expected value.
equals or less than - The value of property must be the same or smaller than the expected value.
greater than - The value of property must be larger than the expected value.
equals or greater than - The value of property must be the same or larger than the expected value.
like – The value of property must contain the expected value.
not like - The value of property must not contain the expected value.
Required
value : string The value expected for the property. If @regularExpression is set to true, you can make use of '?' and '*' in the value field for representing wildcard characters. For example, use "*UI" as @value to find out all model elements with names end with "UI". Optional
length : int   Optional
caseSensitive : boolean Determine whether the checking of string property need to take care of the use of upper and lower case. Optional
regularExpression : boolean When true, you can make use of '?' and '*' in the value field for representing wildcard characters. For example, use "*UI" as @value to find out all model elements with names end with "UI". Optional
id : string

Optional
dateFormatString : string Date value property will be formatted with the format pattern specified before checking. Formatting will only occur when the property is a date value (e.g. pmLastModified).

e.g. @dateFormatString ="yyyy-MM-dd"
Optional
Attributes of <ValueChecker>

<HasChildElementChecker>

The <HasChildElementChecker> element evaluates the querying element to check if it contains any child element, or type(s) of child elements specified by the @modelType or @modelTypes attributes. If the result of evaluation is true, the child elements of <HasChildElementChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <HasChildElementChecker> in a template.

<IterationBlock modelType="Class">
    <HasChildElementChecker modelType="Attribute" flag="true">
        <IterationBlock modelType="Attribute">
            <Property property="name"/>
            <ParagraphBreak>
        </IterationBlock>
    </HasChildElementChecker>
    <HasChildElementChecker modelType="Attribute,Operation" flag="true">
        <IterationBlock modelTypes="Attribute,Operation">
            <Property property="name"/>
            <ParagraphBreak>
        </IterationBlock>
    </HasChildElementChecker>
</IterationBlock>

The following table lists the available attributes of <HasChildElementChecker>.

Name Description/Usage Required?
flag : boolean = true The expected result of checking. If the actual result matches the value specified by @flag, the child elements will be processed.
Optional
modelType : string
The type of model element you want the parent to contain or not contain.
Optional
modelTypes : string The types of model element you want the parent to contain or not contain. Optional
stereotypes : strings Filter the children by a number of stereotypes.
Optional
includeConnectors : boolean Determine whether to retrieve shape or shape+connectors from diagram. This is for retrieving from diagram only. Optional
filterHidden : boolean    
allLevel : boolean Determine whether to retrieve all model elements from project. When false, only the root level elements will be retrieved. This attribute is only useful when retrieving elements from project.
valueConditionCheckId : string    
Attributes of <HasChildElementChecker>

<HasRelationshipChecker>

The <HasRelationshipChecker> element evaluates the querying element to check if it contains any relationship, or type(s) of relationships specified by the @modelType or @modelTypes attributes. If the result of evaluation is true, the child elements of <HasRelationshipChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <HasRelationshipChecker> in a template.

<IterationBlock modelType="Class">
    <HasRelationshipChecker modelType="Association" flag="true">
        <ForEachRelationshipEnd modelType="AssociationEnd" endPointer="self">
            <RelationshipEndEndRelationship>
                <FromEnd>
                    <ModelElementProperty property="EndModelElement">
                        <Property property="name"/>
                        <Text>, </Text>
                    </ModelElementProperty>
                </FromEnd>
                <ToEnd>
                    <ModelElementProperty property="EndModelElement">
                        <Property property="name"/>
                        <Text>, </Text>
                    </ModelElementProperty>
                </ToEnd>
        </ForEachRelationshipEnd>
    </HasRelationshipChecker>

    <HasRelationshipChecker modelType="Generalization" direction="to">
        <ForEachSimpleRelationship type="Generalization">
            <ModelElementProperty property="from">
                <Property property="name"/>
                <Text>, </Text>
            </ModelElementProperty>
        </ForEachSimpleRelationship>
    </HasRelationshipChecker>
</IterationBlock>

The following table lists the available attributes of <HasRelationshipChecker>.

Name Description/Usage Required?
flag : boolean = true The expected result of checking. If the actual result matches the value specified by @flag, the child elements will be processed.
Optional
modelType : string
The type of relationship you want the querying model element to contain.
Optional
modelTypes : string The types of relationship you want the querying model element to contain. If @modelType is specified, @modelTypes will be ignored. Optional
direction

{all | from | to}
Check if the querying model element belongs to a specific end of a relationship. Possible values: all, from, to, self_begins, self_ends Optional
Attributes of <HasRelationshipChecker>

<HasDiagramChecker>

The <HasDiagramChecker> element evaluates the querying "thing" (project or model element) to check if it has specified any diagram for a given property specified by the @property attribute. If the result of evaluation is true, the child elements of <HasDiagramChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <HasDiagramChecker> in a template.

<ProjectBaseInitiationBlock>
    <HasDiagramChecker diagramType="ClassDiagram" flag="true">
        <Text>This project contains at least one class diagram.</Text>
    </HasDiagramChecker>
</ProjectBaseInitiationBlock>

The following table lists the available attributes of <HasDiagramChecker>.

Name Description/Usage Required?
flag : boolean The expected result of checking. If the actual result matches the value specified by @flag, the child elements will be processed.
Optional
property : string
The property from which diagrams can be retrieved.
Optional
diagram : string
The type of diagram you want the project to contain or not contain. Optional
Attributes of <HasDiagramChecker>

<HasValueChecker>

The <HasValueChecker> element evaluates the querying "thing" (project or model element) to check if it has specified a given property, specified by the @property attribute. If the result of evaluation is true, the child elements of <HasDiagramChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <HasValueChecker> in a template.

<IterationBlock modelType="Class">
    <HasValueChecker property="taggedValues" flag="true">
        <Text>This class contains at least one tagged value.</Text>
    </HasValueChecker>
</IterationBlock>

The following table lists the available attributes of <HasValueChecker>.

Name Description/Usage Required?
flag : boolean The expected result of checking. If the actual result matches the value specified by @flag, the child elements will be processed.
Optional
property : string
The name of property to check.
Optional
modelType : string
The result of evaluation will return a true only if the querying model element contains the type of elements specified by @modelType.
Optional
name : string The result of evaluation will return a true only if the querying model element contains the elements with same name as specified by @name. Optional
stereotypes : string The result of evaluation will return a true only if the querying model element contains the elements that are extended from the stereotypes specified by @stereotypes. Optional
Attributes of <HasValueChecker>

<HasParentModelChecker>

The <HasParentModelChecker> element evaluates the querying model element to check if it is being contained by a parent model element. If the result of evaluation is true, the child elements of <HasParentModelChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <HasParentModelChecker> in a template.

<IterationBlock modelType="Class">
    <HasParentModelChecker modelType="Package" flag="true">
        <Text>This class contains is contained by package: </Text>
        <ParentModel>
            <Property property="name"/>
        </ParentModel>
    </HasParentModelChecker>
</IterationBlock>

The following table lists the available attributes of <HasParentModelChecker>.

Name Description/Usage Required?
flag : boolean The expected result of checking. If the actual result matches the value specified by @flag, the child elements will be processed.
Optional
modelType : string
The type of parent model element you want the model element to be/not to be contained by.
Optional
Attributes of <HasParentModelChecker>

<HasSubDiagramChecker>

The <HasSubDiagramChecker> element evaluates the querying model element to check if it contains any sub-diagram. If the result of evaluation is true, the child elements of <HasSubDiagramChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <HasSubDiagramChecker> in a template.

<IterationBlock modelType="Class">
    <HasSubDiagramChecker diagramType="StateMachineDiagram" flag="true">
        <ForEachSubDiagram>
            <Property property="name"/>
        </ForEachSubDiagram>
    </HasSubDiagramChecker>
</IterationBlock>

The following table lists the available attributes of <HasSubDiagramChecker>.

Name Description/Usage Required?
flag : boolean The expected result of checking. If the actual result matches the value specified by @flag, the child elements will be processed.
Optional
diagramType: string
The type of sub-diagram you want the model element to contain.
Optional
Attributes of <HasSubDiagramChecker>

<HasOwnerDiagramsChecker>

The <HasOwnerDiagramsChecker> element evaluates the querying model element to check if it has been visualized in any diagram. If the result of evaluation is true, the child elements of <HasOwnerDiagramsChecker> will be processed. Otherwise, the child elements will be skipped.

The following example shows the use of <HasOwnerDiagramsChecker> in a template.

<IterationBlock modelType="BPTask">
    <HasOwnerDiagramsChecker diagramType="BusinessProcessDiagram" flag="true">
        <ForEachOwnerDiagram>
            <Property property="name"/>
        </ForEachOwnerDiagram>
    </HasOwnerDiagramsChecker>
</IterationBlock>

The following table lists the available attributes of <HasOwnerDiagramsChecker>.

Name Description/Usage Required?
flag : boolean The expected result of checking. If the actual result matches the value specified by @flag, the child elements will be processed.
Optional
diagramType: string
The type of diagram you want the owner diagram to be.
Optional
Attributes of <HasOwnerDiagramsChecker>

Checking multiple conditions with <Conditions>

The use of <...Checker> enables you to perform checking on single condition. Sometimes, you may want to check for multiple conditions at a time. For example, you may want to output the name of all public and static attributes of a class. In order to check for multiple conditions, use <Conditions>. <...Checker> under <Conditions> will all be evaluated. If the result of evaluation are true for ALL checkers, the subsequent elements will be evaluated. Otherwise, the parent iteration will continue to next round.

Note that <Conditions> supports the type attribute, which enables you to specify the way how the result of checkers are evaluated. The value "and" means that the result of checkers must all be positive in order to continue, while the value "or" means that as long as there is one checker that returns a positive result, the flow can continue.

The following example shows the use of <Conditions> in a template.

<IterationBlock modelType="Attribute">
    <Conditions type="and">
        <ValueChecker property="visibility" value="public" />
        <ValueChecker property="scope" value="classifier" />
    </Conditions>

    <Property property="name"/>
    <ParagraphBreak/>
</IterationBlock>

Using <...ConditionChecker> (e.g. <IterationBlockConditionChecker>, <ForEachConditionChecker>, etc.)

The following lists out a set of <...ConditionChecker>.

  • <IterationBlockConditionChecker>
  • <ForEachConditionChecker>
  • <ForEachRelationshipConditionChecker>
  • <ForEachSimpleRelationshipConditionChecker>
  • <ForEachEndRelationshipConditionChecker>
  • <ForEachRelationshipEndConditionChecker>
  • <ForEachSubDiagramConditionChecker>
  • <ForEachOwnerDiagramConditionChecker>
  • <ForEachDiagramConditionChecker>
  • <ForEachDiagramElementConditionChecker>
  • <ModelElementPropertyConditionChecker>
  • <FromEndConditionChecker>
  • <ToEndConditionChecker>
  • <RelationshipEndEndRelationshipConditionChecker>
  • <RelationshipEndOppositeEndConditionChecker>
  • <DiagramPropertyConditionChecker>
  • <DiagramElementPropertyConditionChecker>
  • <ParentModelConditionChecker>
  • <ParentShapeConditionChecker>
  • <OwnerDiagramConditionChecker>

They all share similar usage so let's explain them together. To make it simple, let's explain with <IterationBlockCondictionChecker>, using the example above.

Let's say we want to add a line "Public and static attributes" before we list out the attributes. Here is the problem: If we place a <Text>Public and static attributes</Text> before <IterationBlock>, the line will get output even without any public and static attributes. If we put the <Text> inside the <IterationBlock> and below <Conditions>, the line will get output multiple times if there are multiple public and static attributes.

To solve this problem, use <IterationBlockConditionChecker>. <IterationBlockConditionChecker> enables you to check if there exists an element in an iteration, when certain conditions are applied. The following example is the revised version of the above example. It will output a single line of title above the list of attributes output within the <IterationBlock>.

<IterationBlockConditionChecker>
    <Conditions>
        <ValueChecker property="visibility" value="public" />
        <ValueChecker property="scope" value="classifier" />
    </Conditions>

    <Text>Public and static attributes</Text>
    <ParagraphBreak/>

    <IterationBlock modelType="Attribute">
        <Conditions>
            <ValueChecker property="visibility" value="public" />
            <ValueChecker property="scope" value="classifier" />
       </Conditions>

        <Property property="name"/>
        <ParagraphBreak/>
    </IterationBlock>
<IterationBlockConditionChecker/>

Using <ConditionsChecker>

The use of <Conditions> allows the filtering of elements in a loop. But there are times that you want to check against a querying model element instead of filtering elements in a looping. In such case, use <ConditionsChecker>

The following example shows the use of <ConditionsChecker> in a template.

<ElementBaseInitiationBlock>
    <ConditionsChecker>
        <Conditions type="and">
            <ValueChecker property="visibility" value="public" />
            <ValueChecker property="scope" value="classifier" />
        </Conditions>

        <Property property="name"/>
        <ParagraphBreak/>
    </ConditionsChecker>
</ElementBaseInitiationBlock>

Using nested checkers in propagated checking

Sometimes, a checking requires the checking of not just the querying element, but certain property of the querying element. Let's say we want to retrieve all public attributes from a class whose attribute type has to be classes with names ended with 'Controller'. In order to handle such a complex checking, we have to create a nested checker structure which involves the nested use of <...Checker> and <Conditions>.

The following example shows the use of various checkers in a nested structure.

<IterationBlock modelType="Attribute">
    <Conditions>
        <ValueChecker property="visibility" value="public" />
        <ModelElementPropertyConditionChecker property="type">
            <Conditions>
                <ValueChecker property="name" operator="like" value="Controller" />
            <Conditions>
        </ModelElementPropertyConditionChecker>
    </Conditions>

    <Property property="name"/>
    <ParagraphBreak/>
</IterationBlock>

Related Resources

The following resources may help you to learn more about the topic discussed in this page.

 
6. Sorting in Loop Table of Contents 8. Working with Table

We use cookies to offer you a better experience. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.OK