The following steps occur when creating an audit log record:

When creating new audit log records, you must extend the AgentEvent class to pass your new event properties. You should then extend the agent_audit item-descriptor with a new sub-type to store your properties. Finally, you should extend the AgentAuditRecorder.populateCustomProperties() method to copy your custom AgentEvent's properties to your agent_event RepositoryItem sub-type.

Creating a New Agent Audit Log Record

The process outlined below uses creating a loyalty point redemption event as an example.

  1. Add a new AgentAudit event subclass for the new audit record.

    This may not be necessary if the AgentAudit class has all the necessary properties. In this case, you only need to set the proper type of the event. Every event must extend AgentEvent. The following is an example of a RedeemedLoyaltyPointsEvent:

    package atg.commerce.csr.events;
    import atg.agent.events.AgentEvent;
    public class RedeemedLoyaltyPointsEvent extends AgentEvent {
      public static final String CLASS_VERSION = "$Id: $$Change: $";
      private static final long serialVersionUID = -5747213631038504108L;
      int mPointsRedeemed;
      public void setPointsRedeemed(int pPointsRedeemed) {
        mPointsRedeemed = pPointsRedeemed;
      }
      public int getPointsRedeemed() {
        return mPointsRedeemed;
      }

  2. Add the new audit log repository item definition for the new type.

    Add an item-descriptor to the audit repository for the new agent audit in the/atg file. Add an option to auditType property of the agent_audit item descriptor. For example:

    //Add the item descriptor
    <item-descriptor name="RedeemedLoyaltyPoints" super-type="agent_audit"
      sub-type-value="RedeemedLoyaltyPoints">
        <table name="csr_loyalty" id-column-name="id">
          <property name="pointsRedeemed" data-type="int" column-
            name="points_redeemed" display-name-resource="pointsRedeemed"/>
          <property name="orderId" data-type="string" column-name="order_id"
            display-name-resource="orderId"/>
        </table>
    </item-descriptor>

    //Add the auditType
    <option value="RedeemedLoyaltyPoints" code="1020"/>

  3. Create an AgentAuditLogger component using one of the base classes provided or an extension. This component will receive the AgentAudit events of the new type. For example:

    /atg/commerce/custsvc/logging/RedeemedLoyaltyPointsEventRecorder

    $class=atg.agent.logging.ConfigurableAgentAuditRecorder
    customProperties=\
        pointsRedeemed=pointsRedeemed,\
        orderId=orderId

    ConfigurableAgentAuditRecorder provides a convenient way of defining a recorder where the properties of the event map directly to the properties on the audit log repository item.

  4. Configure the AgentAuditLogger with the new AgentAuditRecorder component mapped to the appropriate audit type. Add an entry into the eventTypeToRecorderMap property of the /atg/agent/logging/
    AgentAuditLogger.properties
    component to provide information on the new event recorder. For example,

    eventTypeToListenerMap+=RedeemedLoyaltyPoints=/atg/commerce/custsvc/
    logging/RedeemedLoyaltyPointsEventRecorder

  5. Create an instance of the AgentAudit object and send it using the AgentMessagesource.sendAgentEventMessage API.

    private void sendRedeemedLoyaltyPointsEvent
    (
      String pAgentId,
      String pCustomerId,
      String pOrderId,
      int pPointsRedeemed,
      String pTicketId
    )
    {
      RedeemedLoyaltyPointsEvent redeemedLoyaltyPointsEvent = null;

      redeemedLoyaltyPointsEvent =
        getAgentMessagingTools().createRedeemedLoyaltyPointsEvent();
      redeemedLoyaltyPointsEvent.setActivityType
        CSRAgentMessagingTools.REDEEMED_LOYALTY_POINTS_TYPE);
      redeemedLoyaltyPointsEvent.setPointsRedemeed (pPointsRedeemed);
      getAgentMessagingTools().getAgentMessageSource().sendAgentEventMessage
        (redeemedLoyaltyPointsEvent, null,
        "myApp.events.RedeemedLoyaltyPoint");
      return;
    }


Copyright © 1997, 2014 Oracle and/or its affiliates. All rights reserved. Legal Notices