eu.etaxonomy.cdm.database
Class PersistentTermInitializer

java.lang.Object
  extended by eu.etaxonomy.cdm.model.common.DefaultTermInitializer
      extended by eu.etaxonomy.cdm.database.PersistentTermInitializer
All Implemented Interfaces:
ITermInitializer

@Component
public class PersistentTermInitializer
extends DefaultTermInitializer

Spring bean class to initialize the IVocabularyStore. To initialize the store the TermLoader and the IVocabularyStore are injected via spring and the initializeTerms method is called as an init-method (@PostConstruct).

Author:
a.mueller

Field Summary
protected  org.springframework.transaction.PlatformTransactionManager transactionManager
           
protected  org.springframework.transaction.support.DefaultTransactionDefinition txDefinition
           
protected  ITermVocabularyDao vocabularyDao
           
 
Fields inherited from class eu.etaxonomy.cdm.model.common.DefaultTermInitializer
termLoader
 
Constructor Summary
PersistentTermInitializer()
           
 
Method Summary
 void doInitialize()
           
 UUID firstPass(VocabularyEnum vocabularyType, Map<UUID,DefinedTermBase> persistedTerms)
          This method loads the vocabularies from CSV files and compares them to the vocabularies already in database.
 void initialize()
          Initializes the IVocabularStore by making sure that all basic terms that are loaded by the TermLoader are available afterwards.
 boolean isOmit()
           
protected  void secondPass(Class clazz, UUID vocabularyUuid, Map<UUID,DefinedTermBase> terms)
          Initializes the static fields of the TermVocabulary classes.
 void setOmit(boolean omit)
           
 void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
           
 void setVocabularyDao(ITermVocabularyDao vocabularyDao)
           
 
Methods inherited from class eu.etaxonomy.cdm.model.common.DefaultTermInitializer
setDefinedTerms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vocabularyDao

protected ITermVocabularyDao vocabularyDao

transactionManager

protected org.springframework.transaction.PlatformTransactionManager transactionManager

txDefinition

protected org.springframework.transaction.support.DefaultTransactionDefinition txDefinition
Constructor Detail

PersistentTermInitializer

public PersistentTermInitializer()
Method Detail

setOmit

public void setOmit(boolean omit)

isOmit

public boolean isOmit()

setVocabularyDao

@Autowired
public void setVocabularyDao(ITermVocabularyDao vocabularyDao)

setTransactionManager

@Autowired
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)

initialize

@PostConstruct
public void initialize()
Description copied from interface: ITermInitializer
Initializes the IVocabularStore by making sure that all basic terms that are loaded by the TermLoader are available afterwards. ATTENTION: Be aware that TermLoader indirectly calls getTermByUuid(uuid) for the default language. So make sure that before loading the Terms by the TermLoader getTermByUuid() returns a valid Object without going to endless recursion.

Specified by:
initialize in interface ITermInitializer
Overrides:
initialize in class DefaultTermInitializer

doInitialize

public void doInitialize()
Overrides:
doInitialize in class DefaultTermInitializer

secondPass

protected void secondPass(Class clazz,
                          UUID vocabularyUuid,
                          Map<UUID,DefinedTermBase> terms)
Initializes the static fields of the TermVocabulary classes.

Parameters:
clazz - the Class of the vocabulary
vocabularyUuid - the UUID of the vocabulary
terms - a Map containing all already loaded terms with their UUID as key

firstPass

public UUID firstPass(VocabularyEnum vocabularyType,
                      Map<UUID,DefinedTermBase> persistedTerms)
This method loads the vocabularies from CSV files and compares them to the vocabularies already in database. Non-existing vocabularies will be created and vocabularies with missing terms will be updated.

Parameters:
clazz - the Class of the vocabulary
persistedTerms - a Map containing all already loaded terms with their UUID as key
Returns:
the UUID of the loaded vocabulary as found in CSV file


Copyright © 2007-2013 EDIT. All Rights Reserved.