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.DatabaseTypeEnum;
|
19
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
20
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
21
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
22
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
23
|
import eu.etaxonomy.cdm.io.common.ImportResult;
|
24
|
import eu.etaxonomy.cdm.io.fact.temporal.in.PhenologyExcelImportConfigurator;
|
25
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
26
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
27
|
|
28
|
/**
|
29
|
* Import for Flora of Uzbekistan phenology.
|
30
|
*
|
31
|
* https://dev.e-taxonomy.eu/redmine/issues/9126
|
32
|
*
|
33
|
* @author a.mueller
|
34
|
* @since 15.07.2020
|
35
|
*/
|
36
|
public class UzbekistanPhenologyActivator {
|
37
|
|
38
|
@SuppressWarnings("unused")
|
39
|
private static final Logger logger = Logger.getLogger(UzbekistanPhenologyActivator.class);
|
40
|
|
41
|
//database validation status (create, update, validate ...)
|
42
|
|
43
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
44
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_uzbekistan();
|
45
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_uzbekistan();
|
46
|
|
47
|
static DbSchemaValidation hbm2dll = cdmDestination.getDatabaseType() == DatabaseTypeEnum.H2 ? DbSchemaValidation.CREATE : DbSchemaValidation.VALIDATE;
|
48
|
|
49
|
static final String fileName = "FoU_template_flowering.xlsx";
|
50
|
|
51
|
static final UUID uuidSourceRef = UUID.fromString("fea9175d-d1be-4f92-b4c2-bec7df449b6e");
|
52
|
|
53
|
//check - import
|
54
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
55
|
|
56
|
private void doImport(ICdmDataSource cdmDestination){
|
57
|
|
58
|
//make Source
|
59
|
URI source = fileName();
|
60
|
// URI source = uzbekistanChecklist_local();
|
61
|
|
62
|
PhenologyExcelImportConfigurator config = PhenologyExcelImportConfigurator.NewInstance(source, cdmDestination);
|
63
|
config.setCheck(check);
|
64
|
config.setDbSchemaValidation(hbm2dll);
|
65
|
config.setFloweringStartColumnLabel("начало цветения");
|
66
|
config.setFloweringEndColumnLabel("конец цветения");
|
67
|
config.setFruitingStartColumnLabel("начало плодоношения");
|
68
|
config.setFruitingEndColumnLabel("конец плодоношения");
|
69
|
|
70
|
config.setSourceReference(getSourceReference());
|
71
|
|
72
|
CdmDefaultImport<PhenologyExcelImportConfigurator> myImport = new CdmDefaultImport<>();
|
73
|
ImportResult result = myImport.invoke(config);
|
74
|
System.out.println(result.createReport());
|
75
|
}
|
76
|
|
77
|
private URI fileName(){
|
78
|
return URI.create("file:////BGBM-PESIHPC/Uzbekistan/" + fileName);
|
79
|
}
|
80
|
@SuppressWarnings("unused")
|
81
|
private URI fileName_local(){
|
82
|
File file = new File("C:\\Users\\a.mueller\\BGBM\\Data\\Uzbekistan\\" + fileName);
|
83
|
return file.toURI();
|
84
|
}
|
85
|
|
86
|
private Reference getSourceReference(){
|
87
|
Reference result = ReferenceFactory.newGeneric();
|
88
|
result.setTitle(fileName);
|
89
|
result.setUuid(uuidSourceRef);
|
90
|
return result;
|
91
|
}
|
92
|
|
93
|
public static void main(String[] args) {
|
94
|
UzbekistanPhenologyActivator me = new UzbekistanPhenologyActivator();
|
95
|
me.doImport(cdmDestination);
|
96
|
System.exit(0);
|
97
|
}
|
98
|
}
|