Project

General

Profile

Download (4.45 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.common;
11

    
12
import java.util.Arrays;
13
import java.util.List;
14

    
15
import org.apache.log4j.Logger;
16

    
17
import eu.etaxonomy.cdm.database.DbSchemaValidation;
18
import eu.etaxonomy.cdm.database.ICdmDataSource;
19
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator;
20
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
21
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
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 base 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 CacheUpdater {
35
	private static final Logger logger = Logger.getLogger(CacheUpdater.class);
36

    
37
	//database validation status (create, update, validate ...)
38
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
39
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_cichorieae();
40
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
41

    
42
	static final List<String> classListStrings =  Arrays.asList(new String[]{
43
			//IdentifiableEntity.class.getName(),
44
//			IdentifiableEntity.class.getName(),
45
			TaxonNameBase.class.getName(),
46
			TaxonBase.class.getName()
47
	});
48
	//new ArrayList<Class<? extends IdentifiableEntity>>();
49

    
50

    
51
	
52
	private boolean doInvoke(ICdmDataSource destination){
53
		boolean success = true;
54

    
55
		CacheUpdaterConfigurator config;
56
		try {
57
			config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings);
58
			
59
			// invoke import
60
			CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<CacheUpdaterConfigurator>();
61
			success &= myImport.invoke(config);
62
			String successString = success ? "successful" : " with errors ";
63
			System.out.println("End updating caches for "+ destination.getDatabase() + "..." +  successString);
64
			return success;
65
		} catch (ClassNotFoundException e) {
66
			logger.error(e);
67
			return false;
68
		}		
69
	}
70
	
71
	/**
72
	 * @param args
73
	 */
74
	public static void main(String[] args) {
75
		ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
76
		
77
		System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
78
		CacheUpdater me = new CacheUpdater();
79
		me.doInvoke(destination);
80
		
81
	}
82
	
83
	// **************** ALL *********************	
84

    
85
//	//DescriptionBase
86
//	static final boolean doTaxonDescription = true;
87
//	static final boolean doSpecimenDescription = true;
88
//	static final boolean doNameDescription = true;
89
//	
90
//	//AgentBase
91
//	static final boolean doPerson = true;
92
//	static final boolean doTeam = true;
93
//	static final boolean doInstitution = true;
94
//	
95
//	//MediaEntities
96
//	static final boolean doCollection = true;
97
//	static final boolean doReferenceBase = true;
98
//	
99
//	//SpecimenOrObservationBase
100
//	static final boolean doFieldObservation = true;
101
//	static final boolean doDeriveUnit = true;
102
//	static final boolean doLivingBeing = true;
103
//	static final boolean doObservation = true;
104
//	static final boolean doSpecimen = true;
105
//	
106
//	//Media
107
//	static final boolean doMedia = true;
108
//	static final boolean doMediaKey = true;
109
//	static final boolean doFigure = true;
110
//	static final boolean doPhylogenticTree = true;
111
//	
112
//	
113
//	//TaxonBase
114
//	static final boolean doTaxon = true;
115
//	static final boolean doSynonym = true;
116
//	
117
//	static final boolean doSequence = true;
118
//	
119
//	//Names
120
//	static final boolean doViralName = true;
121
//	static final boolean doNonViralName = true;
122
//	static final boolean doBotanicalName = true;
123
//	static final boolean doZoologicalName = true;
124
//	static final boolean doCultivarPlantName = true;
125
//	
126
//	static final boolean doClassification = true;
127
//	
128
//	//TermBase
129
//	static final boolean doFeatureTree = true;
130
//	static final boolean doPolytomousKey = true;
131
//	
132
//	static final boolean doTermVocabulary = true;
133
//	static final boolean doDefinedTermBase = true;
134
//	
135
	
136

    
137
}
(2-2/6)