com.ibm.commerce.context.preview

Interface PreviewContext

  • All Superinterfaces:
    Context, java.io.Serializable
    All Known Implementing Classes:
    PreviewContextImpl


    public interface PreviewContext
    extends Context
    The preview context allows users to set their session data without influencing other users and ensuring the content does not require additional changes after validation. In order to achieve this, a context object will be associated with the preview operation. This context object represents the state information that will be used when deciding the content to preview along with other external events. The preview context contains the preview date which will be used to display the content. Since each activity has a unique preview context, multiple users can preview independent content without changing content data or global system state information.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String ACTIVITY_DATA_PARAM_SERIALIZED_PREVIEW_CONTEXT
      The activity data containing the serialized version of the preview context.
      static java.lang.String CONTEXT_NAME
      The name that uniquely identifies this context in the CTXDATA table.
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      java.lang.String getProperty(java.lang.String key)
      Returns the property value based on the specified property name.
      java.util.Iterator getPropertyNames()
      Returns an Iterator of property names currently contained in the preview context.
      java.sql.Timestamp getTimestamp()
      Returns the appropriate timestamp to the caller to use when performing an operation.
      void setProperty(java.lang.String key, java.lang.String value)
      Sets a property to associate with preview.
      void setTimestamp(java.sql.Timestamp time)
      Sets the time to be used by the session.
      void setTimestamp(java.sql.Timestamp time, boolean isStatic)
      Sets the time to be used by the session.
    • Field Detail

      • COPYRIGHT

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

        static final java.lang.String CONTEXT_NAME
        The name that uniquely identifies this context in the CTXDATA table.
      • ACTIVITY_DATA_PARAM_SERIALIZED_PREVIEW_CONTEXT

        static final java.lang.String ACTIVITY_DATA_PARAM_SERIALIZED_PREVIEW_CONTEXT
        The activity data containing the serialized version of the preview context.
        See Also:
        Constant Field Values
    • Method Detail

      • getTimestamp

        java.sql.Timestamp getTimestamp()
        Returns the appropriate timestamp to the caller to use when performing an operation. If the timestamp has not been adjusted by one of the setTimestamp() methods the actual timestamp returns. If the timestamp has been adjusted, the adjusted version of the timestamp returns.
        Returns:
        The appropriate timestamp to use for the operation.
      • setTimestamp

        void setTimestamp(java.sql.Timestamp time)
        Sets the time to be used by the session. When the timestamp is set, time will still elapse but based on the specified timestamp and not the current timestamp.
        Parameters:
        time - The new time of the session.
      • setTimestamp

        void setTimestamp(java.sql.Timestamp time,
                          boolean isStatic)
        Sets the time to be used by the session. After the timestamp is set and time is not static, time will still elapse but based on the specified timestamp and not the current timestamp. If time is static then this time will always be returned.

        An example of using this method follows:

         // get the Command Context 
         CommandContext cContext = getCommandContext(); 
         //get the preview context from command context (Can also use ContextHelper)
         PreviewContext previewCtxt = (com.ibm.commerce.context.preview.PreviewContext);                                                                                                
         cContext.getContext(PreviewContext.CONTEXT_NAME);
         // Set the values from the graphical user interface page in the Preview Context        
         if (previewStartTime != null) { 
                previewCtxt.setTimestamp(previewStartTime, isStatic);
         }      
         
        Parameters:
        time - The new time of the session.
        isStatic - Whether the time should be static. If the time is static, then this time will always be returned.
      • setProperty

        void setProperty(java.lang.String key,
                         java.lang.String value)
        Sets a property to associate with preview. These properties will be used by particular components and they can react accordingly whether the property is specified and what value the property contains.

        An example of using this method follows:

         //Set campaign specific property - inventory evaluation mechanism
         previewCtxt.setProperty(PreviewConstants.PREVIEW_INVENTORY, inventoryValue.toString());
         
        Parameters:
        key - The property name.
        value - The property value.
      • getProperty

        java.lang.String getProperty(java.lang.String key)
        Returns the property value based on the specified property name. The example below illustrates how to retrieve Campaign component specific inventory evaluation mechanism property set using 'c'

         *[comments]
        Gets type of inventory evaluation method. If the evaluation is based on real inventory this method
         *will return INVENTORY_EVAL_REAL.If the evaluation is faked and inventory constraint evaluated to true
         *then this method will return INVENTORY_EVAL_TRUE. If the evaluation is faked and inventory constraint 
         *evaluated to false then this method will return INVENTORY_EVAL_FALSE.
         *@return Inventory evaluation type
         *[/comments]
         
        protected Integer getInventoryEvalType() { PreviewContext previewCtxt; try { previewCtxt = (PreviewContext) getCommandContext().getContext(KEY_PREVIEWCONTEXT); } catch (Exception e) { previewCtxt = null; } if (previewCtxt != null) { String prvInvValue = (String) previewCtxt.getProperty(PreviewConstants.PREVIEW_INVENTORY); if(prvInvValue==null){ return PreviewConstants.INVENTORY_EVAL_REAL; }else{ return new Integer(prvInvValue); } } else { return PreviewConstants.INVENTORY_EVAL_REAL; } }
        Parameters:
        key - The property name.
        Returns:
        The value associated with the specified key. If the key does not exist then null is returned.
      • getPropertyNames

        java.util.Iterator getPropertyNames()
        Returns an Iterator of property names currently contained in the preview context.
        Returns:
        The available property names.