Revision a2a69c81
Added by Andreas Müller about 7 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/ErmsActivator.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 |
*/ |
... | ... | |
13 | 13 |
|
14 | 14 |
import org.apache.log4j.Logger; |
15 | 15 |
|
16 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
|
|
16 |
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
|
17 | 17 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
18 | 18 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
19 | 19 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
... | ... | |
29 | 29 |
|
30 | 30 |
/** |
31 | 31 |
* TODO add the following to a wiki page: |
32 |
* 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 |
* 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 |
|
33 | 33 |
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names. |
34 |
*
|
|
35 |
*
|
|
34 |
* |
|
35 |
* |
|
36 | 36 |
* @author a.mueller |
37 | 37 |
* |
38 | 38 |
*/ |
... | ... | |
45 | 45 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_pesi_erms(); |
46 | 46 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_erms(); |
47 | 47 |
static final UUID treeUuid = UUID.fromString("6fa988a9-10b7-48b0-a370-2586fbc066eb"); |
48 |
|
|
48 |
|
|
49 | 49 |
//check - import |
50 | 50 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
51 | 51 |
|
... | ... | |
53 | 53 |
|
54 | 54 |
//ignore null |
55 | 55 |
static final boolean ignoreNull = true; |
56 |
|
|
56 |
|
|
57 | 57 |
static final boolean includeExport = true; |
58 |
|
|
58 |
|
|
59 | 59 |
// ***************** ALL ************************************************// |
60 |
|
|
60 |
|
|
61 | 61 |
//references |
62 | 62 |
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL; |
63 |
|
|
63 |
|
|
64 | 64 |
//taxa |
65 | 65 |
static final boolean doTaxa = true; |
66 | 66 |
static final boolean doRelTaxa = true; |
67 | 67 |
static final boolean doLinks = true; |
68 | 68 |
static final boolean doOccurences = true; |
69 | 69 |
static final boolean doImages = true; |
70 |
|
|
71 |
|
|
70 |
|
|
71 |
|
|
72 | 72 |
//******************** NONE ***************************************// |
73 |
|
|
73 |
|
|
74 | 74 |
|
75 | 75 |
// //references |
76 | 76 |
// static final DO_REFERENCES doReferences = DO_REFERENCES.NONE; |
77 |
//
|
|
77 |
// |
|
78 | 78 |
// //taxa |
79 | 79 |
// static final boolean doTaxa = false; |
80 | 80 |
// static final boolean doRelTaxa = false; |
81 | 81 |
// static final boolean doLinks = false; |
82 | 82 |
// static final boolean doOccurences = false; |
83 |
//
|
|
84 |
|
|
85 |
|
|
83 |
// |
|
84 |
|
|
85 |
|
|
86 | 86 |
private void doImport(Source source, ICdmDataSource destination, DbSchemaValidation hbm2dll){ |
87 | 87 |
System.out.println("Start import from ("+ ermsSource.getDatabase() + ") ..."); |
88 |
|
|
88 |
|
|
89 | 89 |
//make ERMS Source |
90 |
|
|
90 |
|
|
91 | 91 |
ErmsImportConfigurator config = ErmsImportConfigurator.NewInstance(source, destination); |
92 |
|
|
92 |
|
|
93 | 93 |
config.setClassificationUuid(treeUuid); |
94 |
|
|
94 |
|
|
95 | 95 |
config.setIgnoreNull(ignoreNull); |
96 | 96 |
config.setDoReferences(doReferences); |
97 |
|
|
97 |
|
|
98 | 98 |
config.setDoTaxa(doTaxa); |
99 | 99 |
config.setDoRelTaxa(doRelTaxa); |
100 | 100 |
config.setDoLinks(doLinks); |
... | ... | |
108 | 108 |
// invoke import |
109 | 109 |
CdmDefaultImport<ErmsImportConfigurator> ermsImport = new CdmDefaultImport<ErmsImportConfigurator>(); |
110 | 110 |
ermsImport.invoke(config); |
111 |
|
|
111 |
|
|
112 | 112 |
if (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){ |
113 |
ICdmApplicationConfiguration app = ermsImport.getCdmAppController();
|
|
113 |
ICdmRepository app = ermsImport.getCdmAppController();
|
|
114 | 114 |
ISourceable obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null); |
115 | 115 |
logger.info(obj); |
116 |
|
|
116 |
|
|
117 | 117 |
// //make feature tree |
118 | 118 |
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList); |
119 | 119 |
// app = ermsImport.getCdmAppController(); |
... | ... | |
121 | 121 |
} |
122 | 122 |
System.out.println("End import from ("+ source.getDatabase() + ")..."); |
123 | 123 |
} |
124 |
|
|
124 |
|
|
125 | 125 |
/** |
126 | 126 |
* @param args |
127 | 127 |
*/ |
... | ... | |
129 | 129 |
ICdmDataSource cdmDB = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination; |
130 | 130 |
ErmsActivator ermsImport = new ErmsActivator(); |
131 | 131 |
ermsImport.doImport(ermsSource, cdmDB, hbm2dll); |
132 |
|
|
132 |
|
|
133 | 133 |
if (includeExport){ |
134 | 134 |
PesiExportActivatorERMS ermsExport = new PesiExportActivatorERMS(); |
135 | 135 |
ermsExport.doExport(cdmDB); |
Also available in: Unified diff
ref #6419 rename CdmApplicationDefaultConfiguration in pesi