Completeness checks
Completeness checks perform a boolean evaluation (true/false) on asset features or asset relations.
Usage
Completeness checks can be used standalone, or as part of a quality gate in a quality gate sequence.
A completeness check evaluates the state or value of a feature or an asset relation. Simple completeness checks are written in an XPath expression. More complex completeness checks can be written in an XSLT macro. The result of a completeness check is a boolean (true/false).
Configuration
To set up a completeness check, proceed as follows:
- Create a Completeness check asset, enter a name, enable it and generate a resource key.
Edit the Completeness check properties widget:
Field Required Description Asset type filter / Enter the exact asset type (no wildcards) as stored in the Master data/Asset types table. For example: picture.drawing. If you add multiple asset types, the OR expression is used in the filter.(1) MIME type filter Optionally, add a MIME type to an asset type. Enter the exact value (no wildcards) as stored in the Master data/MIME types table. For example: video/mp4 matches video assets with an MP4 master file. Asset filter (XPath) Alternatively to the Asset type filter, you can enter an XPath expression to match the desired scope of assets to which you want to apply a quality gate sequence. For example: exists(asset/child_asset_rel[@key='user.task.']) matches assets with an assigned task.(2) Expression (XPath) / Enter the XPath expression that evaluates the feature or relation. Replace FEATURE_KEY with the feature key as stored in the Master data/Features table. This checks whether the respective asset property exists in an asset.(3)
Importance Select whether the evaluated feature/relation is required or optional to pass the completeness check. - To assign the completeness check to a quality gate(4) :
- In the Completeness check of widget, click the round plus.(5)
- In the asset picker, select the quality gates to which you want to add the completeness check.
Remarks
(1) If you assign the completeness check to a quality gate in a quality gate sequence, the asset type filter is not required. For standalone completeness checks, always set an asset type filter to avoid unnecessary server load.
(2) If your enter a value in this field, the Asset type filter must be empty. Otherwise the XPath expression in this field is ignored.
(3) If you use an XSLT macro stored in the master file, leave this field empty. Otherwise, the XSLT macro will be ignored.
(4) To create a standalone completeness check, you do not need to assign it to a quality gate.
(5) You can also assign a completeness check in the quality gate, in the Completeness checks widget.
Xpath expressions
XPath expressions can be configured in the following way:
Check if a property exists
exists(asset_feature[@feature='FEATURE_KEY'])
Replace FEATURE_KEY with the key of the desired property.
Example: exists(asset_feature[@feature='product.ean'])
Check if a child property exists
exists(asset_feature/assert_feature[@feature='FEATURE_KEY'])
Replace FEATURE_KEY with the key of the desired property. You can address any depth of child features.
Example: exists(asset_feature/asset_feature/asset_feature[@feature='censhare:adress.city'])
Check if a relation exists
exists(child_asset_rel|parent_asset_rel[@key='RELATION_ID'])
Replace RELATION_ID with the ID of the desired asset relation.
Example: exists(child_asset_rel[@key='user.main-picture.'])
Check if a feature or relation does not exist
Asset property
not(asset_feature[@feature='FEATURE_KEY'])
Replace FEATURE_KEY with the key of the desired property.
Example: not(asset_feature[@feature='censhare:approved-date.'])
Asset relation
not(child_asset_rel|parent_asset_rel[@key='RELATION_ID'])
Replace RELATION_ID with the ID of the desired asset relation.
Example: not(child_asset_rel[@key='user.task.'])
Check if a feature has a specific value
exists(asset_feature[@feature='FEATURE_KEY'
and @value='VALUE'])
Replace FEATURE_KEY with the key of the desired property, and VALUE with the desired value.
Example: exists(asset_feature[@feature='censhare:calc-child-task-completion-percentage' and @value_double='100.0'])
XSLT macros
For more complex scenarios, you can use an XSLLT macro. Store the macro as master file in the completeness check. To apply the XSLT macro, the Expression (XPath) field in the Completeness check properties must be empty.
The following example checks if a budget for a Marketing plan is allocated.
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:my="http://www.censhare.com/my"
exclude-result-prefixes="xi xs my">
<xsl:output method="xml" omit-xml-declaration="no" indent="no"/>
<!-- check if budget is defined in given asset or inherited from parent assets -->
<xsl:template match="asset">
<xsl:variable name="ownBudget"
select="sum(asset_feature[@feature='censhare:budget']/@value_double)"/>
<xsl:variable name="inheritedBudget"
select="sum(parent_asset_rel[@key='user.budget.']/asset_rel_feature[@feature= 'censhare:budget.allocated']/@value_double)"/>
<check name="Check budget defined">
<xsl:choose>
<xsl:when test="$ownBudget=0 and $inheritedBudget=0">
<item passed="false" reason="No budget defined or inherited"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$ownBudget=0">
<item passed="true" reason="Budget inherited"/>
</xsl:when>
<xsl:otherwise>
<item passed="true" reason="Budget defined"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</check>
</xsl:template>
</xsl:stylesheet>
Notes
(1) The asset type filter (Marketing plan) is set in the Completeness check asset. You do not need to define an asset type filter in the macro.
(2) First, the XSLT checks if a property with a defined budget exists.
(3) Next, the XSLT checks if a budget is inherited from a parent asset. The budget is allocated in a user.budget. relation, the value is stored in a relation censhare:budget.allocated property.
(4) The macro output is a boolean (true/false) and a string (budget source).