Java classes for generating data load input files for promotion folders and folder relationships

You can create and use a Java class to generate input files for use with the Data Load utility to create promotion folders and sort promotions into folders. If your store contains many promotions that must be sorted into many promotion folders, consider creating a Java class to generate the Data Load utility input files.

Note: Before you create a class for generating input files to create promotion folders, ensure that your promotions can be sorted based on a specific property of the promotions. For instance, you can create promotion folders that sort promotions based on the defined promotion start or end date. The promotion folder identifiers can then be based on the start or end dates, creating a hierarchy similar to the following structure, which is based on the starting dates:

Promotion folder hierarchy

You can create one Java class to define how to generate an input file that includes data for creating folders for each year, month, and week in which promotions are activated for a store. A second Java class can then define how to read the starting date for the promotions from the STARTDATE column in the PX_PROMOTION database table. This second class can then define how to match the promotions with the right folder and populate the corresponding identifier values into the generated input file.

If you want to view a set of Java classes that generate CSV input files for creating promotion folders and folder relationships, download and extract the GeneratingFolderInputFileSample.zip compressed file. This file includes two classes for generating input CSV files:
PromotionFolders.java
A sample Java class for generating an input file that contains data for creating promotion folders. Use this sample class to help you create your own Java class to generate an input CSV file to load promotion folder data. When you are creating a Java class for generating an input CSV file, ensure that your class includes code to complete the following functions:
  • Generate the folder IDENTIFIER values.
  • Generate any parent folder and child folder relationships. Your method can populate the relationships into a hashmap.
  • Add the generated IDENTIFIER values into an array.
  • Print the array to an output file that generates in a specified filepath with a specified file name.
SortPromotionsIntoFolders.java
A sample Java class for generating an input file that contains data for creating promotion folder relationships to sort store promotions into folders. Use this sample class to help you create your own Java class to generate an input CSV file to sort promotions into folders. When you are creating a Java class for generating an input CSV file, ensure that your class includes code to complete the following functions:
  • Retrieve the PX_PROMOTION_ID and values for sorting promotions (STARTDATE) from the PX_PROMOTION table for all promotions for a store.
  • Retrieve all folder IDENTIFIER values from the FOLDER table for the store that owns the folders.
  • Use the value for sorting promotions (STARTDATE) to generate the promotion folder relationships by comparing the value to the folder IDENTIFIER values.
  • Add the generated relationships into an array.
  • Print the array to an output file that generates in a specified filepath with a specified file name.
You can use each of these sample Java classes or your own classes to generate a CSV input file for loading data with the Data Load utility. For a Data Load sample that loads input files that were generated with the sample classes, see Loading promotion folders and promotions into promotion folders.
To invoke the provided sample classes, run the following usage command:
PromotionFolders output_file_path start_year
Where:
output_file_path
The absolute file path, including the file name and file extension, to the output file.
start_year
(Optional). The starting year in the format \"YYYY\". The year should be less than or equal to the current year. If you do not specify the start_year, a default value of 2012 is used. This default value is defined in the sample classes.