eu.etaxonomy.cdm.io.common.mapping
Class DbImportDefinedTermCreationMapperBase<TERM extends DefinedTermBase,TERMED extends VersionableEntity,STATE extends DbImportStateBase<?,?>>

java.lang.Object
  extended by eu.etaxonomy.cdm.io.common.mapping.CdmMapperBase
      extended by eu.etaxonomy.cdm.io.common.mapping.CdmAttributeMapperBase
          extended by eu.etaxonomy.cdm.io.common.mapping.MultipleAttributeMapperBase<CdmSingleAttributeMapperBase>
              extended by eu.etaxonomy.cdm.io.common.mapping.DbImportMultiAttributeMapperBase<CREATE,STATE>
                  extended by eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase<TERMED,STATE>
                      extended by eu.etaxonomy.cdm.io.common.mapping.DbImportDefinedTermCreationMapperBase<TERM,TERMED,STATE>
All Implemented Interfaces:
IDbImportMapper<STATE,TERMED>
Direct Known Subclasses:
DbImportExtensionTypeCreationMapper, DbImportFeatureCreationMapper

public abstract class DbImportDefinedTermCreationMapperBase<TERM extends DefinedTermBase,TERMED extends VersionableEntity,STATE extends DbImportStateBase<?,?>>
extends DbImportObjectCreationMapperBase<TERMED,STATE>

This class either retrieves a defined Term from the database or creates and saves it in the database. This is done by first checking the according transformer for term attributes map to an existing CDM term (term that is available by static methods in the term classes), if not it tries to retrieve it via its uuid available through the transformer, if not retrievable it tries to retrieve from the database via the original source, if not retrievable it creates the new and stores it in the database.

Version:
1.0
Author:
a.mueller

Field Summary
protected  String dbLabelAbbrevAttribute
           
protected  String dbLabelAttribute
           
protected  String dbTermAttribute
           
 
Fields inherited from class eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase
dbIdAttribute, objectToCreateNamespace
 
Fields inherited from class eu.etaxonomy.cdm.io.common.mapping.DbImportMultiAttributeMapperBase
importMapperHelper
 
Fields inherited from class eu.etaxonomy.cdm.io.common.mapping.MultipleAttributeMapperBase
singleMappers
 
Constructor Summary
protected DbImportDefinedTermCreationMapperBase(String dbIdAttribute, String termNamespace, String dbTermAttribute, String dbLabelAttribute, String dbLabelAbbrevAttribute)
           
 
Method Summary
protected abstract  TERM createDefinedTerm(ResultSet rs)
           
protected  TERMED createObject(ResultSet rs)
          This method creates the object to be created.
protected  TERMED doInvoke(ResultSet rs, TERMED createdObject)
           
protected  String getKeyString(ResultSet rs)
           
protected  TERM getTermByIdentifier(ResultSet rs)
           
protected  TERM getTermByUuid(UUID uuidTerm, ResultSet rs)
           
protected abstract  TERM getTermFromState(UUID uuid)
           
protected  TERM getTermFromTransformer(ResultSet rs)
           
protected abstract  TERM getTermFromTransformer(String key, IInputTransformer transformer)
           
protected  UUID getUuidFromTransformer(ResultSet rs)
           
protected abstract  UUID getUuidFromTransformer(String key, IInputTransformer transformer)
           
 TERMED invoke(ResultSet rs, TERMED noObject)
           
protected abstract  void saveTermToState(TERM term)
          Saves the defined term to the state
 
Methods inherited from class eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase
addOriginalSource, getTransformer
 
Methods inherited from class eu.etaxonomy.cdm.io.common.mapping.DbImportMultiAttributeMapperBase
getForeignKey, getRelatedObject, getRelatedObject, getState, initialize
 
Methods inherited from class eu.etaxonomy.cdm.io.common.mapping.MultipleAttributeMapperBase
getDestinationAttributeList, getDestinationAttributes, getSourceAttributeList, getSourceAttributes, getStringDbValue
 
Methods inherited from class eu.etaxonomy.cdm.io.common.mapping.CdmAttributeMapperBase
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dbTermAttribute

protected String dbTermAttribute

dbLabelAttribute

protected String dbLabelAttribute

dbLabelAbbrevAttribute

protected String dbLabelAbbrevAttribute
Constructor Detail

DbImportDefinedTermCreationMapperBase

protected DbImportDefinedTermCreationMapperBase(String dbIdAttribute,
                                                String termNamespace,
                                                String dbTermAttribute,
                                                String dbLabelAttribute,
                                                String dbLabelAbbrevAttribute)
Parameters:
mappingImport -
Method Detail

invoke

public TERMED invoke(ResultSet rs,
                     TERMED noObject)
                                        throws SQLException
Specified by:
invoke in interface IDbImportMapper<STATE extends DbImportStateBase<?,?>,TERMED extends VersionableEntity>
Overrides:
invoke in class DbImportObjectCreationMapperBase<TERMED extends VersionableEntity,STATE extends DbImportStateBase<?,?>>
Throws:
SQLException

createDefinedTerm

protected abstract TERM createDefinedTerm(ResultSet rs)
                                                           throws SQLException
Parameters:
rs -
Returns:
Throws:
SQLException

getTermByIdentifier

protected TERM getTermByIdentifier(ResultSet rs)
                                                    throws SQLException
Returns:
Throws:
SQLException

getTermByUuid

protected TERM getTermByUuid(UUID uuidTerm,
                             ResultSet rs)
                                              throws SQLException
Parameters:
uuidTerm -
Returns:
Throws:
SQLException

saveTermToState

protected abstract void saveTermToState(TERM term)
Saves the defined term to the state

Parameters:
rs -

getTermFromState

protected abstract TERM getTermFromState(UUID uuid)
Parameters:
rs -
Returns:

getUuidFromTransformer

protected UUID getUuidFromTransformer(ResultSet rs)
                               throws SQLException
Returns:
Throws:
SQLException

getUuidFromTransformer

protected abstract UUID getUuidFromTransformer(String key,
                                               IInputTransformer transformer)
                                        throws UndefinedTransformerMethodException
Returns:
Throws:
UndefinedTransformerMethodException

getTermFromTransformer

protected TERM getTermFromTransformer(ResultSet rs)
                                                       throws SQLException
Parameters:
rs -
Returns:
Throws:
SQLException

getTermFromTransformer

protected abstract TERM getTermFromTransformer(String key,
                                               IInputTransformer transformer)
                                                                throws UndefinedTransformerMethodException
Parameters:
key -
transformer -
Returns:
Throws:
UndefinedTransformerMethodException

getKeyString

protected String getKeyString(ResultSet rs)
                       throws SQLException
Parameters:
rs -
Returns:
Throws:
SQLException

doInvoke

protected TERMED doInvoke(ResultSet rs,
                          TERMED createdObject)
                                             throws SQLException
Specified by:
doInvoke in class DbImportObjectCreationMapperBase<TERMED extends VersionableEntity,STATE extends DbImportStateBase<?,?>>
Throws:
SQLException

createObject

protected TERMED createObject(ResultSet rs)
                                                 throws SQLException
Description copied from class: DbImportObjectCreationMapperBase
This method creates the object to be created. It needs to be implemented by the concrete classes. E.g. if you have a TaxonNameCreation class which inherits from this class you need to implement createObject by creating an empty taxon name.

Specified by:
createObject in class DbImportObjectCreationMapperBase<TERMED extends VersionableEntity,STATE extends DbImportStateBase<?,?>>
Parameters:
rs - The result set
Returns:
The object to be created
Throws:
SQLException


Copyright © 2007-2013 EDIT. All Rights Reserved.