net.sourceforge.fluxion.datapublisher.biomart.impl
Class BiomartBeanFactory

java.lang.Object
  extended by net.sourceforge.fluxion.datapublisher.biomart.impl.BiomartBeanFactory
All Implemented Interfaces:
BeanFactory

@ServiceProvider
public class BiomartBeanFactory
extends java.lang.Object
implements BeanFactory

An implementation of BeanFactory that generates beans from a Biomart datasource.

Version:
1.0
Author:
Tony Burdett

Constructor Summary
BiomartBeanFactory()
           
 
Method Summary
 void acquireDatasourceConnection(java.util.Map<java.lang.String,java.lang.String> connectionDetails)
          Acquire a connection to the underlying datasource.
 boolean dbms(java.lang.String dbms)
          Determines whether a BeanFactory implementation can generate beans for the given dbms.
 void donotUseTableFiltering()
          Use this if a single factory is used to generate multiple sets of beans, and you want to stop tables from being filtered.
 void generateBeans(java.io.File sourceDirectory, java.lang.String packageName, java.util.Set<java.lang.Class> metaBeans, java.lang.String... schemas)
          Generate a set of beans to model the dbms the database this factory represents.
 java.util.Map<java.lang.String,java.lang.String> getDatasourceConnectionParameters()
          Returns the map of connection parameters supplied for this BeanFactory.
 java.lang.String getPackageName()
          Returns the package name known for this BeanFactory
 void terminateDatasourceConnection()
          Close the connection to the underlying datasource.
 void useTableFiltering(java.io.File filterTables)
          Enables filtering of tables by parsing a plain text file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BiomartBeanFactory

public BiomartBeanFactory()
Method Detail

dbms

public boolean dbms(java.lang.String dbms)
Description copied from interface: BeanFactory
Determines whether a BeanFactory implementation can generate beans for the given dbms. Returns true if this is a valid dbms name for this service provider, false otherwise.

Specified by:
dbms in interface BeanFactory
Parameters:
dbms - the name of the dbms for a service provider, e.g. "mysql"
Returns:
true if this service provider can generate beans for the given dbms

useTableFiltering

public void useTableFiltering(java.io.File filterTables)
                       throws java.io.IOException
Description copied from interface: BeanFactory
Enables filtering of tables by parsing a plain text file. The passed file should contain one table name per line. This file will be read in and used to restrict the list of generated OWL classes

Specified by:
useTableFiltering in interface BeanFactory
Parameters:
filterTables - the file to read that restricts the created owl classes
Throws:
java.io.IOException - if there is a problem reading from the file

donotUseTableFiltering

public void donotUseTableFiltering()
Description copied from interface: BeanFactory
Use this if a single factory is used to generate multiple sets of beans, and you want to stop tables from being filtered.

Specified by:
donotUseTableFiltering in interface BeanFactory

getDatasourceConnectionParameters

public java.util.Map<java.lang.String,java.lang.String> getDatasourceConnectionParameters()
Description copied from interface: BeanFactory
Returns the map of connection parameters supplied for this BeanFactory. If this hasn't been set, the BeanFactory should return an initialised map containing the keys required for a connection to be acquired.

Specified by:
getDatasourceConnectionParameters in interface BeanFactory
Returns:
the connection parameters set so far.

acquireDatasourceConnection

public void acquireDatasourceConnection(java.util.Map<java.lang.String,java.lang.String> connectionDetails)
                                 throws BeanGenerationException
Description copied from interface: BeanFactory
Acquire a connection to the underlying datasource. This map should contain parameters for databse URL, username, and password. Use getDatasourceConnectionParameters().keySet() to get the parameters that must be set. Or do a lookup on these key values to get the default values (e.g. "anonymous" is the default username). This way, those parameters which have been set can be used, whilst null fields will be ignored if possible (for example, in the case where password="" in accessing a public MySql database).

Specified by:
acquireDatasourceConnection in interface BeanFactory
Parameters:
connectionDetails - a map containing parameters for connection to the database.
Throws:
BeanGenerationException - if the connection could not be acquired

terminateDatasourceConnection

public void terminateDatasourceConnection()
                                   throws BeanGenerationException
Description copied from interface: BeanFactory
Close the connection to the underlying datasource. Any open connection will be closed, and it is very important that implementations of this class close all connections correclty to prevent future access problems.

Specified by:
terminateDatasourceConnection in interface BeanFactory
Throws:
BeanGenerationException - if there is a problem closing the connection

generateBeans

public void generateBeans(java.io.File sourceDirectory,
                          java.lang.String packageName,
                          java.util.Set<java.lang.Class> metaBeans,
                          java.lang.String... schemas)
                   throws BeanGenerationException
Description copied from interface: BeanFactory
Generate a set of beans to model the dbms the database this factory represents. The output directory where the generated beans should go, the package name to use for all generated sources, and (optionally) the set of annotation classes representing the metadata of this database dbms should be passed.

Specified by:
generateBeans in interface BeanFactory
Parameters:
sourceDirectory - The location for the generated source files to be written to
packageName - The package name to use for generated sources
metaBeans - the set of classes representing the database metadata
schemas - an array of database schema names to use in generating the beans
Throws:
BeanGenerationException - if the beans could not be generated

getPackageName

public java.lang.String getPackageName()
Description copied from interface: BeanFactory
Returns the package name known for this BeanFactory

Specified by:
getPackageName in interface BeanFactory
Returns:
the package name


Copyright © 2010. All Rights Reserved.