Class StockJob

java.lang.Object
  extended by CollectJob
      extended by StockJob
All Implemented Interfaces:
org.quartz.Job
Direct Known Subclasses:
StockJobGoogle

public abstract class StockJob
extends CollectJob

Basic stock collection job, implementing basic configuration handling and collection routines.

Author:
fhogenboom

Field Summary
private static org.slf4j.Logger _log
           
protected  ArrayList<Object> comp
           
private static String cur_date
           
protected  String date_now
           
protected  Database dbs
           
protected  String file_ext
           
protected  String file_path
           
protected  String job_key
           
protected  Integer max_jobs
           
protected  Integer num_files
           
protected  Integer num_jobs
           
private static int num_out
           
private static int num_parts
           
protected  String stock_name
           
protected  String stock_txt_date
           
protected  String stock_txt_time
           
protected  String stock_url
           
protected  String stock_url_base
           
protected  String stock_url_parm
           
protected  String stock_xml_attr
           
protected  ArrayList<Object> stock_xml_elms
           
protected  String stock_xml_root
           
protected  Integer zip_buffer
           
protected  Integer zip_files
           
private static boolean zipping
           
 
Fields inherited from class CollectJob
date, form_date, form_hday, form_time, hday, hour_stop, hour_strt, mnte_stop, mnte_strt, scnd_stop, scnd_strt, time, time_zone
 
Constructor Summary
StockJob()
          Constructor.
 
Method Summary
protected  void collect()
          Collects data from a specific source.
protected  boolean configureLocal(String job_key)
          Configures the StockJob component by parsing a configuration file for local component elements.
protected abstract  org.slf4j.Logger getLogger()
          Retrieves the Logger of the component.
protected  boolean loadLocal(org.quartz.JobExecutionContext context)
          Configures the StockJob component by loading configurations for local component elements stored in a JobDataMap, which is available during runtime of the component.
protected abstract  void parseFeed()
          Parses feed containing stock data.
private  void saveToFile()
          Saves an individual StockJob component's database to a CSV formatted file whenever there is a date swap or the maximum number of jobs allowed to be stored in memory (specified in the configuration file) is exceeded.
protected  void storeLocal(org.quartz.JobExecutionContext context)
          Stores the configuration for local component elements of the StockJob component in a JobDataMap, which is available during runtime of the component.
private  void zipFiles()
          Zips output files whenever there is a date swap or the maximum number of files allowed in a single zip file (specified in the configuration file) is exceeded.
 
Methods inherited from class CollectJob
execute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comp

protected ArrayList<Object> comp

stock_xml_elms

protected ArrayList<Object> stock_xml_elms

dbs

protected Database dbs

max_jobs

protected Integer max_jobs

num_files

protected Integer num_files

num_jobs

protected Integer num_jobs

zip_buffer

protected Integer zip_buffer

zip_files

protected Integer zip_files

date_now

protected String date_now

file_path

protected String file_path

file_ext

protected String file_ext

job_key

protected String job_key

stock_name

protected String stock_name

stock_txt_date

protected String stock_txt_date

stock_txt_time

protected String stock_txt_time

stock_url

protected String stock_url

stock_url_base

protected String stock_url_base

stock_url_parm

protected String stock_url_parm

stock_xml_attr

protected String stock_xml_attr

stock_xml_root

protected String stock_xml_root

zipping

private static boolean zipping

num_parts

private static int num_parts

num_out

private static int num_out

cur_date

private static String cur_date

_log

private static org.slf4j.Logger _log
Constructor Detail

StockJob

public StockJob()
Constructor.

Method Detail

configureLocal

protected boolean configureLocal(String job_key)
Configures the StockJob component by parsing a configuration file for local component elements.

Specified by:
configureLocal in class CollectJob
Parameters:
job_key - ID of the component.
Returns:
Boolean value indicating whether parsed configuration is valid.

loadLocal

protected boolean loadLocal(org.quartz.JobExecutionContext context)
Configures the StockJob component by loading configurations for local component elements stored in a JobDataMap, which is available during runtime of the component.

Specified by:
loadLocal in class CollectJob
Parameters:
context - Execution context of the component.
Returns:
Boolean value indicating whether loaded configuration is valid.

storeLocal

protected void storeLocal(org.quartz.JobExecutionContext context)
Stores the configuration for local component elements of the StockJob component in a JobDataMap, which is available during runtime of the component.

Specified by:
storeLocal in class CollectJob
Parameters:
context - Execution context of the component.

collect

protected void collect()
Collects data from a specific source.

Specified by:
collect in class CollectJob

saveToFile

private void saveToFile()
Saves an individual StockJob component's database to a CSV formatted file whenever there is a date swap or the maximum number of jobs allowed to be stored in memory (specified in the configuration file) is exceeded. File path and extension of the file to be saved are specified in the configuration file. File name is constructed as date_now stock_name num_files, where date_now represents the current date (which can be yesterday's date in case of a date swap), stock_name represents the name of a feed, and where num_files represents the number number of files that have been created by the individual StockJob component.


zipFiles

private void zipFiles()
Zips output files whenever there is a date swap or the maximum number of files allowed in a single zip file (specified in the configuration file) is exceeded. File path and extension of the files to be zipped are specified in the configuration file, as well as the buffer used for zipping. Zip files are stored in the same directory as the files they contain. After completion, target files are removed. File name is constructed as cur_date- num_parts, where cur_date represents the current date (which can be yesterday's date in case of a date swap) and where num_parts represents the number number of zip files that have been created by all StockJob components.


getLogger

protected abstract org.slf4j.Logger getLogger()
Retrieves the Logger of the component.

Specified by:
getLogger in class CollectJob
Returns:
Logger used for logging system output.

parseFeed

protected abstract void parseFeed()
Parses feed containing stock data.