com.ibm.commerce.marketing.commands

Class ImportIntelligentOfferAssociationsCmdImpl

  • All Implemented Interfaces:
    AccCommand, AsyncCommand, ControllerCommand, ECCommand, ECTargetableCommand, ImportIntelligentOfferAssociationsCmd, Protectable, com.ibm.websphere.cache.Sizeable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command, com.ibm.websphere.command.CommandCaller, com.ibm.websphere.command.TargetableCommand, java.io.Serializable


    public class ImportIntelligentOfferAssociationsCmdImpl
    extends AsyncControllerCommandImpl
    implements ImportIntelligentOfferAssociationsCmd
    This command is used to import merchandising associations provided in flat files by Coremetrics Intelligent Offer. It is expected that this command be configured to be run by the Scheduler tool in the Administration Console. This command can be used in one of the following two ways:
    1. Import all of the files in a directory that have the format IO_<client ID>_<offer name>_<YYYYMMDD>_I.txt (for example IO_912345_Product_Page_Offer_20100427_I.txt)

      To import all the files in a directory, specify the following parameter:

      • directory - the directory where the flat files are located. Any error logs will be created in this directory.
    2. Import an individual flat file.

      To import one flat file, specify the following parameters:

      • directory - the directory where the flat file is located. Any error logs will be created in this directory.
      • file - the name of the flat file to import. The file name must have the format IO_<client ID>_<offer name>_<YYYYMMDD>_I.txt (for example IO_912345_Product_Page_Offer_20100427_I.txt)
      • offerName - if you do not want the command to determine the offer name from the flat file name, then the offer name can be specified with this parameter. This is only required if the offer name entered in the Intelligent Offer tool contains underscores. In most situations, this parameter is not required. The value of this parameter should match the offer name contained within the flat file provided by Coremetrics.
    The command will determine the offer name from the flat file name. A merchandising association type will be created using the offer name. Any underscores in the offer name will be changed to spaces. The offer will not be imported if the length of the offer name is greater than 32 characters. If the data should be created in a workspace, the following parameters can be specified:
    • workspaceIdentifier - The workspace code is the system generated identifier for the workspace, not the name assigned to the workspace by the Workspace Manager.
    • taskGroupIdentifier - The task group code is the system generated identifier for the task groups, not the name assigned to the task group by the Workspace Manager. Specify either this attribute or the "taskGroupName" attribute.
    • taskGroupName - The name assigned to the task group by the Workspace Manager. Specify either this attribute or the "taskGroupIdentifier" attribute. If you specify this attribute, since multiple task groups can have the same task group name, ensure that there is only one working task group with the specified task group name. Otherwise, the data load utility throws an exception.
    • taskIdentifier - The task code is the system generated identifier for the task, not the name assigned to the task by the Workspace Manager. Specify either this attribute or the "taskName" attribute.
    • taskName - The name assigned to the task by the Workspace Manager. Specify either this attribute or the "taskIdentifier" attribute. If you specify this attribute, since multiple tasks can have the same task name, ensure that there is only one working task with the specified task name. Otherwise, the data load utility throws an exception.
    The command should be set up to run in the store in which the associations should be imported. This command performs the following tasks:
    • If necessary, create a new entry in the MASSOCTYPE database table.
    • If necessary, delete any existing merchandising associations in the store of the specified offer name.
    • Call the catalog data load to import the merchandising associations.
    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

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

        public static final java.lang.Integer NEW_FILE
        Constant used to represent New file for PROCESSFILE table
      • PROCESSING_STATUS

        public static final java.lang.Integer PROCESSING_STATUS
        Constant used to represent Processing status for PROCESSFILE table
      • SUCCESS_STATUS

        public static final java.lang.Integer SUCCESS_STATUS
        Constant used to represent Complete status for PROCESSFILE table
      • FAILED_STATUS

        public static final java.lang.Integer FAILED_STATUS
        Constant used to represent Failed status for PROCESSFILE table
      • CANCELLED_STATUS

        public static final java.lang.Integer CANCELLED_STATUS
        Constant used to represent Canceled status for PROCESSFILE table
    • Constructor Detail

      • ImportIntelligentOfferAssociationsCmdImpl

        public ImportIntelligentOfferAssociationsCmdImpl()
        Default constructor for this command. It currently performs no actions.
    • Method Detail

      • isReadyToCallExecute

        public boolean isReadyToCallExecute()
        This method returns true.
        Specified by:
        isReadyToCallExecute in interface com.ibm.websphere.command.Command
        Overrides:
        isReadyToCallExecute in class AbstractECTargetableCommand
        Returns:
        This method returns true.
      • checkForExistingAssociationType

        public boolean checkForExistingAssociationType(java.lang.String massocTypeId)
        This method checks if the specified merchandising association type already exists in the MASSOCTYPE database table.
        Parameters:
        massocTypeId - The merchandising association type name.
        Returns:
        This method returns true if the merchandising association type already exists, otherwise it returns false.
      • createAssociationType

        public boolean createAssociationType(java.lang.String massocTypeId)
        This method creates the specified merchandising association type in the MASSOCTYPE database table.
        Parameters:
        massocTypeId - The merchandising association type name.
        Returns:
        This method returns true if the merchandising association type was successfully created, otherwise it returns false.
      • parseFileName

        public java.lang.String[] parseFileName(java.lang.String flatFileName)
                                         throws com.ibm.commerce.marketing.commands.logging.ImportIntelligentOfferAssociationsException
        This method parses the Intelligent Offer flat file name. The file name is expected to have the format IO_<client ID>_<offer name>_<YYYYMMDD>_I.txt (for example IO_912345_Product_Page_Offer_20100427_I.txt).
        Parameters:
        flatFileName - The Intelligent Offer flat file name.
        Returns:
        This method returns an array of three strings: client ID, offer name, and create time.
        Throws:
        com.ibm.commerce.marketing.commands.logging.ImportIntelligentOfferAssociationsException
      • deleteExistingAssociations

        public boolean deleteExistingAssociations(java.lang.String massocTypeId,
                                                  java.lang.Integer massocStoreId)
        This method deletes merchandising associations of the specified type from a store.
        Parameters:
        massocTypeId - The merchandising association type name.
        massocStoreId - The ID of the store in which to delete the associations.
        Returns:
        This method returns true if one or more merchandising associations were deleted, otherwise it returns false.
      • performExecute

        public void performExecute()
                            throws ECException
        For each file to be imported, this method performs the following tasks:
        • If necessary, create a new entry in the MASSOCTYPE database table.
        • If necessary, delete any existing merchandising associations in the store of the specified offer name.
        • Create an entry in the UPLOADFILE, PROCESSFILE and FILEPROCREL tables.
        • Status will be set in the PROCESSFILE table for each flat file import.
        • Status is set 2 if import is successful, 3 if import is failed or 4 if the import is canceled.
        • Status of the import is set to 1 i.e Processing, while processing the import and then set to 2 if the import is Successful or 3 if import is Failed.
        • Files with Status 1 i.e Processing and 3 i.e Failed will be considered for re-import, if the command is scheduled again
        • Files with Status 2 i.e Successful and 4 i.e Canceled will not be considered for re-import.
        • Call the catalog data load to import the merchandising associations.
        Specified by:
        performExecute in interface ECCommand
        Specified by:
        performExecute in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        performExecute in class AbstractECTargetableCommand
        Throws:
        ECException
      • fileImportedStatus

        public int fileImportedStatus(java.lang.String fileName)
        This method will return the process status of the flat file.
        Parameters:
        fileName - The flat file for which the process status has to be retrieved.
        Returns:
        0 if file not found, 1 if process status is processing, 2 if process status is complete and 3 if process status is failed.
      • getProcessFileId

        public long getProcessFileId(java.lang.String fileName)
        This method will retrieve the unique id of the flat file from PROCESSFILE table.
        Parameters:
        fileName - The flat file for which unique id is required.
        Returns:
        The unique id of the record in the PROCESSFILE table, on failure 0 will be returned.
      • manageAssociations

        public void manageAssociations(java.lang.String fileName)
                                throws com.ibm.commerce.marketing.commands.logging.ImportIntelligentOfferAssociationsException
        This method parses the flat file name to find the associated offer and performs the following tasks:
        • If necessary, create a new entry in the MASSOCTYPE database table.
        • If necessary, delete any existing merchandising associations in the store of the specified offer name.
        Parameters:
        fileName - The flat file to import.
        Throws:
        com.ibm.commerce.marketing.commands.logging.ImportIntelligentOfferAssociationsException
      • setRequestProperties

        public void setRequestProperties(TypedProperty reqParms)
                                  throws ECException
        This method extracts the required parameters from the request properties. This command has one mandatory parameter:
        • directory - the directory where the flat files are located. Any error logs will be created in this directory.
        If the file parameter is specified, then that one file will be imported. If the file parameter is not specified, then all the IO_****.txt files from the specified directory will be imported.
        Specified by:
        setRequestProperties in interface ControllerCommand
        Overrides:
        setRequestProperties in class ControllerCommandImpl
        Parameters:
        reqParms - The command parameters.
        Throws:
        ECException - If a required parameter is not found.
      • getDataLoadFilename

        public java.lang.String getDataLoadFilename()
                                             throws ECException
        This method gets the name of the data load configuration file to use when calling the catalog data load. A customization can override this method to specify a different data load configuration file.
        Returns:
        The name of the data load configuration file to use when calling the catalog data load.
        Throws:
        ECException
      • getFileNameList

        public java.lang.String[] getFileNameList(java.lang.String dirName)
                                           throws ECException
        This method returns a list of the flat file names under the specified directory. The files will have the format IO_****.txt.
        Parameters:
        dirName - The directory name.
        Returns:
        A string array of flat file names.
        Throws:
        ECException