1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.app.phycobank;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.util.Date;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
|
18
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
19
|
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor;
|
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.IImportConfigurator.CHECK;
|
24
|
import eu.etaxonomy.cdm.io.phycobank.PhycobankHigherClassificationImportConfigurator;
|
25
|
import eu.etaxonomy.cdm.model.agent.Person;
|
26
|
import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;
|
27
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
28
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
29
|
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
|
30
|
|
31
|
|
32
|
/**
|
33
|
* Activator to import phycobank higher classifications.
|
34
|
* @author a.mueller
|
35
|
* @since 2018-08-09
|
36
|
*/
|
37
|
public class PhycobankHigherClassificationActivator {
|
38
|
@SuppressWarnings("unused")
|
39
|
private static final Logger logger = Logger.getLogger(PhycobankHigherClassificationActivator.class);
|
40
|
|
41
|
|
42
|
// ====================================================================================
|
43
|
|
44
|
//database validation status (create, update, validate ...)
|
45
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
46
|
|
47
|
// static ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
48
|
// static ICdmDataSource cdmDestination = CdmDestinations.cdm_local_test_mysql();
|
49
|
static ICdmDataSource cdmDestination = CdmDestinations.cdm_test_phycobank();
|
50
|
|
51
|
// static Reference secRef = getSecReference_Frey();
|
52
|
static Reference secRef = getSecReference_WoRMS();
|
53
|
static String worksheetName = secRef == getSecReference_WoRMS()? "WoRMS" :
|
54
|
secRef == getSecReference_Frey()? "HigherRanksEntwurfNeu" : null;
|
55
|
|
56
|
//check - import
|
57
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
58
|
|
59
|
private void doImport(ICdmDataSource cdmDestination){
|
60
|
|
61
|
URI source = fileURI();
|
62
|
Reference sourceRef = getSourceReference();
|
63
|
|
64
|
//make Source
|
65
|
PhycobankHigherClassificationImportConfigurator config= PhycobankHigherClassificationImportConfigurator.NewInstance(source, cdmDestination);
|
66
|
config.setWorksheetName(worksheetName);
|
67
|
config.setCheck(check);
|
68
|
config.setDbSchemaValidation(hbm2dll);
|
69
|
config.setSourceReference(sourceRef);
|
70
|
config.setSecReference(secRef);
|
71
|
config.setProgressMonitor(DefaultProgressMonitor.NewInstance());
|
72
|
|
73
|
CdmDefaultImport<PhycobankHigherClassificationImportConfigurator> myImport = new CdmDefaultImport<>();
|
74
|
myImport.invoke(config);
|
75
|
|
76
|
System.exit(0);
|
77
|
|
78
|
}
|
79
|
|
80
|
private static Reference getSecReference_Frey() {
|
81
|
Reference result = ReferenceFactory.newBook();
|
82
|
result.setTitle("Syllabus of the plant families");
|
83
|
result.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(2015));
|
84
|
result.setPublisher("Borntraeger");
|
85
|
result.setPlacePublished("Stuttgart");
|
86
|
Person author = Person.NewInstance();
|
87
|
author.setFamilyName("Frey");
|
88
|
author.setInitials("W.");
|
89
|
result.setAuthorship(author);
|
90
|
result.setUuid(UUID.fromString("2b4a3a67-e432-4d6b-b716-081045179df9"));
|
91
|
return result;
|
92
|
}
|
93
|
|
94
|
private static Reference getSecReference_WoRMS() {
|
95
|
Reference result = ReferenceFactory.newDatabase();
|
96
|
result.setTitle("WoRMS World Register of Marine Species");
|
97
|
result.setDatePublished(TimePeriodParser.parseStringVerbatim("2018-04-20"));
|
98
|
result.setUri(URI.create("http://www.marinespecies.org/index.php"));
|
99
|
result.setUuid(UUID.fromString("b33daeb0-8770-4ee2-92d0-80aaa87bfba2"));
|
100
|
return result;
|
101
|
}
|
102
|
|
103
|
private Reference getSourceReference() {
|
104
|
Reference result = ReferenceFactory.newDatabase();
|
105
|
result.setTitle("Higher classification Excel import: " + fileName());
|
106
|
result.setUri(fileURI());
|
107
|
result.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(new Date(), null));
|
108
|
return result;
|
109
|
}
|
110
|
|
111
|
public static String fileName(){
|
112
|
return "Algen_Syllabus_NormalImplied_Test.xlsx";
|
113
|
}
|
114
|
public static String filePath(){
|
115
|
return "file:////BGBM-PESIHPC/Phycobank/";
|
116
|
}
|
117
|
|
118
|
public static URI fileURI() {
|
119
|
return URI.create(filePath() + fileName());
|
120
|
}
|
121
|
|
122
|
/**
|
123
|
* @param args
|
124
|
*/
|
125
|
public static void main(String[] args) {
|
126
|
PhycobankHigherClassificationActivator me = new PhycobankHigherClassificationActivator();
|
127
|
me.doImport(cdmDestination);
|
128
|
}
|
129
|
|
130
|
}
|