1
|
/**
|
2
|
* Copyright (C) 2016 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.app.redlist;
|
10
|
|
11
|
import java.net.URI;
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
17
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
18
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
19
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
20
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
21
|
import eu.etaxonomy.cdm.io.redlist.germanSL.GermanSLImportConfigurator;
|
22
|
import eu.etaxonomy.cdm.model.agent.Person;
|
23
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
24
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
25
|
|
26
|
/**
|
27
|
* @author a.mueller
|
28
|
* @since 25.11.2016
|
29
|
*
|
30
|
*/
|
31
|
public class GermanSLActivator {
|
32
|
private static final Logger logger = Logger.getLogger(GermanSLActivator.class);
|
33
|
|
34
|
//database validation status (create, update, validate ...)
|
35
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
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_redlist_germanSL_preview();
|
40
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_germanSL_production();
|
41
|
|
42
|
static String versionString = "version_1_3_4";
|
43
|
|
44
|
//feature tree uuid
|
45
|
public static final UUID featureTreeUuid = UUID.fromString("490de21f-db97-49f8-ae2c-48145f592ceb");
|
46
|
|
47
|
//classification
|
48
|
static final UUID classificationUuid = UUID.fromString("25754287-18d8-4352-9cd5-7f2cead4e53c");
|
49
|
private static final String classificationName = "German SL";
|
50
|
|
51
|
//check - import
|
52
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
53
|
|
54
|
// static final boolean doTaxa = false;
|
55
|
// static final boolean doDeduplicate = true;
|
56
|
|
57
|
protected void doImport(ICdmDataSource cdmDestination){
|
58
|
|
59
|
URI source = germanSL();
|
60
|
|
61
|
//make Source
|
62
|
GermanSLImportConfigurator config= GermanSLImportConfigurator.NewInstance(source, cdmDestination);
|
63
|
config.setClassificationUuid(classificationUuid);
|
64
|
config.setClassificationName(classificationName);
|
65
|
config.setCheck(check);
|
66
|
config.setDbSchemaValidation(hbm2dll);
|
67
|
config.setSecReference(getSecReference());
|
68
|
config.setSourceReference(getSourceReference());
|
69
|
config.setSource(source);
|
70
|
config.setVersionString(versionString);
|
71
|
|
72
|
String fileName = source.toString();
|
73
|
fileName = fileName.substring(fileName.lastIndexOf("/") + 1 );
|
74
|
|
75
|
String message = "Start import from ("+ fileName + ") ...";
|
76
|
System.out.println(message);
|
77
|
logger.warn(message);
|
78
|
|
79
|
|
80
|
CdmDefaultImport<GermanSLImportConfigurator> myImport = new CdmDefaultImport<>();
|
81
|
|
82
|
myImport.invoke(config);
|
83
|
|
84
|
System.out.println("End import from ("+ source.toString() + ")...");
|
85
|
|
86
|
}
|
87
|
|
88
|
|
89
|
//GermanSL Excel file
|
90
|
public static URI germanSL() {
|
91
|
return URI.create("file:////BGBM-PESIHPC/GermanSL/GermanSL.xlsx");
|
92
|
}
|
93
|
|
94
|
|
95
|
private Reference getSourceReference() {
|
96
|
Reference result = ReferenceFactory.newGeneric();
|
97
|
result.setTitle("GermanSL.xslx");
|
98
|
Person florian = Person.NewTitledInstance("Jansen");
|
99
|
florian.setGivenName("Florian");
|
100
|
result.setAuthorship(florian);
|
101
|
return result;
|
102
|
}
|
103
|
|
104
|
private Reference getSecReference() {
|
105
|
Reference result = ReferenceFactory.newGeneric();
|
106
|
result.setTitle("German Standard List");
|
107
|
// result.setPlacePublished("Budapest");
|
108
|
// result.setPublisher("Akadémiai Kiadó");
|
109
|
// result.setPages("608 pp.");
|
110
|
// result.setDatePublished(TimePeriodParser.parseString("2012"));
|
111
|
// Person borhidi = Person.NewTitledInstance("Borhidi");
|
112
|
// borhidi.setGivenName("Attila");
|
113
|
// result.setAuthorship(borhidi);
|
114
|
// result.setUuid(MexicoConabioTransformer.uuidReferenceBorhidi);
|
115
|
return result;
|
116
|
}
|
117
|
|
118
|
/**
|
119
|
* @param args
|
120
|
*/
|
121
|
public static void main(String[] args) {
|
122
|
GermanSLActivator me = new GermanSLActivator();
|
123
|
me.doImport(cdmDestination);
|
124
|
System.exit(0);
|
125
|
}
|
126
|
}
|
127
|
|