1
|
/**
|
2
|
* Copyright (C) 2007 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.wp6.cichorieae;
|
10
|
|
11
|
import java.io.File;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
|
15
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
16
|
import eu.etaxonomy.cdm.common.URI;
|
17
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
18
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
19
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
20
|
import eu.etaxonomy.cdm.io.common.ImportResult;
|
21
|
import eu.etaxonomy.cdm.io.wp6.CommonNameImportConfigurator;
|
22
|
|
23
|
/**
|
24
|
* TODO add the following to a wiki page:
|
25
|
* HINT: If you are about to import into a mysql data base running under windows and if you wish to dump and restore the resulting data bas under another operation systen
|
26
|
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
|
27
|
*
|
28
|
* @author a.mueller
|
29
|
*/
|
30
|
public class CichorieaeCommonNameActivator {
|
31
|
private static final Logger logger = Logger.getLogger(CichorieaeCommonNameActivator.class);
|
32
|
|
33
|
//database validation status (create, update, validate ...)
|
34
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
35
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_test_mysql();
|
36
|
static String source = "C:/localCopy/Data/wp6/cich/Common names-Ueberarbeitung_AM.xls";
|
37
|
|
38
|
// **************** ALL *********************
|
39
|
|
40
|
private ImportResult doInvoke(ICdmDataSource destination){
|
41
|
ImportResult success;
|
42
|
|
43
|
URI sourceUri = null;
|
44
|
File file = new File(source);
|
45
|
if (! file.exists()){
|
46
|
logger.warn("File does not exist");
|
47
|
System.exit(-1);
|
48
|
}
|
49
|
sourceUri = URI.fromFile(file);
|
50
|
|
51
|
CommonNameImportConfigurator config;
|
52
|
|
53
|
config = CommonNameImportConfigurator.NewInstance(sourceUri, destination);
|
54
|
|
55
|
// invoke import
|
56
|
CdmDefaultImport<CommonNameImportConfigurator> myImport = new CdmDefaultImport<CommonNameImportConfigurator>();
|
57
|
success = myImport.invoke(config);
|
58
|
String successString = success.isSuccess() ? "successful" : " with errors ";
|
59
|
System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString);
|
60
|
return success;
|
61
|
}
|
62
|
|
63
|
public static void main(String[] args) {
|
64
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
65
|
|
66
|
System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
|
67
|
CichorieaeCommonNameActivator me = new CichorieaeCommonNameActivator();
|
68
|
me.doInvoke(destination);
|
69
|
}
|
70
|
}
|