Project

General

Profile

Download (4.61 KB) Statistics
| Branch: | Revision:
1 91138b6c Andreas Müller
/**
2
* Copyright (C) 2007 EDIT
3 50818ab7 Katja Luther
* European Distributed Institute of Taxonomy
4 91138b6c Andreas Müller
* http://www.e-taxonomy.eu
5 50818ab7 Katja Luther
*
6 91138b6c Andreas Müller
* 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.util.Arrays;
13
import java.util.List;
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.CacheUpdaterConfigurator;
21
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
22 50818ab7 Katja Luther
import eu.etaxonomy.cdm.io.common.ImportResult;
23 91138b6c Andreas Müller
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
24
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
25
26
27
/**
28
 * TODO add the following to a wiki page:
29 50818ab7 Katja Luther
 * 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
30 91138b6c Andreas Müller
 * you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
31 50818ab7 Katja Luther
 *
32
 *
33 91138b6c Andreas Müller
 * @author a.mueller
34
 *
35
 */
36
public class CichorieaeCacheUpdater {
37
	private static final Logger logger = Logger.getLogger(CichorieaeCacheUpdater.class);
38
39
	//database validation status (create, update, validate ...)
40
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
41
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_cichorieae();
42
43
	static final List<String> classListStrings =  Arrays.asList(new String[]{
44
			//IdentifiableEntity.class.getName(),
45
//			IdentifiableEntity.class.getName(),
46
			TaxonNameBase.class.getName(),
47
			TaxonBase.class.getName()
48
	});
49
	//new ArrayList<Class<? extends IdentifiableEntity>>();
50
51 50818ab7 Katja Luther
// **************** ALL *********************
52 91138b6c Andreas Müller
53
//	//DescriptionBase
54
//	static final boolean doTaxonDescription = true;
55
//	static final boolean doSpecimenDescription = true;
56
//	static final boolean doNameDescription = true;
57 50818ab7 Katja Luther
//
58 91138b6c Andreas Müller
//	//AgentBase
59
//	static final boolean doPerson = true;
60
//	static final boolean doTeam = true;
61
//	static final boolean doInstitution = true;
62 50818ab7 Katja Luther
//
63 91138b6c Andreas Müller
//	//MediaEntities
64
//	static final boolean doCollection = true;
65
//	static final boolean doReferenceBase = true;
66 50818ab7 Katja Luther
//
67 91138b6c Andreas Müller
//	//SpecimenOrObservationBase
68
//	static final boolean doFieldObservation = true;
69
//	static final boolean doDeriveUnit = true;
70
//	static final boolean doLivingBeing = true;
71
//	static final boolean doObservation = true;
72
//	static final boolean doSpecimen = true;
73 50818ab7 Katja Luther
//
74 91138b6c Andreas Müller
//	//Media
75
//	static final boolean doMedia = true;
76
//	static final boolean doMediaKey = true;
77
//	static final boolean doFigure = true;
78
//	static final boolean doPhylogenticTree = true;
79 50818ab7 Katja Luther
//
80
//
81 91138b6c Andreas Müller
//	//TaxonBase
82
//	static final boolean doTaxon = true;
83
//	static final boolean doSynonym = true;
84 50818ab7 Katja Luther
//
85 91138b6c Andreas Müller
//	static final boolean doSequence = true;
86 50818ab7 Katja Luther
//
87 91138b6c Andreas Müller
//	//Names
88
//	static final boolean doViralName = true;
89
//	static final boolean doNonViralName = true;
90
//	static final boolean doBotanicalName = true;
91
//	static final boolean doZoologicalName = true;
92
//	static final boolean doCultivarPlantName = true;
93 50818ab7 Katja Luther
//
94 401fe405 Andreas Müller
//	static final boolean doClassification = true;
95 50818ab7 Katja Luther
//
96 91138b6c Andreas Müller
//	//TermBase
97
//	static final boolean doFeatureTree = true;
98
//	static final boolean doPolytomousKey = true;
99 50818ab7 Katja Luther
//
100 91138b6c Andreas Müller
//	static final boolean doTermVocabulary = true;
101
//	static final boolean doDefinedTermBase = true;
102 50818ab7 Katja Luther
//
103
104
105
	private ImportResult doInvoke(ICdmDataSource destination){
106
		ImportResult success;
107 91138b6c Andreas Müller
108
		CacheUpdaterConfigurator config;
109
		try {
110
			config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings);
111 50818ab7 Katja Luther
112 91138b6c Andreas Müller
			// invoke import
113
			CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<CacheUpdaterConfigurator>();
114 50818ab7 Katja Luther
			success = myImport.invoke(config);
115
			String successString = success.isSuccess() ? "successful" : " with errors ";
116 91138b6c Andreas Müller
			System.out.println("End updating caches for "+ destination.getDatabase() + "..." +  successString);
117
			return success;
118
		} catch (ClassNotFoundException e) {
119
			logger.error(e);
120 50818ab7 Katja Luther
			success = new ImportResult();
121
			success.setSuccess(false);
122
			success.addReport(e.getMessage().getBytes());
123
			return success;
124
		}
125 91138b6c Andreas Müller
	}
126 50818ab7 Katja Luther
127 91138b6c Andreas Müller
	/**
128
	 * @param args
129
	 */
130
	public static void main(String[] args) {
131
		ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
132 50818ab7 Katja Luther
133 91138b6c Andreas Müller
		System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
134
		CichorieaeCacheUpdater me = new CichorieaeCacheUpdater();
135
		me.doInvoke(destination);
136 50818ab7 Katja Luther
137 91138b6c Andreas Müller
	}
138
139
}