Each processing block class must implement the processFile method. This method is called when there is an import or export file to be processed:
String processFile (String <directory_name>, String <file_name>, HashMap <args>, HashMap <inactive_records>, TreeMap <primary_key>, StringBuffer <msgs>)
Argument | Data Type | Description |
---|---|---|
<directory_name> | String |
Fully qualified path to the directory containing the file to be processed. The file to be returned must also be placed in this same directory. |
<file_name> | String |
Name of the file to be processed. |
<args> | HashMap |
Map of any pre/post processing arguments defined in the Scheduled Import/Export. |
<inactive_records> | HashMap |
Map containing the primary keys of any records in the repository having a Status of Inactive. This is only set for imports and only if the Inactive Records flag is set to Reactivate. |
<primary_key> | TreeMap |
The primary key for the repository. |
<msgs> | StringBuffer |
Medium for returning error messages to be displayed with the job. |
The method must return either the name of the processed file or null if the processing block failed.
If the processing block class has configurable arguments, there are three methods that must be implemented:
String getDescription()
Returns a detailed description of what the processing block does.
void defineArguments()
Builds the list of arguments that can be configured. Each argument is defined by calling the method: addArgument.
void addArgument(String <arg>, String <description>)
Adds an argument to the list of arguments/properties that can be set for the class in the Scheduled Import or Scheduled Export record:
Argument | Data Type | Description |
---|---|---|
<arg> | String |
Name of argument. This name will be used to retrieve the actual value for the argument. Each defined argument must be uniquely named |
<description> | String |
Detailed description of the argument. It should include a list of possible values or a range of values, any default values, and any other information. |
The BaseCustomProcessFile class has a set of methods that help minimize the amount of coding required in a processing block class:
void clearBadDate(HashMap <parsed_line>, String <column>)
Clears the date value if it is not 10 characters (in mm/dd/yyyy format) or is an invalid date (for example, 00/00/0000).
void closeInput(BufferedReader <buffered_reader>)
Closes the opened CSV or TXT file.
void closeOutput(PrintWriter <output>)
Closes the opened CSV or TXT file.
void convertToBoolean(HashMap <parsed_line>, String <column>)
Converts the values “Y” or “Yes” to 1 and everything else to 0 for the designated column.
boolean doesFileExist(String <directory_name>, String <file_name>)
Returns true if the specified file in the specified directory exists.
void dropLeadingZeros(HashMap <parsed_line>, String <column>)
Removes leading zeros from each value containing them.
ArrayList extractFiles(String <directory_name>, String <file_name>, String <file_encoding>, StringBuffer <msgs>)
Extracts the contents of a zip file and returns a list of unzipped files.
void freeQuery(DBQuery <database_query>)
Frees the query connection that was previously obtained with getQuery()
String[] getHeaderForImportTemplate(String <import_template_name>)
Returns a list of columns based on the mappings in the designated import template.
String getHeaderForImportTemplateAsCsvString(String <import_template_name>, String <delimiter>)
Returns a delimited list of columns based on the mappings in the designated import template.
String getJobNumber()
Retrieves the identification number of the job being processed.
HashMap<String, String> getMapForHeader(String[] <header>)
Returns a map of columns based on the list of columns for the header.
DBQuery getQuery()
Retrieves a query connection that can subsequently be used to query the EPIM database.
PrintWriter getReport()
Retrieves the PrintWriter object that is configured to generate the report for the job. Any calls on this object will update that report.
void insertDecimal(HashMap <parsed_line>, String <column>, int <decimal_position>)
Inserts a decimal point character in a value at the designated number of digits from the right.
void logDebug(String <message>)
Generates a message in the log file if debug logging is enabled (debugEnabled=true) in the Enterworks.properties file.
void logReport(String <message>)
Adds a line to the import or export report file.
void logError(String <message>)
Adds a line to the EPX BIC log file.
void logError(StringBuffer msgs, String <message>)
Adds a line to the EPX BIC log file and to the Errors attribute for the Scheduled Import Job or Scheduled Export Job record.
BufferedReader newInput(String <directory_name>, String <file_name>, String <character_set>)
Opens a CSV or TXT file for reading.
PrintWriter newOutput(String <directory_name>, String <file_name>, String <encoding>)
Opens a CSV or TXT file for writing.
void outputHeaderLine(PrintWriter <output>, String[] <columns>, String <delimiter>)
Outputs the header line with each column separated using the specified delimiter.
void outputHeaderLine(PrintWriter <output>, String[] <columns>, char <delimiter>, char <text_qualifier>)
Outputs the header line with each column separated using the specified delimiter and text qualifier (for when column names include the delimiter or text qualifier character).
void outputParsedLine(PrintWriter <output>, HashMap <parsed_line>, String[] <columns>, char <delimiter>, char <text_qualifier>)
Outputs a line using the parsed values and the designated delimiter and text qualifier.
void outputParsedLine(PrintWriter <output>, HashMap <parsed_line>, String[] <columns>, String <delimiter>)
Outputs a line using the parsed values and the designated delimiter.
String[] parseHeader(String <header_line>, String <delimiter>)
Parses the header line using the designated delimiter. If the delimiter is a comma, then special processing is done for commas and quotes embedded in the header names.
String[] parseHeader(String <header_line>, char <delimiter>, char <text_qualifier>)
Parses the header line using the designated delimiter. Uses the designated textQualifier to handle values that contain the delimiter or the text qualifier. Assumes the embedded text qualifier is escaped with the same character. For example, if the delimiter is a comma and the text qualifier is a double quote, then the value: ,”3”” x 4””, Rough Cut” would be stored as: 3” x 4”, Rough Cut.
HashMap parseLine(String <line>, String[] <header>, String <delimiter>)
Parses a line from the file using the defined header and delimiter. Returns a HashMap where each key matches a column name and its value is the corresponding value from the file.
HashMap parseLine(String line, String[] <header>, String <delimiter>, boolean <trim_white_space>)
Parses a line from the file using the defined header and delimiter. Returns a HashMap where each key matches a column name and its value is the corresponding value from the file. Trims white space from values if <trim_white_space> is true.
HashMap parseMultiLine(BufferedReader <buffered_reader>, String[] <header>, String <delimiter>)
Parses a multi-line (where one or more values contains linefeed/carriage return characters and is properly quoted using the header for the map returned. Returns null if end of file or empty line is encountered.
HashMap parseMultiLine(BufferedReader <buffered_reader>, String[] <header>, char <delimiter>, char <text_qualifier>)
Parses a multi-line (where one or more values contains linefeed/carriage return characters and is properly escaped with the designated <text_qualifier> using the header for the map returned. Returns null if end of file or empty line is encountered.
void reactivateRecord(HashMap <parsed_line>, HashMap <inactive_records>, TreeMap <primary_key>, String <reactivate_column_name>)
Reactivates a record that was previously inactivated but is now in the import file.
void removeCharacter(HashMap <parsed_line>, String <character>)
Removes the designated character from each parsed value.
void removeSpaces(HashMap <parsed_line>)
Removes leading and trailing white space from each parsed value.
String[] simpleParseHeader(String <header_line>, String <delimiter>)
Parses the header line using the designated delimiter. Delimiter is passed to the String.split() method.
void updateExport(HashMap <update>)
Updates the specified attributes in the export job with the specified values.
void updateExportStatus(String <records_processed>, String <records_with_errors>, String <status>, String <export_errors>)
Updates the Scheduled Export Job record with the specified details. This call should be made if the post-processing is going to take a considerable amount of time to complete. The call should be made no more than once every several minutes.
void updateExportStatus(String <records_processed>, String <records_with_errors>, String <status>, String <download_link>, String <export_errors>)
Updates the Scheduled Export Job record with the specified details, including a URL for downloading the processed file. This call should be made after processing of the file has completed.
void updateImportJob(HashMap <update>)
Updates the specified attributes in the import job record with the specified values.
void updateImportStatus(String <records_processed>, String <records_updated>, String <records_created>, String <records_deleted>, String <records_with_errors>, String <status>, String <import_errors>)
Updates the Scheduled Import Job record with the specified details. This call should be made if the pre -processing is going to take a considerable amount of time to complete. The call should be made no more than once every several minutes.