com.ibm.commerce.subscription.facade.server.helpers

Class SubscriptionComponentHelper

  • java.lang.Object
    • com.ibm.commerce.subscription.facade.server.helpers.SubscriptionComponentHelper


  • public class SubscriptionComponentHelper
    extends java.lang.Object
    This class provides common helper methods for the Subscription component.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static long DAY_IN_MILLI_SECONDS
      Constant to indicate the value of a day in milli seconds.
      static long HOUR_IN_MILLI_SECONDS
      Constant to indicate the value of an hour in milli seconds.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.util.List executeSelectStatement(java.lang.String query, java.util.Map parameters)
      Executes a select query
      static java.lang.String findParentCatalogEntryID(java.lang.String catentryId)
      This method is used to find the Catentry ID of the parent, given a child catentry ID
      static CommandContext getCommandContext()
      This method returns the Command Context instance for this request.
      static long getDateDifferenceInDays(java.util.Date date1, java.util.Date date2)
      Returns the difference between two dates in terms of days.
      static long getDateDifferenceInHours(java.util.Date date1, java.util.Date date2)
      Returns the difference between two dates in terms of hours.
      static JDBCQueryService getJDBCQueryService()
      Gets the JDBC query service instance.
      static OrderType getOrder(java.lang.String orderId)
      This method retrieves the order using the order ID specified.
      static ScheduleEvaluateCmd getScheduleEvaluateCmd(java.lang.String scheduleType)
      This method returns the schedule evaluate command based on the schedule type specified.
      static java.lang.Integer getStoreId()
      This method returns the store ID from the business context.
      static Subscription getSubscriptionById(java.lang.Long subscriptionId)
      This method returns the physical Subscription entity based on the subscriptionId specified.
      static SubscriptionDetailsValidator getSubscriptionDetailsValidator()
      Gets the instance of the SubscriptionDetailsValidator which is used for perform validation of the various fields passed in the Subscription noun.
      static java.lang.Long getTemplateIDForSubscription(java.lang.Long catalogEntryID)
      This method returns the template identifier corresponding to the input catalog entry identifier.
      static java.lang.Long getUserId()
      This method returns the user ID from the context.
      static boolean isQtyUnitValid(java.lang.String qtyUnitId)
      This method checks whether the given quantity unit is valid and exists in the database.
      static boolean isSubscriptionTypeCodeValid(java.lang.String subscriptionTypeCode)
      This method checks if the given subscription type code is valid and exists in the data base.
      static java.lang.Integer updateSubscriptionState(java.lang.Long subscriptionId, java.lang.Integer state, boolean isTransient)
      This method updates the state of the subscription as a separate transaction.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DAY_IN_MILLI_SECONDS

        public static final long DAY_IN_MILLI_SECONDS
        Constant to indicate the value of a day in milli seconds.
        See Also:
        Constant Field Values
      • HOUR_IN_MILLI_SECONDS

        public static final long HOUR_IN_MILLI_SECONDS
        Constant to indicate the value of an hour in milli seconds.
        See Also:
        Constant Field Values
    • Method Detail

      • getStoreId

        public static java.lang.Integer getStoreId()
                                            throws SubscriptionApplicationException
        This method returns the store ID from the business context.
        Returns:
        The store ID provided in the context.
        Throws:
        SubscriptionApplicationException - if an error occurs while retrieving the store ID or the store ID is null.
      • getCommandContext

        public static CommandContext getCommandContext()
        This method returns the Command Context instance for this request.
        Returns:
        the instance of the command context.
      • getOrder

        public static OrderType getOrder(java.lang.String orderId)
                                  throws SubscriptionApplicationException
        This method retrieves the order using the order ID specified.
        Parameters:
        orderId - The order ID of the order.
        Returns:
        TheOrderType instance retrieved using the OrderServices.
        Throws:
        SubscriptionApplicationException - When an error occurs while retrieving the order.
      • getDateDifferenceInDays

        public static long getDateDifferenceInDays(java.util.Date date1,
                                                   java.util.Date date2)
        Returns the difference between two dates in terms of days. For the same dates, this method returns zero. A millisecond difference between the dates will also be considered as a single day difference. If this is not desirable, normalizing the two dates for the required accuracy is advised.
        Parameters:
        date1 - The first date.
        date2 - The second date.
        Returns:
        The difference between first and second date in days.
      • getDateDifferenceInHours

        public static long getDateDifferenceInHours(java.util.Date date1,
                                                    java.util.Date date2)
        Returns the difference between two dates in terms of hours.
        Parameters:
        date1 - The first date.
        date2 - The second date.
        Returns:
        The difference between first and second date in hours.
      • isSubscriptionTypeCodeValid

        public static boolean isSubscriptionTypeCodeValid(java.lang.String subscriptionTypeCode)
        This method checks if the given subscription type code is valid and exists in the data base.
        Parameters:
        subscriptionTypeCode - The subscription type code to validate.
        Returns:
        true if the subscription type code is valid. false, otherwise.
      • executeSelectStatement

        public static java.util.List executeSelectStatement(java.lang.String query,
                                                            java.util.Map parameters)
                                                     throws java.lang.Exception
        Executes a select query
        Parameters:
        query - The SQL query
        parameters - The substitution parameters
        Returns:
        A list of objects
        Throws:
        java.lang.Exception - An exception thrown by the data service during the execution of the update statement
      • getJDBCQueryService

        public static JDBCQueryService getJDBCQueryService()
        Gets the JDBC query service instance.
        Returns:
        The JDBC query service instance
      • getSubscriptionById

        public static Subscription getSubscriptionById(java.lang.Long subscriptionId)
        This method returns the physical Subscription entity based on the subscriptionId specified. If the subscription entity could not be resolved, this method returns null.
        Parameters:
        subscriptionId - The subscription ID of the subscription being retrieved.
        Returns:
        The Subscription physical entity if found. null Otherwise.
      • getScheduleEvaluateCmd

        public static ScheduleEvaluateCmd getScheduleEvaluateCmd(java.lang.String scheduleType)
        This method returns the schedule evaluate command based on the schedule type specified.
        Parameters:
        scheduleType - The type of schedule for which the command is being instantiated.
        Returns:
        The implementation of the ScheduleEvaluateCmd for the ScheduleInfoType specified.
      • updateSubscriptionState

        public static java.lang.Integer updateSubscriptionState(java.lang.Long subscriptionId,
                                                                java.lang.Integer state,
                                                                boolean isTransient)
        This method updates the state of the subscription as a separate transaction. Based on the isTransient flag, the method either updates the permanent state or the transient state. If the update fails at any step, the transaction created in the method is rolled back.
        Parameters:
        subscriptionId - The subscription ID of the subscription to be updated.
        state - The state to which the subscription is to be updated.
        isTransient - boolean to indicate if the state being changed is a transient state or a permanent state.
        Returns:
        The state of the subscription before the change.
      • findParentCatalogEntryID

        public static java.lang.String findParentCatalogEntryID(java.lang.String catentryId)
        This method is used to find the Catentry ID of the parent, given a child catentry ID
        Parameters:
        catentryId - The catentry ID whose parent is to be determined
        Returns:
        The catentry ID of the parent
      • isQtyUnitValid

        public static boolean isQtyUnitValid(java.lang.String qtyUnitId)
        This method checks whether the given quantity unit is valid and exists in the database.
        Parameters:
        qtyUnitId - The quantity unit ID to validate.
        Returns:
        true if the quantity unit is valid, false otherwise.
      • getSubscriptionDetailsValidator

        public static SubscriptionDetailsValidator getSubscriptionDetailsValidator()
        Gets the instance of the SubscriptionDetailsValidator which is used for perform validation of the various fields passed in the Subscription noun.
        Returns:
        an instance of SubscriptionDetailsValidator
        See Also:
        SubscriptionDetailsValidator}
      • getTemplateIDForSubscription

        public static java.lang.Long getTemplateIDForSubscription(java.lang.Long catalogEntryID)
                                                           throws DataMediatorException
        This method returns the template identifier corresponding to the input catalog entry identifier. This method finds the parent catalog entry ID for the input catalog entry ID. The parent catalog entry ID is then used to get the template ID from subscrtemplate table.
        Parameters:
        catalogEntryID - The catalog entry identifier.
        Returns:
        The template identifier for the subscription.
        Throws:
        DataMediatorException