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.io.common.ImportResult;
|
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 ImportResult doInvoke(ICdmDataSource destination){
|
61
|
ImportResult result = new ImportResult();
|
62
|
|
63
|
CacheUpdaterConfigurator config;
|
64
|
try {
|
65
|
config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings);
|
66
|
|
67
|
// invoke import
|
68
|
CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<>();
|
69
|
result = myImport.invoke(config);
|
70
|
//String successString = success ? "successful" : " with errors ";
|
71
|
//System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString);
|
72
|
return result;
|
73
|
} catch (ClassNotFoundException e) {
|
74
|
logger.error(e);
|
75
|
result.addException(e);
|
76
|
return result;
|
77
|
}
|
78
|
}
|
79
|
|
80
|
/**
|
81
|
* @param args
|
82
|
*/
|
83
|
public static void main(String[] args) {
|
84
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
85
|
|
86
|
System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
|
87
|
CacheUpdater me = new CacheUpdater();
|
88
|
me.doInvoke(destination);
|
89
|
|
90
|
}
|
91
|
|
92
|
// **************** ALL *********************
|
93
|
|
94
|
// //DescriptionBase
|
95
|
// static final boolean doTaxonDescription = true;
|
96
|
// static final boolean doSpecimenDescription = true;
|
97
|
// static final boolean doNameDescription = true;
|
98
|
//
|
99
|
// //AgentBase
|
100
|
// static final boolean doPerson = true;
|
101
|
// static final boolean doTeam = true;
|
102
|
// static final boolean doInstitution = true;
|
103
|
//
|
104
|
// //MediaEntities
|
105
|
// static final boolean doCollection = true;
|
106
|
// static final boolean doReferenceBase = true;
|
107
|
//
|
108
|
// //SpecimenOrObservationBase
|
109
|
// static final boolean doFieldObservation = true;
|
110
|
// static final boolean doDeriveUnit = true;
|
111
|
// static final boolean doLivingBeing = true;
|
112
|
// static final boolean doObservation = true;
|
113
|
// static final boolean doSpecimen = true;
|
114
|
//
|
115
|
// //Media
|
116
|
// static final boolean doMedia = true;
|
117
|
// static final boolean doMediaKey = true;
|
118
|
// static final boolean doFigure = true;
|
119
|
// static final boolean doPhylogenticTree = true;
|
120
|
//
|
121
|
//
|
122
|
// //TaxonBase
|
123
|
// static final boolean doTaxon = true;
|
124
|
// static final boolean doSynonym = true;
|
125
|
//
|
126
|
// static final boolean doSequence = true;
|
127
|
//
|
128
|
// //Names
|
129
|
// static final boolean doTaxonName = true;
|
130
|
//
|
131
|
// static final boolean doClassification = true;
|
132
|
//
|
133
|
// //TermBase
|
134
|
// static final boolean doFeatureTree = true;
|
135
|
// static final boolean doPolytomousKey = true;
|
136
|
//
|
137
|
// static final boolean doTermVocabulary = true;
|
138
|
// static final boolean doDefinedTermBase = true;
|
139
|
//
|
140
|
|
141
|
|
142
|
}
|