uk.org.ogsadai.client.dbcreate2
Class CreateTestXindiceDB

java.lang.Object
  |
  +--uk.org.ogsadai.client.dbcreate2.CreateTestXindiceDB

public class CreateTestXindiceDB
extends java.lang.Object

This program will create three new Xindice collections called /db/example_{traveller,destination,booking} and populate them with a total of 40,000 entries. The numberOfDocuments field may be modified to generate a database with any desired number of documents. The nth document in each possible database will be identical across each one which has at least n documents (assuming Random is implemented the same way on all Java JDKs). Usage: java uk.org.ogsadai.client.dbcreate.CreateTestXindiceDB [-driverclass XindiceDriverClass] [-host XindiceHostName] [-port XindicePortNumber] [-database XindiceDatabaseName] [-collectionname NameOfCollectionToCreate] [-documents NumberOfDocumentsToCreate] Default Settings: XindiceDriverClass: org.apache.xindice.client.xmldb.DatabaseImpl XindiceHostName: localhost XindicePortNumber: 4080 XindiceDatabaseName: db CollectionPrefix: example_ NumberOfDocumentsToCreate: 40000

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
           
protected  java.lang.String mBookingCollection
           
protected  java.lang.String mCollectionPrefix
           
protected  TravelDataCreator mData
          Generates the test data.
protected  java.lang.String mDatabase
           
protected  java.lang.String mDBMS
           
protected  java.lang.String mDestinationCollection
           
protected  java.lang.String mDriver
           
protected  int mEntries
           
protected  java.lang.String mHost
           
protected  int mNumberOfBookings
           
protected  int mNumberOfDestinations
           
protected  int mNumberOfTravellers
           
protected  java.lang.String mPassword
           
protected  java.lang.String mPort
           
protected  java.lang.String mTravellerCollection
           
protected  java.lang.String mUsername
           
 
Constructor Summary
CreateTestXindiceDB(java.lang.String[] args)
          Creates and populates Xindice test database according to the specified settings or the default settings if no arguments are used.
 
Method Summary
private  void closeCollection(org.xmldb.api.base.Collection child)
          Closes the specified collection
private  void createBookingCollection(org.xmldb.api.modules.CollectionManagementService service)
          Creates a collection with booking data.
private  void createDestinationCollection(org.xmldb.api.modules.CollectionManagementService service)
          Creates a collection with destination data.
private  void createTravellerCollection(org.xmldb.api.modules.CollectionManagementService service)
          Creates a collection with traveller data.
static void main(java.lang.String[] args)
           
private  java.lang.String makeBookingEntry(long i)
           
private  java.lang.String makeDestinationEntry(int i)
          Constructs the documents for the destination collection.
private  java.lang.String makeTravellerEntry(int i)
          Constructs the entry documents for the traveller collection.
protected  void populateDatabase()
           
protected  void printUsage()
           
protected  void printVariables(java.lang.String prefix)
           
private  void removeCollectionIfExists(org.xmldb.api.modules.CollectionManagementService service, org.xmldb.api.base.Collection parent, java.lang.String collectionName)
          Remove a collection.
protected  void setDefaultSettings()
           
protected  boolean setupArguments(java.lang.String[] args)
          Configures the class based on string arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
See Also:
Constant Field Values

mData

protected final TravelDataCreator mData
Generates the test data.


mDBMS

protected java.lang.String mDBMS

mDriver

protected java.lang.String mDriver

mHost

protected java.lang.String mHost

mPort

protected java.lang.String mPort

mDatabase

protected java.lang.String mDatabase

mUsername

protected java.lang.String mUsername

mPassword

protected java.lang.String mPassword

mCollectionPrefix

protected java.lang.String mCollectionPrefix

mTravellerCollection

protected java.lang.String mTravellerCollection

mDestinationCollection

protected java.lang.String mDestinationCollection

mBookingCollection

protected java.lang.String mBookingCollection

mEntries

protected int mEntries

mNumberOfTravellers

protected int mNumberOfTravellers

mNumberOfDestinations

protected int mNumberOfDestinations

mNumberOfBookings

protected int mNumberOfBookings
Constructor Detail

CreateTestXindiceDB

public CreateTestXindiceDB(java.lang.String[] args)
Creates and populates Xindice test database according to the specified settings or the default settings if no arguments are used.

Parameters:
args - arguments passed to the main method.
Method Detail

main

public static void main(java.lang.String[] args)

setDefaultSettings

protected void setDefaultSettings()

populateDatabase

protected void populateDatabase()
                         throws CreateTestDatabaseException
CreateTestDatabaseException

removeCollectionIfExists

private void removeCollectionIfExists(org.xmldb.api.modules.CollectionManagementService service,
                                      org.xmldb.api.base.Collection parent,
                                      java.lang.String collectionName)
                               throws org.xmldb.api.base.XMLDBException
Remove a collection. This method does not throw an error if the collection does not exist.

Parameters:
service - CollectionManagementService of the parent collection
parent - the parent collection
collectionName - the name of the collection to be removed
Throws:
org.xmldb.api.base.XMLDBException

createTravellerCollection

private void createTravellerCollection(org.xmldb.api.modules.CollectionManagementService service)
                                throws org.xmldb.api.base.XMLDBException
Creates a collection with traveller data.

Parameters:
service - CollectionManagementService of the parent collection
Throws:
org.xmldb.api.base.XMLDBException

createDestinationCollection

private void createDestinationCollection(org.xmldb.api.modules.CollectionManagementService service)
                                  throws org.xmldb.api.base.XMLDBException
Creates a collection with destination data.

Parameters:
service - CollectionManagementService of the parent collection
Throws:
org.xmldb.api.base.XMLDBException

createBookingCollection

private void createBookingCollection(org.xmldb.api.modules.CollectionManagementService service)
                              throws org.xmldb.api.base.XMLDBException
Creates a collection with booking data.

Parameters:
service - CollectionManagementService of the parent collection
Throws:
org.xmldb.api.base.XMLDBException

closeCollection

private void closeCollection(org.xmldb.api.base.Collection child)
Closes the specified collection


makeTravellerEntry

private java.lang.String makeTravellerEntry(int i)
Constructs the entry documents for the traveller collection.

Parameters:
i - document id
Returns:
a document as a String

makeDestinationEntry

private java.lang.String makeDestinationEntry(int i)
Constructs the documents for the destination collection.

Parameters:
i - number of document
Returns:
the document as a String

makeBookingEntry

private java.lang.String makeBookingEntry(long i)

setupArguments

protected boolean setupArguments(java.lang.String[] args)
Configures the class based on string arguments. Returns false if the arguments are wrong.


printUsage

protected void printUsage()

printVariables

protected void printVariables(java.lang.String prefix)