1
|
package eu.etaxonomy.cdm.app.caryophyllales;
|
2
|
import java.util.Arrays;
|
3
|
import java.util.List;
|
4
|
|
5
|
import org.apache.log4j.Logger;
|
6
|
|
7
|
|
8
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
9
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
10
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
11
|
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator;
|
12
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
13
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
14
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
15
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
16
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
17
|
|
18
|
public class CaryophyllalesCacheUpdater {
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
private static final Logger logger = Logger.getLogger(CaryophyllalesCacheUpdater.class);
|
25
|
|
26
|
//database validation status (create, update, validate ...)
|
27
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
28
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo();
|
29
|
|
30
|
static final List<String> classListStrings = Arrays.asList(new String[]{
|
31
|
//IdentifiableEntity.class.getName(),
|
32
|
// IdentifiableEntity.class.getName(),
|
33
|
AgentBase.class.getName(),
|
34
|
Reference.class.getName(),
|
35
|
TaxonNameBase.class.getName(),
|
36
|
TaxonBase.class.getName()
|
37
|
|
38
|
|
39
|
});
|
40
|
//new ArrayList<Class<? extends IdentifiableEntity>>();
|
41
|
|
42
|
// **************** ALL *********************
|
43
|
|
44
|
// //DescriptionBase
|
45
|
// static final boolean doTaxonDescription = true;
|
46
|
// static final boolean doSpecimenDescription = true;
|
47
|
// static final boolean doNameDescription = true;
|
48
|
//
|
49
|
// //AgentBase
|
50
|
// static final boolean doPerson = true;
|
51
|
// static final boolean doTeam = true;
|
52
|
// static final boolean doInstitution = true;
|
53
|
//
|
54
|
// //MediaEntities
|
55
|
// static final boolean doCollection = true;
|
56
|
// static final boolean doReferenceBase = true;
|
57
|
//
|
58
|
// //SpecimenOrObservationBase
|
59
|
// static final boolean doFieldObservation = true;
|
60
|
// static final boolean doDeriveUnit = true;
|
61
|
// static final boolean doLivingBeing = true;
|
62
|
// static final boolean doObservation = true;
|
63
|
// static final boolean doSpecimen = true;
|
64
|
//
|
65
|
// //Media
|
66
|
// static final boolean doMedia = true;
|
67
|
// static final boolean doMediaKey = true;
|
68
|
// static final boolean doFigure = true;
|
69
|
// static final boolean doPhylogenticTree = true;
|
70
|
//
|
71
|
//
|
72
|
// //TaxonBase
|
73
|
// static final boolean doTaxon = true;
|
74
|
// static final boolean doSynonym = true;
|
75
|
//
|
76
|
// static final boolean doSequence = true;
|
77
|
//
|
78
|
// //Names
|
79
|
// static final boolean doViralName = true;
|
80
|
// static final boolean doNonViralName = true;
|
81
|
// static final boolean doBotanicalName = true;
|
82
|
// static final boolean doZoologicalName = true;
|
83
|
// static final boolean doCultivarPlantName = true;
|
84
|
//
|
85
|
// static final boolean doClassification = true;
|
86
|
//
|
87
|
// //TermBase
|
88
|
// static final boolean doFeatureTree = true;
|
89
|
// static final boolean doPolytomousKey = true;
|
90
|
//
|
91
|
// static final boolean doTermVocabulary = true;
|
92
|
// static final boolean doDefinedTermBase = true;
|
93
|
//
|
94
|
|
95
|
|
96
|
private boolean doInvoke(ICdmDataSource destination){
|
97
|
boolean success = true;
|
98
|
|
99
|
CacheUpdaterConfigurator config;
|
100
|
try {
|
101
|
config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings);
|
102
|
|
103
|
// invoke import
|
104
|
CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<CacheUpdaterConfigurator>();
|
105
|
success &= myImport.invoke(config);
|
106
|
String successString = success ? "successful" : " with errors ";
|
107
|
System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString);
|
108
|
return success;
|
109
|
} catch (ClassNotFoundException e) {
|
110
|
logger.error(e);
|
111
|
return false;
|
112
|
}
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* @param args
|
117
|
*/
|
118
|
public static void main(String[] args) {
|
119
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
120
|
|
121
|
System.out.println("Start updating caches for "+ destination.getDatabase() + "...");
|
122
|
CaryophyllalesCacheUpdater me = new CaryophyllalesCacheUpdater();
|
123
|
me.doInvoke(destination);
|
124
|
|
125
|
}
|
126
|
|
127
|
}
|
128
|
|
129
|
|