WebSphere Commerce Enterprise

Deploying custom extended terms

When you created the entry in the TCSUBTYPE table for an extended term, you had a choice of specifying its deploy command. If you did not specify the value, then no deployment command is called to deploy the extended term during the contract deployment process.

About this task

You can also deploy a new term with a custom deployment command. The custom command that is recorded in the TCSUBTYPE table is used for deployment. The deployment command must implement an interface that extends com.ibm.commerce.contract.commands.DeployExtendedTCCmd, and the command must extend com.ibm.commerce.contract.commands.DeployExtendedTCCmdImpl.

To use a custom deployment command to deploy an extended term:

Procedure

  1. Create an interface, such as DeploySurchargeTCCmd in the following sample, by extending com.ibm.commerce.contract.commands.DeployExtendedTCCmd. Define the variable defaultCommandClassName of the new interface to be the name of the new deployment command that you create in the following step. For instance DeploySurchargeTCCmdImpl in the following sample.
  2. Create a deployment command (like DeploySurchargeTCCmdImpl in the following sample) by extending com.ibm.commerce.contract.commands.DeployExtendedTCCmdImpl and implementing the new interface.
  3. Compile the Java classes and copy the class files into a new JAR file. Add the new JAR file to your class path.
  4. Optional: If you did not define an entry for the new term in the TCSUBTYPE table, run the following SQL statement:
    insert into tcsubtype(TCSUBTYPE_ID, TCTYPE_ID, ACCESSBEANNAME, DEPLOYCOMMAND) Values ( 'YourTcSubtypeID','YourTctypeID', null,  'YourDeployCommandName');
  5. Optional: If you already defined an entry for the new term in the TCSUBTYPE table, run the following SQL statement:
    update tcsubtype set DEPLOYCOMMAND= 'YourDeployCommandName'where tcsubtype_id= 'YourTcSubtypeId';

Example

In the following sample, the following values are used:
  • YourTctypeID as the value for ExtendedTC
  • YourTcSubtypeI as the value for SurChargeTC
  • YourDeployCommandName as the value for com.ibm.commerce.sample.contract.commands.DeploySurchargeTCCmd
Example interface:


package com.ibm.commerce.sample.contract.commands;

import java.util.*;
import com.ibm.commerce.command.*;

public interface DeploySurchargeTCCmd extends
com.ibm.commerce.contract.commands.DeployExtendedTCCmd
{       
        /**
         * The fully qualified name of this class.
         */
         public final static String NAME =
"com.ibm.commerce.productset.commands.DeploySurchargeTCCmd";

        /**
         * The fully qualified name of the default implementation
class.
         */
        public static String defaultCommandClassName =
"com.ibm.commerce.productset.commands.DeploySurchargeTCCmdImpl";
}
Example implementation:


package com.ibm.commerce.sample.contract.commands;

import com.ibm.commerce.contract.objects.*;
import com.ibm.commerce.contract.helper.*;

DeploySurchargeTCCmdImpl.java
public class DeploySurchargeTCCmdImpl  extends
com.ibm.commerce.contract.commands.DeployExtendedTCCmdImpl
implements DeploySurchargeTCCmd
{

public void performExecute() throws ECException{

       ECTrace.entry(ECTraceIdentifiers.COMPONENT_CONTRACT,
this.CLASSNAME, "performExecute");
       try{
              
              if(this.tcId != null){
                     ExtendedTermConditionAccessBean etcAB = new
ExtendedTermConditionAccessBean();
                    
etcAB.setInitKey_referenceNumber(com.ibm.commerce.base.objects.WCSStringConverter
                                   .LongToString(tcId));
                     Map properties = etcAB.getProperties();
                    
ECTrace.trace(ECTraceIdentifiers.COMPONENT_CONTRACT,
this.CLASSNAME, "performExecute","The properties of the TC which
TermCond_id='"+
com.ibm.commerce.base.objects.WCSStringConverter.LongToString((Long)tcId)+"'
is:"+ properties.toString());
              }
       }catch(Exception e){
              ECTrace.trace(ECTraceIdentifiers.COMPONENT_CONTRACT,
this.CLASSNAME, "performExecute","An exception was thrown when
deploying the extended TC:");
              e.printStackTrace();
       }
       ECTrace.exit(ECTraceIdentifiers.COMPONENT_CONTRACT,
this.CLASSNAME, "performExecute");
  }
       

}