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
.app
.berlinModelImport
;
11 import java
.util
.UUID
;
13 import org
.apache
.logging
.log4j
.LogManager
;
14 import org
.apache
.logging
.log4j
.Logger
;
16 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
17 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
18 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
19 import eu
.etaxonomy
.cdm
.io
.berlinModel
.in
.BerlinModelImportConfigurator
;
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
.IImportConfigurator
.EDITOR
;
24 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
25 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
29 * TODO add the following to a wiki page:
30 * 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
31 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
35 public class MTMooseActivator
{
37 private static final Logger logger
= LogManager
.getLogger();
39 //database validation status (create, update, validate ...)
40 static DbSchemaValidation hbm2dll
= DbSchemaValidation
.CREATE
;
41 static final Source berlinModelSource
= BerlinModelSources
.MT_MOOSE();
43 // static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
44 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_moose_production();
45 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_test_local_mysql_test();
47 static final UUID classificationUuid
= UUID
.fromString("601d8a00-cffe-4509-af93-b15b543ccf8d");
48 static final UUID sourceRefUuid
= UUID
.fromString("601d8a00-cffe-4509-af93-b15b543ccf8d");
50 // static final UUID featureTreeUuid = UUID.fromString("4c5b5bbe-6fef-4607-96b2-1b0104eac19e");
51 // static final Object[] featureKeyList = new Integer[]{7,201,202,203,204,205,206,207};
53 static final boolean includeFlatClassifications
= true;
55 static final String relPTaxonIdQuery
= "SELECT * FROM RelPTaxon r " +
56 " WHERE NOT (r.PTRefFk1 <> r.PTRefFk2 AND r.RelQualifierFk = 1)";
57 static final String taxonTable
= "PTaxon WHERE notIntoCdm = 0";
58 static final String authorTable
= "v_cdmExport_authors";
59 static final String authorTeamTable
= "v_cdmExport_authorTeamsAll";
60 static final String referenceTable
= "v_cdmExport_references";
63 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
66 static final NomenclaturalCode nomenclaturalCode
= NomenclaturalCode
.ICNAFP
;
68 static final EDITOR editor
= EDITOR
.EDITOR_AS_EDITOR
;
70 // ****************** ALL *****************************************
73 static final boolean doAuthors
= true;
75 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
77 static final boolean doTaxonNames
= true;
78 static final boolean doRelNames
= true;
79 static final boolean doNameStatus
= true;
80 static final boolean doTypes
= true;
81 static final boolean doNameFacts
= false; //no name facts exist
84 static final boolean doTaxa
= true;
85 static final boolean doRelTaxa
= true;
86 static final boolean doFacts
= false; //no facts exist
87 static final boolean doNamedAreas
= false; //no areas exist
88 static final boolean doOccurences
= false; //no occurrences exist
89 static final boolean doOccurenceSources
= false; //no occurrences exist
90 static final boolean doCommonNames
= false; //no common names exist
92 // ************************ NONE **************************************** //
95 // static final boolean doAuthors = false;
97 // static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
99 // static final boolean doTaxonNames = false;
100 // static final boolean doRelNames = false;
101 // static final boolean doNameStatus = false;
102 // static final boolean doTypes = false;
103 // static final boolean doNameFacts = false;
106 // static final boolean doTaxa = false;
107 // static final boolean doRelTaxa = false;
108 // static final boolean doFacts = false;
109 // static final boolean doNamedAreas = false;
110 // static final boolean doOccurences = false;
111 // static final boolean doOccurenceSources = false;
112 // static final boolean doCommonNames = false;
115 public void invoke(String
[] args
){
116 System
.out
.println("Start import from BerlinModel("+ berlinModelSource
.getDatabase() + ") ...");
117 logger
.debug("Start");
118 //make BerlinModel Source
119 Source source
= berlinModelSource
;
120 ICdmDataSource destination
= CdmDestinations
.chooseDestination(args
) != null ? CdmDestinations
.chooseDestination(args
) : cdmDestination
;
122 BerlinModelImportConfigurator config
= BerlinModelImportConfigurator
.NewInstance(source
, destination
);
124 config
.setClassificationUuid(classificationUuid
);
125 // bmImportConfigurator.setSourceSecId(sourceSecId);
126 config
.setNomenclaturalCode(nomenclaturalCode
);
127 config
.setEditor(editor
);
128 config
.setIncludeFlatClassifications(includeFlatClassifications
);
130 config
.setDoAuthors(doAuthors
);
131 config
.setDoReferences(doReferences
);
132 config
.setDoTaxonNames(doTaxonNames
);
133 config
.setDoRelNames(doRelNames
);
134 config
.setDoNameStatus(doNameStatus
);
135 config
.setDoTypes(doTypes
);
136 config
.setDoNameFacts(doNameFacts
);
138 config
.setDoTaxa(doTaxa
);
139 config
.setDoRelTaxa(doRelTaxa
);
140 config
.setDoFacts(doFacts
);
141 config
.setDoNamedAreas(doNamedAreas
);
142 config
.setDoOccurrence(doOccurences
);
143 config
.setDoOccurrenceSources(doOccurenceSources
);
144 config
.setDoCommonNames(doCommonNames
);
145 config
.setSourceRefUuid(sourceRefUuid
);
148 config
.setRelTaxaIdQuery(relPTaxonIdQuery
);
149 config
.setTaxonTable(taxonTable
);
150 config
.setAuthorFilter(authorTable
);
151 config
.setAuthorTeamFilter(authorTeamTable
);
152 config
.setReferenceIdTable(referenceTable
);
154 config
.setDbSchemaValidation(hbm2dll
);
156 config
.setCheck(check
);
159 CdmDefaultImport
<BerlinModelImportConfigurator
> bmImport
= new CdmDefaultImport
<BerlinModelImportConfigurator
>();
160 bmImport
.invoke(config
);
162 // if (doFacts && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){
163 // ICdmRepository app = bmImport.getCdmAppController();
165 // //make feature tree
166 // FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, config.getFeatureMap(), featureKeyList);
167 // FeatureNode distributionNode = FeatureNode.NewInstance(Feature.DISTRIBUTION());
168 // tree.getRoot().addChild(distributionNode, 0);
169 // app.getTermTreeService().saveOrUpdate(tree);
172 System
.out
.println("End import from BerlinModel ("+ source
.getDatabase() + ")...");
175 public static void main(String
[] args
) {
177 MTMooseActivator activator
= new MTMooseActivator();
179 activator
.invoke(args
);
180 } catch (Exception e
) {