Revision 81c27837
Added by Lorna Morris over 9 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/vibrant/DwcaScratchpadImportActivator.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.app.vibrant; |
11 | 11 |
|
12 |
import java.io.File; |
|
12 | 13 |
import java.net.URI; |
13 | 14 |
import java.util.UUID; |
14 | 15 |
|
... | ... | |
37 | 38 |
private static final Logger logger = Logger.getLogger(DwcaScratchpadImportActivator.class); |
38 | 39 |
|
39 | 40 |
//database validation status (create, update, validate ...) |
40 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
|
41 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.UPDATE;//UPDATE;//CREATE;//UPDATE;
|
|
41 | 42 |
|
42 | 43 |
// static final URI source = dwca_emonocots_dioscoreaceae(); |
43 | 44 |
// static final URI source = dwca_emonocots_zingiberaceae(); |
44 | 45 |
//static final URI source = dwca_emonocots_cypripedioideae(); |
45 |
static final URI source = dwca_emonocots_dioscoreaceae(); |
|
46 |
static final URI source = null;//dwca_antkey();//dwca_emonocots_dioscoreaceae();
|
|
46 | 47 |
|
47 | 48 |
|
48 | 49 |
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
... | ... | |
51 | 52 |
|
52 | 53 |
//default nom code is ICZN as it allows adding publication year |
53 | 54 |
static final NomenclaturalCode defaultNomCode = NomenclaturalCode.ICBN; |
55 |
|
|
56 |
//classification Name |
|
57 |
static String classificationName = "Default classification"; |
|
54 | 58 |
|
55 | 59 |
//title |
56 | 60 |
static final String title = "Scratchpad test import"; |
... | ... | |
108 | 112 |
config.setGuessNomenclaturalReferences(guessNomRef); |
109 | 113 |
config.setHandleAllRefsAsCitation(handleAllRefsAsCitation); |
110 | 114 |
config.setUseSourceReferenceAsSec(useSourceReferenceAsSec); |
111 |
config.setSourceReferenceTitle(title); |
|
115 |
config.setSourceReferenceTitle(classificationName);//title); |
|
116 |
config.setClassificationName(classificationName); |
|
117 |
|
|
118 |
config.setUseSourceReferenceAsSec(true);//Lorna: what shall we use as sec reference for Scratchpads data? |
|
112 | 119 |
|
113 | 120 |
CdmDefaultImport myImport = new CdmDefaultImport(); |
114 | 121 |
|
... | ... | |
143 | 150 |
return sourceUrl; |
144 | 151 |
} |
145 | 152 |
|
153 |
//dwca_antkey_org.zip |
|
154 |
public static URI dwca_antkey() { |
|
155 |
//URI sourceUrl = URI.create("file:////PESIIMPORT3/vibrant/dwca/dwca_emonocots_dioscoreaceae.zip");//dwca_dioscoreaceae_e_monocot.zip |
|
156 |
URI sourceUrl = URI.create("file:///C:/Users/l.morris/Downloads/amaryllidaceae.zip");//antkey.zip");//alismataceae.zip");//hypoxidaceae.zip");//dwca_antkey.zip"); |
|
157 |
return sourceUrl; |
|
158 |
} |
|
159 |
|
|
146 | 160 |
//emonocots_zingiberaceae |
147 | 161 |
public static URI dwca_emonocots_zingiberaceae() { |
148 | 162 |
URI sourceUrl = URI.create("file:////PESIIMPORT3/vibrant/dwca/dwca_emonocots_zingiberaceae.zip"); |
... | ... | |
161 | 175 |
*/ |
162 | 176 |
public static void main(String[] args) { |
163 | 177 |
DwcaScratchpadImportActivator me = new DwcaScratchpadImportActivator(); |
164 |
me.doImport(source, cdmDestination, classificationUuid, title, hbm2dll); |
|
178 |
|
|
179 |
//lorna: TODO get the classification name from the dwca zip file name |
|
180 |
classificationName = "Scratchpad classification";//"Amaryllidaceae"; |
|
181 |
|
|
182 |
// Directory path here |
|
183 |
String path = "C:/Users/l.morris/Downloads/dwca_scratchpads/nine"; |
|
184 |
URI sourceUrl; |
|
185 |
//URI sourceUrl = URI.create("file:////PESIIMPORT3/vibrant/dwca/dwca_emonocots_zingiberaceae.zip"); |
|
186 |
|
|
187 |
String zipFile; |
|
188 |
File folder = new File(path); |
|
189 |
File[] listOfFiles = folder.listFiles(); |
|
190 |
|
|
191 |
for (int i = 0; i < listOfFiles.length; i++) |
|
192 |
{ |
|
193 |
|
|
194 |
if (listOfFiles[i].isFile()) |
|
195 |
{ |
|
196 |
zipFile = listOfFiles[i].getName(); |
|
197 |
|
|
198 |
if (zipFile.endsWith(".zip")) |
|
199 |
{ |
|
200 |
//classificationName = zipFile.split(".zip")[0]; |
|
201 |
classificationName = zipFile.split("dwca_")[1]; |
|
202 |
classificationName = classificationName.split("_")[0]; |
|
203 |
System.out.println(classificationName); |
|
204 |
//start the Scratchpad name with uppercase. |
|
205 |
char[] stringArray = classificationName.toCharArray(); |
|
206 |
stringArray[0] = Character.toUpperCase(stringArray[0]); |
|
207 |
classificationName = new String(stringArray) + " (Scratchpads)"; |
|
208 |
System.out.println(classificationName); |
|
209 |
//System.exit(999); |
|
210 |
|
|
211 |
sourceUrl = URI.create("file:///" + path + "/" + zipFile); |
|
212 |
System.out.println(sourceUrl); |
|
213 |
me.doImport(sourceUrl, cdmDestination, classificationUuid, title, hbm2dll); |
|
214 |
//System.exit(999); |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
//System.exit(999); |
|
220 |
//list all files in the directory |
|
221 |
//get the URI of each |
|
222 |
//URI sourceUrl = URI.create("file:///C:/Users/l.morris/Downloads/amaryllidaceae.zip"); |
|
223 |
|
|
224 |
//Lorna iterate through the dwca directly getting each dwca.zip and generate a URI for each source |
|
225 |
//me.doImport(source, cdmDestination, classificationUuid, title, hbm2dll); |
|
165 | 226 |
} |
166 | 227 |
|
167 | 228 |
} |
Also available in: Unified diff
Now iterates through all dwca.zip files downloaded using Scratchpads service and imports them into the CDM.