Project

General

Profile

Download (2.73 KB) Statistics
| Branch: | Revision:
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

    
10
package eu.etaxonomy.cdm.app.wp6.cichorieae;
11

    
12
import java.io.File;
13
import java.net.URI;
14

    
15
import org.apache.log4j.Logger;
16

    
17
import eu.etaxonomy.cdm.app.common.CdmDestinations;
18
import eu.etaxonomy.cdm.database.DbSchemaValidation;
19
import eu.etaxonomy.cdm.database.ICdmDataSource;
20
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
21
import eu.etaxonomy.cdm.io.common.ImportResult;
22
import eu.etaxonomy.cdm.io.wp6.CommonNameImportConfigurator;
23

    
24

    
25
/**
26
 * TODO add the following to a wiki page:
27
 * 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
28
 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
29
 *
30
 *
31
 * @author a.mueller
32
 *
33
 */
34
public class CichorieaeCommonNameActivator {
35
	private static final Logger logger = Logger.getLogger(CichorieaeCommonNameActivator.class);
36

    
37
	//database validation status (create, update, validate ...)
38
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
39
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_test_mysql();
40
	static String source = "C:/localCopy/Data/wp6/cich/Common names-Ueberarbeitung_AM.xls";
41

    
42
// **************** ALL *********************
43

    
44
	private ImportResult doInvoke(ICdmDataSource destination){
45
		ImportResult success;
46

    
47
		URI sourceUri = null;
48
		File file = new File(source);
49
		if (! file.exists()){
50
			logger.warn("File does not exist");
51
			System.exit(-1);
52
		}
53
		sourceUri = file.toURI();
54

    
55
		CommonNameImportConfigurator config;
56

    
57
		config = CommonNameImportConfigurator.NewInstance(sourceUri, destination);
58

    
59
		// invoke import
60
		CdmDefaultImport<CommonNameImportConfigurator> myImport = new CdmDefaultImport<CommonNameImportConfigurator>();
61
		success = myImport.invoke(config);
62
		String successString = success.isSuccess() ? "successful" : " with errors ";
63
		System.out.println("End updating caches for "+ destination.getDatabase() + "..." +  successString);
64
		return success;
65
	}
66

    
67
	/**
68
	 * @param args
69
	 */
70
	public static void main(String[] args) {
71
		ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
72

    
73
		System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
74
		CichorieaeCommonNameActivator me = new CichorieaeCommonNameActivator();
75
		me.doInvoke(destination);
76

    
77
	}
78

    
79
}
(3-3/6)