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
.berlinModelImport
;
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
.berlinModel
.in
.BerlinModelImportConfigurator
;
21 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultImport
;
22 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.CHECK
;
23 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.DO_REFERENCES
;
24 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
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
;
32 * TODO add the following to a wiki page:
33 * 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
34 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
40 public class MTMooseActivator
{
41 private static final Logger logger
= Logger
.getLogger(AlgaTerraActivator
.class);
43 //database validation status (create, update, validate ...)
44 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
45 static final Source berlinModelSource
= BerlinModelSources
.MT_MOOSE();
46 // static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
47 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_mt_moose();
49 static final UUID treeUuid
= UUID
.fromString("1f617402-78dc-4bf1-ac77-d260600a8879");
50 static final int sourceSecId
= 7331;
51 static final UUID sourceRefUuid
= UUID
.fromString("7e1a2500-93a5-40c2-ba34-0213d7822379");
53 static final UUID featureTreeUuid
= UUID
.fromString("a970168a-36fd-4c7c-931e-87214a965c14");
54 static final Object
[] featureKeyList
= new Integer
[]{7,201,202,203,204,205,206,207};
57 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
61 static final NomenclaturalCode nomenclaturalCode
= NomenclaturalCode
.ICBN
;
63 // ****************** ALL *****************************************
66 static final boolean doAuthors
= true;
68 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
70 static final boolean doTaxonNames
= true;
71 static final boolean doRelNames
= true;
72 static final boolean doNameStatus
= true;
73 static final boolean doTypes
= true;
74 static final boolean doNameFacts
= false;
77 static final boolean doTaxa
= true;
78 static final boolean doRelTaxa
= true;
79 static final boolean doFacts
= true;
80 static final boolean doOccurences
= true;
81 static final boolean doCommonNames
= false;
83 // ************************ NONE **************************************** //
86 // static final boolean doAuthors = false;
88 // static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
90 // static final boolean doTaxonNames = false;
91 // static final boolean doRelNames = false;
92 // static final boolean doNameStatus = false;
93 // static final boolean doTypes = false;
94 // static final boolean doNameFacts = false;
97 // static final boolean doTaxa = false;
98 // static final boolean doRelTaxa = false;
99 // static final boolean doFacts = false;
100 // static final boolean doOccurences = false;
101 // static final boolean doCommonNames = false;
104 public void invoke(String
[] args
){
105 System
.out
.println("Start import from BerlinModel("+ berlinModelSource
.getDatabase() + ") ...");
106 logger
.debug("Start");
107 //make BerlinModel Source
108 Source source
= berlinModelSource
;
109 ICdmDataSource destination
= CdmDestinations
.chooseDestination(args
) != null ? CdmDestinations
.chooseDestination(args
) : cdmDestination
;
111 BerlinModelImportConfigurator bmImportConfigurator
= BerlinModelImportConfigurator
.NewInstance(source
, destination
);
113 bmImportConfigurator
.setClassificationUuid(treeUuid
);
114 bmImportConfigurator
.setSourceSecId(sourceSecId
);
115 bmImportConfigurator
.setNomenclaturalCode(nomenclaturalCode
);
117 bmImportConfigurator
.setDoAuthors(doAuthors
);
118 bmImportConfigurator
.setDoReferences(doReferences
);
119 bmImportConfigurator
.setDoTaxonNames(doTaxonNames
);
120 bmImportConfigurator
.setDoRelNames(doRelNames
);
121 bmImportConfigurator
.setDoNameStatus(doNameStatus
);
122 bmImportConfigurator
.setDoTypes(doTypes
);
123 bmImportConfigurator
.setDoNameFacts(doNameFacts
);
125 bmImportConfigurator
.setDoTaxa(doTaxa
);
126 bmImportConfigurator
.setDoRelTaxa(doRelTaxa
);
127 bmImportConfigurator
.setDoFacts(doFacts
);
128 bmImportConfigurator
.setDoOccurrence(doOccurences
);
129 bmImportConfigurator
.setDoCommonNames(doCommonNames
);
130 bmImportConfigurator
.setSourceRefUuid(sourceRefUuid
);
132 bmImportConfigurator
.setDbSchemaValidation(hbm2dll
);
134 bmImportConfigurator
.setCheck(check
);
137 CdmDefaultImport
<BerlinModelImportConfigurator
> bmImport
= new CdmDefaultImport
<BerlinModelImportConfigurator
>();
138 bmImport
.invoke(bmImportConfigurator
);
140 if (doFacts
&& (bmImportConfigurator
.getCheck().equals(CHECK
.CHECK_AND_IMPORT
) || bmImportConfigurator
.getCheck().equals(CHECK
.IMPORT_WITHOUT_CHECK
) ) ){
141 ICdmApplicationConfiguration app
= bmImport
.getCdmAppController();
144 FeatureTree tree
= TreeCreator
.flatTree(featureTreeUuid
, bmImportConfigurator
.getFeatureMap(), featureKeyList
);
145 FeatureNode imageNode
= FeatureNode
.NewInstance(Feature
.IMAGE());
146 tree
.getRoot().addChild(imageNode
);
147 FeatureNode distributionNode
= FeatureNode
.NewInstance(Feature
.DISTRIBUTION());
148 tree
.getRoot().addChild(distributionNode
, 2);
149 app
.getFeatureTreeService().saveOrUpdate(tree
);
153 System
.out
.println("End import from BerlinModel ("+ source
.getDatabase() + ")...");
160 public static void main(String
[] args
) {
161 MTMooseActivator activator
= new MTMooseActivator();
162 activator
.invoke(args
);