Project

General

Profile

Download (4.33 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.taxon.TaxonBase;
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 base 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 CacheUpdater {
34
	private static final Logger logger = Logger.getLogger(CacheUpdater.class);
35

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

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

    
48

    
49
	
50
	private boolean doInvoke(ICdmDataSource destination){
51
		boolean success = true;
52

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

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

    
135
}
(2-2/6)