Revision 8422c0cd
Added by Andreas Müller almost 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/vibrant/DwcaScratchpadImportActivator.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
36 | 36 |
public class DwcaScratchpadImportActivator { |
37 | 37 |
@SuppressWarnings("unused") |
38 | 38 |
private static final Logger logger = Logger.getLogger(DwcaScratchpadImportActivator.class); |
39 |
|
|
39 |
|
|
40 | 40 |
//database validation status (create, update, validate ...) |
41 | 41 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.UPDATE;//UPDATE;//CREATE;//UPDATE; |
42 | 42 |
|
... | ... | |
44 | 44 |
// static final URI source = dwca_emonocots_zingiberaceae(); |
45 | 45 |
//static final URI source = dwca_emonocots_cypripedioideae(); |
46 | 46 |
static final URI source = null;//dwca_antkey();//dwca_emonocots_dioscoreaceae(); |
47 |
|
|
48 |
|
|
47 |
|
|
48 |
|
|
49 | 49 |
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
50 | 50 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql(); |
51 | 51 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test(); |
52 |
|
|
53 |
//default nom code is ICZN as it allows adding publication year
|
|
52 |
|
|
53 |
//default nom code is ICZN as it allows adding publication year |
|
54 | 54 |
static final NomenclaturalCode defaultNomCode = NomenclaturalCode.ICNAFP; |
55 |
|
|
55 |
|
|
56 | 56 |
//classification Name |
57 | 57 |
static String classificationName = "Default classification"; |
58 | 58 |
|
59 | 59 |
//title |
60 | 60 |
static final String title = "Scratchpad test import"; |
61 |
|
|
61 |
|
|
62 | 62 |
//check - import |
63 | 63 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
64 | 64 |
static int partitionSize = 1000; |
65 |
|
|
65 |
|
|
66 | 66 |
//config |
67 | 67 |
static DatasetUse datasetUse = DatasetUse.CLASSIFICATION; |
68 |
|
|
68 |
|
|
69 | 69 |
//validate |
70 | 70 |
static boolean validateRankConsistency = false; |
71 |
|
|
72 |
|
|
71 |
|
|
72 |
|
|
73 | 73 |
//taxa |
74 | 74 |
static final boolean doTaxa = true; |
75 | 75 |
static final boolean doDistribution = true; |
76 |
|
|
77 |
|
|
78 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 | 79 |
static final MappingType mappingType = MappingType.InMemoryMapping; |
80 |
|
|
80 |
|
|
81 | 81 |
//classification |
82 | 82 |
static final UUID classificationUuid = UUID.fromString("d9d199b6-eaf4-47c8-a732-0639bc445c56"); |
83 |
|
|
84 |
|
|
83 |
|
|
84 |
|
|
85 | 85 |
//config |
86 | 86 |
static boolean scientificNameIdAsOriginalSourceId = true; |
87 | 87 |
static boolean guessNomRef = false; |
88 | 88 |
private boolean handleAllRefsAsCitation = false; |
89 | 89 |
private static final boolean useSourceReferenceAsSec = true; |
90 |
|
|
90 |
|
|
91 | 91 |
|
92 | 92 |
//deduplicate |
93 | 93 |
static final boolean doDeduplicate = false; |
94 | 94 |
|
95 |
|
|
96 |
|
|
95 |
|
|
96 |
|
|
97 | 97 |
protected void doImport(URI source, ICdmDataSource cdmDestination, UUID classificationUuid, String title, DbSchemaValidation hbm2dll){ |
98 |
|
|
98 |
|
|
99 | 99 |
//make Source |
100 | 100 |
DwcaImportConfigurator config= DwcaImportConfigurator.NewInstance(source, cdmDestination); |
101 | 101 |
config.addObserver(new LoggingIoObserver()); |
... | ... | |
103 | 103 |
config.setCheck(check); |
104 | 104 |
config.setDbSchemaValidation(hbm2dll); |
105 | 105 |
config.setMappingType(mappingType); |
106 |
|
|
106 |
|
|
107 | 107 |
config.setScientificNameIdAsOriginalSourceId(scientificNameIdAsOriginalSourceId); |
108 | 108 |
config.setValidateRankConsistency(validateRankConsistency); |
109 | 109 |
config.setDefaultPartitionSize(partitionSize); |
... | ... | |
114 | 114 |
config.setUseSourceReferenceAsSec(useSourceReferenceAsSec); |
115 | 115 |
config.setSourceReferenceTitle(classificationName);//title); |
116 | 116 |
config.setClassificationName(classificationName); |
117 |
|
|
117 |
|
|
118 | 118 |
config.setUseSourceReferenceAsSec(true);//Lorna: what shall we use as sec reference for Scratchpads data? |
119 |
|
|
119 |
|
|
120 | 120 |
CdmDefaultImport myImport = new CdmDefaultImport(); |
121 | 121 |
|
122 |
|
|
122 |
|
|
123 | 123 |
//... |
124 | 124 |
if (true){ |
125 | 125 |
System.out.println("Start import from ("+ source.toString() + ") ..."); |
... | ... | |
127 | 127 |
myImport.invoke(config); |
128 | 128 |
System.out.println("End import from ("+ source.toString() + ")..."); |
129 | 129 |
} |
130 |
|
|
131 |
|
|
130 |
|
|
131 |
|
|
132 | 132 |
} |
133 | 133 |
|
134 |
private Reference<?> getSourceReference(String string) {
|
|
135 |
Reference<?> result = ReferenceFactory.newGeneric();
|
|
136 |
result.setTitleCache(string); |
|
134 |
private Reference getSourceReference(String string) { |
|
135 |
Reference result = ReferenceFactory.newGeneric(); |
|
136 |
result.setTitleCache(string, true);
|
|
137 | 137 |
return result; |
138 | 138 |
} |
139 | 139 |
|
... | ... | |
142 | 142 |
URI sourceUrl = URI.create("file:///C:/localCopy/Data/dwca/import/Scratchpads/dwca_dioscoreaceae_emonocots.zip"); |
143 | 143 |
return sourceUrl; |
144 | 144 |
} |
145 |
|
|
145 |
|
|
146 | 146 |
//emonocots_dioscoreaceae |
147 | 147 |
public static URI dwca_emonocots_dioscoreaceae() { |
148 | 148 |
//URI sourceUrl = URI.create("file:////PESIIMPORT3/vibrant/dwca/dwca_emonocots_dioscoreaceae.zip");//dwca_dioscoreaceae_e_monocot.zip |
149 | 149 |
URI sourceUrl = URI.create("file:///C:/Users/l.morris/Downloads/dwca_scratchpads/dwca_dioscoreaceae_e_monocot_org.zip"); |
150 | 150 |
return sourceUrl; |
151 | 151 |
} |
152 |
|
|
152 |
|
|
153 | 153 |
//dwca_antkey_org.zip |
154 | 154 |
public static URI dwca_antkey() { |
155 | 155 |
//URI sourceUrl = URI.create("file:////PESIIMPORT3/vibrant/dwca/dwca_emonocots_dioscoreaceae.zip");//dwca_dioscoreaceae_e_monocot.zip |
156 | 156 |
URI sourceUrl = URI.create("file:///C:/Users/l.morris/Downloads/amaryllidaceae.zip");//antkey.zip");//alismataceae.zip");//hypoxidaceae.zip");//dwca_antkey.zip"); |
157 | 157 |
return sourceUrl; |
158 | 158 |
} |
159 |
|
|
159 |
|
|
160 | 160 |
//emonocots_zingiberaceae |
161 | 161 |
public static URI dwca_emonocots_zingiberaceae() { |
162 | 162 |
URI sourceUrl = URI.create("file:////PESIIMPORT3/vibrant/dwca/dwca_emonocots_zingiberaceae.zip"); |
... | ... | |
168 | 168 |
URI sourceUrl = URI.create("file:///C:/Users/l.morris/Downloads/dwca_scratchpads/dwca_cypripedioideae_e-monocot_org.zip"); |
169 | 169 |
return sourceUrl; |
170 | 170 |
} |
171 |
|
|
171 |
|
|
172 | 172 |
|
173 | 173 |
/** |
174 | 174 |
* @param args |
... | ... | |
186 | 186 |
|
187 | 187 |
String zipFile; |
188 | 188 |
File folder = new File(path); |
189 |
File[] listOfFiles = folder.listFiles();
|
|
189 |
File[] listOfFiles = folder.listFiles(); |
|
190 | 190 |
|
191 |
for (int i = 0; i < listOfFiles.length; i++)
|
|
191 |
for (int i = 0; i < listOfFiles.length; i++) |
|
192 | 192 |
{ |
193 | 193 |
|
194 |
if (listOfFiles[i].isFile())
|
|
194 |
if (listOfFiles[i].isFile()) |
|
195 | 195 |
{ |
196 | 196 |
zipFile = listOfFiles[i].getName(); |
197 | 197 |
|
... | ... | |
215 | 215 |
} |
216 | 216 |
} |
217 | 217 |
} |
218 |
|
|
218 |
|
|
219 | 219 |
//System.exit(999); |
220 | 220 |
//list all files in the directory |
221 | 221 |
//get the URI of each |
222 | 222 |
//URI sourceUrl = URI.create("file:///C:/Users/l.morris/Downloads/amaryllidaceae.zip"); |
223 |
|
|
223 |
|
|
224 | 224 |
//Lorna iterate through the dwca directly getting each dwca.zip and generate a URI for each source |
225 | 225 |
//me.doImport(source, cdmDestination, classificationUuid, title, hbm2dll); |
226 | 226 |
} |
227 |
|
|
227 |
|
|
228 | 228 |
} |
Also available in: Unified diff
Remove generics from Reference in cdmlib-app #5830