Créez une classe d'implémentation de commande de tâche pour votre nouvel attribut de segment de clientèle et enregistrez-la dans la table CMDREG. La commande de tâche vérifie si un client appartient à un segment de clientèle spécifié dans une promotion ou une activité marketing.
Pourquoi et quand exécuter cette tâche
Dans l'outil Marketing du Management Center, les professionnels peuvent spécifier un segment de clientèle comme cible d'une promotion, d'une activité Web ou Dialogue ou d'une activité de courrier électronique. Lorsque la promotion ou l'activité est en cours d'exécution, les services marketing appellent la commande CheckUserInMemberGroupCmdImpl pour déterminer si un client appartient au segment de clientèle spécifié. La commande recherche les données liées aux attributs définis dans le segment client. Dans les tables de base de données WebSphere Commerce. Par exemple, l'âge et le sexe du client. La commande procède ensuite à l'évaluation et renvoie true ou false. Vous devez étendre la classe CheckUserInMemberGroupCmdImpl pour que les services marketing puissent inclure votre nouvel attribut de segment de clientèle dans le processus de validation.
Procédure
-
Ouvrez HCL Commerce Developer et basculez vers la vue Explorateur d'entreprise.
-
Créez un module pour les fichiers de votre commande de tâche :
-
Naviguez jusqu'à WebSphereCommerceServerExtensionsLogic > src.
-
Cliquez avec le bouton droit sur le dossier src, puis cliquez sur Nouveau > Package.
-
Dans la zone Nom, entrez le nom d'un package.
Par exemple, com.your_company_name.membergroup.commands.
-
Vérifiez que WebSphereCommerceServerExtensionsLogic/src est spécifié dans le champ Dossier source.
-
Cliquez sur Terminer.
-
Dans le nouveau module, créez une implémentation de commande de tâche étendant la classe CheckUserInMemberGroupCmdImpl. Donnez un nom à cette classe.
Par exemple,
ExtCheckUserInMemberGroupCmdImpl.
L'exemple suivant illustre une implémentation de commande de tâche pour un nouvel attribut de segment de clientèle. Cet attribut permet aux professionnels de spécifier que les clients doivent posséder un certain nombre de points de fidélité pour appartenir au segment de clientèle.
/**
* This class extends the CheckUserInMemberGroupCmdImpl class to implement
* the evaluation programming logic that handles the loyalty points
* simple condition.
*/
package com.yourcompanyname.membergroup.commands;
import com.ibm.commerce.condition.ConditionUtil;
import com.ibm.commerce.condition.SimpleCondition;
import com.ibm.commerce.membergroup.commands.CheckUserInMemberGroupCmdImpl;
public class ExtCheckUserInMemberGroupCmdImpl
extends CheckUserInMemberGroupCmdImpl {
/**
* For this example, the simple condition variable name is defined as
* a string of "loyalty". In practice, this constant should be defined in
* a separate constant class.
*/
public static final String VARIABLE_LOYALTY_POINTS = "loyalty";
/**
* Override the parent's method to evaluate the loyalty points
* simple condition.
* @return <code>true</code> if the condition evaluates to true.
*/
public boolean evaluate(
String variable,
String operator,
String value,
SimpleCondition.Qualifier[] qualifiers) {
boolean result = false;
if (VARIABLE_LOYALTY_POINTS.equals(variable)) {
// If the simple condition is for loyalty points,
// invoke the specific loyalty points evaluation
// method to handle the case.
result = evaluateLoyaltyPointsCondition(operator, value, qualifiers);
} else {
// Since we override this evaluate() method from
// the parent class to take care of the new loyalty
// points condition, call the parent's
// evaluate() method to handle all the other simple
// conditions.
result = super.evaluate(variable, operator, value, qualifiers);
}
return result;
}
/**
* Evaluate the loyalty points condition.
*/
protected boolean evaluateLoyaltyPointsCondition(
String operator,
String value,
SimpleCondition.Qualifier[] qualifiers) {
Integer numOfPoints = null;
try {
// To simplify this example, assume the loyalty points
// value is stored in the table USERDEMO in the
// customizable column FIELD6. We can use the parent's
// class method getDemographics() to retrieve the access
// bean that contains the USERDEMO information.
if (getDemographics() != null) {
numOfPoints = getDemographics().getField6InEJBType();
}
}
catch (Exception e) {
// Handle the exception here.
}
// Call the ConditionUtil helper class's evaluateInteger()
// method to evaluate the loyalty points integer value
// with the given operator.
return ConditionUtil.evaluateInteger
(numOfPoints, operator, SegmentUtil.toInteger(value));
}
}//end-ExtCheckUserInMemberGroupCmdImpl
-
Sauvegardez et fermez le nouveau fichier de classe d'implémentation.
-
Enregistrez la commande de tâche dans la table CMDREG :
-
Exécutez l'instruction SQL suivante :
INSERT INTO cmdreg (STOREENT_ID, INTERFACENAME, DESCRIPTION, CLASSNAME, PROPERTIES, LASTUPDATE, TARGET, OPTCOUNTER)
VALUES (0, 'com.ibm.commerce.membergroup.commands.CheckUserInMemberGroupCmd',
null, 'IMPL_CLASS_FULL_NAME', null, null, 'Local', null);
Où
IMPL_CLASS_FULL_NAME correspond au nom complet de votre classe d'implémentation étendue. Par exemple :
com.yourcompanyname.membergroup.commands.ExtCheckUserInMemberGroupCmdImpl
-
Redémarrez le serveur HCL Commerce pour appliquer les modifications.
- Facultatif :
Les professionnels peuvent souhaiter consulter une liste des clients dans un segment de clientèle qui utilise votre nouvel attribut. La consultation de ce type de liste n'est pas prise en charge dans l'outil Marketing du Management Center, mais elle l'est dans HCL Commerce Accelerator.
-
Pour prendre en charge l'affichage de ce type de liste dans HCL Commerce Accelerator, vous pouvez étendre la classe ListUsersInMemberGroupCmdImpl. Voici un exemple :
/**
* This class extends the ListUsersInMemberGroupCmdImpl class to implement
* the query programming logic that lists all of the customers who belong to
* a specified customer segment with the loyalty points condition.
*/
package com.yourcompanyname.membergroup.commands;
import com.ibm.commerce.condition.SimpleCondition;
import com.ibm.commerce.membergroup.commands.ListUsersInMemberGroupCmdImpl;
public class ExtListUsersInMemberGroupCmdImpl
extends ListUsersInMemberGroupCmdImpl {
/**
* For this example, the simple condition variable name is defined as
* a string of "loyalty". In practice, this constant should be defined in
* a separate constant class.
*/
public static final String VARIABLE_LOYALTY_POINTS = "loyalty";
/**
* Default constructor
*/
public ExtListUsersInMemberGroupCmdImpl() {
super();
}
/**
* Override the parent's method to convert the loyalty
* points simple condition to SQL.
* @param condition SimpleCondition
* @return SQL string.
*/
protected String convertToSQL(SimpleCondition condition) {
String sql = null;
if (condition != null) {
String variable = condition.getVariable();
String operator = condition.getOperator();
String value = condition.getValue();
SimpleCondition.Qualifier[] qualifiers = condition.getQualifiers();
if (VARIABLE_LOYALTY_POINTS.equals(variable)) {
// If the simple condition is for loyalty points,
// invoke the specific convertLoyaltyPointsCondition()
// method to handle the case.
sql = convertLoyaltyPointsCondition(operator, value, qualifiers);
} else {
// Since we override this convertToSQL() method from
// the parent class to take care of the new loyalty
// points condition, we should call the parent's
// convertToSQL() method to handle all the other
// simple conditions.
sql = super.convertToSQL(condition);
}
}
return sql;
}
/**
* Converts the loyalty points condition to an SQL query.
*
* @param operator - The name of the operator.
* @param value - The data for the value.
* @param qualifiers - An array of qualifiers.
*
* @return An SQL string.
*/
protected String convertLoyaltyPointsCondition(
String operator,
String value,
SimpleCondition.Qualifier[] qualifiers) {
// To simplify this example, assume the loyalty points
// value is stored in the table USERDEMO in the
// customizable column FIELD6.
String sql = "MEMBER.MEMBER_ID = any ("
+ "select USERS_ID from USERDEMO where FIELD6"
+ operator
+ value
+ ")";
return sql;
}
}//end-ExtListUsersInMemberGroupCmdImpl
-
Pour enregistrer la commande de tâche dans la table CMDREG, exécutez l'instruction SQL suivante :
INSERT INTO cmdreg (STOREENT_ID, INTERFACENAME, DESCRIPTION, CLASSNAME, PROPERTIES, LASTUPDATE, TARGET, OPTCOUNTER)
VALUES (0, 'com.ibm.commerce.membergroup.commands.ListUsersInMemberGroupCmd',
null, 'IMPL_CLASS_FULL_NAME', null, null, 'Local', null);
Où IMPL_CLASS_FULL_NAME correspond au nom complet de votre classe d'implémentation étendue.
-
Redémarrez le serveur HCL Commerce pour appliquer les modifications.