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