Revision ffd6058e
Added by Andreas Müller over 4 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/IndexFungorumActivator.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
14 | 14 |
import org.apache.log4j.Logger; |
15 | 15 |
|
16 | 16 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
17 |
import eu.etaxonomy.cdm.database.DatabaseTypeEnum; |
|
18 | 17 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
19 | 18 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
20 | 19 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
21 | 20 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
22 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES; |
|
23 | 21 |
import eu.etaxonomy.cdm.io.common.Source; |
24 | 22 |
import eu.etaxonomy.cdm.io.pesi.indexFungorum.IndexFungorumImportConfigurator; |
25 | 23 |
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer; |
26 | 24 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
27 | 25 |
|
28 |
|
|
29 | 26 |
/** |
30 |
* TODO add the following to a wiki page: |
|
31 |
* 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 base under another operation systen |
|
32 |
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names. |
|
33 |
* |
|
34 |
* |
|
35 | 27 |
* @author a.mueller |
36 |
* |
|
37 | 28 |
*/ |
38 | 29 |
public class IndexFungorumActivator { |
39 |
@SuppressWarnings("unused") |
|
30 |
|
|
31 |
@SuppressWarnings("unused") |
|
40 | 32 |
private static final Logger logger = Logger.getLogger(IndexFungorumActivator.class); |
41 | 33 |
|
42 | 34 |
//database validation status (create, update, validate ...) |
43 | 35 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE; |
36 |
|
|
44 | 37 |
static final Source indexFungorumSource = PesiSources.PESI3_IF(); |
45 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_pesi_erms(); |
|
46 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_indexFungorum(); |
|
47 |
static final UUID treeUuid = UUID.fromString("4bea48c3-eb10-41d1-b708-b5ee625ed243"); |
|
48 |
|
|
49 |
//check - import |
|
50 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
|
51 | 38 |
|
52 |
static final int partitionSize = 2000; |
|
53 |
|
|
39 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_indexFungorum2(); |
|
40 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_indexFungorum2(); |
|
41 |
|
|
42 |
static final UUID classificationUuid = UUID.fromString("4bea48c3-eb10-41d1-b708-b5ee625ed243"); |
|
43 |
|
|
54 | 44 |
static final boolean doPesiExport = false; |
55 |
|
|
56 | 45 |
|
57 |
//NomenclaturalCode |
|
46 |
//check - import |
|
47 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
|
48 |
static final int partitionSize = 2000; |
|
58 | 49 |
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICNAFP; |
59 | 50 |
|
60 |
|
|
61 |
// ***************** ALL ************************************************// |
|
62 |
|
|
63 |
//taxa |
|
64 |
static final boolean doTaxa = true; |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
//******************** NONE ***************************************// |
|
69 |
|
|
70 |
// |
|
71 |
// //taxa |
|
72 |
// static final boolean doTaxa = false; |
|
73 |
|
|
74 |
|
|
51 |
|
|
75 | 52 |
public void doImport(Source source, ICdmDataSource destination){ |
76 | 53 |
System.out.println("Start import from ("+ indexFungorumSource.getDatabase() + ") ..."); |
77 |
|
|
54 |
|
|
78 | 55 |
IndexFungorumImportConfigurator ifImportConfigurator = IndexFungorumImportConfigurator.NewInstance(source, destination); |
79 |
|
|
80 |
ifImportConfigurator.setClassificationUuid(treeUuid);
|
|
56 |
|
|
57 |
ifImportConfigurator.setClassificationUuid(classificationUuid);
|
|
81 | 58 |
ifImportConfigurator.setNomenclaturalCode(nomenclaturalCode); |
82 | 59 |
|
83 |
ifImportConfigurator.setDoTaxa(doTaxa);
|
|
60 |
ifImportConfigurator.setDoTaxa(true);
|
|
84 | 61 |
ifImportConfigurator.setDbSchemaValidation(hbm2dll); |
85 | 62 |
|
86 | 63 |
ifImportConfigurator.setCheck(check); |
... | ... | |
90 | 67 |
// invoke import |
91 | 68 |
CdmDefaultImport<IndexFungorumImportConfigurator> ifImport = new CdmDefaultImport<IndexFungorumImportConfigurator>(); |
92 | 69 |
ifImport.invoke(ifImportConfigurator); |
93 |
|
|
70 |
|
|
94 | 71 |
if (ifImportConfigurator.getCheck().equals(CHECK.CHECK_AND_IMPORT) || ifImportConfigurator.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){ |
95 | 72 |
// ICdmApplicationConfiguration app = ifImport.getCdmAppController(); |
96 | 73 |
// ISourceable obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null); |
97 | 74 |
// logger.info(obj); |
98 |
|
|
75 |
|
|
99 | 76 |
// //make feature tree |
100 | 77 |
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList); |
101 | 78 |
// app = ermsImport.getCdmAppController(); |
... | ... | |
103 | 80 |
} |
104 | 81 |
System.out.println("End import from ("+ source.getDatabase() + ")..."); |
105 | 82 |
} |
106 |
|
|
107 |
|
|
108 |
/** |
|
109 |
* @param args |
|
110 |
*/ |
|
83 |
|
|
111 | 84 |
public static void main(String[] args) { |
112 |
|
|
85 |
|
|
113 | 86 |
//make IF Source |
114 | 87 |
Source source = indexFungorumSource; |
115 | 88 |
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination; |
116 | 89 |
IndexFungorumActivator ifActivator = new IndexFungorumActivator(); |
117 | 90 |
ifActivator.doImport(source, destination); |
118 |
|
|
91 |
|
|
119 | 92 |
if (doPesiExport){ |
120 | 93 |
PesiExportActivatorIF ifExportActivator = new PesiExportActivatorIF(); |
121 | 94 |
ifExportActivator.doExport(destination); |
122 | 95 |
} |
123 | 96 |
} |
124 |
|
|
97 |
|
|
125 | 98 |
|
126 | 99 |
|
127 | 100 |
} |
Also available in: Unified diff
ref #2826 cleanup IF import