fr.ird.msaccess.importer
Class AbstractAccessDataSource<T extends org.nuiton.topia.persistence.TopiaEntityEnum,M extends AbstractAccessEntityMeta<T>>

java.lang.Object
  extended by fr.ird.msaccess.importer.AbstractAccessDataSource<T,M>

public abstract class AbstractAccessDataSource<T extends org.nuiton.topia.persistence.TopiaEntityEnum,M extends AbstractAccessEntityMeta<T>>
extends Object

Une data source sur une base access

Since:
1.0
Author:
tchemit

Nested Class Summary
static class AbstractAccessDataSource.DataSourceState
           
 
Field Summary
protected  Map<M,Map<String,Object>[]> cache
          le cache des données (on lie une seule fois les tables)
protected  File dbFile
           
protected  Class<M> metaClass
           
protected  M[] metas
          La liste des méta données reconnues pour la base ouverte.
protected  Class<? extends AccessEntityMetaProvider<T,M>> providerClass
           
protected  AbstractAccessDataSource.DataSourceState state
           
protected  Map<String,Set<String>> tableColumns
           
protected  Map<String,Set<String>> unusedTableColumns
           
 
Constructor Summary
AbstractAccessDataSource(Class<? extends AbstractAccessEntityMeta> metaClass, Class<? extends AccessEntityMetaProvider<T,M>> providerClass, File dbFile)
           
 
Method Summary
protected  void checkIfInit()
           
protected  void checkIfLoad()
           
protected  void closeConnexion(com.healthmarketscience.jackcess.Database connexion)
           
 void destroy()
           
protected  void finalize()
           
protected  com.healthmarketscience.jackcess.Database getConnexion()
           
 M getMeta(T type)
           
 M[] getMetaForType(Class<?> type)
           
 M[] getMetas()
           
 M[] getMetaWithError()
           
 M[] getMetaWithWarning()
           
 Object[] getPkey(List<String> keys, Map<String,Object> map)
           
 Object[] getPkey(M meta, Map<String,Object> map)
           
 int getRowCount(com.healthmarketscience.jackcess.Table table)
          Obtains the number of rows of a table by iterating on each row of it.
 Set<String> getTableColumns(String tableName)
           
 Map<String,Object>[] getTableData(M meta)
           
 Map<String,Object> getTableDataRow(M meta, int row)
           
 Set<String> getTableNames()
           
 Set<String> getUnusedTableColumns(String tableName)
           
 Set<String> getUnusedTableNames()
           
 boolean hasError()
           
 boolean hasWarning()
           
 void init()
           
protected  M initMeta(M meta)
           
protected  boolean isInit()
           
protected  boolean isLoad()
           
 void load()
           
<E extends org.nuiton.topia.persistence.TopiaEntity>
E[]
loadAssociation(M meta, M container, Object[] pkeys)
           
<E extends org.nuiton.topia.persistence.TopiaEntity>
List<E>
loadEntities(M meta)
           
 Map<String,Object>[] loadTable(M meta, com.healthmarketscience.jackcess.Database connexion)
           
protected abstract  M[] newMetaArray(Collection<M> iterable)
           
protected abstract  void onPKeyMissing(M meta, String pkey)
           
protected abstract  void onPropertyMissing(M meta, String property, String column)
           
protected abstract  void onTableMissing(M meta)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metas

protected M extends AbstractAccessEntityMeta<T>[] metas
La liste des méta données reconnues pour la base ouverte.


cache

protected Map<M extends AbstractAccessEntityMeta<T>,Map<String,Object>[]> cache
le cache des données (on lie une seule fois les tables)


tableColumns

protected Map<String,Set<String>> tableColumns

unusedTableColumns

protected Map<String,Set<String>> unusedTableColumns

metaClass

protected final Class<M extends AbstractAccessEntityMeta<T>> metaClass

providerClass

protected final Class<? extends AccessEntityMetaProvider<T extends org.nuiton.topia.persistence.TopiaEntityEnum,M extends AbstractAccessEntityMeta<T>>> providerClass

state

protected AbstractAccessDataSource.DataSourceState state

dbFile

protected final File dbFile
Constructor Detail

AbstractAccessDataSource

public AbstractAccessDataSource(Class<? extends AbstractAccessEntityMeta> metaClass,
                                Class<? extends AccessEntityMetaProvider<T,M>> providerClass,
                                File dbFile)
Method Detail

isInit

protected boolean isInit()

isLoad

protected boolean isLoad()

checkIfInit

protected void checkIfInit()

checkIfLoad

protected void checkIfLoad()

newMetaArray

protected abstract M[] newMetaArray(Collection<M> iterable)

onTableMissing

protected abstract void onTableMissing(M meta)

onPropertyMissing

protected abstract void onPropertyMissing(M meta,
                                          String property,
                                          String column)

onPKeyMissing

protected abstract void onPKeyMissing(M meta,
                                      String pkey)

init

public void init()
          throws Exception
Throws:
Exception

load

public void load()
          throws IOException
Throws:
IOException

initMeta

protected final M initMeta(M meta)
                                                        throws Exception
Throws:
Exception

getRowCount

public int getRowCount(com.healthmarketscience.jackcess.Table table)
Obtains the number of rows of a table by iterating on each row of it. This is due to a bug in the jackess library (should fill a bug report for it) using the Table.getRowCount() method (sometines it misses one row...)

Parameters:
table - the table to seek
Returns:
the number of rows of the given table.

loadTable

public final Map<String,Object>[] loadTable(M meta,
                                            com.healthmarketscience.jackcess.Database connexion)
                                     throws IOException
Throws:
IOException

getConnexion

protected com.healthmarketscience.jackcess.Database getConnexion()
                                                          throws IOException
Throws:
IOException

closeConnexion

protected void closeConnexion(com.healthmarketscience.jackcess.Database connexion)

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

destroy

public final void destroy()

getTableNames

public final Set<String> getTableNames()

getUnusedTableNames

public final Set<String> getUnusedTableNames()

getTableColumns

public Set<String> getTableColumns(String tableName)

getUnusedTableColumns

public Set<String> getUnusedTableColumns(String tableName)

hasError

public final boolean hasError()

hasWarning

public final boolean hasWarning()

getMetaWithError

public final M[] getMetaWithError()

getMetaWithWarning

public final M[] getMetaWithWarning()

getMetas

public M[] getMetas()

getMetaForType

public M[] getMetaForType(Class<?> type)

getMeta

public M getMeta(T type)

getTableData

public final Map<String,Object>[] getTableData(M meta)

getTableDataRow

public final Map<String,Object> getTableDataRow(M meta,
                                                int row)

loadAssociation

public final <E extends org.nuiton.topia.persistence.TopiaEntity> E[] loadAssociation(M meta,
                                                                                      M container,
                                                                                      Object[] pkeys)
                                                                           throws Exception
Throws:
Exception

loadEntities

public final <E extends org.nuiton.topia.persistence.TopiaEntity> List<E> loadEntities(M meta)

getPkey

public Object[] getPkey(M meta,
                        Map<String,Object> map)

getPkey

public Object[] getPkey(List<String> keys,
                        Map<String,Object> map)


Copyright © 2010-2011 IRD. All Rights Reserved.