1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2016 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
|
package eu.etaxonomy.cdm.app.mexico;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
18
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
19
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
20
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
22
|
import eu.etaxonomy.cdm.io.mexico.MexicoConabioImportConfigurator;
|
23
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
24
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
25
|
|
26
|
/**
|
27
|
* @author a.mueller
|
28
|
* @date 16.06.2016
|
29
|
*
|
30
|
*/
|
31
|
public class MexicoConabioActivator {
|
32
|
private static final Logger logger = Logger.getLogger(MexicoConabioActivator.class);
|
33
|
|
34
|
//database validation status (create, update, validate ...)
|
35
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
36
|
|
37
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
38
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
39
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_mexico_production();
|
40
|
|
41
|
static boolean invers = true;
|
42
|
|
43
|
// boolean doRubiaceae = include;
|
44
|
|
45
|
// static boolean include = !invers;
|
46
|
|
47
|
|
48
|
//feature tree uuid
|
49
|
public static final UUID featureTreeUuid = UUID.fromString("d1f4ed29-9aae-4f6e-aa1e-4a3bf780e11d");
|
50
|
|
51
|
//classification
|
52
|
static final UUID classificationUuid = UUID.fromString("61968b43-e881-4043-b5c2-ba192e8f72dc");
|
53
|
private static final String classificationName = "Rubiaceae Conabio";
|
54
|
|
55
|
static final String sourceReferenceTitle = "Conabio XXX";
|
56
|
|
57
|
//check - import
|
58
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
59
|
|
60
|
boolean doVocabularies = (hbm2dll == DbSchemaValidation.CREATE);
|
61
|
static final boolean doTaxa = true;
|
62
|
static final boolean doDistributions = false;
|
63
|
static final boolean doCommonNames = false;
|
64
|
// static final boolean doDeduplicate = true;
|
65
|
|
66
|
private void doImport(ICdmDataSource cdmDestination){
|
67
|
|
68
|
URI source = conabio_rubiaceae();
|
69
|
|
70
|
//make Source
|
71
|
MexicoConabioImportConfigurator config= MexicoConabioImportConfigurator.NewInstance(source, cdmDestination);
|
72
|
config.setClassificationUuid(classificationUuid);
|
73
|
config.setClassificationName(classificationName);
|
74
|
config.setCheck(check);
|
75
|
config.setDoTaxa(doTaxa);
|
76
|
config.setDoDistributions(doDistributions);
|
77
|
config.setDoCommonNames(doCommonNames);
|
78
|
config.setDbSchemaValidation(hbm2dll);
|
79
|
config.setSourceReferenceTitle(sourceReferenceTitle);
|
80
|
// config.setDoVocabularies(doVocabularies);
|
81
|
|
82
|
config.setSource(source);
|
83
|
String fileName = source.toString();
|
84
|
fileName = fileName.substring(fileName.lastIndexOf("/") + 1 );
|
85
|
|
86
|
String message = "Start import from ("+ fileName + ") ...";
|
87
|
System.out.println(message);
|
88
|
logger.warn(message);
|
89
|
|
90
|
config.setSourceReference(getSourceReference(sourceReferenceTitle));
|
91
|
// config.setDoVocabularies(doVocabularies);
|
92
|
|
93
|
CdmDefaultImport<MexicoConabioImportConfigurator> myImport = new CdmDefaultImport<MexicoConabioImportConfigurator>();
|
94
|
|
95
|
myImport.invoke(config);
|
96
|
|
97
|
// if (makeFeatureTree){
|
98
|
// FeatureTree tree = makeFeatureNodes(myImport.getCdmAppController().getTermService());
|
99
|
// myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);
|
100
|
// }
|
101
|
|
102
|
System.out.println("End import from ("+ source.toString() + ")...");
|
103
|
|
104
|
}
|
105
|
|
106
|
|
107
|
//Conabio Rubiaceae
|
108
|
public static URI conabio_rubiaceae() {
|
109
|
return URI.create("file:////BGBM-PESIHPC/Mexico/CONABIO-Rubiaceae.xlsx");
|
110
|
}
|
111
|
|
112
|
private Reference getSourceReference(String string) {
|
113
|
Reference result = ReferenceFactory.newGeneric();
|
114
|
result.setTitleCache(string, true);
|
115
|
// result.setInReference(inRef);
|
116
|
// inRef.setTitleCache(sourceReferenceTitle, true);
|
117
|
return result;
|
118
|
}
|
119
|
|
120
|
/**
|
121
|
* @param args
|
122
|
*/
|
123
|
public static void main(String[] args) {
|
124
|
MexicoConabioActivator me = new MexicoConabioActivator();
|
125
|
me.doImport(cdmDestination);
|
126
|
System.exit(0);
|
127
|
}
|
128
|
}
|