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