Creating the campaign element task command
Create a new task command interface and its associated implementation class for your new campaign element. The task command performs the work for the campaign element, and it can also validate parameters if required.
Before you begin
About this task
The campaign element task command must be a class that implements the MarketingCampaignElementTaskCmd interface and should extend from the MarketingCampaignElementTaskCmdImpl class.
Procedure
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- Create a package for your task command files:
- Navigate to WebSphereCommerceServerExtensionsLogic > src.
- Right-click the src folder; then click New > Package.
- In the Name field, type:
com.your_company_name.marketing.commands.elements
- Click Finish.
- In the new package, create a new interface class for your
campaign element task command that extends from the MarketingCampaignElementTaskCmd
interface. Give the class the name that you specified in the implementation definition, for example,
CustomLevelOfSupportTargetTaskCmd
.Here is an example of a task command for a target that targets customers who have paid for a specific level of support:
public interface CustomLevelOfSupportTargetTaskCmd extends MarketingCampaignElementTaskCmd { public final static String defaultCommandClassName = CustomLevelOfSupportTargetTaskCmdImpl.class.getName(); }
- In the new package, create a task command implementation
that extends from MarketingCampaignElementTaskCmdImpl class. Give
the class a name that uses this syntax: campaign_element_nameTaskCmdImpl;
for example,
CustomLevelOfSupportTargetTaskCmdImpl
.- For targets and actions, this task command implementation must implement the method performExecute. The task command implementation can also implement the method validateParameters to validate that the element has all the required user interface parameters.
- For triggers, this task command implementation can implement either
of the following methods, if required:
- forwardTriggersForProcessing method: If the trigger is a daily check trigger, this method finds all the customers who meet the trigger criteria and then forwards the trigger for each customer.
- validateParameters method: this method validates that the element has all the required user interface parameters.
- For any server-side error messages in the
task command, create a new message key class:
- Navigate to WebSphereCommerceServerExtensionsLogic > src.
- Right-click the src folder; then click New > Package.
- In the Name field, type:
com.your_company_name.marketing.logging
- Click Finish.
- In the new package, create a new class file to contain
the message keys, for example, CustomMarketingMessageKeys.java.
The following is an example of this type of class; the example contains message keys for the four sample campaign elements linked from the previous step:
package com.mycompany.commerce.marketing.logging; public class CustomMarketingMessageKeys { public final static String _APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_MISSING = "_APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_MISSING"; public final static String _APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_INVALID = "_APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_INVALID"; public final static String _APP_ACTIVITY_GIFT_REGISTRY_MISSING_NUMBER_OF_DAYS = "_APP_ACTIVITY_GIFT_REGISTRY_MISSING_NUMBER_OF_DAYS"; public final static String _APP_ACTIVITY_LEVEL_OF_SUPPORT_TYPE_IS_MISSING = "_APP_ACTIVITY_LEVEL_OF_SUPPORT_TYPE_IS_MISSING"; public final static String _APP_ACTIVITY_SEND_CATALOG_NAME_IS_MISSING = "_APP_ACTIVITY_SEND_CATALOG_NAME_IS_MISSING"; }
- Save the class file.
- Create a properties file to define the server-side
error message text:
- Navigate to WebSphereCommerceServerExtensionsLogic > src.
- Right-click the src folder; then click New > Package.
- In the Name field, type:
com.your_company_name.marketing.logging.properties
- Click Finish.
- In the new package, create a properties file to define
the message text, for example, WcMarketingMessages.properties.
The following is an example properties file; the example contains message text for the four sample campaign elements:
_APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_MISSING=Specify a value for the Event type field. _APP_ACTIVITY_FRAUD_EVENT_TYPE_IS_INVALID=The value in the Event type is not valid. _APP_ACTIVITY_GIFT_REGISTRY_MISSING_NUMBER_OF_DAYS=Specify a value for the Number of days field. _APP_ACTIVITY_LEVEL_OF_SUPPORT_TYPE_IS_MISSING=Specify a value for the Level of support field. _APP_ACTIVITY_SEND_CATALOG_NAME_IS_MISSING=Specify a value for the Catalog name field.
- Save the properties file.