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
.wp6
.diptera
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
17 import eu
.etaxonomy
.cdm
.app
.berlinModelImport
.BerlinModelSources
;
18 import eu
.etaxonomy
.cdm
.app
.berlinModelImport
.TreeCreator
;
19 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
20 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
21 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
22 import eu
.etaxonomy
.cdm
.io
.berlinModel
.BerlinModelImportConfigurator
;
23 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
24 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
25 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
26 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.DO_REFERENCES
;
27 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
28 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
29 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
30 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
31 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
35 * TODO add the following to a wiki page:
36 * HINT: If you are about to import into a mysql data base running under windows and if you wish to dump and restore the resulting data bas under another operation systen
37 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
43 public class DipteraActivator
{
44 @SuppressWarnings("unused")
45 private static final Logger logger
= Logger
.getLogger(DipteraActivator
.class);
47 //database validation status (create, update, validate ...)
48 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
49 static final Source berlinModelSource
= BerlinModelSources
.EDIT_Diptera();
50 static final ICdmDataSource cdmDestination
= CdmDestinations
.localH2Diptera();
51 static final UUID secUuid
= UUID
.fromString("06fd671f-1226-4e3b-beca-1959b3b32e20");
52 static final int sourceSecId
= 1000000;
53 static final UUID featureTreeUuid
= UUID
.fromString("ae9615b8-bc60-4ed0-ad96-897f9226d568");
54 static final Object
[] featureKeyList
= new Integer
[]{1,4,5,10,11,12,13,99};
57 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
59 static final boolean doDistributionParser
= true; //also run DipteraDistributionParser
62 static final NomenclaturalCode nomenclaturalCode
= NomenclaturalCode
.ICZN
;
65 static final boolean ignoreNull
= true;
68 static final boolean doAuthors
= true;
70 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
72 static final boolean doTaxonNames
= true;
73 static final boolean doRelNames
= true;
74 static final boolean doNameStatus
= true;
75 static final boolean doTypes
= true;
76 static final boolean doNameFacts
= true;
79 static final boolean doTaxa
= true;
80 static final boolean doRelTaxa
= true;
81 static final boolean doFacts
= true;
82 static final boolean doOccurences
= false;
85 // static final boolean doAuthors = true;
87 // static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
89 // static final boolean doTaxonNames = false;
90 // static final boolean doRelNames = false;
91 // static final boolean doNameStatus = false;
92 // static final boolean doTypes = false;
93 // static final boolean doNameFacts = false;
96 // static final boolean doTaxa = true;
97 // static final boolean doRelTaxa = false;
98 // static final boolean doFacts = true;
99 // static final boolean doOccurences = false;
106 public static void main(String
[] args
) {
107 System
.out
.println("Start import from BerlinModel("+ berlinModelSource
.getDatabase() + ") ...");
109 //make BerlinModel Source
110 Source source
= berlinModelSource
;
111 ICdmDataSource destination
= cdmDestination
;
113 BerlinModelImportConfigurator bmImportConfigurator
= BerlinModelImportConfigurator
.NewInstance(source
, destination
);
115 bmImportConfigurator
.setSecUuid(secUuid
);
116 bmImportConfigurator
.setSourceSecId(sourceSecId
);
117 bmImportConfigurator
.setNomenclaturalCode(nomenclaturalCode
);
119 bmImportConfigurator
.setIgnoreNull(ignoreNull
);
120 bmImportConfigurator
.setDoAuthors(doAuthors
);
121 bmImportConfigurator
.setDoReferences(doReferences
);
122 bmImportConfigurator
.setDoTaxonNames(doTaxonNames
);
123 bmImportConfigurator
.setDoRelNames(doRelNames
);
124 bmImportConfigurator
.setDoNameStatus(doNameStatus
);
125 bmImportConfigurator
.setDoTypes(doTypes
);
126 bmImportConfigurator
.setDoNameFacts(doNameFacts
);
128 bmImportConfigurator
.setDoTaxa(doTaxa
);
129 bmImportConfigurator
.setDoRelTaxa(doRelTaxa
);
130 bmImportConfigurator
.setDoFacts(doFacts
);
131 bmImportConfigurator
.setDoOccurrence(doOccurences
);
132 bmImportConfigurator
.setDbSchemaValidation(hbm2dll
);
134 bmImportConfigurator
.setCheck(check
);
137 CdmDefaultImport
<BerlinModelImportConfigurator
> bmImport
= new CdmDefaultImport
<BerlinModelImportConfigurator
>();
138 bmImport
.invoke(bmImportConfigurator
);
140 if (bmImportConfigurator
.getCheck().equals(CHECK
.CHECK_AND_IMPORT
) || bmImportConfigurator
.getCheck().equals(CHECK
.IMPORT_WITHOUT_CHECK
) ){
141 CdmApplicationController app
= bmImport
.getCdmApp();
143 //parse distributions
144 if (doDistributionParser
){
145 DipteraDistributionParser dipDist
= new DipteraDistributionParser();
146 dipDist
.doDistribution(app
);
149 app
= bmImport
.getCdmApp();
150 FeatureTree tree
= TreeCreator
.flatTree(featureTreeUuid
, bmImportConfigurator
.getFeatureMap(), featureKeyList
);
151 FeatureNode distributionNode
= FeatureNode
.NewInstance(Feature
.DISTRIBUTION());
152 tree
.getRoot().addChild(distributionNode
);
153 app
.getDescriptionService().saveFeatureTree(tree
);
155 System
.out
.println("End import from BerlinModel ("+ source
.getDatabase() + ")...");