The PromotionImportExport component contains the main methods used for importing and exporting promotions. Both processes start and end with startImportExportSession() and endImportExportSession() methods.

Warning: The atg.commerce.promotion.PromotionImportExport class on which this component is based allows you to run multiple concurrent import/export sessions. However, it provides no safeguards against making multiple concurrent updates to a given repository item.

The sections that follow describe the methods in this component at a high level. See the ATG Platform API Reference for additional details.

startImportExportSession()

To import promotions, first call startImportExportSession(). This method sets up the import session, and must be called before doing the import itself.

The method performs the following tasks:

The method returns a PromotionImportExportSession object.

importPromotion()

This method enables you to create or update an individual promotion and its associated items (such as closeness qualifiers, promotion folders, coupons, and coupon folders), depending on the action specified.

Always make sure that you have a PromotionImportExportSession object before using importPromotion().

The method performs the following tasks:

The action property on the PromotionImportExportInfo object determines whether the repository item is created, updated, or deleted. Each item associated with the promotion also specifies its own action, but the available actions depend on the parent promotion’s action, as shown by this table:

Promotion Action

Supported Closeness Qualifier Actions

Supported Coupon Actions

ADD

UPDATE
DELETE

DELETE

UPDATE

(none)

(none)

When adding promotions, property values from the template manager take precedence over the equivalent values specified in the PromotionImportExportInfo object; for updates, the opposite holds.

The method returns a PromotionImportExportSessionStatus object.

exportPromotionsById()

This method enables you to export promotions by specifying a list of promotion item IDs (for an alternative export method, see the exportPromotionsByRQLQuery section.

This method first calls the PromotionManager.getPromotionsById() method using the specified list of promotion IDs (if the list is null, all promotions are returned). The getPromotionsById() method returns a list of promotion repository items. The exportPromotionsById() method then processes each of the returned promotion repository items as follows:

  1. Create a PromotionImportExportInfo object.

  2. Populate the object’s promotionPropertyValues, templateId and templateValues properties from the promotion repository item.

  3. Retrieve the promotion’s folder (if not null).

  4. For each closeness qualifier in the closenessQualifiers property of the promotions repository item, execute the following tasks:

    • Call the PromotionImportExportTools.getClosenessQualifier() method to get the closenessQualifier repository item.

    • Create a new ClosenessQualifierImportExportInfo object.

    • Populate its closenessQualifierPropertyValues map from the repository item properties.

    • Add the ClosenessQualifierImportExportInfo object to the closenessQualifiers list property in the PromotionImportExportInfo object.

  5. Call the ClaimableTools.getCouponsForPromotion() method to retrieve the coupon details associated with the promotion. That method returns a list of coupon repository items. For each coupon item in the list, execute the following tasks:

    • Create a new CouponImportExportInfo object and populate its couponPropertyValues map from the repository item properties.

    • If the coupon repository item’s parentFolder property is not null, then call the ClaimableTools.getCouponFolderPath() method. That method returns the full path for the coupon folder, which is used to set the couponFolderPath property in the CouponImportExportInfo object.

    • Add the CouponImportExportInfo object to the coupons list property in the PromotionImportExportInfo object.

  6. Add the PromotionImportExportInfo object to the list to be returned to the caller.

  7. Return the list of PromotionImportExportInfo objects.

exportPromotionsByRQLQuery

This method enables the user to export promotions by specifying a list of promotion via an RQL query.

This method calls the PromotionImportExportTools.getPromotionsByRQLQuery() method to query the promotions item descriptor. The method returns a list of promotion repository items. Once the list of repository items has been returned the remaining processing is identical to that of the exportPromotionsById method.

endImportExportSession

The endImportExportSession() method ends your import session. The method performs the following tasks:

  1. If the session ID is not specified, throws an exception.

  2. Checks the component’s integrators property to establish whether or not any integrators have been configured. (See Using the PromotionImportExportIntegrator Interface.) For each configured integrator, call its postImportExportSession method, passing the session object as a parameter. In case of exceptions, the PublishingWorlflowAutomator’s endWorkflowSession method must be called to clean up the session.

  3. Checks if the current transaction is marked for roll back; if it is, then the roll back is executed, otherwise, the transaction is committed.

  4. If running against a versioned repository and the sessionStatus is set to SESSION_ERROR, the workflow session is rolled back by calling the abandonWorkflowSession method on the PublishingWorkflowAutomator component.

    If running against a versioned repository and the sessionStatus is set to SESSION_OK, then the workflow session is committed by calling the stopWorkflowSession method on the PublishingWorkflowAutomator component.

After finishing the import, the workflow advances to the next stage.


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