Tutorials > Contracts > Extend the existing contract model


Create an access bean and deploying

In this task we will create an access bean for the new business policy, and create a deployment command for it.


Procedure

  1. Create an access bean for MySubTC

    1. In the Enterprise Explorer view, right-click Enablement-RelationshipManagementData and select New > Other. The new wizard selection dialog opens.

    2. Click EJB > Access Bean. Click Next.

    3. Select Copy Helper and click Next.

    4. Select the MySubTC bean and click Next.

    5. From the Constructor method list, select findByPrimaryKey(com.ibm.commerce.contract.objects.TermConditionKey) as the constructor method.

    6. Select all attributes in the Attribute Helpers section.

    7. Click Finish.

    8. Save the work.

    9. From the Project menu, select Build All.... The project will compile.

  2. Generate the deploy code

    1. In the Enterprise Explorer view, navigate to Enablement-RelationManagementData > Deployment Descriptor: Enablement-RelationManagementData > Entity Beans(1.x-2.x) > TermCondition > MySubTC .

    2. Right-click on the MySubTC bean and select Prepare for Deployment.

  3. Regenerate the MySubTCAccessBean

    1. In the Enterprise Explorer view, navigate to Enablement-RelationManagementData > Deployment Descriptor: Enablement-RelationManagementData .

    2. Right-click on Deployment Descriptor: Enablement-RelationManagementData and select Java EE > Access Beans > Regenerate Access Beans .

    3. In the Regenerate Access Beans window:

      1. Click Deselect All.

      2. Select MySubTCAccessBean.

      3. Click Finish.

    4. In the Enterprise Explorer view, navigate to Enablement-RelationManagementData > ejbModule > com.ibm.commerce.contract.objects > MySubTCAccessBean.java .

    5. Double-click on MySubTCAccessBean.java to open it.

    6. Add the following method to the file:

          public java.lang.Long getReferenceNumberInEJBType() throws java.rmi.RemoteException,         javax.ejb.CreateException, javax.ejb.FinderException, javax.naming.NamingException {
              return (((java.lang.Long) __getCache("referenceNumber")));     }
                  
      

      This method is called by WebSphere Commerce when saving the data for MySubTC.

  4. Ovveride methods in the validate contract task command

    The next step is to override methods that are in the ValidateContractCmd task command. In this command, there are three methods that you may want to override to support the new term and condition object. They are:

    • validateTCType() This method checks what type of term can be in a contract. For example, the InvoiceTC belongs to account and therefore, it cannot appear in a contract.

    • validateTCOccurrence() This method checks the occurrence of the terms. For example, in the default implementation of this method, a contract has to have at least one PriceTC.

    • otherValidateCheck() The default implementation of this method is empty. You can add any additional validation that does not fall into the first two methods.

  5. Create a new deployment command

    To deploy a term and condition, create a deployment command and register this command in the database, if required:

    1. In this example, the new deployment command interface is called MySubTCDeployedCmd and the implementation class is called MySubTCDeployedCmdImpl. In addition, the command is packaged in the com.mycompany.mycommands package. To register this command, issue the following SQL command:

          insert into CMDREG (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) 
              values (0, 'com.mycompany.mycommands.MySubTCDeployCmd', 'com.mycompany.mycommands.MySubTCDeployCmdImpl', 'Local');             
      

    2. In the com.mycompany.mycommands package, create the new MySubTCDeployedCmd interface. This interface must extend the com.ibm.commerce.contract.commands.DeployTCCmd command interface. Create the following interface in the com.mycompany.mycommands package under the WebSphereCommerceServerExtensionsLogic project:

          public interface MySubTCDeployCmd extends com.ibm.commerce.contract.commands.DeployTCCmd {
              // customized code
          }
                  
      

    3. In the same package, create the MySubTCDeployCmdImpl implementation class. This implementation class must extend com.ibm.commerce.contract.commands.DeployTCCmdImpl. The following describes the new command implementation class:

          public class MySubTCDeployCmdImpl extends com.ibm.commerce.contract.commands.DeployTCCmdImpl 
              implements MySubTCDeployCmd {
              
              // customer code
          } 
                  
      

      There is a protected parameter abTC in samp class="codeph">DeployTCCmdImpl and a method called getTargetStoreId() in DeployTCCmd. The value of abTC is MySubTCAccessBean and the getTargetStoreId() method returns the identifier of the store to which the contract is being deployed.


Previous topic: Create the enterprise bean


Next topic: Update WebSphere Commerce Accelerator to use the new term and condition


+

Search Tips   |   Advanced Search