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.CdmApplicationController;
|
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.Source;
|
24
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
25
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES;
|
26
|
import eu.etaxonomy.cdm.io.globis.GlobisImportConfigurator;
|
27
|
import eu.etaxonomy.cdm.model.common.ISourceable;
|
28
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
29
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
30
|
|
31
|
/**
|
32
|
* @author a.mueller
|
33
|
* @created 14.04.2010
|
34
|
* @version 1.0
|
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();
|
42
|
static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
43
|
static final UUID treeUuid = UUID.fromString("8bd27d84-fd4f-4bfa-bde0-3e6b7311b334");
|
44
|
static final UUID featureTreeUuid = UUID.fromString("33cbf7a8-0c47-4d47-bd11-b7d77a38d0f6");
|
45
|
//static final Object[] featureKeyList = new Integer[]{1,4,5,10,11,12,13,14, 249, 250, 251, 252, 253};
|
46
|
|
47
|
//check - import
|
48
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
49
|
|
50
|
static final int partitionSize = 2000;
|
51
|
|
52
|
|
53
|
//NomeclaturalCode
|
54
|
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICZN;
|
55
|
|
56
|
//ignore null
|
57
|
static final boolean ignoreNull = true;
|
58
|
|
59
|
// ***************** ALL ************************************************//
|
60
|
|
61
|
//references
|
62
|
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
63
|
|
64
|
//taxa
|
65
|
static final boolean doTaxa = true;
|
66
|
static final boolean doRelTaxa = true;
|
67
|
static final boolean doLinks = true;
|
68
|
static final boolean doOccurences = true;
|
69
|
static final boolean doImages = true;
|
70
|
|
71
|
|
72
|
//******************** NONE ***************************************//
|
73
|
|
74
|
|
75
|
// //references
|
76
|
// static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
|
77
|
//
|
78
|
// //taxa
|
79
|
// static final boolean doTaxa = false;
|
80
|
// static final boolean doRelTaxa = false;
|
81
|
// static final boolean doLinks = false;
|
82
|
// static final boolean doOccurences = false;
|
83
|
//
|
84
|
|
85
|
|
86
|
/**
|
87
|
* @param args
|
88
|
*/
|
89
|
public static void main(String[] args) {
|
90
|
System.out.println("Start import from ("+ globisSource.getDatabase() + ") ...");
|
91
|
|
92
|
//make ERMS Source
|
93
|
Source source = globisSource;
|
94
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
95
|
|
96
|
GlobisImportConfigurator config = GlobisImportConfigurator.NewInstance(source, destination);
|
97
|
|
98
|
config.setClassificationUuid(treeUuid);
|
99
|
config.setNomenclaturalCode(nomenclaturalCode);
|
100
|
|
101
|
config.setIgnoreNull(ignoreNull);
|
102
|
config.setDoReferences(doReferences);
|
103
|
|
104
|
config.setDoTaxa(doTaxa);
|
105
|
config.setDoRelTaxa(doRelTaxa);
|
106
|
config.setDoLinks(doLinks);
|
107
|
config.setDoOccurrence(doOccurences);
|
108
|
config.setDbSchemaValidation(hbm2dll);
|
109
|
|
110
|
config.setCheck(check);
|
111
|
config.setRecordsPerTransaction(partitionSize);
|
112
|
|
113
|
// invoke import
|
114
|
CdmDefaultImport<GlobisImportConfigurator> globisImport = new CdmDefaultImport<GlobisImportConfigurator>();
|
115
|
globisImport.invoke(config);
|
116
|
|
117
|
if (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){
|
118
|
CdmApplicationController app = globisImport.getCdmAppController();
|
119
|
ISourceable obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null);
|
120
|
logger.info(obj);
|
121
|
|
122
|
// //make feature tree
|
123
|
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList);
|
124
|
// app = ermsImport.getCdmAppController();
|
125
|
// app.getFeatureTreeService().saveOrUpdate(tree);
|
126
|
}
|
127
|
System.out.println("End import from ("+ source.getDatabase() + ")...");
|
128
|
}
|
129
|
|
130
|
|
131
|
}
|