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.
10 package eu
.etaxonomy
.cdm
.app
.pesi
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
17 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
18 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
19 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
20 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
21 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
22 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.DO_REFERENCES
;
23 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
24 import eu
.etaxonomy
.cdm
.io
.pesi
.faunaEuropaea
.FaunaEuropaeaImportConfigurator
;
25 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
26 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
27 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
28 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
31 * @author a.babadshanjan
34 public class FaunaEuropaeaActivator
{
35 @SuppressWarnings("unused")
36 private static final Logger logger
= Logger
.getLogger(FaunaEuropaeaActivator
.class);
38 static final Source faunaEuropaeaSource
= FaunaEuropaeaSources
.faunaEu_1_3();
39 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_test_andreasM();
41 static final int limitSave
= 2000;
43 // static final CHECK check = CHECK.CHECK_AND_IMPORT;
44 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
45 static DbSchemaValidation dbSchemaValidation
= DbSchemaValidation
.CREATE
;
46 // static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.UPDATE;
47 // static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
48 static final NomenclaturalCode nomenclaturalCode
= NomenclaturalCode
.ICZN
;
50 // ****************** ALL *****************************************
52 // Fauna Europaea to CDM import
53 static final boolean doAuthors
= true;
54 static final boolean doTaxa
= true;
55 static final boolean doBasionyms
= true;
56 static final boolean doTaxonomicallyIncluded
= true;
57 static final boolean doMisappliedNames
= true;
58 static final boolean doHeterotypicSynonyms
= true;
59 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
60 static final boolean doDistributions
= true;
61 static final boolean makeFeatureTree
= true;
63 static final boolean doHeterotypicSynonymsForBasionyms
= true;
65 // ************************ NONE **************************************** //
67 // Fauna Europaea to CDM import
68 // static final boolean doAuthors = false;
69 // static final boolean doTaxa = false;
70 // static final boolean doBasionyms = false;
71 // static final boolean doTaxonomicallyIncluded = false;
72 // static final boolean doMisappliedNames = false;
73 // static final boolean doHeterotypicSynonyms = false;
74 // static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
75 // static final boolean doDistributions = false;
76 // static final boolean makeFeatureTree = false;
77 // // CDM to CDM import
78 // static final boolean doHeterotypicSynonymsForBasionyms = false;
84 public static void main(String
[] args
) {
86 ICdmDataSource destination
= cdmDestination
;
87 System
.out
.println("Starting import from Fauna Europaea (" + faunaEuropaeaSource
.getDatabase() + ") to CDM (" + destination
.getDatabase() + ")...");
89 // invoke Fauna Europaea to CDM import
91 FaunaEuropaeaImportConfigurator fauEuImportConfigurator
=
92 FaunaEuropaeaImportConfigurator
.NewInstance(faunaEuropaeaSource
, destination
);
94 fauEuImportConfigurator
.setDbSchemaValidation(dbSchemaValidation
);
95 fauEuImportConfigurator
.setNomenclaturalCode(nomenclaturalCode
);
96 fauEuImportConfigurator
.setCheck(check
);
98 fauEuImportConfigurator
.setDoAuthors(doAuthors
);
99 fauEuImportConfigurator
.setDoTaxa(doTaxa
);
100 fauEuImportConfigurator
.setDoReferences(doReferences
);
101 fauEuImportConfigurator
.setDoOccurrence(doDistributions
);
102 fauEuImportConfigurator
.setDoTaxonomicallyIncluded(doTaxonomicallyIncluded
);
103 fauEuImportConfigurator
.setDoBasionyms(doBasionyms
);
104 fauEuImportConfigurator
.setDoMisappliedNames(doMisappliedNames
);
105 fauEuImportConfigurator
.setDoHeterotypicSynonyms(doHeterotypicSynonyms
);
106 fauEuImportConfigurator
.setDoHeterotypicSynonymsForBasionyms(doHeterotypicSynonymsForBasionyms
);
108 CdmDefaultImport
<FaunaEuropaeaImportConfigurator
> fauEuImport
=
109 new CdmDefaultImport
<FaunaEuropaeaImportConfigurator
>();
111 fauEuImport
.invoke(fauEuImportConfigurator
);
112 } catch (Exception e
) {
113 System
.out
.println("ERROR in Fauna Europaea to CDM import");
117 // invoke CDM to CDM import
119 // System.out.println("Starting import from CDM to CDM (" + destination.getDatabase() + ")...");
121 // CdmImportConfigurator cdmImportConfigurator =
122 // CdmImportConfigurator.NewInstance(destination, destination);
124 // cdmImportConfigurator.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
125 // cdmImportConfigurator.setNomenclaturalCode(nomenclaturalCode);
126 // cdmImportConfigurator.setCheck(check);
128 // cdmImportConfigurator.setDoHeterotypicSynonymsForBasionyms(doHeterotypicSynonymsForBasionyms);
129 // cdmImportConfigurator.setDoAuthors(false);
130 // cdmImportConfigurator.setDoTaxa(false);
131 // cdmImportConfigurator.setDoReferences(DO_REFERENCES.NONE);
132 // cdmImportConfigurator.setDoOccurrence(false);
133 // cdmImportConfigurator.setLimitSave(limitSave);
135 // CdmDefaultImport<CdmImportConfigurator> cdmImport =
136 // new CdmDefaultImport<CdmImportConfigurator>();
138 // cdmImport.invoke(cdmImportConfigurator);
139 // } catch (Exception e) {
140 // System.out.println("ERROR in CDM to CDM import");
141 // e.printStackTrace();
146 if (makeFeatureTree
== true) {
147 FeatureTree featureTree
= FeatureTree
.NewInstance(UUID
.fromString("ff59b9ad-1fb8-4aa4-a8ba-79d62123d0fb"));
148 FeatureNode root
= featureTree
.getRoot();
150 ICdmApplicationConfiguration app
= fauEuImport
.getCdmAppController();
151 Feature citationFeature
= (Feature
)app
.getTermService().find(UUID
.fromString("99b2842f-9aa7-42fa-bd5f-7285311e0101"));
152 FeatureNode citationNode
= FeatureNode
.NewInstance(citationFeature
);
153 root
.addChild(citationNode
);
154 Feature distributionFeature
= (Feature
)app
.getTermService().find(UUID
.fromString("9fc9d10c-ba50-49ee-b174-ce83fc3f80c6"));
155 FeatureNode distributionNode
= FeatureNode
.NewInstance(distributionFeature
);
156 root
.addChild(distributionNode
);
158 app
.getFeatureTreeService().saveOrUpdate(featureTree
);
161 System
.out
.println("End importing Fauna Europaea data");