1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.app.globis;
|
12
|
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
|
18
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
19
|
import eu.etaxonomy.cdm.app.common.CdmImportSources;
|
20
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
21
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
22
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
23
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
24
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES;
|
25
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.EDITOR;
|
26
|
import eu.etaxonomy.cdm.io.common.Source;
|
27
|
import eu.etaxonomy.cdm.io.globis.GlobisImportConfigurator;
|
28
|
import eu.etaxonomy.cdm.model.common.ISourceable;
|
29
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
30
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
31
|
|
32
|
/**
|
33
|
* @author a.mueller
|
34
|
* @created 14.04.2010
|
35
|
*/
|
36
|
public class GlobisActivator {
|
37
|
private static final Logger logger = Logger.getLogger(GlobisActivator.class);
|
38
|
|
39
|
//database validation status (create, update, validate ...)
|
40
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
41
|
static final Source globisSource = CdmImportSources.GLOBIS_MDB_20140113_PESIIMPORT_SQLSERVER();
|
42
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
43
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
|
44
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_globis_dev();
|
45
|
|
46
|
|
47
|
|
48
|
static final UUID classificationUuid = UUID.fromString("8bd27d84-fd4f-4bfa-bde0-3e6b7311b334");
|
49
|
static final UUID featureTreeUuid = UUID.fromString("33cbf7a8-0c47-4d47-bd11-b7d77a38d0f6");
|
50
|
//static final Object[] featureKeyList = new Integer[]{1,4,5,10,11,12,13,14, 249, 250, 251, 252, 253};
|
51
|
|
52
|
static final String classificationName = "Globis";
|
53
|
static final String sourceReferenceTitle = "Globis Informix Database";
|
54
|
|
55
|
static final EDITOR editor = EDITOR.EDITOR_AS_EDITOR;
|
56
|
|
57
|
static final String imageBaseUrl = "http://globis-images.insects-online.de/images/";
|
58
|
|
59
|
//check - import
|
60
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
61
|
|
62
|
static final int partitionSize = 3000;
|
63
|
|
64
|
|
65
|
//NomeclaturalCode
|
66
|
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICZN;
|
67
|
|
68
|
|
69
|
static final boolean doReadMediaData = false;
|
70
|
|
71
|
// //ignore null
|
72
|
static final boolean ignoreNull = true;
|
73
|
|
74
|
// ***************** ALL ************************************************//
|
75
|
|
76
|
// //references
|
77
|
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
78
|
|
79
|
//taxa
|
80
|
static final boolean doCurrentTaxa = true;
|
81
|
static final boolean doSpecTaxa = true;
|
82
|
static final boolean doImages = true;
|
83
|
static final boolean doCommonNames = true;
|
84
|
|
85
|
|
86
|
//******************** NONE ***************************************//
|
87
|
|
88
|
|
89
|
//references
|
90
|
// static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
91
|
//
|
92
|
// //taxa
|
93
|
// static final boolean doCurrentTaxa = false;
|
94
|
// static final boolean doSpecTaxa = false;
|
95
|
// static final boolean doImages = false;
|
96
|
// static final boolean doCommonNames = false;
|
97
|
|
98
|
//
|
99
|
|
100
|
|
101
|
/**
|
102
|
* @param args
|
103
|
*/
|
104
|
public static void main(String[] args) {
|
105
|
System.out.println("Start import from ("+ globisSource.getDatabase() + ") ...");
|
106
|
|
107
|
//make Globis Source
|
108
|
Source source = globisSource;
|
109
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
110
|
|
111
|
GlobisImportConfigurator config = GlobisImportConfigurator.NewInstance(source, destination);
|
112
|
|
113
|
config.setClassificationUuid(classificationUuid);
|
114
|
config.setNomenclaturalCode(nomenclaturalCode);
|
115
|
|
116
|
config.setIgnoreNull(ignoreNull);
|
117
|
config.setDoReadMediaData(doReadMediaData);
|
118
|
config.setDoReferences(doReferences);
|
119
|
|
120
|
config.setDoCurrentTaxa(doCurrentTaxa);
|
121
|
config.setDoSpecTaxa(doSpecTaxa);
|
122
|
config.setDoImages(doImages);
|
123
|
config.setDoCommonNames(doCommonNames);
|
124
|
config.setImageBaseUrl(imageBaseUrl);
|
125
|
|
126
|
config.setDbSchemaValidation(hbm2dll);
|
127
|
config.setCheck(check);
|
128
|
config.setRecordsPerTransaction(partitionSize);
|
129
|
config.setClassificationName(classificationName);
|
130
|
config.setSourceReferenceTitle(sourceReferenceTitle);
|
131
|
config.setEditor(editor);
|
132
|
|
133
|
// invoke import
|
134
|
CdmDefaultImport<GlobisImportConfigurator> globisImport = new CdmDefaultImport<GlobisImportConfigurator>();
|
135
|
globisImport.invoke(config);
|
136
|
|
137
|
if (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){
|
138
|
ICdmApplicationConfiguration app = globisImport.getCdmAppController();
|
139
|
ISourceable<?> obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null);
|
140
|
logger.info(obj);
|
141
|
|
142
|
// //make feature tree
|
143
|
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList);
|
144
|
// app = ermsImport.getCdmAppController();
|
145
|
// app.getFeatureTreeService().saveOrUpdate(tree);
|
146
|
}
|
147
|
System.out.println("End import from ("+ source.getDatabase() + ")...");
|
148
|
}
|
149
|
|
150
|
|
151
|
}
|