Project

General

Profile

« Previous | Next » 

Revision c483dd7e

Added by Katja Luther over 9 years ago

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiDescriptionExport.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
25 25
import org.springframework.stereotype.Component;
26 26
import org.springframework.transaction.TransactionStatus;
27 27

  
28
import com.microsoft.sqlserver.jdbc.SQLServerException;
29

  
28 30
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;
29 31
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
30 32
import eu.etaxonomy.cdm.io.common.Source;
......
37 39
import eu.etaxonomy.cdm.io.common.mapping.out.DbDescriptionElementTaxonMapper;
38 40
import eu.etaxonomy.cdm.io.common.mapping.out.DbDistributionStatusMapper;
39 41
import eu.etaxonomy.cdm.io.common.mapping.out.DbExportIgnoreMapper;
40
import eu.etaxonomy.cdm.io.common.mapping.out.DbExportNotYetImplementedMapper;
41 42
import eu.etaxonomy.cdm.io.common.mapping.out.DbLanguageMapper;
42 43
import eu.etaxonomy.cdm.io.common.mapping.out.DbObjectMapper;
43 44
import eu.etaxonomy.cdm.io.common.mapping.out.DbOriginalNameMapper;
......
68 69
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
69 70
import eu.etaxonomy.cdm.model.taxon.Taxon;
70 71
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
71
import eu.etaxonomy.cdm.profiler.ProfilerController;
72 72
/**
73 73
 * The export class for {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase DescriptionElements}.<p>
74 74
 * Inserts into DataWarehouse database table <code>Note</code>.<p>
......
82 82
@Component
83 83
public class PesiDescriptionExport extends PesiExportBase {
84 84
	private static final Logger logger = Logger.getLogger(PesiDescriptionExport.class);
85
	
85

  
86 86
	private static final Class<? extends CdmBase> standardMethodParameter = DescriptionElementBase.class;
87 87

  
88 88
	private static int modCount = 1000;
......
97 97
	//decide where to handle them best (configurator, transformer, single method, ...)
98 98
	private static Set<Integer> excludedNoteCategories = new HashSet<Integer>(Arrays.asList(new Integer[]{250,251,252,253,10,11,13}));
99 99

  
100
	
100

  
101 101
	//debugging
102 102
	private static int countDescriptions;
103 103
	private static int countTaxa;
......
105 105
	private static int countAdditionalSources;
106 106
	private static int countImages;
107 107
	private static int countNotes;
108
	
108

  
109 109
	private static int countCommonName;
110 110
	private static int countOccurrence;
111 111
	private static int countOthers;
112
	
112

  
113 113
	public PesiDescriptionExport() {
114 114
		super();
115 115
	}
......
132 132

  
133 133
			// Stores whether this invoke was successful or not.
134 134
			boolean success = true;
135
	
135

  
136 136
			// Get specific mappings: (CDM) DescriptionElement -> (PESI) Note
137 137
			PesiExportMapping notesMapping = getNotesMapping();
138 138
			notesMapping.initialize(state);
......
148 148
			additionalSourceMapping.initialize(state);
149 149

  
150 150
			// Get specific mappings: (CDM) DescriptionElement -> (PESI) Additional taxon source
151

  
151 152
			PesiExportMapping vernacularMapping = getVernacularNamesMapping();
152 153
			vernacularMapping.initialize(state);
153
			
154

  
154 155
			// Get specific mappings: (CDM) DescriptionElement -> (PESI) Additional taxon source
155 156
			PesiExportMapping imageMapping = getImageMapping();
156 157
			imageMapping.initialize(state);
157
			
158

  
158 159
			// Start transaction
159 160
			success &= doPhase01(state, notesMapping, occurrenceMapping, addSourceSourceMapping, additionalSourceMapping, vernacularMapping, imageMapping);
160 161

  
161 162
			// Start transaction
162 163
			success &= doPhase01b(state, notesMapping, occurrenceMapping, addSourceSourceMapping, additionalSourceMapping, vernacularMapping, imageMapping);
163 164

  
164
			
165

  
165 166
			logger.info("PHASE 2...");
166 167
			success &= doPhase02(state);
167 168

  
168 169

  
169 170
			logger.info("*** Finished Making " + pluralString + " ..." + getSuccessString(success));
170
			
171

  
171 172
			if (!success){
172 173
				state.setUnsuccessfull();
173 174
			}
......
180 181
	}
181 182

  
182 183
	//PHASE 01: Description Elements
183
	private boolean doPhase01(PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping, PesiExportMapping addSourceSourceMapping, 
184
	private boolean doPhase01(PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping, PesiExportMapping addSourceSourceMapping,
184 185
			PesiExportMapping additionalSourceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping) throws SQLException {
185
		logger.info("PHASE 1...");
186

  
187
	    System.out.println("PHASE 1 of occurence import");
188
	    logger.info("PHASE 1...");
186 189
		int count = 0;
187 190
		int pastCount = 0;
188 191
		boolean success = true;
189 192
		int limit = state.getConfig().getLimitSave();
190 193

  
191 194
		List<Taxon> taxonList = null;
192
		
195

  
193 196
		TransactionStatus txStatus = startTransaction(true);
194 197
		logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
195 198
		List<String> propPath = Arrays.asList(new String[]{"descriptions.elements.*"});
196
		
199

  
197 200
		logger.debug("Start snapshot, before starting loop");
198
		ProfilerController.memorySnapshot();
201
	//	ProfilerController.memorySnapshot();
199 202
		//taxon descriptions
200 203
		int partitionCount = 0;
201 204
		while ((taxonList = getNextTaxonPartition(Taxon.class, limit, partitionCount++, propPath )) != null   ) {
202 205

  
203 206
			logger.info("Fetched " + taxonList.size() + " " + pluralString + ". Exporting...");
204
			
207

  
205 208
			for (Taxon taxon : taxonList) {
206 209
				countTaxa++;
207 210
				doCount(count++, modCount, pluralString);
208 211
				state.setCurrentTaxon(taxon);
209
				success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addSourceSourceMapping, 
210
						additionalSourceMapping, vernacularMapping, imageMapping);	
212
				success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addSourceSourceMapping,
213
						additionalSourceMapping, vernacularMapping, imageMapping);
211 214
			}
212 215
			taxonList = null;
213 216
			state.setCurrentTaxon(null);
......
221 224
			txStatus = startTransaction(true);
222 225
			logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") for description import ...");
223 226
		}
224
		
225
	
227

  
228

  
226 229
		logger.info("No " + pluralString + " left to fetch.");
227 230
		logger.info("Partition: " + partitionCount);
228 231
		logger.info("Taxa: " + countTaxa);
......
234 237
		logger.info("Images: " + countImages);
235 238
		logger.info("Notes: " + countNotes);
236 239
		logger.info("Others: " + countOthers);
237
		
240

  
238 241
		// Commit transaction
239 242
		commitTransaction(txStatus);
240 243
		logger.debug("Committed transaction.");
241 244
		return success;
242 245
	}
243
	
246

  
244 247
	//PHASE 01b: Name Descriptions
245
	private boolean doPhase01b(PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping, PesiExportMapping addSourceSourceMapping, 
248
	private boolean doPhase01b(PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping, PesiExportMapping addSourceSourceMapping,
246 249
			PesiExportMapping additionalSourceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping) throws SQLException {
247 250
		logger.info("PHASE 1b...");
248 251
		int count = 0;
249 252
		int pastCount = 0;
250 253
		boolean success = true;
251 254
		int limit = state.getConfig().getLimitSave();
252
		
255

  
253 256
		List<TaxonNameDescription> nameDescList = null;
254
		
257

  
255 258
		TransactionStatus txStatus = startTransaction(true);
256 259
		logger.info("Started new transaction. Fetching some name descriptions (max: " + limit + ") ...");
257 260
		List<String> propPath = Arrays.asList(new String[]{"descriptions.elements.*"});
258
		
261

  
259 262
		//name descriptions
260 263
		int partitionCount = 0;
261 264
		while ((nameDescList = getNextNameDescriptionPartition( limit, partitionCount++, propPath )) != null   ) {
262
			
265

  
263 266
			logger.info("Fetched " + nameDescList.size() + " name descriptions. Exporting...");
264
			
267

  
265 268
			for (TaxonNameDescription desc : nameDescList) {
266 269
				countTaxa++;
267 270
				doCount(count++, modCount, "name descriptions");
268 271
				boolean isImageGallery = desc.isImageGallery();
269
				
272

  
270 273
				TaxonNameBase<?,?> name = desc.getTaxonName();
271
				
274

  
272 275
				for (DescriptionElementBase element : desc.getElements()){
273 276
					if (isPurePesiName(name)){
274 277
						success &= handleDescriptionElement(state, notesMapping, occurrenceMapping, vernacularMapping, imageMapping,
......
298 301
			txStatus = startTransaction(true);
299 302
			logger.info("Started new transaction. Fetching some name descriptions (max: " + limit + ") for description import ...");
300 303
		}
301
		
304

  
302 305
		logger.info("No " + pluralString + " left to fetch.");
303 306
		logger.info("Partition: " + partitionCount);
304 307
		logger.info("Taxa: " + countTaxa);
......
310 313
		logger.info("Images: " + countImages);
311 314
		logger.info("Notes: " + countNotes);
312 315
		logger.info("Others: " + countOthers);
313
		
316

  
314 317
		// Commit transaction
315 318
		commitTransaction(txStatus);
316 319
		logger.debug("Committed transaction.");
......
318 321
	}
319 322

  
320 323
	private boolean handleSingleTaxon(Taxon taxon, PesiExportState state, PesiExportMapping notesMapping, PesiExportMapping occurrenceMapping,
321
			PesiExportMapping addSourceSourceMapping, PesiExportMapping additionalSourceMapping, 
324
			PesiExportMapping addSourceSourceMapping, PesiExportMapping additionalSourceMapping,
322 325
			PesiExportMapping vernacularMapping, PesiExportMapping imageMapping) throws SQLException {
323 326
		boolean success = true;
327

  
328
		System.out.println("handle single Taxon");
324 329
		Set<DescriptionBase<?>> descriptions = new HashSet<DescriptionBase<?>>();
325 330
		descriptions.addAll(taxon.getDescriptions());
326
		
331

  
327 332
		for (DescriptionBase<?> desc : descriptions){
328 333
			countDescriptions++;
329 334

  
......
338 343
	}
339 344

  
340 345
	private boolean handleDescriptionElement(PesiExportState state, PesiExportMapping notesMapping,
341
			PesiExportMapping occurrenceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping, 
346
			PesiExportMapping occurrenceMapping, PesiExportMapping vernacularMapping, PesiExportMapping imageMapping,
342 347
			PesiExportMapping addSourceSourceMapping, PesiExportMapping additionalSourceMapping, boolean isImageGallery, DescriptionElementBase element) throws SQLException {
343 348
		try {
344 349
			boolean success = true;
......
357 362
				countOccurrence++;
358 363
				Distribution distribution = CdmBase.deproxy(element, Distribution.class);
359 364
				MarkerType markerType = getUuidMarkerType(PesiTransformer.uuidMarkerTypeHasNoLastAction, state);
360
				
365

  
361 366
				distribution.addMarker(Marker.NewInstance(markerType, true));
362 367
				if (isPesiDistribution(state, distribution)){
363 368
					countDistribution++;
364
					success &=occurrenceMapping.invoke(element);
369
					try{
370
					    success &=occurrenceMapping.invoke(element);
371
					}catch(SQLServerException e){
372
					    System.err.println(element.getInDescription().getTitleCache());
373
					    e.printStackTrace();
374
					}
365 375
				}
366 376
			}else if (isAdditionalTaxonSource(element)){
367 377
				countAdditionalSources++;
......
374 384
			}else if (isPesiNote(element)){
375 385
				countNotes++;
376 386
				success &= notesMapping.invoke(element);
377
			
387

  
378 388
			}else{
379 389
				countOthers++;
380 390
				String featureTitle = element.getFeature() == null ? "no feature" :element.getFeature().getTitleCache();
......
399 409
		if (distribution.getStatus() == null){
400 410
			return false;
401 411
		}
402
		
412

  
403 413
		//...this may change in future so we keep the following code
404 414
		Integer key;
405 415
		//area filter
......
417 427
//			//Macaronesia records should not be exported to PESI
418 428
//			return false;
419 429
//		//TODO exclude Russion areas Rs*, and maybe ohters
420
		
421
		} else
422
			try {
430

  
431
		} else {
432
            try {
423 433
				if (state.getTransformer().getKeyByNamedArea(area) == null){
424 434
					String warning = "Area (%s,%s) not available in PESI transformer for taxon %S: ";
425 435
					TaxonBase<?> taxon =  state.getCurrentTaxon();
......
431 441
				logger.warn("Area not available in PESI transformer " +  area.getTitleCache());
432 442
				return false;
433 443
			}
444
        }
434 445
		return true;
435
		
436
//		
446

  
447
//
437 448
//		//status
438 449
//		PresenceAbsenceTermBase<?> status = distribution.getStatus();
439 450
//		if (status == null){
......
490 501
	private boolean doPhase02(PesiExportState state) {
491 502
		TransactionStatus txStatus;
492 503
		boolean success =  true;
493
		
504

  
494 505
		// Get the limit for objects to save within a single transaction.
495 506
		int limit = state.getConfig().getLimitSave();
496
					
507

  
497 508
		txStatus = startTransaction(true);
498 509
		ExtensionType taxCommentExtensionType = (ExtensionType)getTermService().find(PesiTransformer.taxCommentUuid);
499 510
		ExtensionType fauCommentExtensionType = (ExtensionType)getTermService().find(PesiTransformer.fauCommentUuid);
500 511
		ExtensionType fauExtraCodesExtensionType = (ExtensionType)getTermService().find(PesiTransformer.fauExtraCodesUuid);
501 512
		List<TaxonNameBase> taxonNameList = null;
502
		
513

  
503 514
		int count = 0;
504 515
		int pastCount = 0;
505 516
		Connection connection = state.getConfig().getDestination().getConnection();
......
513 524
				for (Extension extension : extensions) {
514 525
					if (extension.getType().equals(taxCommentExtensionType)) {
515 526
						String taxComment = extension.getValue();
516
						invokeNotes(taxComment, 
517
								PesiTransformer.getNoteCategoryFk(PesiTransformer.taxCommentUuid), 
527
						invokeNotes(taxComment,
528
								PesiTransformer.getNoteCategoryFk(PesiTransformer.taxCommentUuid),
518 529
								PesiTransformer.getNoteCategoryCache(PesiTransformer.taxCommentUuid),
519 530
								null, null, getTaxonKey(taxonName, state),connection);
520 531
					} else if (extension.getType().equals(fauCommentExtensionType)) {
521 532
						String fauComment = extension.getValue();
522
						invokeNotes(fauComment, 
523
								PesiTransformer.getNoteCategoryFk(PesiTransformer.fauCommentUuid), 
533
						invokeNotes(fauComment,
534
								PesiTransformer.getNoteCategoryFk(PesiTransformer.fauCommentUuid),
524 535
								PesiTransformer.getNoteCategoryCache(PesiTransformer.fauCommentUuid),
525 536
								null, null, getTaxonKey(taxonName, state),connection);
526 537
					} else if (extension.getType().equals(fauExtraCodesExtensionType)) {
527 538
						String fauExtraCodes = extension.getValue();
528
						invokeNotes(fauExtraCodes, 
529
								PesiTransformer.getNoteCategoryFk(PesiTransformer.fauExtraCodesUuid), 
539
						invokeNotes(fauExtraCodes,
540
								PesiTransformer.getNoteCategoryFk(PesiTransformer.fauExtraCodesUuid),
530 541
								PesiTransformer.getNoteCategoryCache(PesiTransformer.fauExtraCodesUuid),
531 542
								null, null, getTaxonKey(taxonName, state),connection);
532 543
					}
533 544
				}
534
				
545

  
535 546
				doCount(count++, modCount, pluralString);
536 547
			}
537 548

  
......
563 574
	 * @param object2
564 575
	 */
565 576
	private void invokeNotes(String note, Integer noteCategoryFk,
566
			String noteCategoryCache, Integer languageFk, String languageCache, 
577
			String noteCategoryCache, Integer languageFk, String languageCache,
567 578
			Integer taxonFk, Connection connection) {
568
		String notesSql = "UPDATE Note SET Note_1 = ?, NoteCategoryFk = ?, NoteCategoryCache = ?, LanguageFk = ?, LanguageCache = ? WHERE TaxonFk = ?"; 
579
		String notesSql = "UPDATE Note SET Note_1 = ?, NoteCategoryFk = ?, NoteCategoryCache = ?, LanguageFk = ?, LanguageCache = ? WHERE TaxonFk = ?";
569 580
		try {
570 581
			PreparedStatement notesStmt = connection.prepareStatement(notesSql);
571
			
582

  
572 583
			if (note != null) {
573 584
				notesStmt.setString(1, note);
574 585
			} else {
575 586
				notesStmt.setObject(1, null);
576 587
			}
577
			
588

  
578 589
			if (noteCategoryFk != null) {
579 590
				notesStmt.setInt(2, noteCategoryFk);
580 591
			} else {
581 592
				notesStmt.setObject(2, null);
582 593
			}
583
			
594

  
584 595
			if (noteCategoryCache != null) {
585 596
				notesStmt.setString(3, noteCategoryCache);
586 597
			} else {
587 598
				notesStmt.setObject(3, null);
588 599
			}
589
			
600

  
590 601
			if (languageFk != null) {
591 602
				notesStmt.setInt(4, languageFk);
592 603
			} else {
593 604
				notesStmt.setObject(4, null);
594 605
			}
595
			
606

  
596 607
			if (languageCache != null) {
597 608
				notesStmt.setString(5, languageCache);
598 609
			} else {
599 610
				notesStmt.setObject(5, null);
600 611
			}
601
			
612

  
602 613
			if (taxonFk != null) {
603 614
				notesStmt.setInt(6, taxonFk);
604 615
			} else {
605 616
				notesStmt.setObject(6, null);
606 617
			}
607
			
618

  
608 619
			notesStmt.executeUpdate();
609 620
		} catch (SQLException e) {
610 621
			logger.error("Note could not be created: " + note);
......
620 631
	 * @return Whether the delete operation was successful or not.
621 632
	 */
622 633
	protected boolean doDelete(PesiExportState state) {
623
		PesiExportConfigurator pesiConfig = (PesiExportConfigurator) state.getConfig();
624
		
634
		PesiExportConfigurator pesiConfig = state.getConfig();
635

  
625 636
		String sql;
626 637
		Source destination =  pesiConfig.getDestination();
627 638

  
......
679 690
		}
680 691
		return result;
681 692
	}
682
	
693

  
683 694
	/**
684 695
	 * Returns the <code>NoteCategoryCache</code> attribute.
685 696
	 * @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
......
690 701
	private static String getNoteCategoryCache(DescriptionElementBase descriptionElement, PesiExportState state) {
691 702
		return state.getTransformer().getCacheByFeature(descriptionElement.getFeature());
692 703
	}
693
	
694
	
704

  
705

  
695 706

  
696 707

  
697 708
	/**
......
711 722
	 * Returns the <code>LanguageCache</code> attribute.
712 723
	 * @param descriptionElement The {@link DescriptionElementBase DescriptionElement}.
713 724
	 * @return The <code>LanguageCache</code> attribute.
714
	 * @throws UndefinedTransformerMethodException 
725
	 * @throws UndefinedTransformerMethodException
715 726
	 * @see MethodMapper
716 727
	 */
717 728
	@SuppressWarnings("unused")
......
739 750
		} else {
740 751
			logger.debug("Given descriptionElement does not support languages. Hence LanguageCache could not be determined: " + descriptionElement.getUuid());
741 752
		}
742
		
753

  
743 754
		if (multilanguageText != null) {
744 755
			Set<Language> languages = multilanguageText.keySet();
745 756

  
......
764 775
//	private static String getRegion(DescriptionElementBase descriptionElement) {
765 776
//		String result = null;
766 777
//		DescriptionBase<?> inDescription = descriptionElement.getInDescription();
767
//		
778
//
768 779
//		// Area information are associated to TaxonDescriptions and Distributions.
769 780
//		if (descriptionElement.isInstanceOf(Distribution.class)) {
770 781
//			Distribution distribution = CdmBase.deproxy(descriptionElement, Distribution.class);
......
781 792
//		return result;
782 793
//	}
783 794

  
784
	
795

  
785 796
	/**
786 797
	 * Returns the TaxonFk for a given TaxonName or Taxon.
787 798
	 * @param state The {@link DbExportStateBase DbExportState}.
......
792 803
		TaxonBase<?> entity = state.getCurrentTaxon();
793 804
		return state.getDbId(entity);
794 805
	}
795
	
806

  
796 807
	/**
797 808
	 * Returns the TaxonFk for a given TaxonName.
798 809
	 * @param taxonName The {@link TaxonNameBase TaxonName}.
......
802 813
	private static Integer getTaxonKey(TaxonNameBase<?,?> taxonName, DbExportStateBase<?, PesiTransformer> state) {
803 814
		return state.getDbId(taxonName);
804 815
	}
805
	
816

  
806 817
	/**
807 818
	 * Returns the <code>FullName</code> attribute.
808 819
	 * @param taxonName The {@link NonViralName NonViralName}.
......
811 822
	 */
812 823
	@SuppressWarnings("unused")
813 824
	private static String getTaxonFullNameCache(DescriptionElementBase deb, PesiExportState state) {
814
		
825

  
815 826
		TaxonBase<?> taxon =  state.getCurrentTaxon();
816 827
		TaxonNameBase<?,?> taxonName = taxon.getName();
817 828
		NonViralName<?> nvn = CdmBase.deproxy(taxonName, NonViralName.class);
......
826 837
	 */
827 838
	private PesiExportMapping getNotesMapping() {
828 839
		PesiExportMapping mapping = new PesiExportMapping(dbNoteTableName);
829
		
840

  
830 841
		mapping.addMapper(IdMapper.NewInstance("NoteId"));
831 842
		mapping.addMapper(DbTextDataMapper.NewInstance(Language.ENGLISH(), "Note_1"));
832 843
		//TODO
833 844
		mapping.addMapper(MethodMapper.NewInstance("Note_2", this, DescriptionElementBase.class));
834 845
		mapping.addMapper(MethodMapper.NewInstance("NoteCategoryFk", this, DescriptionElementBase.class ));
835
		
846

  
836 847
		mapping.addMapper(MethodMapper.NewInstance("NoteCategoryCache", this, DescriptionElementBase.class, PesiExportState.class ));
837 848
		mapping.addMapper(MethodMapper.NewInstance("LanguageFk", this));
838 849
		mapping.addMapper(MethodMapper.NewInstance("LanguageCache", this, DescriptionElementBase.class, PesiExportState.class));
839
		
850

  
840 851
//		mapping.addMapper(MethodMapper.NewInstance("Region", this));
841 852
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
842
		mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
853
	//	mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
843 854
		mapping.addCollectionMapping(getNoteSourceMapping());
844 855
		return mapping;
845 856
	}
846
	
857

  
847 858
	private CollectionExportMapping<PesiExportState, PesiExportConfigurator,PesiTransformer> getNoteSourceMapping() {
848 859
		String tableName = "NoteSource";
849 860
		String collectionAttribute = "sources";
......
855 866
		mapping.addMapper(DbStringMapper.NewInstance("CitationMicroReference", "SourceDetail"));
856 867
		return mapping;
857 868
	}
858
	
869

  
859 870

  
860 871
	/**
861 872
	 * Returns the CDM to PESI specific export mappings for occurrences.
......
863 874
	 */
864 875
	private PesiExportMapping getOccurrenceMapping() {
865 876
		PesiExportMapping mapping = new PesiExportMapping(dbOccurrenceTableName);
866
		
877

  
867 878
		mapping.addMapper(IdMapper.NewInstance("OccurrenceId"));
868 879
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
869
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("TaxonFullNameCache", true, true, null)); 
870
		
880
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("TaxonFullNameCache", true, true, null));
881

  
871 882
		mapping.addMapper(DbAreaMapper.NewInstance(Distribution.class, "Area", "AreaFk", ! IS_CACHE));
872 883
		mapping.addMapper(DbAreaMapper.NewInstance(Distribution.class, "Area", "AreaNameCache", IS_CACHE));
873 884
		mapping.addMapper(DbDistributionStatusMapper.NewInstance("OccurrenceStatusFk", ! IS_CACHE));
874 885
		mapping.addMapper(DbDistributionStatusMapper.NewInstance("OccurrenceStatusCache", IS_CACHE));
875
		
886

  
876 887
//		Use Occurrence source instead
877 888
		mapping.addMapper(DbExportIgnoreMapper.NewInstance("SourceFk", "Use OccurrenceSource table for sources instead"));
878 889
		mapping.addMapper(DbExportIgnoreMapper.NewInstance("SourceNameCache", "Use OccurrenceSource table for sources instead"));
879
		
890

  
880 891
		mapping.addMapper(DbAnnotationMapper.NewInstance(null, "Notes"));
881
		mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
892
	//	mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
882 893
		mapping.addCollectionMapping(getOccurrenceSourceMapping());
883
		
894

  
884 895
		return mapping;
885 896
	}
886 897

  
......
896 907

  
897 908
		return mapping;
898 909
	}
899
	
910

  
900 911

  
901 912
	/**
902 913
	 * Returns the CDM to PESI specific export mappings for additional taxon sources to create a new
......
906 917
	 */
907 918
	private PesiExportMapping getAddTaxonSourceSourceMapping() {
908 919
		PesiExportMapping sourceMapping = new PesiExportMapping(PesiSourceExport.dbTableName);
909
		
920

  
910 921
		sourceMapping.addMapper(IdMapper.NewInstance("SourceId"));
911 922
		sourceMapping.addMapper(DbConstantMapper.NewInstance("SourceCategoryFk", Types.INTEGER, PesiTransformer.REF_UNRESOLVED));
912 923
		sourceMapping.addMapper(DbConstantMapper.NewInstance("SourceCategoryCache", Types.VARCHAR, PesiTransformer.REF_STR_UNRESOLVED));
913
		
924

  
914 925
//		sourceMapping.addMapper(MethodMapper.NewInstance("NomRefCache", PesiSourceExport.class, "getNomRefCache", Reference.class));
915
		
926

  
916 927
		sourceMapping.addMapper(DbTextDataMapper.NewInstance(Language.ENGLISH(), "NomRefCache"));
917
		
928

  
918 929
		return sourceMapping;
919 930
	}
920 931

  
921
	
932

  
922 933
	/**
923 934
	 * Returns the CDM to PESI specific export mappings for additional taxon sources.
924 935
	 * @see #{@link PesiDescriptionExport#getAddTaxonSourceSourceMapping()}
925 936
	 * @return The {@link PesiExportMapping PesiExportMapping}.
926 937
	 */
927 938
	private PesiExportMapping getAdditionalTaxonSourceMapping() {
928
	
939

  
929 940
		PesiExportMapping mapping = new PesiExportMapping(dbAdditionalSourceTableName);
930
		
941

  
931 942
		mapping.addMapper(MethodMapper.NewInstance("TaxonFk", this, DescriptionElementBase.class, PesiExportState.class));
932
		
943

  
933 944
		mapping.addMapper(IdMapper.NewInstance("SourceFk"));
934 945
		mapping.addMapper(DbTextDataMapper.NewInstance(Language.ENGLISH(), "SourceNameCache"));
935
		
946

  
936 947
		mapping.addMapper(DbConstantMapper.NewInstance("SourceUseFk", Types.INTEGER, PesiTransformer.NOMENCLATURAL_REFERENCE));
937 948
		mapping.addMapper(DbConstantMapper.NewInstance("SourceUseCache", Types.VARCHAR, PesiTransformer.STR_NOMENCLATURAL_REFERENCE));
938
		
949

  
939 950
		mapping.addMapper(DbExportIgnoreMapper.NewInstance("SourceDetail", "SourceDetails not available for additional sources"));
940
		
951

  
941 952
		return mapping;
942 953
	}
943
	
954

  
944 955
	/**
945 956
	 * Returns the CDM to PESI specific export mappings for common names.
946 957
	 * @return The {@link PesiExportMapping PesiExportMapping}.
947 958
	 */
948 959
	private PesiExportMapping getVernacularNamesMapping() {
949 960
		PesiExportMapping mapping = new PesiExportMapping(dbVernacularTableName);
950
		
961

  
951 962
		mapping.addMapper(IdMapper.NewInstance("CommonNameId"));
952 963
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
953
		
964

  
954 965
		mapping.addMapper(DbStringMapper.NewInstance("Name", "CommonName"));
955 966
		mapping.addMapper(DbAreaMapper.NewInstance(CommonTaxonName.class, "Area", "Region", IS_CACHE));
956
		
967

  
957 968
		mapping.addMapper(DbLanguageMapper.NewInstance(CommonTaxonName.class, "Language", "LanguageFk", ! IS_CACHE));
958 969
		mapping.addMapper(DbLanguageMapper.NewInstance(CommonTaxonName.class, "Language", "LanguageCache", IS_CACHE));
959
		
970

  
960 971
		mapping.addMapper(DbSingleSourceMapper.NewInstance("SourceFk", of ( DbSingleSourceMapper.EXCLUDE.WITH_ID) , ! IS_CACHE));
961 972
		mapping.addMapper(DbSingleSourceMapper.NewInstance("SourceNameCache", of ( DbSingleSourceMapper.EXCLUDE.WITH_ID) , IS_CACHE));
962
		mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
973
		//mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
963 974
		return mapping;
964 975

  
965 976
	}
966
	
977

  
967 978
	private PesiExportMapping getImageMapping() {
968 979
		PesiExportMapping mapping = new PesiExportMapping(dbImageTableName);
969 980
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
970
		
981

  
971 982
		//TODO xxx
972
		
983

  
973 984
		return mapping;
974 985
	}
975 986

  

Also available in: Unified diff