Using Canonical Attributes

Canonical attributes are used to describe the canonical item type. You can also use attributes to disable or override transformation expressions.

How are Canonical Attributes Created or Updated

Canonical attributes can be created or updated using one of these methods:

  1. Using the XML extension file that is used to load the data structure of Data Hub, as was mentioned earlier. You can create a new CanonicalAttributeModelDefinition or CanonicalAttributeDefinition, but not update existing ones.
  2. You can add a new canonical attribute manually by using the RESTful POST command against the following call: https://host:8443/datahub-webapp/v1/item-classes/canonical/item-types/CanonicalProduct/<Attribute_Name>. You can issue a RESTful GET to check it.
  3. You can manually update the values of a canonical attribute by using Data Hub RESTful API calls. Data Hub API supports a RESTful PUT for the canonical metadata attributes. The call is https://host:8443/datahub-webapp/v1/item-classes/canonical/item-types/CanonicalProduct/attributes/<Attribute_Name>. You can issue a RESTful GET to check it.

Using Attributes to Disable or Override Canonical Transformation Expressions

When Data Hub loads, it loads all of its extensions. This process creates the metadata model for Data Hub. In the process of building the metadata model, the transformations are loaded. Specifically, the canonicalItems <transformation> expression is loaded, and it supports two attributes:

  • disabled - By default, this attribute is false. When this attribute is set equal to "true", the <transformation> expression is inactive and, therefore, ignored.
  • override - By default, this attribute is false. When this attribute is set equal to "true", the value of the <transformation> expression overrides any other definitions for the same <rawSource> reference.

Assume that you have an extension 'A' and an extension 'B', which extends extension 'A'. Setting the <transformation> expression in extension 'B' to have a override value equal to "true" overrides the equivalent <transformation> expression in extension 'A'. So, the <transformation> expressions in the dependent extension take precedence.

<canonicalItems>
   <item>
      <type>CanonicalCyclingApparel</type>
      <attributes>
         <attribute>
            <name>identifier</name>
            <transformations>
               <transformation disabled="true">
                  <rawSource>RawCyclingShoeSize</rawSource>
                  <expression>usSize</expression>
               </transformation>
            </transformations>
         </attribute>
         <attribute>
            <name>region</name>
            <transformations>
               <transformation disabled="false" override="true">
                  <rawSource>RawCyclingApparel</rawSource>
                  <expression>region</expression>
               </transformation>
            </transformations>
         </attribute>
      </attributes>
   </item>
</canonicalItems>