com.ibm.commerce.marketing.commands.elements

Class CustomerFilterOrderTargetBase

    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • CLASSNAME

        public static final java.lang.String CLASSNAME
        The name of this class.
        See Also:
        Constant Field Values
      • TYPE_SHOPCART

        public static final java.lang.String TYPE_SHOPCART
        Constant to specify to evaluate the shopping cart
        See Also:
        Constant Field Values
      • TYPE_PURCHASE_HISTORY

        public static final java.lang.String TYPE_PURCHASE_HISTORY
        Constant to specify to evaluate the purchase history
        See Also:
        Constant Field Values
      • ANY

        public static final java.lang.String ANY
        Constant to specify that one or more can match (any, or)
        See Also:
        Constant Field Values
      • ALL

        public static final java.lang.String ALL
        Constant to specify that all must match (all, and)
        See Also:
        Constant Field Values
    • Constructor Detail

      • CustomerFilterOrderTargetBase

        public CustomerFilterOrderTargetBase()
        This method is the default constructor. It currently performs no actions.
    • Method Detail

      • getMemberIdsForOrderQuery

        public java.lang.Long[] getMemberIdsForOrderQuery(java.lang.String type)
        This method returns the member IDs to use with any order queries. This method will not return the generic member id (-1002) in order to not query any order owned by the generic user (the junk shopping cart). If the provided type is "sc" (shopping cart), then only the member id from the context is returned (excluding generic user). If the provided type is "ph" (purchase history), then the array of returned member IDs first has the member ID from the context, followed by any other member IDs associated with the customer's personalization ID (again, excluding generic user). For a customization, return the list of member IDs applicable to your query. The method getMemberId(boolean) can be used if you only want the member ID from the context. Pass true if you do not want the generic member id to be returned. The method getMemberIdsForPersonalizationId(boolean) can be used if you want the member ID from the context as well as any member IDs associated with the personalization ID. Pass true if you do not want the generic member id to be returned. This method is called by getOrder, getOrderProduct, and getOrderCategory. The following is an example of a customization that targets the interest item list.
                        private static final String TYPE_INTEREST_ITEM_LIST = "ii";
                        Long [] memberIds = null;
                        if (TYPE_INTEREST_ITEM_LIST.equals(type)) {
                                // only use the current user for the interest item list target
                                Long memberId = getMemberId(true);
                                if (memberId != null) {
                                        memberIds = new Long[] { memberId };
                                }
                        } else {
                                memberIds = super.getMemberIdsForOrderQuery(type);
                        }
         
        Parameters:
        type - The type of order query being done. Possible values include "sc" and "ph".
        Returns:
        This method returns the member IDs to use to find the customer's orders. The method may return null, or an empty array.
      • getOrderData

        public OrderInfo[] getOrderData(java.lang.String type,
                                        java.lang.Integer storeId,
                                        java.lang.Long[] memberIds,
                                        java.lang.String daysOperator,
                                        java.lang.String daysValue,
                                        java.lang.String dateOperator1,
                                        java.lang.String dateValue1,
                                        java.lang.String dateOperator2,
                                        java.lang.String dateValue2,
                                        boolean getItems)
                                 throws java.lang.Exception
        This method returns the OrderInfo objects that represent a customer's order or orders. This method is called by getOrder, getOrderProduct, and getOrderCategory. Those methods use the order information returned from this method to evaluate if the order matches the target criteria. Note that the methods ConditionUtil.getDateClause, ConditionUtil.getOrderStatementDateParameters, and ConditionUtil.checkEqualDate can be used to leverage the existing infrastructure to have the order query check the appropriate dates set in the target. The following is an example of a customization that targets the interest item list.
         insert into dmeletemplate (dmeletemplate_id, dmelementtype_id, name, implxml) 
         values (2000, 2, 'interestItemListCategoryContents',
         '<FlowElementImplementation type="Interest Item List Category Contents">
             <Implementation invocationType="TaskCommand">
                <Class name="com.ibm.mycompany.commands.elements.InterestItemListCategoryTargetTaskCmd">
                 <Argument name="type" value="ii"/>
                 <Argument name="anyOrAll" value="MARKETING_anyOrAll"/>
                 <Argument name="containsOperator" value="MARKETING_containsOperator"/>
                 <Argument name="categoryIdList" value="MARKETING_categoryIdList"/>
                 <Argument name="daysOperator" value="MARKETING_daysOperator"/>
                 <Argument name="daysValue" value="MARKETING_days"/>
                 <Argument name="dateOperator1" value="MARKETING_beforeAfterOnDate"/>
                 <Argument name="dateValue1" value="MARKETING_date1"/>
                 <Argument name="dateOperator2" value="MARKETING_beforeDate"/>
                 <Argument name="dateValue2" value="MARKETING_date2"/>
                 <Argument name="amountOperator1" value="MARKETING_amountOperator1"/>
                 <Argument name="amountValue1" value="MARKETING_amountValue1"/>
                 <Argument name="amountOperator2" value="MARKETING_amountOperator2"/>
                 <Argument name="amountValue2" value="MARKETING_amountValue2"/>
                 <Argument name="amountCurrency" value="MARKETING_amountCurrency"/>
                 <Argument name="quantityOperator1" value="MARKETING_quantityOperator1"/>
                 <Argument name="quantityValue1" value="MARKETING_quantityValue1"/>
                 <Argument name="quantityOperator2" value="MARKETING_quantityOperator2"/>
                 <Argument name="quantityValue2" value="MARKETING_quantityValue2"/>
               </Class>
            </Implementation>
          </FlowElementImplementation>');
                private static final String TYPE_INTEREST_ITEM_LIST = "ii";
                        OrderInfo [] orderInfoList = null;
                        if (TYPE_INTEREST_ITEM_LIST.equals(type)) {
        
                                java.sql.Connection connection = com.ibm.commerce.scheduler.SchedulerDataAccessObject.getDataSourceConnection();
                                PreparedStatement interestItemSelectStmt = null;
                                ResultSet interestItemSelectRs = null;
                                try {
                                        // assume no storepath, only find interest item list in the current store
                                        final String INTEREST_ITEM_LIST_QUERY = "SELECT iitem.CATENTRY_ID, iitem.QUANTITY, iitem.LASTUPDATE FROM iitem iitem WHERE iitem.MEMBER_ID = ? and iitem.STOREENT_ID = ?";
                                        
                                        StringBuffer strQuery = new StringBuffer(INTEREST_ITEM_LIST_QUERY);
                                        strQuery.append(ConditionUtil.getDateClause(" AND iitem.LASTUPDATE ", daysOperator, daysValue, dateOperator1, dateValue1, dateOperator2, dateValue2));
                                        interestItemSelectStmt = connection.prepareStatement(strQuery.toString());
                                        int index = 1;
                                        interestItemSelectStmt.setLong(index++, memberIds[0].longValue());
                                        interestItemSelectStmt.setLong(index++, storeId.intValue());
        
                                        interestItemSelectStmt = ConditionUtil.getOrderStatementDateParameters(interestItemSelectStmt, index,
                                                        daysOperator, daysValue, dateOperator1, dateValue1, dateOperator2, dateValue2);
                                        
                                        interestItemSelectRs = interestItemSelectStmt.executeQuery();
                                        if (interestItemSelectRs != null) {
                                                ArrayList tempResult = new ArrayList(1);
                                                while (interestItemSelectRs.next()) {
                                                        OrderInfo orderItem = new OrderInfo();
                                                        int i = 1;
                                                        orderItem.setCatentryId(interestItemSelectRs.getLong(i++));
                                                        orderItem.setQuantity(new Double(interestItemSelectRs.getDouble(i++)));
        
                                                        if (ConditionUtil.OPERATOR_EQUAL_TO.equals(dateOperator1)) {
                                                                if (ConditionUtil.checkEqualDate(dateValue1, interestItemSelectRs.getTimestamp(i++))) {
                                                                        tempResult.add(orderItem);
                                                                }
                                                        } else {
                                                                tempResult.add(orderItem);
                                                        }
                                                }
                                                orderInfoList = new OrderInfo[tempResult.size()];
                                                orderInfoList = (OrderInfo[]) tempResult.toArray(orderInfoList);
                                        }
                                } finally {
                                        // ... close interestItemSelectRs, interestItemSelectStmt, connection
                                }
                                
                        } else {
                                orderInfoList = super.getOrderData(type, storeId, memberIds,
                                                daysOperator, daysValue, dateOperator1, dateValue1, dateOperator2, dateValue2,
                                                getItems);
                        }
        
                        return orderInfoList;
        
         
        Parameters:
        type - Specify "sc" to check the user's shopping cart, or specify "ph" to check the user's purchase history.
        storeId - The store ID in which to find the order.
        memberIds - The member IDs for which to find the orders. This is the information returned from the method getMemberIdsForOrderQuery.
        daysOperator - The operator to use when checking if this behavior has occurred within or prior to a number of days. Valid values are: =, <, <=, >, >=. However, from a business point of view, only <= (within) and > (prior) make sense. There is a special case for the purchase history target to specify that only a specific number of previous orders should be checked. In that scenario the daysOperator is equal to previousOrders, and daysValue is the number of previous orders to consider. The other date parameters are not valid when previousOrders is used.
        daysValue - When has this behavior has occurred; within or prior to the specified number of days.
        dateOperator1 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue1 - When has this behavior has occurred; on, before, after, or between the specified date.
        dateOperator2 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue2 - When has this behavior has occurred; on, before, after, or between the specified date.
        getItems - This flags specifies for purchase history if the order information returned should include the information about all the order items (required for checking category and product), or just the totals from the order are required (required for the purchase history total target).
        Returns:
        This method returns an array of OrderInfo objects representing the customer's orders.
        Throws:
        java.lang.Exception
      • getTemporarySharedDataCacheKey

        public java.lang.String getTemporarySharedDataCacheKey(java.lang.String type,
                                                               java.lang.Integer storeId,
                                                               java.lang.String daysOperator,
                                                               java.lang.String daysValue,
                                                               java.lang.String dateOperator1,
                                                               java.lang.String dateValue1,
                                                               java.lang.String dateOperator2,
                                                               java.lang.String dateValue2)
        This method creates a cache key used to store temporary data that can be passed between all the campaign elements when evaluating an e-Marketing Spot. The cached data currently stores shopping cart and purchase history queries. This avoids multiple queries to the ORDER and ORDERITEM tables to get the same information. As well, this avoids calls to catalog to get the parent categories of the items in an order. The cached data is available to all campaign elements called in a single e-Marketing Spot evaluation, even if the campaign elements are in different activities. Any customizations that extend the method getOrderData will be part of this framework, and will have the database queries shared between campaign elements.
        Parameters:
        type - The type of data being cached. Current values in sc, scproduct, sccategory, ph, phproduct, phcategory. Any custom type can be specified as well.
        storeId - The store ID in which to find the order.
        daysOperator - The operator to use when checking if this behavior has occurred within or prior to a number of days. Valid values are: =, <, <=, >, >=. However, from a business point of view, only <= (within) and > (prior) make sense. There is a special case for the purchase history target to specify that only a specific number of previous orders should be checked. In that scenario the daysOperator is equal to previousOrders, and daysValue is the number of previous orders to consider. The other date parameters are not valid when previousOrders is used.
        daysValue - When has this behavior has occurred; within or prior to the specified number of days.
        dateOperator1 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue1 - When has this behavior has occurred; on, before, after, or between the specified date.
        dateOperator2 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue2 - When has this behavior has occurred; on, before, after, or between the specified date.
        Returns:
        This method returns the cache key to use when getting and putting data in the temporary shared data map.
      • getOrder

        public java.util.List getOrder(java.lang.String type,
                                       java.util.List order,
                                       java.lang.String currency,
                                       java.lang.String daysOperator,
                                       java.lang.String daysValue,
                                       java.lang.String dateOperator1,
                                       java.lang.String dateValue1,
                                       java.lang.String dateOperator2,
                                       java.lang.String dateValue2)
        This method returns the total value of the user's order, and the quantity (unique order items for shopping cart, number of orders for purchase history) that are within the specified dates.
        Parameters:
        type - Specify "sc" to check the user's shopping cart, or specify "ph" to check the user's purchase history.
        order - The current data retrieved by previously calling this method. If the data has already been retrieved, then the existing data is returned.
        currency - The currency in which to return the value of the user's orders.
        daysOperator - The operator to use when checking if this behavior has occurred within or prior to a number of days. Valid values are: =, <, <=, >, >=. However, from a business point of view, only <= (within) and > (prior) make sense. There is a special case for the purchase history target to specify that only a specific number of previous orders should be checked. In that scenario the daysOperator is equal to previousOrders, and daysValue is the number of previous orders to consider. The other date parameters are not valid when previousOrders is used.
        daysValue - When has this behavior has occurred; within or prior to the specified number of days.
        dateOperator1 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue1 - When has this behavior has occurred; on, before, after, or between the specified date.
        dateOperator2 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue2 - When has this behavior has occurred; on, before, after, or between the specified date.
        Returns:
        This method returns a List. The first element contains the total value of the orders as a BigDecimal. The second element contains the quantity as an Integer.
      • getOrderProduct

        public java.util.List getOrderProduct(java.lang.String type,
                                              java.util.List order,
                                              java.lang.String catentryId,
                                              java.util.List childCatentries,
                                              java.lang.String currency,
                                              java.lang.String daysOperator,
                                              java.lang.String daysValue,
                                              java.lang.String dateOperator1,
                                              java.lang.String dateValue1,
                                              java.lang.String dateOperator2,
                                              java.lang.String dateValue2)
        This method returns the total value of the user's order, and the quantity, associated with the specified product or item, that are within the specified dates.
        Parameters:
        type - Specify "sc" to check the user's shopping cart, or specify "ph" to check the user's purchase history.
        order - The current data retrieved by previously calling this method.
        catentryId - The catalog entry ID to check in the user's orders. If this value is null, then only load the orders, but do not do any additional checking.
        childCatentries - A list of child catalog entry IDs of the product to check in the user's orders.
        currency - The currency in which to return the value of the user's orders.
        daysOperator - The operator to use when checking if this behavior has occurred within or prior to a number of days. Valid values are: =, <, <=, >, >=. However, from a business point of view, only <= (within) and > (prior) make sense. There is a special case for the purchase history target to specify that only a specific number of previous orders should be checked. In that scenario the daysOperator is equal to previousOrders, and daysValue is the number of previous orders to consider. The other date parameters are not valid when previousOrders is used.
        daysValue - When has this behavior has occurred; within or prior to the specified number of days.
        dateOperator1 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue1 - When has this behavior has occurred; on, before, after, or between the specified date.
        dateOperator2 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue2 - When has this behavior has occurred; on, before, after, or between the specified date.
        Returns:
        This method returns a List. The first element contains the total value of the orders as a BigDecimal. The second element contains the quantity as an Integer. The third element contains an array of OrderInfo objects that contain the user's orders.
      • getOrderCategory

        public java.util.List getOrderCategory(java.lang.String type,
                                               java.util.List order,
                                               java.lang.String categoryId,
                                               java.lang.String currency,
                                               java.lang.String daysOperator,
                                               java.lang.String daysValue,
                                               java.lang.String dateOperator1,
                                               java.lang.String dateValue1,
                                               java.lang.String dateOperator2,
                                               java.lang.String dateValue2)
        This method returns the total value of the user's order, and the quantity, associated with the items contained within the specified category, that are within the specified dates.
        Parameters:
        type - Specify "sc" to check the user's shopping cart, or specify "ph" to check the user's purchase history.
        order - The current data retrieved by previously calling this method.
        categoryId - The category ID to check in the user's orders.
        currency - The currency in which to return the value of the user's orders.
        daysOperator - The operator to use when checking if this behavior has occurred within or prior to a number of days. Valid values are: =, <, <=, >, >=. However, from a business point of view, only <= (within) and > (prior) make sense. There is a special case for the purchase history target to specify that only a specific number of previous orders should be checked. In that scenario the daysOperator is equal to previousOrders, and daysValue is the number of previous orders to consider. The other date parameters are not valid when previousOrders is used.
        daysValue - When has this behavior has occurred; within or prior to the specified number of days.
        dateOperator1 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue1 - When has this behavior has occurred; on, before, after, or between the specified date.
        dateOperator2 - The operator to use when checking if this behavior has occurred on, before, after or between a specified date. Valid values are: =, <, <=, >, >=.
        dateValue2 - When has this behavior has occurred; on, before, after, or between the specified date.
        Returns:
        This method returns a Vector. The first element contains the total value of the orders as a BigDecimal. The second element contains the quantity as an Integer. The third element contains an array of OrderInfo objects that contain the user's orders.
      • validateParameters

        public void validateParameters(java.util.Map elementParameters,
                                       java.util.List validationErrors)
        This method validates the numeric data for the element. It checks for a valid integer for: days, quantityValue1, quantityValue2. It checks for a valid numeric value for: amountValue1, amountValue2.
        Parameters:
        elementParameters - The name value pairs for this element.
        validationErrors - The list of ApplicationError exceptions that contains any validation errors. The list may be empty.