Project

General

Profile

Download (2.69 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.wp6.CommonNameImportConfigurator;
22

    
23

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

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

    
41
// **************** ALL *********************	
42

    
43
	private boolean doInvoke(ICdmDataSource destination){
44
		boolean success = true;
45

    
46
		URI sourceUri = null;
47
		File file = new File(source);
48
		if (! file.exists()){
49
			logger.warn("File does not exist");
50
			System.exit(-1);
51
		}
52
		sourceUri = file.toURI();
53
		
54
		CommonNameImportConfigurator config;
55
		
56
		config = CommonNameImportConfigurator.NewInstance(sourceUri, destination);
57
			
58
		// invoke import
59
		CdmDefaultImport<CommonNameImportConfigurator> myImport = new CdmDefaultImport<CommonNameImportConfigurator>();
60
		success &= myImport.invoke(config);
61
		String successString = success ? "successful" : " with errors ";
62
		System.out.println("End updating caches for "+ destination.getDatabase() + "..." +  successString);
63
		return success;
64
	}
65
	
66
	/**
67
	 * @param args
68
	 */
69
	public static void main(String[] args) {
70
		ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
71
		
72
		System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
73
		CichorieaeCommonNameActivator me = new CichorieaeCommonNameActivator();
74
		me.doInvoke(destination);
75
		
76
	}
77

    
78
}
(3-3/5)