Revision 9a942f8a
Added by Andreas Müller over 6 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/caryophyllales/PlumbaginaceaeIdentifierActivator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 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.caryophyllales; |
|
10 |
|
|
11 |
import java.io.File; |
|
12 |
import java.io.FileReader; |
|
13 |
import java.io.IOException; |
|
14 |
import java.io.InputStreamReader; |
|
15 |
import java.util.UUID; |
|
16 |
|
|
17 |
import org.apache.log4j.Logger; |
|
18 |
|
|
19 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
|
20 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
21 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
22 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
23 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
24 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
|
25 |
import eu.etaxonomy.cdm.io.identifier.IdentifierImportConfigurator; |
|
26 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
|
27 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author a.mueller |
|
31 |
* @date 18.10.2017 |
|
32 |
* |
|
33 |
*/ |
|
34 |
public class PlumbaginaceaeIdentifierActivator { |
|
35 |
|
|
36 |
@SuppressWarnings("unused") |
|
37 |
private static final Logger logger = Logger.getLogger(PlumbaginaceaeIdentifierActivator.class); |
|
38 |
|
|
39 |
//database validation status (create, update, validate ...) |
|
40 |
static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE; |
|
41 |
|
|
42 |
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
|
43 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp(); |
|
44 |
|
|
45 |
// private static final UUID idTypeUuid = DefinedTerm.uuidWfoNameIdentifier; |
|
46 |
private static final UUID idTypeUuid = DefinedTerm.uuidIpniNameIdentifier; |
|
47 |
|
|
48 |
//check - import |
|
49 |
static CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
|
50 |
|
|
51 |
private void doImport(ICdmDataSource cdmDestination){ |
|
52 |
|
|
53 |
InputStreamReader source = getPlumbaginaceaeIdentifier_IPNI(); |
|
54 |
IdentifierImportConfigurator config= IdentifierImportConfigurator.NewInstance(source, cdmDestination); |
|
55 |
config.setDbSchemaValidation(dbSchemaValidation); |
|
56 |
config.setIdentifierTypeUuid(idTypeUuid); |
|
57 |
config.setCdmClass(TaxonName.class); |
|
58 |
config.setCheck(check); |
|
59 |
config.setIgnoreEmptyIdentifier(true); |
|
60 |
|
|
61 |
CdmDefaultImport<IdentifierImportConfigurator> myImport = new CdmDefaultImport<>(); |
|
62 |
myImport.invoke(config); |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
private InputStreamReader getPlumbaginaceaeIdentifier() { |
|
67 |
String filename = "WFONamesInCDM_Plumbaginaceae.csv"; |
|
68 |
|
|
69 |
// URI.create("file:////BGBM-PESIHPC/FloraMalesianaXml/fmvol14_final2.xml") |
|
70 |
String path = "C://opt//data//Caryophyllales"; |
|
71 |
File file = new File(path + CdmUtils.getFolderSeperator() + filename); |
|
72 |
if (!file.exists()){ |
|
73 |
System.exit(-1); |
|
74 |
return null; |
|
75 |
} |
|
76 |
try { |
|
77 |
InputStreamReader input = new FileReader(file); |
|
78 |
return input; |
|
79 |
} catch (IOException e) { |
|
80 |
e.printStackTrace(); |
|
81 |
System.exit(-1); |
|
82 |
return null; |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
private InputStreamReader getPlumbaginaceaeIdentifier_IPNI() { |
|
87 |
String filename = "WFONamesInCDM_Plumbaginaceae_IPNI.csv"; |
|
88 |
|
|
89 |
String path = "C://opt//data//Caryophyllales"; |
|
90 |
File file = new File(path + CdmUtils.getFolderSeperator() + filename); |
|
91 |
if (!file.exists()){ |
|
92 |
System.exit(-1); |
|
93 |
return null; |
|
94 |
} |
|
95 |
try { |
|
96 |
InputStreamReader input = new FileReader(file); |
|
97 |
return input; |
|
98 |
} catch (IOException e) { |
|
99 |
e.printStackTrace(); |
|
100 |
System.exit(-1); |
|
101 |
return null; |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
/** |
|
107 |
* @param args |
|
108 |
*/ |
|
109 |
public static void main(String[] args) { |
|
110 |
PlumbaginaceaeIdentifierActivator me = new PlumbaginaceaeIdentifierActivator(); |
|
111 |
me.doImport(cdmDestination); |
|
112 |
System.exit(0); |
|
113 |
} |
|
114 |
} |
Also available in: Unified diff
PlumbaginaceaeIdentifierActivator