Document Composer questions

I have several questions about using Document Composer that I hope are easy to answer.

  1. I am iterating through the attributes of classes to produce the documentation for each of them. I use a <> stereotype to indicate required fields. To print ‘N’ for an attribute that is marked as such I use this:

    N

Is there a better way to check for the existence of that stereotype without iterating through all stereotypes. I’ve tried a number of tests with <Has…> elements with no success so far.

  1. To indicate that an attribute must have a unique value, we check the “Unique” box in the attribute’s specification dialog. I haven’t been able to figure out the proper tests/conditions to determine whether that box is checked or not. I was able to see that a ‘unique’ property exists within the ‘multiplicityDetail’ property but could not seem to access the value.

  2. This one’s harder but also maybe more interesting. For attributes whose value is constrained to an enumeration, we model that attribute’s data type as an associated enumeration class:

TestDocument

For the attribute’s documentation, we want to list the allowable values like this:
Values
- DOCUMENT
- EMAIL
- SMS
- JMS
- WORKFLOW

So the logical flow would be
1. Identify the association that matches the attribute’s data type
2. Identify the enumeration class at the other end of the association (DocType)
3. Iterate through the attributes of the enumeration class and output the attribute names

Is this even possible?

Anyways, I’m really enjoying learning about this language and bending it to my will. :grinning:

Thanks in advance for any advice!

let me answer the question one by one

  1. print “N” for <<Not Null>> attribute.
    You may use <ValueChecker property="stereotypes" value="Not Null">...</ValueChecker>
<?xml version="1.0" encoding="UTF-8"?>
<ElementBaseInitiationBlock>
	
	<Inline template="General/Element Basic"/>
	
	<Block>
		<Text style="@heading+">Attributes</Text>
		<ParagraphBreak/>
		<IterationBlock modelType="Attribute">
			<!-- showing [N] for Not Null attribute -->
			<ValueChecker property="stereotypes" value="Not Null">
				<Text>[N]</Text>
			</ValueChecker>
			<!-- disable the default sorting-->
			<Sortings noSort="true">
			</Sortings>
			
			<Property property="name"/>
			<ParagraphBreak/>
		</IterationBlock>
	</Block>
	
	<!-- list of Not Null attributes -->
	<IterationBlockConditionChecker modelType="Attribute">
		<Conditions>
			<ValueChecker property="stereotypes" value="Not Null"/>
		</Conditions>
		
		<Text style="@heading+">&lt;&lt;Not Null&gt;&gt; Attributes</Text>
		<ParagraphBreak/>
		<IterationBlock modelType="Attribute">
			<Conditions>
				<ValueChecker property="stereotypes" value="Not Null"/>
			</Conditions>
			<Sortings noSort="true">
			</Sortings>
			
			<Property property="name"/>
			<ParagraphBreak/>
		</IterationBlock>
	</IterationBlockConditionChecker>
	
</ElementBaseInitiationBlock>

NotNullAttributes

1 Like
  1. Unique value of attribute

Sorry, in UML spec, the isUnique of Multiplicity is not used for Attribute.value unique or not.
If the attribute allows multiple values, Multiplicity.isUnique is used to identify its values can or not be repeatable.
(my description may confuse you, better to read the UML spec)

So, I think you may define a <<IsUnique>> stereotype for your attributes.


If you still want to use Multiplicity.isUnique, you can do it as following:
(under an attribute)

<ConditionsChecker>
	<Conditions type="OR">
		<ModelElementPropertyConditionChecker property="multiplicityDetail">
			<Conditions>
				<ValueChecker property="unique" value="true"/>
			</Conditions>
		</ModelElementPropertyConditionChecker>
		
		<HasValueChecker property="multiplicityDetail" flag="false"/>
	</Conditions>
		
	<Text> [U]</Text>
</ConditionsChecker>

1 Like
  1. list Attribute -> Enumeration Literal
    as screenshot, the Enumeration should be a Class with <<enumeration>> stereotype

Then, you retrieve the enumeration literals from Attribute.type :

<ModelElementPropertyConditionChecker property="type">
	<Conditions>
		<ValueChecker property="modelType" value="Class"/>
		<ValueChecker property="stereotypes" value="enumeration"/>
		<IterationBlockConditionChecker modelType="EnumerationLiteral"/>
	</Conditions>
	
	<Text> : [</Text>
	<ModelElementProperty property="type">
		<IterationBlock modelType="EnumerationLiteral" ignoreLastSeparator="true">
			<Property property="name"/>
			<Text>, </Text>
		</IterationBlock>
	</ModelElementProperty>
	<Text>]</Text>
</ModelElementPropertyConditionChecker>

1 Like

Yes I do understand the UML semantics. I was trying to repurpose for my own use. But your solution I think is better.
But at least I learned a little more about the ConditionsChecker!

Still working on understanding this one but it works perfectly!

Thank you so much for your help!