1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.io.pesi.out;
|
11
|
|
12
|
import static java.util.EnumSet.of;
|
13
|
|
14
|
import java.sql.Connection;
|
15
|
import java.sql.PreparedStatement;
|
16
|
import java.sql.SQLException;
|
17
|
import java.sql.Types;
|
18
|
import java.util.Arrays;
|
19
|
import java.util.HashSet;
|
20
|
import java.util.List;
|
21
|
import java.util.Map;
|
22
|
import java.util.Set;
|
23
|
|
24
|
import org.apache.log4j.Logger;
|
25
|
import org.springframework.stereotype.Component;
|
26
|
import org.springframework.transaction.TransactionStatus;
|
27
|
|
28
|
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;
|
29
|
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
|
30
|
import eu.etaxonomy.cdm.io.common.Source;
|
31
|
import eu.etaxonomy.cdm.io.common.mapping.DbIgnoreMapper;
|
32
|
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
|
33
|
import eu.etaxonomy.cdm.io.common.mapping.out.CollectionExportMapping;
|
34
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbAreaMapper;
|
35
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbConstantMapper;
|
36
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbDescriptionElementTaxonMapper;
|
37
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbDistributionStatusMapper;
|
38
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbExportIgnoreMapper;
|
39
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbExportNotYetImplementedMapper;
|
40
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbLanguageMapper;
|
41
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbObjectMapper;
|
42
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbOriginalNameMapper;
|
43
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbSimpleFilterMapper;
|
44
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbSingleSourceMapper;
|
45
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbStringMapper;
|
46
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbTextDataMapper;
|
47
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbTimePeriodMapper;
|
48
|
import eu.etaxonomy.cdm.io.common.mapping.out.IdMapper;
|
49
|
import eu.etaxonomy.cdm.io.common.mapping.out.MethodMapper;
|
50
|
import eu.etaxonomy.cdm.io.profiler.ProfilerController;
|
51
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
52
|
import eu.etaxonomy.cdm.model.common.Extension;
|
53
|
import eu.etaxonomy.cdm.model.common.ExtensionType;
|
54
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
55
|
import eu.etaxonomy.cdm.model.common.Language;
|
56
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
57
|
import eu.etaxonomy.cdm.model.common.Marker;
|
58
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
59
|
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
|
60
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
61
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
62
|
import eu.etaxonomy.cdm.model.description.Distribution;
|
63
|
import eu.etaxonomy.cdm.model.description.Feature;
|
64
|
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
|
65
|
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
|
66
|
import eu.etaxonomy.cdm.model.description.TextData;
|
67
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
68
|
import eu.etaxonomy.cdm.model.location.TdwgArea;
|
69
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
70
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
71
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
72
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
73
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
74
|
/**
|
75
|
* The export class for {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase DescriptionElements}.<p>
|
76
|
* Inserts into DataWarehouse database table <code>Note</code>.<p>
|
77
|
* It is divided into two phases:<ul>
|
78
|
* <li>Phase 1: Export of DescriptionElements as Notes.
|
79
|
* <li>Phase 2: Export of TaxonName extensions <code>taxComment</code>, <code>fauComment</code> and <code>fauExtraCodes</code> as Notes.</ul>
|
80
|
* @author e.-m.lee
|
81
|
* @date 23.02.2010
|
82
|
*
|
83
|
*/
|
84
|
@Component
|
85
|
public class PesiDescriptionExport extends PesiExportBase {
|
86
|
private static final Logger logger = Logger.getLogger(PesiDescriptionExport.class);
|
87
|
|
88
|
private static final Class<? extends CdmBase> standardMethodParameter = DescriptionElementBase.class;
|
89
|
|
90
|
private static int modCount = 1000;
|
91
|
private static final String dbNoteTableName = "Note";
|
92
|
private static final String dbOccurrenceTableName = "Occurrence";
|
93
|
private static final String dbVernacularTableName = "CommonName";
|
94
|
private static final String dbImageTableName = "Image";
|
95
|
private static final String dbAdditionalSourceTableName = "AdditionalTaxonSource";
|
96
|
private static final String pluralString = "attached infos";
|
97
|
private static final String parentPluralString = "Taxa";
|
98
|
|
99
|
//decide where to handle them best (configurator, transformer, single method, ...)
|
100
|
private static Set<Integer> excludedNoteCategories = new HashSet<Integer>(Arrays.asList(new Integer[]{250,251,252,253,10,11,13}));
|
101
|
|
102
|
|
103
|
//debugging
|
104
|
private static int countDescriptions;
|
105
|
private static int countTaxa;
|
106
|
private static int countDistribution;
|
107
|
private static int countAdditionalSources;
|
108
|
private static int countImages;
|
109
|
private static int countNotes;
|
110
|
|
111
|
private static int countCommonName;
|
112
|
private static int countOccurrence;
|
113
|
private static int countOthers;
|
114
|
|
115
|
public PesiDescriptionExport() {
|
116
|
super();
|
117
|
}
|
118
|
|
119
|
/* (non-Javadoc)
|
120
|
* @see eu.etaxonomy.cdm.io.common.DbExportBase#getStandardMethodParameter()
|
121
|
*/
|
122
|
@Override
|
123
|
public Class<? extends CdmBase> getStandardMethodParameter() {
|
124
|
return standardMethodParameter;
|
125
|
}
|
126
|
|
127
|
/* (non-Javadoc)
|
128
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase)
|
129
|
*/
|
130
|
@Override
|
131
|
protected boolean doCheck(PesiExportState state) {
|
132
|
boolean result = true;
|
133
|
return result;
|
134
|
}
|
135
|
|
136
|
/* (non-Javadoc)
|
137
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doInvoke(eu.etaxonomy.cdm.io.common.IoStateBase)
|
138
|
*/
|
139
|
@Override
|
140
|
protected void doInvoke(PesiExportState state) {
|
141
|
try {
|
142
|
logger.info("*** Started Making " + pluralString + " ...");
|
143
|
|
144
|
// Stores whether this invoke was successful or not.
|
145
|
boolean success = true;
|
146
|
|
147
|
// PESI: Clear the database table Note.
|
148
|
// doDelete(state);
|
149
|
|
150
|
// Start transaction
|
151
|
success &= doPhase01(state);
|
152
|
|
153
|
|
154
|
logger.info("PHASE 2...");
|
155
|
success &= doPhase02(state);
|
156
|
|
157
|
|
158
|
logger.info("*** Finished Making " + pluralString + " ..." + getSuccessString(success));
|
159
|
|
160
|
if (!success){
|
161
|
state.setUnsuccessfull();
|
162
|
}
|
163
|
return;
|
164
|
} catch (SQLException e) {
|
165
|
e.printStackTrace();
|
166
|
logger.error(e.getMessage());
|
167
|
state.setUnsuccessfull();
|
168
|
}
|
169
|
}
|
170
|
|
171
|
//PHASE 01: Description Elements
|
172
|
private boolean doPhase01(PesiExportState state) throws SQLException {
|
173
|
logger.info("PHASE 1...");
|
174
|
int count = 0;
|
175
|
int pastCount = 0;
|
176
|
boolean success = true;
|
177
|
int limit = state.getConfig().getLimitSave();
|
178
|
|
179
|
// Get specific mappings: (CDM) DescriptionElement -> (PESI) Note
|
180
|
PesiExportMapping notesMapping = getNotesMapping();
|
181
|
notesMapping.initialize(state);
|
182
|
|
183
|
// Get specific mappings: (CDM) DescriptionElement -> (PESI) Occurrence
|
184
|
PesiExportMapping occurrenceMapping = getOccurrenceMapping();
|
185
|
occurrenceMapping.initialize(state);
|
186
|
|
187
|
// Get specific mappings: (CDM) DescriptionElement -> (PESI) Additional taxon source
|
188
|
PesiExportMapping addSourceSourceMapping = getAddTaxonSourceSourceMapping();
|
189
|
addSourceSourceMapping.initialize(state);
|
190
|
PesiExportMapping additionalSourceMapping = getAdditionalTaxonSourceMapping();
|
191
|
additionalSourceMapping.initialize(state);
|
192
|
|
193
|
// Get specific mappings: (CDM) DescriptionElement -> (PESI) Additional taxon source
|
194
|
PesiExportMapping vernacularMapping = getVernacularNamesMapping();
|
195
|
vernacularMapping.initialize(state);
|
196
|
|
197
|
// Get specific mappings: (CDM) DescriptionElement -> (PESI) Additional taxon source
|
198
|
PesiExportMapping imageMapping = getImageMapping();
|
199
|
imageMapping.initialize(state);
|
200
|
|
201
|
|
202
|
List<Taxon> list = null;
|
203
|
|
204
|
TransactionStatus txStatus = startTransaction(true);
|
205
|
logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
|
206
|
List<String> propPath = Arrays.asList(new String[]{"descriptions.elements.*"});
|
207
|
|
208
|
logger.debug("Start snapshot, before starting loop");
|
209
|
ProfilerController.memorySnapshot();
|
210
|
//taxon descriptions
|
211
|
int partitionCount = 0;
|
212
|
while ((list = getNextTaxonPartition(Taxon.class, limit, partitionCount++, propPath )) != null ) {
|
213
|
|
214
|
logger.info("Fetched " + list.size() + " " + pluralString + ". Exporting...");
|
215
|
|
216
|
logger.debug("Start snapshot, beginning of loop, fetched " + list.size() + " " + pluralString);
|
217
|
ProfilerController.memorySnapshot();
|
218
|
|
219
|
for (Taxon taxon : list) {
|
220
|
countTaxa++;
|
221
|
doCount(count++, modCount, pluralString);
|
222
|
success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addSourceSourceMapping,
|
223
|
additionalSourceMapping, vernacularMapping, imageMapping);
|
224
|
}
|
225
|
list = null;
|
226
|
state.setCurrentTaxon(null);
|
227
|
|
228
|
// Commit transaction
|
229
|
commitTransaction(txStatus);
|
230
|
logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count);
|
231
|
pastCount = count;
|
232
|
|
233
|
// Start transaction
|
234
|
txStatus = startTransaction(true);
|
235
|
logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") for description import ...");
|
236
|
logger.debug("Start snapshot, end of loop, fetched " + " " + pluralString);
|
237
|
ProfilerController.memorySnapshot();
|
238
|
}
|
239
|
|
240
|
// //name descriptions
|
241
|
// while ((list = getNextNameDescriptionPartition( limit, partitionCount++, propPath )) != null ) {
|
242
|
//
|
243
|
// logger.info("Fetched " + list.size() + " " + pluralString + ". Exporting...");
|
244
|
//
|
245
|
//
|
246
|
// for (Taxon taxon : list) {
|
247
|
// countTaxa++;
|
248
|
// doCount(count++, modCount, pluralString);
|
249
|
// success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addittionalSourceMapping, vernacularMapping, imageMapping);
|
250
|
// }
|
251
|
// state.setCurrentTaxon(null);
|
252
|
//
|
253
|
// // Commit transaction
|
254
|
// commitTransaction(txStatus);
|
255
|
// logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count);
|
256
|
// pastCount = count;
|
257
|
//
|
258
|
// // Start transaction
|
259
|
// txStatus = startTransaction(true);
|
260
|
// logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") for description import ...");
|
261
|
// }
|
262
|
|
263
|
|
264
|
|
265
|
if (list == null) {
|
266
|
logger.info("No " + pluralString + " left to fetch.");
|
267
|
logger.info("Partition: " + partitionCount);
|
268
|
logger.info("Taxa: " + countTaxa);
|
269
|
logger.info("Desc: " + countDescriptions);
|
270
|
logger.info("Distr: " + countDistribution);
|
271
|
logger.info("Occur: " + countOccurrence);
|
272
|
logger.info("Commons: " + countCommonName);
|
273
|
logger.info("AddSrc: " + countAdditionalSources);
|
274
|
logger.info("Images: " + countImages);
|
275
|
logger.info("Notes: " + countNotes);
|
276
|
logger.info("Others: " + countOthers);
|
277
|
|
278
|
}
|
279
|
|
280
|
list = null;
|
281
|
// Commit transaction
|
282
|
commitTransaction(txStatus);
|
283
|
logger.debug("Committed transaction.");
|
284
|
return success;
|
285
|
}
|
286
|
|
287
|
private boolean handleSingleTaxon(Taxon taxon, PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping,
|
288
|
PesiExportMapping addSourceSourceMapping, PesiExportMapping additionalSourceMapping,
|
289
|
PesiExportMapping vernacularMapping, PesiExportMapping imageMapping) throws SQLException {
|
290
|
boolean success = true;
|
291
|
Set<DescriptionBase<?>> descriptions = new HashSet<DescriptionBase<?>>();
|
292
|
descriptions.addAll(taxon.getDescriptions());
|
293
|
|
294
|
//FIXME incorrect as this creates duplicates
|
295
|
descriptions.addAll(taxon.getName().getDescriptions());
|
296
|
|
297
|
state.setCurrentTaxon(taxon);
|
298
|
for (DescriptionBase<?> desc : descriptions){
|
299
|
countDescriptions++;
|
300
|
|
301
|
boolean isImageGallery = desc.isImageGallery();
|
302
|
for (DescriptionElementBase element : desc.getElements()){
|
303
|
success &= handleDescriptionElement(state, notesMapping, occurrenceMapping, vernacularMapping, imageMapping,
|
304
|
addSourceSourceMapping, additionalSourceMapping, isImageGallery, element);
|
305
|
}
|
306
|
}
|
307
|
return success;
|
308
|
}
|
309
|
|
310
|
private boolean handleDescriptionElement(PesiExportState state, PesiExportMapping notesMapping,
|
311
|
PesiExportMapping occurrenceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping,
|
312
|
PesiExportMapping addSourceSourceMapping, PesiExportMapping additionalSourceMapping, boolean isImageGallery, DescriptionElementBase element) throws SQLException {
|
313
|
try {
|
314
|
boolean success = true;
|
315
|
if (isImageGallery){
|
316
|
//TODO handle Images
|
317
|
countImages++;
|
318
|
success &= imageMapping.invoke(element);
|
319
|
}else if (isCommonName(element)){
|
320
|
countCommonName++;
|
321
|
if (element.isInstanceOf(TextData.class)){
|
322
|
//we do not import text data common names
|
323
|
}else{
|
324
|
success &= vernacularMapping.invoke(element);
|
325
|
}
|
326
|
}else if (isOccurrence(element)){
|
327
|
countOccurrence++;
|
328
|
Distribution distribution = CdmBase.deproxy(element, Distribution.class);
|
329
|
MarkerType markerType = getUuidMarkerType(PesiTransformer.uuidMarkerTypeHasNoLastAction, state);
|
330
|
|
331
|
distribution.addMarker(Marker.NewInstance(markerType, true));
|
332
|
if (isPesiDistribution(state, distribution)){
|
333
|
countDistribution++;
|
334
|
success &=occurrenceMapping.invoke(element);
|
335
|
}
|
336
|
}else if (isAdditionalTaxonSource(element)){
|
337
|
countAdditionalSources++;
|
338
|
success &= addSourceSourceMapping.invoke(element);
|
339
|
success &= additionalSourceMapping.invoke(element);
|
340
|
}else if (isExcludedNote(element)){
|
341
|
//do nothing
|
342
|
}else if (isPesiNote(element)){
|
343
|
countNotes++;
|
344
|
success &= notesMapping.invoke(element);
|
345
|
|
346
|
}else{
|
347
|
countOthers++;
|
348
|
String featureTitle = element.getFeature() == null ? "no feature" :element.getFeature().getTitleCache();
|
349
|
logger.warn("Description element type not yet handled by PESI export: " + element.getUuid() + ", " + element.getClass() + ", " + featureTitle);
|
350
|
}
|
351
|
return success;
|
352
|
} catch (Exception e) {
|
353
|
logger.warn("Exception appeared in description element handling: " + e);
|
354
|
e.printStackTrace();
|
355
|
return false;
|
356
|
}
|
357
|
}
|
358
|
|
359
|
private boolean isExcludedNote(DescriptionElementBase element) {
|
360
|
Integer categoryFk = PesiTransformer.feature2NoteCategoryFk(element.getFeature());
|
361
|
//TODO decide where to handle them best (configurator, transformer, single method, ...)
|
362
|
return (excludedNoteCategories.contains(categoryFk));
|
363
|
}
|
364
|
|
365
|
private boolean isPesiDistribution(PesiExportState state, Distribution distribution) {
|
366
|
//currently we use the E+M summary status to decide if a distribution should be exported
|
367
|
if (distribution.getStatus() == null){
|
368
|
return false;
|
369
|
}
|
370
|
|
371
|
//...this may change in future so we keep the following code
|
372
|
Integer key;
|
373
|
//area filter
|
374
|
NamedArea area = distribution.getArea();
|
375
|
if (area == null){
|
376
|
logger.warn("Area is null for distribution " + distribution.getUuid());
|
377
|
return false;
|
378
|
}else if (area.getUuid().equals(BerlinModelTransformer.euroMedUuid)){
|
379
|
//E+M area only holds endemic status information and therefore is not exported to PESI
|
380
|
return false;
|
381
|
}else if (area.equals(TdwgArea.getAreaByTdwgAbbreviation("1"))){
|
382
|
//Europe area never holds status information (may probably be deleted in E+M)
|
383
|
return false;
|
384
|
// }else if (area.equals(TdwgArea.getAreaByTdwgAbbreviation("21"))){
|
385
|
// //Macaronesia records should not be exported to PESI
|
386
|
// return false;
|
387
|
// //TODO exclude Russion areas Rs*, and maybe ohters
|
388
|
|
389
|
} else
|
390
|
try {
|
391
|
if (state.getTransformer().getKeyByNamedArea(area) == null){
|
392
|
logger.warn("Area not available in PESI transformer " + area.getTitleCache() + ", " + area.getRepresentation(Language.ENGLISH()).getAbbreviatedLabel());
|
393
|
return false;
|
394
|
}
|
395
|
} catch (UndefinedTransformerMethodException e1) {
|
396
|
logger.warn("Area not available in PESI transformer " + area.getTitleCache());
|
397
|
return false;
|
398
|
}
|
399
|
return true;
|
400
|
|
401
|
//
|
402
|
// //status
|
403
|
// PresenceAbsenceTermBase<?> status = distribution.getStatus();
|
404
|
// if (status == null){
|
405
|
// logger.warn("No status for distribution: " + distribution.getUuid());
|
406
|
// return false;
|
407
|
// }
|
408
|
// try {
|
409
|
// key = (Integer)state.getTransformer().getKeyByPresenceAbsenceTerm(status);
|
410
|
// if (key != null){
|
411
|
// return true;
|
412
|
// }else{
|
413
|
// logger.warn("PresenceAbsenceTerm " + status.getTitleCache() + "not handled in transformer");
|
414
|
// return false;
|
415
|
// }
|
416
|
// } catch (UndefinedTransformerMethodException e) {
|
417
|
// logger.warn("PresenceAbsenceTerm " + status.getTitleCache() + "not handled in transformer");
|
418
|
// return false;
|
419
|
// }
|
420
|
}
|
421
|
|
422
|
private boolean isPesiNote(DescriptionElementBase element) {
|
423
|
return (getNoteCategoryFk(element) != null);
|
424
|
}
|
425
|
|
426
|
private boolean isAdditionalTaxonSource(DescriptionElementBase element) {
|
427
|
Feature feature = element.getFeature();
|
428
|
if (feature == null){
|
429
|
return false;
|
430
|
}
|
431
|
return (feature.equals(Feature.CITATION()) || feature.equals(Feature.ADDITIONAL_PUBLICATION()));
|
432
|
}
|
433
|
|
434
|
private boolean isOccurrence(DescriptionElementBase element) {
|
435
|
Feature feature = element.getFeature();
|
436
|
if (feature != null && feature.equals(Feature.DISTRIBUTION())){
|
437
|
return true;
|
438
|
}else if (element.isInstanceOf(Distribution.class)){
|
439
|
logger.warn("Description element has class 'Distribution' but has no feature 'Distribution'");
|
440
|
return true;
|
441
|
}else{
|
442
|
return false;
|
443
|
}
|
444
|
}
|
445
|
|
446
|
private boolean isCommonName(DescriptionElementBase element) {
|
447
|
Feature feature = element.getFeature();
|
448
|
if (feature == null){
|
449
|
return false;
|
450
|
}
|
451
|
return (feature.equals(Feature.COMMON_NAME()));
|
452
|
}
|
453
|
|
454
|
//PHASE 02: Name extensions
|
455
|
private boolean doPhase02(PesiExportState state) {
|
456
|
TransactionStatus txStatus;
|
457
|
boolean success = true;
|
458
|
|
459
|
// Get the limit for objects to save within a single transaction.
|
460
|
int limit = state.getConfig().getLimitSave();
|
461
|
|
462
|
txStatus = startTransaction(true);
|
463
|
ExtensionType taxCommentExtensionType = (ExtensionType)getTermService().find(PesiTransformer.taxCommentUuid);
|
464
|
ExtensionType fauCommentExtensionType = (ExtensionType)getTermService().find(PesiTransformer.fauCommentUuid);
|
465
|
ExtensionType fauExtraCodesExtensionType = (ExtensionType)getTermService().find(PesiTransformer.fauExtraCodesUuid);
|
466
|
List<TaxonNameBase> taxonNameList = null;
|
467
|
|
468
|
int count = 0;
|
469
|
int pastCount = 0;
|
470
|
Connection connection = state.getConfig().getDestination().getConnection();
|
471
|
logger.info("Started new transaction. Fetching some " + parentPluralString + " first (max: " + limit + ") ...");
|
472
|
logger.warn("TODO handle extensions on taxon level, not name level (");
|
473
|
while ((taxonNameList = getNameService().list(null, limit, count, null, null)).size() > 0) {
|
474
|
|
475
|
logger.info("Fetched " + taxonNameList.size() + " names. Exporting...");
|
476
|
for (TaxonNameBase<?,?> taxonName : taxonNameList) {
|
477
|
Set<Extension> extensions = taxonName.getExtensions();
|
478
|
for (Extension extension : extensions) {
|
479
|
if (extension.getType().equals(taxCommentExtensionType)) {
|
480
|
String taxComment = extension.getValue();
|
481
|
invokeNotes(taxComment,
|
482
|
PesiTransformer.getNoteCategoryFk(PesiTransformer.taxCommentUuid),
|
483
|
PesiTransformer.getNoteCategoryCache(PesiTransformer.taxCommentUuid),
|
484
|
null, null, getTaxonKey(taxonName, state),connection);
|
485
|
} else if (extension.getType().equals(fauCommentExtensionType)) {
|
486
|
String fauComment = extension.getValue();
|
487
|
invokeNotes(fauComment,
|
488
|
PesiTransformer.getNoteCategoryFk(PesiTransformer.fauCommentUuid),
|
489
|
PesiTransformer.getNoteCategoryCache(PesiTransformer.fauCommentUuid),
|
490
|
null, null, getTaxonKey(taxonName, state),connection);
|
491
|
} else if (extension.getType().equals(fauExtraCodesExtensionType)) {
|
492
|
String fauExtraCodes = extension.getValue();
|
493
|
invokeNotes(fauExtraCodes,
|
494
|
PesiTransformer.getNoteCategoryFk(PesiTransformer.fauExtraCodesUuid),
|
495
|
PesiTransformer.getNoteCategoryCache(PesiTransformer.fauExtraCodesUuid),
|
496
|
null, null, getTaxonKey(taxonName, state),connection);
|
497
|
}
|
498
|
}
|
499
|
|
500
|
doCount(count++, modCount, pluralString);
|
501
|
}
|
502
|
|
503
|
// Commit transaction
|
504
|
commitTransaction(txStatus);
|
505
|
logger.debug("Committed transaction.");
|
506
|
logger.info("Exported " + (count - pastCount) + " names. Total: " + count);
|
507
|
pastCount = count;
|
508
|
|
509
|
// Start transaction
|
510
|
txStatus = startTransaction(true);
|
511
|
logger.info("Started new transaction. Fetching some names first (max: " + limit + ") ...");
|
512
|
}
|
513
|
if (taxonNameList.size() == 0) {
|
514
|
logger.info("No names left to fetch.");
|
515
|
}
|
516
|
taxonNameList = null;
|
517
|
// Commit transaction
|
518
|
commitTransaction(txStatus);
|
519
|
logger.debug("Committed transaction.");
|
520
|
return success;
|
521
|
}
|
522
|
|
523
|
/**
|
524
|
* @param taxComment
|
525
|
* @param noteCategoryFk
|
526
|
* @param noteCategoryCache
|
527
|
* @param object
|
528
|
* @param object2
|
529
|
*/
|
530
|
private void invokeNotes(String note, Integer noteCategoryFk,
|
531
|
String noteCategoryCache, Integer languageFk, String languageCache,
|
532
|
Integer taxonFk, Connection connection) {
|
533
|
String notesSql = "UPDATE Note SET Note_1 = ?, NoteCategoryFk = ?, NoteCategoryCache = ?, LanguageFk = ?, LanguageCache = ? WHERE TaxonFk = ?";
|
534
|
try {
|
535
|
PreparedStatement notesStmt = connection.prepareStatement(notesSql);
|
536
|
|
537
|
if (note != null) {
|
538
|
notesStmt.setString(1, note);
|
539
|
} else {
|
540
|
notesStmt.setObject(1, null);
|
541
|
}
|
542
|
|
543
|
if (noteCategoryFk != null) {
|
544
|
notesStmt.setInt(2, noteCategoryFk);
|
545
|
} else {
|
546
|
notesStmt.setObject(2, null);
|
547
|
}
|
548
|
|
549
|
if (noteCategoryCache != null) {
|
550
|
notesStmt.setString(3, noteCategoryCache);
|
551
|
} else {
|
552
|
notesStmt.setObject(3, null);
|
553
|
}
|
554
|
|
555
|
if (languageFk != null) {
|
556
|
notesStmt.setInt(4, languageFk);
|
557
|
} else {
|
558
|
notesStmt.setObject(4, null);
|
559
|
}
|
560
|
|
561
|
if (languageCache != null) {
|
562
|
notesStmt.setString(5, languageCache);
|
563
|
} else {
|
564
|
notesStmt.setObject(5, null);
|
565
|
}
|
566
|
|
567
|
if (taxonFk != null) {
|
568
|
notesStmt.setInt(6, taxonFk);
|
569
|
} else {
|
570
|
notesStmt.setObject(6, null);
|
571
|
}
|
572
|
|
573
|
notesStmt.executeUpdate();
|
574
|
} catch (SQLException e) {
|
575
|
logger.error("Note could not be created: " + note);
|
576
|
e.printStackTrace();
|
577
|
}
|
578
|
|
579
|
|
580
|
}
|
581
|
|
582
|
/**
|
583
|
* Deletes all entries of database tables related to <code>Note</code>.
|
584
|
* @param state The PesiExportState
|
585
|
* @return Whether the delete operation was successful or not.
|
586
|
*/
|
587
|
protected boolean doDelete(PesiExportState state) {
|
588
|
PesiExportConfigurator pesiConfig = (PesiExportConfigurator) state.getConfig();
|
589
|
|
590
|
String sql;
|
591
|
Source destination = pesiConfig.getDestination();
|
592
|
|
593
|
// Clear NoteSource
|
594
|
sql = "DELETE FROM NoteSource";
|
595
|
destination.setQuery(sql);
|
596
|
destination.update(sql);
|
597
|
|
598
|
// Clear Note
|
599
|
sql = "DELETE FROM " + dbNoteTableName;
|
600
|
destination.setQuery(sql);
|
601
|
destination.update(sql);
|
602
|
return true;
|
603
|
}
|
604
|
|
605
|
/* (non-Javadoc)
|
606
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IoStateBase)
|
607
|
*/
|
608
|
@Override
|
609
|
protected boolean isIgnore(PesiExportState state) {
|
610
|
return ! state.getConfig().isDoDescription();
|
611
|
}
|
612
|
|
613
|
|
614
|
/**
|
615
|
* Returns the <code>Note_2</code> attribute.
|
616
|
* @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
|
617
|
* @return The <code>Note_2</code> attribute.
|
618
|
* @see MethodMapper
|
619
|
*/
|
620
|
@SuppressWarnings("unused") //used for mapper
|
621
|
private static String getNote_2(DescriptionElementBase element) {
|
622
|
//E+M map links -> medium
|
623
|
if (element.getFeature() != null && element.getFeature().getUuid().equals(BerlinModelTransformer.uuidFeatureMaps)){
|
624
|
String text = CdmBase.deproxy(element, TextData.class).getText(Language.ENGLISH());
|
625
|
if (text.contains("medium")){
|
626
|
return "medium";
|
627
|
}
|
628
|
}
|
629
|
return null;
|
630
|
}
|
631
|
|
632
|
/**
|
633
|
* Returns the <code>NoteCategoryFk</code> attribute.
|
634
|
* @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
|
635
|
* @return The <code>NoteCategoryFk</code> attribute.
|
636
|
* @see MethodMapper
|
637
|
*/
|
638
|
private static Integer getNoteCategoryFk(DescriptionElementBase descriptionElement) {
|
639
|
Integer result = null;
|
640
|
result = PesiTransformer.feature2NoteCategoryFk(descriptionElement.getFeature());
|
641
|
//TODO decide where to handle them best (configurator, transformer, single method, ...)
|
642
|
if (excludedNoteCategories.contains(result)){
|
643
|
result = null;
|
644
|
}
|
645
|
return result;
|
646
|
}
|
647
|
|
648
|
/**
|
649
|
* Returns the <code>NoteCategoryCache</code> attribute.
|
650
|
* @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
|
651
|
* @return The <code>NoteCategoryCache</code> attribute.
|
652
|
* @see MethodMapper
|
653
|
*/
|
654
|
@SuppressWarnings("unused")
|
655
|
private static String getNoteCategoryCache(DescriptionElementBase descriptionElement, PesiExportState state) {
|
656
|
return state.getTransformer().getCacheByFeature(descriptionElement.getFeature());
|
657
|
}
|
658
|
|
659
|
|
660
|
|
661
|
|
662
|
/**
|
663
|
* Returns the <code>LanguageFk</code> attribute.
|
664
|
* @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
|
665
|
* @return The <code>LanguageFk</code> attribute.
|
666
|
* @see MethodMapper
|
667
|
*/
|
668
|
@SuppressWarnings("unused")
|
669
|
private static Integer getLanguageFk(DescriptionElementBase descriptionElement) {
|
670
|
Language language = getLanguage(descriptionElement);
|
671
|
|
672
|
return PesiTransformer.language2LanguageId(language);
|
673
|
}
|
674
|
|
675
|
/**
|
676
|
* Returns the <code>LanguageCache</code> attribute.
|
677
|
* @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
|
678
|
* @return The <code>LanguageCache</code> attribute.
|
679
|
* @throws UndefinedTransformerMethodException
|
680
|
* @see MethodMapper
|
681
|
*/
|
682
|
@SuppressWarnings("unused")
|
683
|
private static String getLanguageCache(DescriptionElementBase descriptionElement, PesiExportState state) throws UndefinedTransformerMethodException {
|
684
|
Language language = getLanguage(descriptionElement);
|
685
|
return state.getTransformer().getCacheByLanguage(language);
|
686
|
}
|
687
|
|
688
|
private static Language getLanguage(DescriptionElementBase descriptionElement) {
|
689
|
Language language = null;
|
690
|
|
691
|
Map<Language, LanguageString> multilanguageText = null;
|
692
|
if (descriptionElement.isInstanceOf(CommonTaxonName.class)) {
|
693
|
CommonTaxonName commonTaxonName = CdmBase.deproxy(descriptionElement, CommonTaxonName.class);
|
694
|
language = commonTaxonName.getLanguage();
|
695
|
} else if (descriptionElement.isInstanceOf(TextData.class)) {
|
696
|
TextData textData = CdmBase.deproxy(descriptionElement, TextData.class);
|
697
|
multilanguageText = textData.getMultilanguageText();
|
698
|
} else if (descriptionElement.isInstanceOf(IndividualsAssociation.class)) {
|
699
|
IndividualsAssociation individualsAssociation = CdmBase.deproxy(descriptionElement, IndividualsAssociation.class);
|
700
|
multilanguageText = individualsAssociation.getDescription();
|
701
|
} else if (descriptionElement.isInstanceOf(TaxonInteraction.class)) {
|
702
|
TaxonInteraction taxonInteraction = CdmBase.deproxy(descriptionElement, TaxonInteraction.class);
|
703
|
multilanguageText = taxonInteraction.getDescriptions();
|
704
|
} else {
|
705
|
logger.debug("Given descriptionElement does not support languages. Hence LanguageCache could not be determined: " + descriptionElement.getUuid());
|
706
|
}
|
707
|
|
708
|
if (multilanguageText != null) {
|
709
|
Set<Language> languages = multilanguageText.keySet();
|
710
|
|
711
|
// TODO: Think of something more sophisticated than this
|
712
|
if (languages.size() > 0) {
|
713
|
language = languages.iterator().next();
|
714
|
}
|
715
|
if (languages.size() > 1){
|
716
|
logger.warn("There is more than 1 language for a given description (" + descriptionElement.getClass().getSimpleName() + "):" + descriptionElement.getUuid());
|
717
|
}
|
718
|
}
|
719
|
return language;
|
720
|
}
|
721
|
|
722
|
// /**
|
723
|
// * Returns the <code>Region</code> attribute.
|
724
|
// * @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
|
725
|
// * @return The <code>Region</code> attribute.
|
726
|
// * @see MethodMapper
|
727
|
// */
|
728
|
// @SuppressWarnings("unused")
|
729
|
// private static String getRegion(DescriptionElementBase descriptionElement) {
|
730
|
// String result = null;
|
731
|
// DescriptionBase<?> inDescription = descriptionElement.getInDescription();
|
732
|
//
|
733
|
// // Area information are associated to TaxonDescriptions and Distributions.
|
734
|
// if (descriptionElement.isInstanceOf(Distribution.class)) {
|
735
|
// Distribution distribution = CdmBase.deproxy(descriptionElement, Distribution.class);
|
736
|
// result = PesiTransformer.area2AreaCache(distribution.getArea());
|
737
|
// } else if (inDescription != null && inDescription.isInstanceOf(TaxonDescription.class)) {
|
738
|
// TaxonDescription taxonDescription = CdmBase.deproxy(inDescription, TaxonDescription.class);
|
739
|
// Set<NamedArea> namedAreas = taxonDescription.getGeoScopes();
|
740
|
// if (namedAreas.size() == 1) {
|
741
|
// result = PesiTransformer.area2AreaCache(namedAreas.iterator().next());
|
742
|
// } else if (namedAreas.size() > 1) {
|
743
|
// logger.warn("This TaxonDescription contains more than one NamedArea: " + taxonDescription.getTitleCache());
|
744
|
// }
|
745
|
// }
|
746
|
// return result;
|
747
|
// }
|
748
|
|
749
|
|
750
|
/**
|
751
|
* Returns the TaxonFk for a given TaxonName or Taxon.
|
752
|
* @param state The {@link DbExportStateBase DbExportState}.
|
753
|
* @return
|
754
|
*/
|
755
|
@SuppressWarnings("unused") //used by mapper
|
756
|
private static Integer getTaxonFk(DescriptionElementBase deb, PesiExportState state) {
|
757
|
IdentifiableEntity<?> entity = state.getCurrentTaxon();
|
758
|
return state.getDbId(entity);
|
759
|
}
|
760
|
|
761
|
/**
|
762
|
* Returns the TaxonFk for a given TaxonName.
|
763
|
* @param taxonName The {@link TaxonNameBase TaxonName}.
|
764
|
* @param state The {@link DbExportStateBase DbExportState}.
|
765
|
* @return
|
766
|
*/
|
767
|
private static Integer getTaxonKey(TaxonNameBase<?,?> taxonName, DbExportStateBase<?, PesiTransformer> state) {
|
768
|
return state.getDbId(taxonName);
|
769
|
}
|
770
|
|
771
|
/**
|
772
|
* Returns the <code>FullName</code> attribute.
|
773
|
* @param taxonName The {@link NonViralName NonViralName}.
|
774
|
* @return The <code>FullName</code> attribute.
|
775
|
* @see MethodMapper
|
776
|
*/
|
777
|
@SuppressWarnings("unused")
|
778
|
private static String getTaxonFullNameCache(DescriptionElementBase deb, PesiExportState state) {
|
779
|
|
780
|
IdentifiableEntity<?> taxon = state.getCurrentTaxon();
|
781
|
TaxonBase<?> taxonDeproxy = CdmBase.deproxy(taxon, TaxonBase.class);
|
782
|
TaxonNameBase<?,?> taxonName = taxonDeproxy.getName();
|
783
|
taxonDeproxy = null;
|
784
|
NonViralName<?> nvn = CdmBase.deproxy(taxonName, NonViralName.class);
|
785
|
String result = getCacheStrategy(nvn).getTitleCache(nvn);
|
786
|
nvn = null;
|
787
|
return result;
|
788
|
}
|
789
|
|
790
|
|
791
|
/**
|
792
|
* Returns the CDM to PESI specific export mappings for PESI notes.
|
793
|
* @return The {@link PesiExportMapping PesiExportMapping}.
|
794
|
*/
|
795
|
private PesiExportMapping getNotesMapping() {
|
796
|
PesiExportMapping mapping = new PesiExportMapping(dbNoteTableName);
|
797
|
|
798
|
mapping.addMapper(IdMapper.NewInstance("NoteId"));
|
799
|
mapping.addMapper(DbTextDataMapper.NewInstance(Language.ENGLISH(), "Note_1"));
|
800
|
//TODO
|
801
|
mapping.addMapper(MethodMapper.NewInstance("Note_2", this, DescriptionElementBase.class));
|
802
|
mapping.addMapper(MethodMapper.NewInstance("NoteCategoryFk", this, DescriptionElementBase.class ));
|
803
|
|
804
|
mapping.addMapper(MethodMapper.NewInstance("NoteCategoryCache", this, DescriptionElementBase.class, PesiExportState.class ));
|
805
|
mapping.addMapper(MethodMapper.NewInstance("LanguageFk", this));
|
806
|
mapping.addMapper(MethodMapper.NewInstance("LanguageCache", this, DescriptionElementBase.class, PesiExportState.class));
|
807
|
|
808
|
// mapping.addMapper(MethodMapper.NewInstance("Region", this));
|
809
|
mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
|
810
|
mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
|
811
|
mapping.addCollectionMapping(getNoteSourceMapping());
|
812
|
return mapping;
|
813
|
}
|
814
|
|
815
|
private CollectionExportMapping<PesiExportState, PesiExportConfigurator,PesiTransformer> getNoteSourceMapping() {
|
816
|
String tableName = "NoteSource";
|
817
|
String collectionAttribute = "sources";
|
818
|
IdMapper parentMapper = IdMapper.NewInstance("NoteFk");
|
819
|
CollectionExportMapping<PesiExportState, PesiExportConfigurator, PesiTransformer> mapping = CollectionExportMapping.NewInstance(tableName, collectionAttribute, parentMapper);
|
820
|
mapping.addMapper(DbSimpleFilterMapper.NewSingleNullAttributeInstance("idInSource", "Sources with idInSource currently handle data lineage"));
|
821
|
mapping.addMapper(DbObjectMapper.NewInstance("Citation", "SourceFk"));
|
822
|
mapping.addMapper(DbObjectMapper.NewInstance("Citation", "SourceNameCache", IS_CACHE));
|
823
|
mapping.addMapper(DbStringMapper.NewInstance("CitationMicroReference", "SourceDetail"));
|
824
|
return mapping;
|
825
|
}
|
826
|
|
827
|
|
828
|
/**
|
829
|
* Returns the CDM to PESI specific export mappings for occurrences.
|
830
|
* @return The {@link PesiExportMapping PesiExportMapping}.
|
831
|
*/
|
832
|
private PesiExportMapping getOccurrenceMapping() {
|
833
|
PesiExportMapping mapping = new PesiExportMapping(dbOccurrenceTableName);
|
834
|
|
835
|
mapping.addMapper(IdMapper.NewInstance("OccurrenceId"));
|
836
|
mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
|
837
|
mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("TaxonFullNameCache", true, true, null));
|
838
|
|
839
|
mapping.addMapper(DbAreaMapper.NewInstance(Distribution.class, "Area", "AreaFk", ! IS_CACHE));
|
840
|
mapping.addMapper(DbAreaMapper.NewInstance(Distribution.class, "Area", "AreaNameCache", IS_CACHE));
|
841
|
mapping.addMapper(DbDistributionStatusMapper.NewInstance("OccurrenceStatusFk", ! IS_CACHE));
|
842
|
mapping.addMapper(DbDistributionStatusMapper.NewInstance("OccurrenceStatusCache", IS_CACHE));
|
843
|
|
844
|
// Use Occurrence source instead
|
845
|
mapping.addMapper(DbExportIgnoreMapper.NewInstance("SourceFk", "Use OccurrenceSource table for sources instead"));
|
846
|
mapping.addMapper(DbExportIgnoreMapper.NewInstance("SourceNameCache", "Use OccurrenceSource table for sources instead"));
|
847
|
|
848
|
|
849
|
mapping.addMapper(DbExportNotYetImplementedMapper.NewInstance("Notes", "Needs reimplementation in description export"));
|
850
|
mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
|
851
|
mapping.addCollectionMapping(getOccurrenceSourceMapping());
|
852
|
|
853
|
return mapping;
|
854
|
}
|
855
|
|
856
|
private CollectionExportMapping<PesiExportState, PesiExportConfigurator, PesiTransformer> getOccurrenceSourceMapping() {
|
857
|
String tableName = "OccurrenceSource";
|
858
|
String collectionAttribute = "sources";
|
859
|
IdMapper parentMapper = IdMapper.NewInstance("OccurrenceFk");
|
860
|
CollectionExportMapping<PesiExportState, PesiExportConfigurator, PesiTransformer> mapping = CollectionExportMapping.NewInstance(tableName, collectionAttribute, parentMapper);
|
861
|
mapping.addMapper(DbSimpleFilterMapper.NewSingleNullAttributeInstance("idInSource", "Sources with idInSource currently handle data lineage"));
|
862
|
mapping.addMapper(DbObjectMapper.NewInstance("Citation", "SourceFk"));
|
863
|
mapping.addMapper(DbObjectMapper.NewInstance("Citation", "SourceNameCache", IS_CACHE));
|
864
|
mapping.addMapper(DbOriginalNameMapper.NewInstance("OldTaxonName", IS_CACHE, null));
|
865
|
|
866
|
return mapping;
|
867
|
}
|
868
|
|
869
|
|
870
|
/**
|
871
|
* Returns the CDM to PESI specific export mappings for additional taxon sources to create a new
|
872
|
* source for the additional source
|
873
|
* @see #{@link PesiDescriptionExport#getAdditionalTaxonSourceMapping()}
|
874
|
* @return The {@link PesiExportMapping PesiExportMapping}.
|
875
|
*/
|
876
|
private PesiExportMapping getAddTaxonSourceSourceMapping() {
|
877
|
PesiExportMapping sourceMapping = new PesiExportMapping(PesiSourceExport.dbTableName);
|
878
|
|
879
|
sourceMapping.addMapper(IdMapper.NewInstance("SourceId"));
|
880
|
sourceMapping.addMapper(DbConstantMapper.NewInstance("SourceCategoryFk", Types.INTEGER, PesiTransformer.REF_UNRESOLVED));
|
881
|
sourceMapping.addMapper(DbConstantMapper.NewInstance("SourceCategoryCache", Types.VARCHAR, PesiTransformer.REF_STR_UNRESOLVED));
|
882
|
|
883
|
// sourceMapping.addMapper(MethodMapper.NewInstance("NomRefCache", PesiSourceExport.class, "getNomRefCache", Reference.class));
|
884
|
|
885
|
sourceMapping.addMapper(DbTextDataMapper.NewInstance(Language.ENGLISH(), "NomRefCache"));
|
886
|
|
887
|
return sourceMapping;
|
888
|
}
|
889
|
|
890
|
|
891
|
/**
|
892
|
* Returns the CDM to PESI specific export mappings for additional taxon sources.
|
893
|
* @see #{@link PesiDescriptionExport#getAddTaxonSourceSourceMapping()}
|
894
|
* @return The {@link PesiExportMapping PesiExportMapping}.
|
895
|
*/
|
896
|
private PesiExportMapping getAdditionalTaxonSourceMapping() {
|
897
|
|
898
|
PesiExportMapping mapping = new PesiExportMapping(dbAdditionalSourceTableName);
|
899
|
|
900
|
mapping.addMapper(MethodMapper.NewInstance("TaxonFk", this, DescriptionElementBase.class, PesiExportState.class));
|
901
|
|
902
|
mapping.addMapper(IdMapper.NewInstance("SourceFk"));
|
903
|
mapping.addMapper(DbTextDataMapper.NewInstance(Language.ENGLISH(), "SourceNameCache"));
|
904
|
|
905
|
mapping.addMapper(DbConstantMapper.NewInstance("SourceUseFk", Types.INTEGER, PesiTransformer.NOMENCLATURAL_REFERENCE));
|
906
|
mapping.addMapper(DbConstantMapper.NewInstance("SourceUseCache", Types.VARCHAR, PesiTransformer.STR_NOMENCLATURAL_REFERENCE));
|
907
|
|
908
|
// mapping.addMapper(DbIgnoreMapper.NewInstance("SourceDetail", "SourceDetails not available for additional sources"));
|
909
|
|
910
|
return mapping;
|
911
|
}
|
912
|
|
913
|
/**
|
914
|
* Returns the CDM to PESI specific export mappings for common names.
|
915
|
* @return The {@link PesiExportMapping PesiExportMapping}.
|
916
|
*/
|
917
|
private PesiExportMapping getVernacularNamesMapping() {
|
918
|
PesiExportMapping mapping = new PesiExportMapping(dbVernacularTableName);
|
919
|
|
920
|
mapping.addMapper(IdMapper.NewInstance("CommonNameId"));
|
921
|
mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
|
922
|
|
923
|
mapping.addMapper(DbStringMapper.NewInstance("Name", "CommonName"));
|
924
|
mapping.addMapper(DbAreaMapper.NewInstance(CommonTaxonName.class, "Area", "Region", IS_CACHE));
|
925
|
|
926
|
mapping.addMapper(DbLanguageMapper.NewInstance(CommonTaxonName.class, "Language", "LanguageFk", ! IS_CACHE));
|
927
|
mapping.addMapper(DbLanguageMapper.NewInstance(CommonTaxonName.class, "Language", "LanguageCache", IS_CACHE));
|
928
|
|
929
|
mapping.addMapper(DbSingleSourceMapper.NewInstance("SourceFk", of ( DbSingleSourceMapper.EXCLUDE.WITH_ID) , ! IS_CACHE));
|
930
|
mapping.addMapper(DbSingleSourceMapper.NewInstance("SourceNameCache", of ( DbSingleSourceMapper.EXCLUDE.WITH_ID) , IS_CACHE));
|
931
|
mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
|
932
|
return mapping;
|
933
|
|
934
|
}
|
935
|
|
936
|
private PesiExportMapping getImageMapping() {
|
937
|
PesiExportMapping mapping = new PesiExportMapping(dbImageTableName);
|
938
|
mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
|
939
|
|
940
|
//TODO xxx
|
941
|
|
942
|
return mapping;
|
943
|
}
|
944
|
|
945
|
}
|