Revision 156f2413
Added by Andreas Müller almost 4 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/uzbekistan/UzbekistanDescriptionsActivator.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.textdata.in.TextDataExcelImportConfigurator; |
|
25 |
import eu.etaxonomy.cdm.model.common.Language; |
|
26 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
27 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
28 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
29 |
|
|
30 |
/** |
|
31 |
* Import for Flora of Uzbekistan descriptions. |
|
32 |
* |
|
33 |
* https://dev.e-taxonomy.eu/redmine/issues/9125 |
|
34 |
* |
|
35 |
* @author a.mueller |
|
36 |
* @since 06.07.2020 |
|
37 |
*/ |
|
38 |
public class UzbekistanDescriptionsActivator { |
|
39 |
|
|
40 |
@SuppressWarnings("unused") |
|
41 |
private static final Logger logger = Logger.getLogger(UzbekistanDescriptionsActivator.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_uzbekistan(); |
|
47 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_uzbekistan(); |
|
48 |
|
|
49 |
static DbSchemaValidation hbm2dll = cdmDestination.getDatabaseType() == DatabaseTypeEnum.H2 ? DbSchemaValidation.CREATE : DbSchemaValidation.VALIDATE; |
|
50 |
|
|
51 |
static final String fileName = "FoU_template_descriptions.xls"; |
|
52 |
|
|
53 |
static final UUID uuidDescription = Feature.uuidDescription; |
|
54 |
static final UUID uuidTextLanguage = Language.uuidRussian; |
|
55 |
|
|
56 |
static final UUID uuidSourceRef = UUID.fromString("5d7ee0da-ccce-4666-b6f9-434d71dbddfd"); |
|
57 |
|
|
58 |
//check - import |
|
59 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
|
60 |
|
|
61 |
private void doImport(ICdmDataSource cdmDestination){ |
|
62 |
|
|
63 |
//make Source |
|
64 |
URI source = fileName(); |
|
65 |
// URI source = uzbekistanChecklist_local(); |
|
66 |
|
|
67 |
TextDataExcelImportConfigurator config = TextDataExcelImportConfigurator.NewInstance(source, cdmDestination); |
|
68 |
config.setCheck(check); |
|
69 |
config.setDbSchemaValidation(hbm2dll); |
|
70 |
config.setFeatureUuid(uuidDescription); |
|
71 |
config.setSourceReference(getSourceReference()); |
|
72 |
config.setTextLanguageUuid(uuidTextLanguage); |
|
73 |
config.setTextColumnLabel("morphological description"); |
|
74 |
|
|
75 |
CdmDefaultImport<TextDataExcelImportConfigurator> myImport = new CdmDefaultImport<>(); |
|
76 |
ImportResult result = myImport.invoke(config); |
|
77 |
System.out.println(result.createReport()); |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
private URI fileName(){ |
|
82 |
return URI.create("file:////BGBM-PESIHPC/Uzbekistan/" + fileName); |
|
83 |
} |
|
84 |
@SuppressWarnings("unused") |
|
85 |
private URI fileName_local(){ |
|
86 |
File file = new File("C:\\Users\\a.mueller\\BGBM\\Data\\Uzbekistan\\" + fileName); |
|
87 |
return file.toURI(); |
|
88 |
} |
|
89 |
|
|
90 |
private Reference getSourceReference(){ |
|
91 |
Reference result = ReferenceFactory.newGeneric(); |
|
92 |
result.setTitle(fileName); |
|
93 |
result.setUuid(uuidSourceRef); |
|
94 |
return result; |
|
95 |
} |
|
96 |
|
|
97 |
public static void main(String[] args) { |
|
98 |
UzbekistanDescriptionsActivator me = new UzbekistanDescriptionsActivator(); |
|
99 |
me.doImport(cdmDestination); |
|
100 |
System.exit(0); |
|
101 |
} |
|
102 |
} |
Also available in: Unified diff
ref #9125 add UzbekistanDescriptionsActivator