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.bogota;
|
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.bogota.BogotaChecklistImportConfigurator;
|
20
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
22
|
import eu.etaxonomy.cdm.model.agent.Person;
|
23
|
import eu.etaxonomy.cdm.model.agent.Team;
|
24
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
25
|
import eu.etaxonomy.cdm.model.reference.IWebPage;
|
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
|
* Activator for import of Bogota Checklist
|
32
|
|
33
|
* @author a.mueller
|
34
|
* @date 21.04.2017
|
35
|
*
|
36
|
*/
|
37
|
public class BogotaChecklistActivator {
|
38
|
private static final Logger logger = Logger.getLogger(BogotaChecklistActivator.class);
|
39
|
|
40
|
//database validation status (create, update, validate ...)
|
41
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
42
|
|
43
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
44
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
45
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_bogota_production();
|
46
|
|
47
|
//classification
|
48
|
static final UUID classificationUuid = UUID.fromString("c7779e17-8d45-4429-a9b0-e9c0fce93ec5");
|
49
|
private static final String classificationName = "Bogota Taxonomic Backbone";
|
50
|
|
51
|
//check - import
|
52
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
53
|
|
54
|
protected void doImport(ICdmDataSource cdmDestination){
|
55
|
|
56
|
URI source = bogotaChecklist();
|
57
|
|
58
|
//make Source
|
59
|
BogotaChecklistImportConfigurator config= BogotaChecklistImportConfigurator.NewInstance(source, cdmDestination);
|
60
|
config.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
|
61
|
config.setClassificationUuid(classificationUuid);
|
62
|
config.setClassificationName(classificationName);
|
63
|
config.setCheck(check);
|
64
|
config.setDbSchemaValidation(hbm2dll);
|
65
|
config.setSecReference(getSecReference());
|
66
|
|
67
|
config.setSource(source);
|
68
|
String fileName = source.toString();
|
69
|
fileName = fileName.substring(fileName.lastIndexOf("/") + 1 );
|
70
|
|
71
|
String message = "Start import from ("+ fileName + ") ...";
|
72
|
System.out.println(message);
|
73
|
logger.warn(message);
|
74
|
|
75
|
config.setSourceReference(getSourceReference());
|
76
|
|
77
|
CdmDefaultImport<BogotaChecklistImportConfigurator> myImport = new CdmDefaultImport<>();
|
78
|
|
79
|
myImport.invoke(config);
|
80
|
|
81
|
System.out.println("End import from ("+ source.toString() + ")...");
|
82
|
|
83
|
}
|
84
|
|
85
|
|
86
|
//bogotaChecklist
|
87
|
public static URI bogotaChecklist() {
|
88
|
return URI.create("file:////BGBM-PESIHPC/Bogota/Resultados_Busqueda_avanzada_2017-04-19_0810_import.xlsx");
|
89
|
}
|
90
|
|
91
|
|
92
|
private Reference getSourceReference() {
|
93
|
Reference result = ReferenceFactory.newGeneric();
|
94
|
result.setTitle("Resultados_Busqueda_avanzada_2017-04-19_0810_import.xlsx");
|
95
|
return result;
|
96
|
}
|
97
|
|
98
|
private Reference getSecReference() {
|
99
|
IWebPage result = ReferenceFactory.newWebPage();
|
100
|
result.setTitle("Catálogo de plantas y líquenes de Colombia");
|
101
|
result.setPlacePublished("Bogotá");
|
102
|
result.setUri(URI.create("http://catalogoplantasdecolombia.unal.edu.co/"));
|
103
|
result.setPublisher("Instituto de Ciencias Naturales, Universidad Nacional de Colombia");
|
104
|
result.setDatePublished(TimePeriodParser.parseString("2016"));
|
105
|
result.getDatePublished().setFreeText("2016 (visited 2017-04-19)");
|
106
|
|
107
|
Team team = Team.NewInstance();
|
108
|
Person bernal = Person.NewTitledInstance("Bernal, R.");
|
109
|
bernal.setFirstname("R.");
|
110
|
bernal.setLastname("Bernal");
|
111
|
Person gradstein = Person.NewTitledInstance("Gradstein, S.R.");
|
112
|
gradstein.setFirstname("S.R.");
|
113
|
gradstein.setLastname("Gradstein");
|
114
|
Person celis = Person.NewTitledInstance("Celis, M.");
|
115
|
celis.setFirstname("M.");
|
116
|
celis.setLastname("Celis");
|
117
|
team.addTeamMember(bernal);
|
118
|
team.addTeamMember(gradstein);
|
119
|
team.addTeamMember(celis);
|
120
|
result.setAuthorship(team);
|
121
|
|
122
|
return (Reference)result;
|
123
|
}
|
124
|
|
125
|
/**
|
126
|
* @param args
|
127
|
*/
|
128
|
public static void main(String[] args) {
|
129
|
BogotaChecklistActivator me = new BogotaChecklistActivator();
|
130
|
me.doImport(cdmDestination);
|
131
|
System.exit(0);
|
132
|
}
|
133
|
}
|