Project

General

Profile

Download (4.94 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.ICdmDataSource;
18
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator;
19
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
20
import eu.etaxonomy.cdm.model.agent.AgentBase;
21
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
22
import eu.etaxonomy.cdm.model.reference.Reference;
23
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
24

    
25

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

    
38
	//database validation status (create, update, validate ...)
39
//	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
40
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview_direct();
41
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_cichorieae();
42
//	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
43
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_euromed3();
44
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_flora_deutschland();
45
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales();
46
	
47

    
48
	static final List<String> classListStrings =  Arrays.asList(new String[]{
49
			//IdentifiableEntity.class.getName(),
50
//			IdentifiableEntity.class.getName(),
51
//			AgentBase.class.getName(),
52
			Reference.class.getName(),
53
			TaxonNameBase.class.getName(),
54
			TaxonBase.class.getName()
55
	});
56
	//new ArrayList<Class<? extends IdentifiableEntity>>();
57

    
58

    
59
	
60
	private boolean doInvoke(ICdmDataSource destination){
61
		boolean success = true;
62

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

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

    
145
}
(2-2/6)