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.uzbekistan;
|
10
|
|
11
|
import java.io.File;
|
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.uzbekistan.UzbekistanTaxonImportConfigurator;
|
23
|
import eu.etaxonomy.cdm.model.agent.Person;
|
24
|
import eu.etaxonomy.cdm.model.agent.Team;
|
25
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
26
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
27
|
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
|
28
|
|
29
|
/**
|
30
|
*
|
31
|
* Import for Flora of Uzbekistan taxa.
|
32
|
*
|
33
|
* https://dev.e-taxonomy.eu/redmine/issues/8996
|
34
|
*
|
35
|
* @author a.mueller
|
36
|
* @since 05.05.2020
|
37
|
*/
|
38
|
public class UzbekistanTaxonActivator {
|
39
|
@SuppressWarnings("unused")
|
40
|
private static final Logger logger = Logger.getLogger(UzbekistanTaxonActivator.class);
|
41
|
|
42
|
//database validation status (create, update, validate ...)
|
43
|
|
44
|
static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
45
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_cdmtest_mysql();
|
46
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_uzbekistan();
|
47
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_uzbekistan();
|
48
|
|
49
|
static DbSchemaValidation hbm2dll = cdmDestination == CdmDestinations.localH2() ? DbSchemaValidation.CREATE : DbSchemaValidation.VALIDATE;
|
50
|
|
51
|
//classification
|
52
|
static final UUID classificationUuid = UUID.fromString("230ca922-bf63-4297-b631-aed87f553107");
|
53
|
private static final String classificationName = "Flora of Uzbekistan";
|
54
|
|
55
|
static final UUID secRefUuid = UUID.fromString("09b9b07a-a501-49d0-877c-14dd738537bb");
|
56
|
static final UUID sourceRefUuid = UUID.fromString("295e0b9c-c637-45db-8e71-ca664f128221");
|
57
|
|
58
|
static final String fileName = "FoU_taxonomy_2020_05_12.xlsx";
|
59
|
|
60
|
//check - import
|
61
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
62
|
|
63
|
private void doImport(ICdmDataSource cdmDestination){
|
64
|
|
65
|
//make Source
|
66
|
URI source = uzbekistanChecklist();
|
67
|
// URI source = uzbekistanChecklist_local();
|
68
|
|
69
|
UzbekistanTaxonImportConfigurator config = UzbekistanTaxonImportConfigurator.NewInstance(source, cdmDestination);
|
70
|
config.setClassificationUuid(classificationUuid);
|
71
|
config.setClassificationName(classificationName);
|
72
|
config.setCheck(check);
|
73
|
config.setDbSchemaValidation(hbm2dll);
|
74
|
// config.setUuidFeatureTree(featureTreeUuid);
|
75
|
// config.setFeatureTreeTitle(featureTreeTitle);
|
76
|
config.setSecReference(getSecReference());
|
77
|
config.setSourceReference(getSourceReference());
|
78
|
|
79
|
CdmDefaultImport<UzbekistanTaxonImportConfigurator> myImport = new CdmDefaultImport<>();
|
80
|
myImport.invoke(config);
|
81
|
}
|
82
|
|
83
|
|
84
|
private URI uzbekistanChecklist(){
|
85
|
return URI.create("file:////BGBM-PESIHPC/Uzbekistan/" + fileName);
|
86
|
}
|
87
|
@SuppressWarnings("unused")
|
88
|
private URI uzbekistanChecklist_local(){
|
89
|
File file = new File("C:\\Users\\a.mueller\\BGBM\\Data\\Uzbekistan\\" + fileName);
|
90
|
return file.toURI();
|
91
|
}
|
92
|
|
93
|
private Reference secRef;
|
94
|
private Reference getSecReference(){
|
95
|
if (secRef != null){
|
96
|
return secRef;
|
97
|
}
|
98
|
Reference result = ReferenceFactory.newArticle();
|
99
|
result.setTitle("Corrections and amendments to the 2016 classification of lichenized fungi in the Ascomycota and Basidiomycota");
|
100
|
result.setDatePublished(TimePeriodParser.parseStringVerbatim("2016"));
|
101
|
|
102
|
Team team = Team.NewInstance();
|
103
|
|
104
|
Person person = Person.NewInstance();
|
105
|
person.setInitials("R.");
|
106
|
person.setFamilyName("Lücking");
|
107
|
team.addTeamMember(person);
|
108
|
|
109
|
result.setAuthorship(team);
|
110
|
|
111
|
// result.setPublisher("Berlin: Botanic Garden and Botanical Museum Berlin-Dahlem; Athens: Hellenic Botanical Society.");
|
112
|
|
113
|
result.setVolume("120(1)");
|
114
|
Reference journal = ReferenceFactory.newJournal();
|
115
|
journal.setTitle("The Bryologist");
|
116
|
result.setInReference(journal);
|
117
|
secRef = result;
|
118
|
|
119
|
secRef.setUuid(secRefUuid);
|
120
|
return result;
|
121
|
}
|
122
|
|
123
|
private Reference getSourceReference(){
|
124
|
Reference result = ReferenceFactory.newGeneric();
|
125
|
result.setTitle("Excelfile (FoU_taxonomy_template.xlsx) derived from ");
|
126
|
// result.setInReference(getSecReference());
|
127
|
result.setUuid(sourceRefUuid);
|
128
|
|
129
|
return result;
|
130
|
}
|
131
|
|
132
|
public static void main(String[] args) {
|
133
|
UzbekistanTaxonActivator me = new UzbekistanTaxonActivator();
|
134
|
me.doImport(cdmDestination);
|
135
|
System.exit(0);
|
136
|
}
|
137
|
}
|