HCL Commerce Enterprise

Creating the object definition for the price rule element

Create an object definition for the new condition or action to collect input from the Management Center user interface. When business users fill in data about the new condition or action in a price rule, the object definition persists the data in two tables: PRELEMENT and PRELEMENTATTR.

Before you begin

About this task

The object definition for a new price rule element is a definition XML file containing a definition that uses the <FlowElementObjectDefinition> element.

Procedure

  1. Open HCL Commerce Developer and switch to the Enterprise Explorer view.
  2. Create a directory to store your new price rule element object definition.
    You can store the file in a directory structure similar to the following example:

    LOBTools\WebContent\WEB-INF\src\xml\your_company_name\price\objectDefinitions\priceRuleBuilder

  3. Create a new definition file for the price rule element object definition. Name the file using this syntax:

    pricerule_element_nameFlowElementObjectDefinition.xml; for example,

    RegistrationTimeConditionFlowElementObjectDefinition.xml

  4. Define the element object definition.

    The following XML code is a simple example of an object definition for a new condition element. The example is split into four parts, and each part is explained in a step after the table.

    Object definition example
    1
    <Definitions>
    
      <FlowElementObjectDefinition 
         definitionName = "prcRegistrationTimeConditionElementObject" 
         displayName = "${prcMyPriceResources.RegistrationTimeCondition_displayName}" 
         elemTemplateType="Condition" 
         objectType = "RegistrationTimeCondition"      
         flowIcon = "RegistrationTimeConditionElementIcon" 
         headerIcon = "RegistrationTimeConditionElementHeaderIcon" 
         paletteIcon = "RegistrationTimeConditionPaletteIcon" 
         package="cmc/price" 
         propertiesDefinitionName = "prcRegistrationTimeConditionElementProperties" 
         summaryClass = "prcRegistrationTimeConditionElementSummary">
    
    2
            <CreateService baseDefinitionName = "prcFlowElementCreateService">
                <ServiceParam name = "PROPERTY_registrationTime" propertyName = "registrationTime"/>
                <ServiceParam name = "PROPERTY_registrationTimeOperator" propertyName = "registrationTimeOperator" optional = "true"/>
            </CreateService>
            <UpdateService baseDefinitionName = "prcFlowElementUpdateService">
                <ServiceParam name = "PROPERTY_registrationTime" propertyName = "registrationTime"/>
                <ServiceParam name = "PROPERTY_registrationTimeOperator" propertyName = "registrationTimeOperator" optional = "true"/>
            </UpdateService>
    3
            <PropertyDefinition propertyName = "registrationTime" required = "true" type = "date"/>
            <PropertyDefinition propertyName = "registrationTimeOperator">
                <PropertyValue displayName = "${prcMyPriceResources.RegistrationTimeCondition_lessComparison}" value = "<"/>
                <PropertyValue displayName = "${prcMyPriceResources.RegistrationTimeCondition_greatComparison}" value = ">"/>
                <PropertyValue displayName = "${prcMyPriceResources.RegistrationTimeCondition_equalComparison}" value = "="/>
            </PropertyDefinition>
    4
            <Xml name = "template">
                <elemTemplateName>RegistrationTimeCondition</elemTemplateName>
                <registrationTimeOperator><</registrationTimeOperator>
            </Xml>
        </FlowElementObjectDefinition>
    </Definitions>
    1. As per example section 1, specify the following attributes for the object definition:
      definitionName
      A unique name for this price rule element definition. Use any name that you want.
      displayName
      The display text for the price rule element. You can either provide a static string, or provide a reference to a resource in your custom resource bundle, as shown in the example code.
      elemTemplateType
      The type of price rule element; the value can be Condition or Action.
      objectType
      A name for this price rule object type. Use the same name that you used for the associated price rule element template definition, which is stored as the IDENTIFIER value in the PRELETEMPLATE table. When you add this condition or action to the Price Rule Builder palette later on, you must specify this objectType value in the priceRuleBuilder.xml file.
      flowIcon
      The image resource for the price rule element that is displayed in the Price Rule Builder work area.
      headerIcon
      The image resource for the price rule element that is displayed in the top-left corner of the properties view for the price rule element.
      paletteIcon
      The image resource for the price rule element that is displayed in the Price Rule Builder palette.
      package
      Use the value cmc/price, which indicates that this object definition is for a price rule element.
      propertiesDefinitionName
      Optional: The name of the definition to use for displaying the properties view of this price rule element object. If your price rule element requires input from a business user, you must create a custom properties view definition for the user interface, which is covered in the procedure Creating the properties view for the price rule element. You can either give your custom properties view definition a name now, or update this attribute later, after you have created the custom properties view definition.
      summaryClass
      Optional: The name of the class to use for displaying the summary of this price rule element object. The summary text is displayed in the Price Rule Builder work area below the price rule element icon. If your price rule element requires this summary text, you must create a custom summary class, which is covered in the procedure Creating the summary for the price rule element. You can either give your custom summary class a name now, or update this attribute later, after you have created the custom summary class.
    2. As per example section 2, add the following child service definitions:
      • prcFlowElementCreateService
      • prcFlowElementUpdateService

      These services are used when business users create and update price rule elements using the Price Rule Builder, and might require additional attributes and child ServiceParam definitions, depending on the requirements of your price rule element.

      If your parameters refer to other service parameters, such as a category, then you require service parameter definitions like the following examples:

      <CreateService baseDefinitionName="prcFlowElementCreateService">
          <ServiceParam
              name = "PROPERTY_categoryIdList"
              objectPath = "ChildCatalogGroup/CatalogGroupAlias"
              propertyName = "catgroupId"
              optional = "false"/>
      </CreateService>
      <UpdateService baseDefinitionName="prcFlowElementUpdateService">
          <ServiceParam
              name = "PROPERTY_categoryIdList"
              objectPath = "ChildCatalogGroup/CatalogGroupAlias"
              propertyName = "catgroupId"
              optional = "false"/>
      </UpdateService>
    3. As per example section 3, if required, define the properties of the price rule element.
      More complex price rule elements can have multiple properties and child objects. At a minimum, declare PropertyDefinition instances or property definitions for any variables the business user needs to provide that are defined in the price rule element template definition. Your price rule element might also require instances of:
      • ReferenceObjectDefinition
      • ChildObjectDefinition
      • nameValidator (see the subclasses of the Validator class for the foundation component)

      Consider using the object definition of an existing, similar price rule element as a reference for your new price rule element. The existing object definition files are stored here:

      LOBTools\WebContent\WEB-INF\src\xml\commerce\price\objectDefinitions\priceRuleBuilder

    4. As per example section 4, if required, add an <Xml> element with the name attribute set to template. You can use the template to declare default values for the price rule element properties. The <Xml> element must have an <elemTemplateName> child element. The value of the <elemTemplateName> must match the value in the IDENTIFIER column of the PRELETEMPLATE table for this price rule element. You can also use the template to declare child objects that will be instantiated within the new price rule element object.
  5. Register the new object definition in its parent object definition:
    1. Open the file at the following path:

      LOBTools\WebContent\WEB-INF\src\xml\commerce\price\objectDefinitions\priceRuleBuilder\FlowPathElementObjectDefinition.xml

    2. Within this definition, add your new object definition as a child by inserting a single line similar to the following example (see the second-last line in bold font):
      <ChildObjectDefinition definitionName="cmc/price/BaseFlowPathElementObject" displayName="Path" isBaseDefinition="true">	
      	<Xml name="template">
      		<elemTemplateName>path</elemTemplateName>
      	</Xml>	
      	<FlowElementObjectDefinition baseDefinitionName="cmc/price/PriceListElementObject" package="cmc/price"/>
      	<FlowElementObjectDefinition baseDefinitionName="cmc/price/CalculatePriceElementObject" package="cmc/price"/>
      	<FlowElementObjectDefinition baseDefinitionName="cmc/price/ExternalPriceRuleElementObject" package="cmc/price"/>
      	<FlowElementObjectDefinition baseDefinitionName="cmc/price/CatalogConditionElementObject" package="cmc/price"/>
      	<FlowElementObjectDefinition baseDefinitionName="cmc/price/SimpleBranchElementObject" package="cmc/price"/>
      	<FlowElementObjectDefinition baseDefinitionName="cmc/price/CompareConditionElementObject" package="cmc/price"/>
      	<FlowElementObjectDefinition baseDefinitionName="cmc/price/NestedPriceRuleElementObject" package="cmc/price"/>
      	<FlowElementObjectDefinition baseDefinitionName="cmc/price/MyCustomConditionElementObject" package="cmc/price"/>
      </ChildObjectDefinition>
    3. Add a dependency to the prc module similar to the PriceResources dependency in the file.
    4. Save and close the file.