myShell
Class MainClass

java.lang.Object
  extended by myShell.MainClass

public class MainClass
extends java.lang.Object

The main class of the Crowd-Powered-Sort program.

This class contains the main method that parses command line arguments to call the right function. It also implements :

Author:
Leo Perrin (perrin.leo@gmail.com)

Field Summary
static java.util.List<java.lang.Integer[]> allMedia
          A list of array containing all the media to sort and the advancement of the sort.
static Comparator comp
          The Comparator instance that will perform the SplitSort along each specified axis.
static java.util.Map<java.lang.String,java.lang.String> config
          A map containing the data within the config.xml file.
static MySQLbase hitBdd
          The MySQLbase instance used to store the job results, both raw and refined.
static Interpreter inter
          This Interpreter will read the config.xml file and write the results.xml one.
static java.lang.Boolean keepGoing
          Is true if the sort must continue; is false when everything is over.
static LogWriter log
          A LogWriter instance used to... write a log file.
static MediaBase mediaBdd
          A MediaBase used to store the content of the media.xml file.
static CrowdManager theBoss
          The CrowdManager instance supposed to be the interface with Crowdflower and the Antechamber during the splitsort.
 
Constructor Summary
MainClass()
           
 
Method Summary
static void displayHelp()
          Displays this program's help and exit.
static void generateJob(java.lang.String dbPasswd)
          Performs the first half of a quicksort iteration, generates the comparisons it requires and submits them in a new job at CrowdFlower.
static void initialize(java.lang.String dbPasswd)
          Initializes the classes necessary for a splitsort iteration and checks whether the sort must go on or not.
static void main(java.lang.String[] args)
          Main method of this program.
static void save(java.lang.Boolean finished)
          Saves the results, either intermediary ones if finished is false or final ones if it is true.
static void sqlFile()
          Creates a .sql file allowing the creation of the database and the tables necessary for CPS.
static void useResults(java.lang.String dbPasswd)
          Human made results are downloaded, interpreted, ameliorated and put in the MySQLbase instance hitBdd allowing the second half of a quicksort iteration to be performed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static LogWriter log
A LogWriter instance used to... write a log file. Isn't it amazing ?


config

public static java.util.Map<java.lang.String,java.lang.String> config
A map containing the data within the config.xml file.


hitBdd

public static MySQLbase hitBdd
The MySQLbase instance used to store the job results, both raw and refined.


mediaBdd

public static MediaBase mediaBdd
A MediaBase used to store the content of the media.xml file.


allMedia

public static java.util.List<java.lang.Integer[]> allMedia
A list of array containing all the media to sort and the advancement of the sort.


theBoss

public static CrowdManager theBoss
The CrowdManager instance supposed to be the interface with Crowdflower and the Antechamber during the splitsort.


inter

public static Interpreter inter
This Interpreter will read the config.xml file and write the results.xml one.


comp

public static Comparator comp
The Comparator instance that will perform the SplitSort along each specified axis.


keepGoing

public static java.lang.Boolean keepGoing
Is true if the sort must continue; is false when everything is over.

Constructor Detail

MainClass

public MainClass()
Method Detail

main

public static void main(java.lang.String[] args)
Main method of this program.

Parses command line option to launch the right function. If no argument is specified, help is displayed using the displayHelp() method. A description of what is done depending on the command line arguments is given in the body of the displayHelp() method.

Parameters:
args - Arguments sent using the command line when the program is launched.

save

public static void save(java.lang.Boolean finished)
Saves the results, either intermediary ones if finished is false or final ones if it is true.

If the finished parameter is false, then the current state of the splitsort iswritten in as much < axis>.xml files as there are axes, with < axis>'s value going through all the axes considered. Such results are formatted so as to be easily retrieved during the next iteration.

If finished is true, final results are saved in the ../results.xml file. It contains all the information in the media.xml file plus the coordinates of each one of them along each axis. When the file is written, it is sent to the Antechamber using . Such call should only be made when the sort is done.

Parameters:
finished - If true, write definitive results ; if false, write temporary ones.
See Also:
Interpreter.generateIntermediaryXMLs(String, List), Interpreter.generateFinalXML(String, Map), CrowdManager.thisIsTheEnd(String, String)

initialize

public static void initialize(java.lang.String dbPasswd)
Initializes the classes necessary for a splitsort iteration and checks whether the sort must go on or not.

In this method, several classes are initialized using the content of the media.xml and config.xml files. They correspond to all of the MainClass attribute.

It also checks whether the sort should go on using the Comparator.notFinished( ) method.

Parameters:
dbPasswd - The password of the MySQL database used.

generateJob

public static void generateJob(java.lang.String dbPasswd)
Performs the first half of a quicksort iteration, generates the comparisons it requires and submits them in a new job at CrowdFlower.
  1. First, this class' attributes are set using the initialise method.
  2. The Comparator instance performs the first step of a quicksort iteration and thus generates a list of unknown comparisons.
  3. These comparisons are sent to a CrowdManager instance.
  4. If it is necessary (i.e, if there ARE unknown comparisons), the CrowdManager instance then generates the HITs and uploads them to the right job at CrowdFlower.

Parameters:
dbPasswd - The password of the database matching the user specified in the config.xml file.

useResults

public static void useResults(java.lang.String dbPasswd)
Human made results are downloaded, interpreted, ameliorated and put in the MySQLbase instance hitBdd allowing the second half of a quicksort iteration to be performed.
  1. The MainClass' attributes are initialized.
  2. Results are read and ameliorated using code from P. Ipeirotis and is students' program, get another label.
  3. The Comparator instance performs the last step of the quicksort.
  4. A dump of the DBcps database is created to make sure that, even if this program fails, it won't be necessary to submit again already sent HITs.
  5. The results are saved along each axis in an xml file.


sqlFile

public static void sqlFile()
Creates a .sql file allowing the creation of the database and the tables necessary for CPS.

It contains the information necessary to create the hit and results table, each one having the fields necessary for the CPS to work as well as those added in the config.xml file. Each table is creating in a different way:

The file generated is ../data/mysql/createCPStables.sql.


displayHelp

public static void displayHelp()
Displays this program's help and exit.

The appearance of the help displayed is copied from typical UNIX man pages.