Revision 8072bd02
Added by Andreas Müller about 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/berlinModelImport/AlgaTerraActivator.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 |
*/ |
... | ... | |
13 | 13 |
|
14 | 14 |
import org.apache.log4j.Logger; |
15 | 15 |
|
16 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
|
|
16 |
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
|
17 | 17 |
import eu.etaxonomy.cdm.api.service.ITermService; |
18 | 18 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
19 | 19 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
... | ... | |
35 | 35 |
|
36 | 36 |
/** |
37 | 37 |
* TODO add the following to a wiki page: |
38 |
* 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
|
|
38 |
* 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 |
|
39 | 39 |
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names. |
40 |
*
|
|
41 |
*
|
|
40 |
* |
|
41 |
* |
|
42 | 42 |
* @author a.mueller |
43 | 43 |
* |
44 | 44 |
*/ |
... | ... | |
53 | 53 |
|
54 | 54 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_algaterra_preview(); |
55 | 55 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_algaterra_production(); |
56 |
|
|
57 |
|
|
56 |
|
|
57 |
|
|
58 | 58 |
static final UUID treeUuid = UUID.fromString("1f617402-78dc-4bf1-ac77-d260600a8879"); |
59 | 59 |
static final int sourceSecId = 7331; |
60 | 60 |
static final UUID sourceRefUuid = UUID.fromString("7e1a2500-93a5-40c2-ba34-0213d7822379"); |
61 |
|
|
61 |
|
|
62 | 62 |
static final UUID featureTreeUuid = UUID.fromString("a970168a-36fd-4c7c-931e-87214a965c14"); |
63 |
static final Object[] featureKeyList = new Integer[]{7,201,203,204,206,207};
|
|
63 |
static final Object[] featureKeyList = new Integer[]{7,201,203,204,206,207}; |
|
64 | 64 |
static final UUID specimenFeatureTreeUuid = UUID.fromString("ba86246e-d4d0-419f-832e-86d70b1e4bd7"); |
65 |
|
|
65 |
|
|
66 | 66 |
static final boolean loginAsDefaultAdmin = true; |
67 | 67 |
//TODO set to false for final import |
68 | 68 |
static final boolean removeRestricted = true; |
69 |
|
|
69 |
|
|
70 | 70 |
static final boolean importOriginalSizeMedia = false; |
71 |
|
|
71 |
|
|
72 | 72 |
//check - import |
73 | 73 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
74 | 74 |
|
75 | 75 |
private boolean ignoreNull = true; |
76 |
|
|
76 |
|
|
77 | 77 |
private boolean includeFlatClassifications = true; |
78 | 78 |
private boolean includeAllNonMisappliedRelatedClassifications = true; |
79 |
|
|
79 |
|
|
80 | 80 |
private EDITOR editor = EDITOR.EDITOR_AS_EDITOR; |
81 | 81 |
|
82 | 82 |
//NomenclaturalCode |
83 | 83 |
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICNAFP; |
84 |
|
|
84 |
|
|
85 | 85 |
static String factFilter = " factCategoryFk NOT IN (7, 201, 202, 203, 204, 205, 206, 207, 208, 1000 ) "; |
86 |
|
|
87 |
|
|
86 |
|
|
87 |
|
|
88 | 88 |
// ****************** ALL ***************************************** |
89 |
|
|
89 |
|
|
90 | 90 |
//authors |
91 | 91 |
static final boolean doAuthors = true; |
92 | 92 |
//references |
... | ... | |
95 | 95 |
static final boolean doTaxonNames = true; |
96 | 96 |
static final boolean doRelNames = true; |
97 | 97 |
static final boolean doNameStatus = true; |
98 |
static final boolean doTypes = true;
|
|
99 |
|
|
98 |
static final boolean doTypes = true; |
|
99 |
|
|
100 | 100 |
//taxa |
101 | 101 |
static final boolean doTaxa = true; |
102 | 102 |
static final boolean doRelTaxa = true; |
103 | 103 |
static final boolean doFacts = true; |
104 |
|
|
104 |
|
|
105 | 105 |
//alga terra specific |
106 | 106 |
static final boolean ecoFacts = true; |
107 | 107 |
static final boolean doFactEcology = true; |
... | ... | |
110 | 110 |
static final boolean doMorphology = true; |
111 | 111 |
|
112 | 112 |
// ************************ NONE **************************************** // |
113 |
|
|
113 |
|
|
114 | 114 |
// //authors |
115 | 115 |
// static final boolean doAuthors = false; |
116 | 116 |
// //references |
... | ... | |
121 | 121 |
// static final boolean doNameStatus = false; |
122 | 122 |
// static final boolean doTypes = true; |
123 | 123 |
// static final boolean doNameFacts = false; |
124 |
//
|
|
124 |
// |
|
125 | 125 |
// //taxa |
126 | 126 |
// static final boolean doTaxa = false; |
127 | 127 |
// static final boolean doRelTaxa = false; |
128 | 128 |
// static final boolean doFacts = false; |
129 |
//
|
|
129 |
// |
|
130 | 130 |
// //alga terra specific |
131 | 131 |
// static final boolean ecoFacts = false; |
132 | 132 |
// static final boolean doFactEcology = false; |
133 | 133 |
// static final boolean doImages = false; |
134 | 134 |
// static final boolean doDna = false; |
135 | 135 |
// static final boolean doMorphology = false; |
136 |
|
|
137 |
|
|
136 |
|
|
137 |
|
|
138 | 138 |
public void invoke(String[] args){ |
139 | 139 |
System.out.println("Start import from BerlinModel("+ berlinModelSource.getDatabase() + ") ..."); |
140 | 140 |
logger.debug("Start"); |
141 | 141 |
//make BerlinModel Source |
142 | 142 |
Source source = berlinModelSource; |
143 | 143 |
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination; |
144 |
|
|
144 |
|
|
145 | 145 |
AlgaTerraImportConfigurator config = AlgaTerraImportConfigurator.NewInstance(source, destination); |
146 |
|
|
146 |
|
|
147 | 147 |
config.setClassificationUuid(treeUuid); |
148 | 148 |
config.setSourceSecId(sourceSecId); |
149 | 149 |
config.setNomenclaturalCode(nomenclaturalCode); |
... | ... | |
154 | 154 |
config.setDoRelNames(doRelNames); |
155 | 155 |
config.setDoNameStatus(doNameStatus); |
156 | 156 |
config.setDoTypes(doTypes); |
157 |
|
|
157 |
|
|
158 | 158 |
config.setDoTaxa(doTaxa); |
159 | 159 |
config.setDoRelTaxa(doRelTaxa); |
160 | 160 |
config.setDoFacts(doFacts); |
... | ... | |
163 | 163 |
config.setDoFactEcology(doFactEcology); |
164 | 164 |
config.setDoDna(doDna); |
165 | 165 |
config.setDoMorphology(doMorphology); |
166 |
|
|
166 |
|
|
167 | 167 |
config.setSourceRefUuid(sourceRefUuid); |
168 | 168 |
config.setIgnoreNull(ignoreNull); |
169 | 169 |
config.setRemoveRestricted(removeRestricted); |
170 | 170 |
config.setImportOriginalSizeMedia(importOriginalSizeMedia); |
171 |
|
|
171 |
|
|
172 | 172 |
config.setIncludeFlatClassifications(includeFlatClassifications); |
173 | 173 |
config.setIncludeAllNonMisappliedRelatedClassifications(includeAllNonMisappliedRelatedClassifications); |
174 | 174 |
config.setFactFilter(factFilter); |
175 |
|
|
175 |
|
|
176 | 176 |
config.setDbSchemaValidation(hbm2dll); |
177 | 177 |
|
178 | 178 |
config.setCheck(check); |
179 | 179 |
config.setEditor(editor); |
180 |
|
|
180 |
|
|
181 | 181 |
if (loginAsDefaultAdmin){ |
182 | 182 |
config.authenticateAsDefaultAdmin(); |
183 | 183 |
} |
184 |
|
|
184 |
|
|
185 | 185 |
// invoke import |
186 | 186 |
CdmDefaultImport<BerlinModelImportConfigurator> bmImport = new CdmDefaultImport<BerlinModelImportConfigurator>(); |
187 | 187 |
bmImport.invoke(config); |
188 | 188 |
|
189 | 189 |
if (doFacts && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){ |
190 |
ICdmApplicationConfiguration app = bmImport.getCdmAppController();
|
|
191 |
|
|
190 |
ICdmRepository app = bmImport.getCdmAppController();
|
|
191 |
|
|
192 | 192 |
//make feature tree |
193 | 193 |
makeTaxonFeatureTree(config, app); |
194 | 194 |
|
... | ... | |
197 | 197 |
makeSpecimenFeatureTree(config, app); |
198 | 198 |
|
199 | 199 |
} |
200 |
|
|
201 |
|
|
200 |
|
|
201 |
|
|
202 | 202 |
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")..."); |
203 | 203 |
} |
204 | 204 |
|
... | ... | |
207 | 207 |
* @param config |
208 | 208 |
* @param app |
209 | 209 |
*/ |
210 |
private void makeTaxonFeatureTree(AlgaTerraImportConfigurator config, ICdmApplicationConfiguration app) {
|
|
210 |
private void makeTaxonFeatureTree(AlgaTerraImportConfigurator config, ICdmRepository app) {
|
|
211 | 211 |
FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, config.getFeatureMap(), featureKeyList); |
212 | 212 |
tree.setTitleCache("AlgaTerra Taxon Feature Tree", true); |
213 |
|
|
213 |
|
|
214 | 214 |
FeatureNode node = FeatureNode.NewInstance(Feature.HABITAT()); |
215 | 215 |
tree.getRoot().addChild(node); |
216 |
|
|
216 |
|
|
217 | 217 |
// node = FeatureNode.NewInstance(Feature.OBSERVATION()); |
218 | 218 |
// tree.getRoot().addChild(node); |
219 |
//
|
|
219 |
// |
|
220 | 220 |
// node = FeatureNode.NewInstance(Feature.SPECIMEN()); |
221 | 221 |
// tree.getRoot().addChild(node); |
222 |
//
|
|
222 |
// |
|
223 | 223 |
// node = FeatureNode.NewInstance(Feature.INDIVIDUALS_ASSOCIATION()); |
224 | 224 |
// tree.getRoot().addChild(node); |
225 |
|
|
225 |
|
|
226 | 226 |
//needed ?? |
227 | 227 |
FeatureNode distributionNode = FeatureNode.NewInstance(Feature.DISTRIBUTION()); |
228 | 228 |
tree.getRoot().addChild(distributionNode, 2); |
229 |
|
|
229 |
|
|
230 | 230 |
// //needed ?? |
231 | 231 |
// FeatureNode imageNode = FeatureNode.NewInstance(Feature.IMAGE()); |
232 | 232 |
// tree.getRoot().addChild(imageNode); |
233 |
|
|
233 |
|
|
234 | 234 |
app.getFeatureTreeService().saveOrUpdate(tree); |
235 | 235 |
} |
236 | 236 |
|
... | ... | |
240 | 240 |
* @param app |
241 | 241 |
* @param tree |
242 | 242 |
*/ |
243 |
private void makeSpecimenFeatureTree(AlgaTerraImportConfigurator config, ICdmApplicationConfiguration app) {
|
|
243 |
private void makeSpecimenFeatureTree(AlgaTerraImportConfigurator config, ICdmRepository app) {
|
|
244 | 244 |
ITermService termService = app.getTermService(); |
245 | 245 |
FeatureTree specimenTree = FeatureTree.NewInstance(specimenFeatureTreeUuid); |
246 | 246 |
// FeatureTree specimenTree = TreeCreator.flatTree(specimenFeatureTreeUuid, config.getFeatureMap(), featureKeyList); |
247 | 247 |
specimenTree.setTitleCache("AlgaTerra Specimen Feature Tree", true); |
248 | 248 |
FeatureNode root = specimenTree.getRoot(); |
249 |
|
|
250 |
|
|
249 |
|
|
250 |
|
|
251 | 251 |
FeatureNode imageNode = FeatureNode.NewInstance(Feature.IMAGE()); |
252 | 252 |
root.addChild(imageNode); |
253 |
|
|
253 |
|
|
254 | 254 |
addFeatureNodeByUuid(root, termService, AlgaTerraSpecimenImportBase.uuidFeatureAlgaTerraClimate); |
255 | 255 |
FeatureNode node = FeatureNode.NewInstance(Feature.HABITAT()); |
256 | 256 |
root.addChild(node); |
257 | 257 |
addFeatureNodeByUuid(root, termService, AlgaTerraSpecimenImportBase.uuidFeatureHabitatExplanation); |
258 | 258 |
addFeatureNodeByUuid(root, termService, AlgaTerraSpecimenImportBase.uuidFeatureAlgaTerraLifeForm); |
259 |
|
|
259 |
|
|
260 | 260 |
addFeatureNodeByUuid(root, termService, AlgaTerraSpecimenImportBase.uuidFeatureAdditionalData); |
261 | 261 |
addFeatureNodeByUuid(root, termService, AlgaTerraSpecimenImportBase.uuidFeatureSpecimenCommunity); |
262 |
|
|
262 |
|
|
263 | 263 |
addFeatureNodeByUuid(root, termService, AlgaTerraImportTransformer.uuidFeaturePH); |
264 | 264 |
addFeatureNodeByUuid(root, termService, AlgaTerraImportTransformer.uuidFeatureConductivity); |
265 | 265 |
addFeatureNodeByUuid(root, termService, AlgaTerraImportTransformer.uuidFeatureWaterTemperature); |
... | ... | |
279 | 279 |
addFeatureNodeByUuid(root, termService, AlgaTerraImportTransformer.uuidFeatureCommunity); |
280 | 280 |
app.getFeatureTreeService().saveOrUpdate(specimenTree); |
281 | 281 |
} |
282 |
|
|
282 |
|
|
283 | 283 |
private FeatureNode makeNitrogenNode(FeatureNode root, ITermService termService) { |
284 | 284 |
Feature nFeature = Feature.NewInstance("Supra feature for all Nitrogen related subfeatures", "Nitrogen", "N"); |
285 | 285 |
termService.save(nFeature); |
... | ... | |
308 | 308 |
Feature feature = (Feature)termService.find(featureUuid); |
309 | 309 |
if (feature != null){ |
310 | 310 |
FeatureNode child = FeatureNode.NewInstance(feature); |
311 |
root.addChild(child);
|
|
311 |
root.addChild(child); |
|
312 | 312 |
} |
313 | 313 |
} |
314 |
|
|
315 |
|
|
314 |
|
|
315 |
|
|
316 | 316 |
/** |
317 | 317 |
* @param args |
318 | 318 |
*/ |
Also available in: Unified diff
ref #6419 adapt to CdmRepository in cdmlib-app