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