Completeness checks - key concept_sysadmin
The Completeness Check provides the completeness information of an asset. The check is performed by a series of Completeness check assets defined for a particular asset type and which always result to true or false . The final results of the Completeness Check are displayed in a report widget as shown on the image below.
Completeness check Assets
A Completeness check asset evaluates the state of a given feature within the metadata of an asset, via macro (XSLT or xPath). As already mentioned, each Completeness check asset can result to true or false.
Asset Configuration:
- Asset type -
module.completeness-check.
- Must contain a Resource Key
- Must contain an Asset type Filter which will dedicate the Completeness check asset to a particular asset type
- Must contain a macro (Completeness check expression (xPath) or XSLT as master file)
Example:
The default Completeness check asset “Check EAN (product)” with Asset type filter product.
and the below Completeness check expression (xPath):
|
This check will result to true as soon as a value is inserted into the censhare:product.ean
feature, in the metadata of the currently checked out product asset.
Completeness check widget
The Completeness check widget is a ‘report type’ (csReportWidget
) widget which uses the censhare:report.completeness-check
transformation to display the completeness check results.
The transformation is responsible to build a table that contains all Completeness check assets and their result state. In more detail the transformation contains the following two important function:
csc:getCompletenessCheckAssets
- Gathers all completeness check assets where their asset type filter is corresponding to the type of the currently checked out asset:<
xsl:function
name
=
"csc:getCompletenessCheckAssets"
as
=
"element(asset)*"
>
<
xsl:param
name
=
"asset"
as
=
"element(asset)"
/>
<
xsl:variable
name
=
"assetType"
select
=
"$asset/@type"
/>
<
xsl:variable
name
=
"elements"
select
=
"tokenize($assetType, '\.')"
/>
<
xsl:variable
name
=
"query"
>
<
query
>
<
condition
name
=
"censhare:asset.type"
op
=
"="
value
=
"module.completeness-check."
/>
<
condition
name
=
"censhare:resource-enabled"
op
=
"="
value
=
"1"
/>
<
or
>
<
condition
name
=
"censhare:asset-type-filter"
op
=
"="
value
=
"*"
/>
<
xsl:for-each
select
=
"$elements"
>
<
xsl:if
test
=
"position() lt last()"
>
<
xsl:variable
name
=
"position"
select
=
"xs:long(position())"
/>
<
condition
name
=
"censhare:asset-type-filter"
op
=
"="
value
=
"{concat(string-join($elements[position()=(1 to $position)], '.'), '.*')}"
/>
</
xsl:if
>
</
xsl:for-each
>
<
condition
name
=
"censhare:asset-type-filter"
op
=
"="
value
=
"{$assetType}"
/>
</
or
>
</
query
>
</
xsl:variable
>
<
xsl:copy-of
select
=
"cs:asset($query)"
/>
</
xsl:function
>
csc:getCheckAssetResult
- Verifies which of the two macro methods (XSLT or xPath) is used on the current completeness check asset and evaluates the result:<
xsl:function
name
=
"csc:getCheckAssetResult"
>
<
xsl:param
name
=
"checkAsset"
as
=
"element(asset)"
/>
<
xsl:param
name
=
"asset"
as
=
"element(asset)"
/>
<
xsl:variable
name
=
"xpathExpression"
select
=
"$checkAsset/asset_feature[@feature='censhare:completeness-check.expression.xpath']/@value_string"
/>
<
xsl:choose
>
<!-- macro is defined by XPath expression -->
<
xsl:when
test
=
"$xpathExpression"
>
<
xsl:value-of
select
=
"$asset/cs:evaluate($xpathExpression)"
/>
</
xsl:when
>
<!-- macro is defined by XSLT as master file -->
<
xsl:when
test
=
"$checkAsset/storage_item[@key='master']"
>
<
xsl:variable
name
=
"result"
>
<
cs:command
name
=
"com.censhare.api.transformation.XslTransformation"
>
<
cs:param
name
=
"stylesheet"
select
=
"$checkAsset/storage_item[@key='master'][1]"
/>
<
cs:param
name
=
"source"
select
=
"$asset"
/>
</
cs:command
>
</
xsl:variable
>
<
xsl:value-of
select
=
"$result"
/>
</
xsl:when
>
<!-- XPath expression and XSLT not exists -->
<
xsl:otherwise
>
<
xsl:value-of
select
=
"'Definition (XPath or XSLT) not exists'"
/>
</
xsl:otherwise
>
</
xsl:choose
>
</
xsl:function
>
How can the completeness check be enhanced
Depending on the requirements and specifications, the completeness check can be enhanced both on the level of the Completeness Check asset as well as on the level of the widget by performing changes to the current transformation.
- Completeness Check asset - When in need to use a more complex logic for the check, an XSLT can be used as the master file of the check asset, instead of an xPath expression.
- Transformation - When in need to perform changes on the data being displayed within the Completeness Check widget, a new transformation can be used or customizations can be performed on a resource replace variant of the current transformation
censhare:report.completeness-check
.