WebSphere Commerce EnterpriseIntroduced in Feature Pack 2

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

  • Review the prcFlowElementObjectDefinition class, which is the parent object definition for all price rule element object definitions. Later in this procedure, you must register your new object definition in this file so that your new condition or action can be dropped onto the path in the Price Rule Builder.
  • To familiarize yourself with definitions in Management Center, see Management Center definitions.
  • For information about creating resource bundles for text strings, see Defining properties files and bundle keys for user interface text.

About this task

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

Procedure

  1. Open WebSphere 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/config/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.def; for example,

    RegistrationTimeConditionFlowElementObjectDefinition.def

  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 substep 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="prc" 
         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.def 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 prc, 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 wcfServiceParam 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.
      See lzx/commerce/foundation/restricted/PropertyDefinition.lzx/wcfPropertyDefinition. More complex price rule elements can have multiple properties and child objects. At a minimum, declare wcfPropertyDefinition 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:

      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/config/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. For more details on using a template, see wcfObjectDefinition.
  5. Register the new object definition in its parent object definition:
    1. Open the file at the following path:

      LOBTools/WebContent/config/commerce/price/objectDefinitions/priceRuleBuilder/FlowPathElementObjectDefinition.def

    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="prcBaseFlowPathElementObject" displayName="Path" isBaseDefinition="true">
      		
         <Xml name="template">
            <elemTemplateName>path</elemTemplateName>
         </Xml>
      		
            <FlowElementObjectDefinition baseDefinitionName="prcPriceListElementObject" package="prc"/>
            <FlowElementObjectDefinition baseDefinitionName="prcCalculatePriceElementObject" package="prc"/>
            <FlowElementObjectDefinition baseDefinitionName="prcExternalPriceRuleElementObject" package="prc"/>
            <FlowElementObjectDefinition baseDefinitionName="prcCatalogConditionElementObject" package="prc"/>
            <FlowElementObjectDefinition baseDefinitionName="prcSimpleBranchElementObject" package="prc"/>
            <FlowElementObjectDefinition baseDefinitionName="prcCompareConditionElementObject" package="prc"/>
            <FlowElementObjectDefinition baseDefinitionName="prcNestedPriceRuleElementObject" package="prc"/>
            <FlowElementObjectDefinition baseDefinitionName="prcMyCustomConditionElementObject" package="prc"/>
      </ChildObjectDefinition>
    3. Save and close the file.