2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.model
.common
;
11 import java
.util
.HashMap
;
13 import java
.util
.UUID
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.model
.common
.init
.ITermLoader
;
18 import eu
.etaxonomy
.cdm
.model
.common
.init
.ITermInitializer
;
19 import eu
.etaxonomy
.cdm
.model
.common
.init
.TermLoader
;
20 import eu
.etaxonomy
.cdm
.model
.description
.AbsenceTerm
;
21 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
22 import eu
.etaxonomy
.cdm
.model
.description
.PresenceTerm
;
23 import eu
.etaxonomy
.cdm
.model
.description
.Sex
;
24 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
25 import eu
.etaxonomy
.cdm
.model
.location
.Continent
;
26 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
27 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaLevel
;
28 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaType
;
29 import eu
.etaxonomy
.cdm
.model
.location
.TdwgArea
;
30 import eu
.etaxonomy
.cdm
.model
.location
.WaterbodyOrCountry
;
31 import eu
.etaxonomy
.cdm
.model
.media
.RightsTerm
;
32 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationshipType
;
33 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
34 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
35 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
36 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
37 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationStatus
;
38 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivationEventType
;
39 import eu
.etaxonomy
.cdm
.model
.occurrence
.DeterminationModifier
;
40 import eu
.etaxonomy
.cdm
.model
.occurrence
.PreservationMethod
;
41 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
42 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
48 public class DefaultTermInitializer
implements ITermInitializer
{
49 @SuppressWarnings("unused")
50 private static final Logger logger
= Logger
.getLogger(DefaultTermInitializer
.class);
51 protected ITermLoader termLoader
= new TermLoader();
53 @SuppressWarnings("unchecked")
54 protected static Class
[] classesToInitialize
= {
57 WaterbodyOrCountry
.class,
59 TypeDesignationStatus
.class,
60 NomenclaturalStatusType
.class,
61 SynonymRelationshipType
.class,
62 HybridRelationshipType
.class,
63 NameRelationshipType
.class,
64 TaxonRelationshipType
.class,
69 //NomenclaturalCode.class,
76 DerivationEventType
.class,
77 PreservationMethod
.class,
78 DeterminationModifier
.class,
79 StatisticalMeasure
.class,
83 public void initialize() {
84 Map
<UUID
,DefinedTermBase
> terms
= new HashMap
<UUID
,DefinedTermBase
>();
86 for(Class
<?
extends DefinedTermBase
<?
>> clazz
: classesToInitialize
) {
87 TermVocabulary
<?
> voc
= termLoader
.loadTerms(clazz
, terms
);
88 setDefinedTerms(clazz
,voc
);
92 protected void setDefinedTerms(Class
<?
extends DefinedTermBase
<?
>> clazz
, TermVocabulary
<?
> vocabulary
) {
93 DefinedTermBase newInstance
;
95 newInstance
= clazz
.newInstance();
96 newInstance
.setDefaultTerms(vocabulary
);
97 } catch (InstantiationException e
) {
98 // TODO Exception type
99 throw new RuntimeException("NewInstance could not be initialized in term initializer", e
);
100 } catch (IllegalAccessException e
) {
101 // TODO Exception type
102 throw new RuntimeException("NewInstance could not be accessed in term initializer", e
);