Revision 50818ab7
Added by Katja Luther over 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/wp6/cichorieae/CichorieaeCacheUpdater.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
19 | 19 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
20 | 20 |
import eu.etaxonomy.cdm.io.common.CacheUpdaterConfigurator; |
21 | 21 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
22 |
import eu.etaxonomy.cdm.io.common.ImportResult; |
|
22 | 23 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
23 | 24 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
24 | 25 |
|
25 | 26 |
|
26 | 27 |
/** |
27 | 28 |
* 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 bas under another operation systen
|
|
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 bas under another operation systen |
|
29 | 30 |
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names. |
30 |
*
|
|
31 |
*
|
|
31 |
* |
|
32 |
* |
|
32 | 33 |
* @author a.mueller |
33 | 34 |
* |
34 | 35 |
*/ |
... | ... | |
47 | 48 |
}); |
48 | 49 |
//new ArrayList<Class<? extends IdentifiableEntity>>(); |
49 | 50 |
|
50 |
// **************** ALL *********************
|
|
51 |
// **************** ALL ********************* |
|
51 | 52 |
|
52 | 53 |
// //DescriptionBase |
53 | 54 |
// static final boolean doTaxonDescription = true; |
54 | 55 |
// static final boolean doSpecimenDescription = true; |
55 | 56 |
// static final boolean doNameDescription = true; |
56 |
//
|
|
57 |
// |
|
57 | 58 |
// //AgentBase |
58 | 59 |
// static final boolean doPerson = true; |
59 | 60 |
// static final boolean doTeam = true; |
60 | 61 |
// static final boolean doInstitution = true; |
61 |
//
|
|
62 |
// |
|
62 | 63 |
// //MediaEntities |
63 | 64 |
// static final boolean doCollection = true; |
64 | 65 |
// static final boolean doReferenceBase = true; |
65 |
//
|
|
66 |
// |
|
66 | 67 |
// //SpecimenOrObservationBase |
67 | 68 |
// static final boolean doFieldObservation = true; |
68 | 69 |
// static final boolean doDeriveUnit = true; |
69 | 70 |
// static final boolean doLivingBeing = true; |
70 | 71 |
// static final boolean doObservation = true; |
71 | 72 |
// static final boolean doSpecimen = true; |
72 |
//
|
|
73 |
// |
|
73 | 74 |
// //Media |
74 | 75 |
// static final boolean doMedia = true; |
75 | 76 |
// static final boolean doMediaKey = true; |
76 | 77 |
// static final boolean doFigure = true; |
77 | 78 |
// static final boolean doPhylogenticTree = true; |
78 |
//
|
|
79 |
//
|
|
79 |
// |
|
80 |
// |
|
80 | 81 |
// //TaxonBase |
81 | 82 |
// static final boolean doTaxon = true; |
82 | 83 |
// static final boolean doSynonym = true; |
83 |
//
|
|
84 |
// |
|
84 | 85 |
// static final boolean doSequence = true; |
85 |
//
|
|
86 |
// |
|
86 | 87 |
// //Names |
87 | 88 |
// static final boolean doViralName = true; |
88 | 89 |
// static final boolean doNonViralName = true; |
89 | 90 |
// static final boolean doBotanicalName = true; |
90 | 91 |
// static final boolean doZoologicalName = true; |
91 | 92 |
// static final boolean doCultivarPlantName = true; |
92 |
//
|
|
93 |
// |
|
93 | 94 |
// static final boolean doClassification = true; |
94 |
//
|
|
95 |
// |
|
95 | 96 |
// //TermBase |
96 | 97 |
// static final boolean doFeatureTree = true; |
97 | 98 |
// static final boolean doPolytomousKey = true; |
98 |
//
|
|
99 |
// |
|
99 | 100 |
// static final boolean doTermVocabulary = true; |
100 | 101 |
// static final boolean doDefinedTermBase = true; |
101 |
//
|
|
102 |
|
|
103 |
|
|
104 |
private boolean doInvoke(ICdmDataSource destination){
|
|
105 |
boolean success = true;
|
|
102 |
// |
|
103 |
|
|
104 |
|
|
105 |
private ImportResult doInvoke(ICdmDataSource destination){
|
|
106 |
ImportResult success;
|
|
106 | 107 |
|
107 | 108 |
CacheUpdaterConfigurator config; |
108 | 109 |
try { |
109 | 110 |
config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings); |
110 |
|
|
111 |
|
|
111 | 112 |
// invoke import |
112 | 113 |
CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<CacheUpdaterConfigurator>(); |
113 |
success &= myImport.invoke(config);
|
|
114 |
String successString = success ? "successful" : " with errors "; |
|
114 |
success = myImport.invoke(config); |
|
115 |
String successString = success.isSuccess() ? "successful" : " with errors ";
|
|
115 | 116 |
System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString); |
116 | 117 |
return success; |
117 | 118 |
} catch (ClassNotFoundException e) { |
118 | 119 |
logger.error(e); |
119 |
return false; |
|
120 |
} |
|
120 |
success = new ImportResult(); |
|
121 |
success.setSuccess(false); |
|
122 |
success.addReport(e.getMessage().getBytes()); |
|
123 |
return success; |
|
124 |
} |
|
121 | 125 |
} |
122 |
|
|
126 |
|
|
123 | 127 |
/** |
124 | 128 |
* @param args |
125 | 129 |
*/ |
126 | 130 |
public static void main(String[] args) { |
127 | 131 |
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination; |
128 |
|
|
132 |
|
|
129 | 133 |
System.out.println("Start updating caches for "+ destination.getDatabase() + "..."); |
130 | 134 |
CichorieaeCacheUpdater me = new CichorieaeCacheUpdater(); |
131 | 135 |
me.doInvoke(destination); |
132 |
|
|
136 |
|
|
133 | 137 |
} |
134 | 138 |
|
135 | 139 |
} |
Also available in: Unified diff
adapt the import classes to the new return type ImportResult