Project

General

Profile

« Previous | Next » 

Revision d2c73605

Added by Katja Luther almost 12 years ago

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiDescriptionExport.java
204 204
		while ((list = getNextTaxonPartition(Taxon.class, limit, partitionCount++, propPath )) != null   ) {
205 205

  
206 206
			logger.info("Fetched " + list.size() + " " + pluralString + ". Exporting...");
207
			logger.warn("Start snapshot, beginning of loop, fetched " + list.size() + " " + pluralString);
207
			
208 208
			if (partitionCount % 10 == 0){
209
				logger.warn("Start snapshot, beginning of loop, fetched " + list.size() + " " + pluralString);
209 210
				ProfilerController.memorySnapshot();
210 211
			}
211 212
			for (Taxon taxon : list) {
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportBase.java
82 82
			if (! isPesiTaxon(taxonBase)){
83 83
				it.remove();
84 84
			}
85
			taxonBase = null;
85 86
		}
86 87
		
87 88
		return list;
......
214 215
			SynonymRelationship synRel = CdmBase.deproxy(rel, SynonymRelationship.class);
215 216
			taxonBase = synRel.getSynonym();
216 217
			taxon = synRel.getAcceptedTaxon();
218
			synRel = null;
217 219
		}else if (rel.isInstanceOf(TaxonRelationship.class)){
218 220
			TaxonRelationship taxRel = CdmBase.deproxy(rel, TaxonRelationship.class);
219 221
			taxonBase = taxRel.getFromTaxon();
220 222
			taxon = taxRel.getToTaxon();
223
			taxRel = null;
221 224
		}else{
222 225
			logger.warn ("Only synonym - and taxon-relationships alowed here");
223 226
			return false;
......
342 345
			Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
343 346
			for (Marker marker : taxon.getMarkers()){
344 347
				if (marker.getValue() == false && marker.getMarkerType().equals(MarkerType.PUBLISH())){
348
					taxon = null;
345 349
					return false;
346 350
				//probably not needed any more after #2786 was fixed
347 351
				}else if (marker.getValue() == true && marker.getMarkerType().getUuid().equals(BerlinModelTransformer.uuidMisappliedCommonName)){
348 352
					logger.warn("Misapplied common name still exists");
353
					taxon = null;
349 354
					return false;
350 355
				}
351 356
				
......
354 359
			if (! taxon.isMisapplication()){
355 360
				for (Marker marker : taxon.getMarkers()){
356 361
					if (marker.getValue() == false && marker.getMarkerType().equals(MarkerType.PUBLISH())){
362
						taxon = null;
357 363
						return false;
358 364
					}
359 365
				}
......
361 367
			//handle misapplied names
362 368
			}else{
363 369
				if (excludeMisappliedNames){
370
					taxon = null;
364 371
					return false;
365 372
				}
366 373
				for (Marker marker : taxon.getMarkers()){
367 374
					//probably not needed any more after #2786 was fixed
368 375
					if (marker.getValue() == true && marker.getMarkerType().getUuid().equals(BerlinModelTransformer.uuidMisappliedCommonName)){
369 376
						logger.warn("Misapplied common name still exists");
377
						taxon = null;
370 378
						return false;
371 379
					}
372 380
				}
......
374 382
					if (taxRel.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
375 383
//						logger.warn(taxRel.getUuid() + "; " + taxRel.getToTaxon().getUuid() + " + " + taxRel.getToTaxon().getTitleCache());
376 384
						if (isPesiTaxon(taxRel.getToTaxon(), true)){
385
							taxon = null;
377 386
							return true;
378 387
						}
379 388
					}
380 389
				}
381 390
				if (logger.isDebugEnabled()){ logger.debug("Misapplied name has no accepted PESI taxon: " +  taxon.getUuid() + ", (" +  taxon.getTitleCache() + ")");}
391
				taxon = null;
382 392
				return false;
383 393
			}
384 394
		//handle synonyms
......
391 401
				}
392 402
			}
393 403
			if (!hasAcceptedPesiTaxon) {if (logger.isDebugEnabled()){logger.debug("Synonym has no accepted PESI taxon: " +  synonym.getUuid() + ", (" +  synonym.getTitleCache() + ")");}}
404
			synonym = null;
394 405
			return hasAcceptedPesiTaxon;
395 406
		}else {
396 407
			throw new RuntimeException("Unknown taxon base type: " + taxonBase.getClass());
......
432 443
	
433 444
	
434 445
	
435
	static NonViralNameDefaultCacheStrategy getCacheStrategy(TaxonNameBase<?, ?> taxonName) {
446
	protected static NonViralNameDefaultCacheStrategy getCacheStrategy(TaxonNameBase<?, ?> taxonName) {
436 447
		NonViralNameDefaultCacheStrategy cacheStrategy;
437 448
		if (taxonName.isInstanceOf(ZoologicalName.class)){
438 449
			cacheStrategy = zooNameStrategy;
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiRelTaxonExport.java
215 215
		}
216 216
		list = null;
217 217
		logger.info("End PHASE 2: Name Relationships ...");
218
				
218
		state.setCurrentFromObject(null);
219
		state.setCurrentToObject(null);	
219 220
		return success;
220 221
	}
221 222

  
......
421 422
			// SynonymNameRelationship
422 423
			success &= saveNameRelationships(state, synonym);
423 424
		}
425
		state.setCurrentFromObject(null);
424 426
		return success;
425 427
	}
426 428

  
......
439 441
		state.setCurrentToObject(taxonBase);
440 442
		isFrom = false;
441 443
		success &= saveOneSideNameRelation(state, isFrom, nameRelations);
442
		
444
		state.setCurrentToObject(null);
443 445
		return success;
444 446
	}
445 447

  
......
474 476
			doCount(count++, modCount, pluralString);
475 477
			success &= mapping.invoke(nameRelation);
476 478
		}
479
		state.setCurrentFromObject(null);
480
		state.setCurrentToObject(null);
477 481
		return success;
478 482
	}
479 483

  
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java
31 31
import org.springframework.stereotype.Component;
32 32
import org.springframework.transaction.TransactionStatus;
33 33

  
34
import com.yourkit.api.Controller;
35

  
34 36
import eu.etaxonomy.cdm.api.service.TaxonServiceImpl;
35 37
import eu.etaxonomy.cdm.common.CdmUtils;
36 38
import eu.etaxonomy.cdm.io.common.Source;
......
338 340
		logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
339 341
		
340 342
		
343
		
341 344
		int partitionCount = 0;
342
		while ((list = getNextTaxonPartition(null, limit, partitionCount++, null)) != null   ) {
343 345

  
346
		logger.warn("Taking snapshot at the beginning of phase 1 of taxonExport");
347
		ProfilerController.memorySnapshot();
348
		while ((list = getNextTaxonPartition(null, limit, partitionCount++, null)) != null   ) {
349
			
344 350
			logger.info("Fetched " + list.size() + " " + pluralString + ". Exporting...");
345 351
			for (TaxonBase<?> taxon : list) {
346 352
				doCount(count++, modCount, pluralString);
......
364 370
				
365 371
				validatePhaseOne(taxon, nvn);
366 372
				taxon = null;
373
				nvn = null;
374
				taxonName = null;
375

  
376
				
367 377
				
368 378
			}
379
			
369 380

  
370 381
			// Commit transaction
371 382
			commitTransaction(txStatus);
372 383
			logger.debug("Committed transaction.");
373 384
			logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count);
374 385
			pastCount = count;
375

  
386
			/*logger.warn("Taking snapshot at the end of the loop of phase 1 of taxonExport");
387
			ProfilerController.memorySnapshot();
388
			*/
376 389
			// Start transaction
377 390
			txStatus = startTransaction(true);
378 391
			logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
......
383 396
		}
384 397
		
385 398
		
386
		logger.warn("Taking snapshot at the end of phase 1 of taxonExport");
387
		ProfilerController.memorySnapshot();
399
		
388 400
		// Commit transaction
389 401
		commitTransaction(txStatus);
402
		txStatus = null;
390 403
		logger.debug("Committed transaction.");
391 404
		list = null;
405
		logger.warn("Taking snapshot at the end of phase 1 of taxonExport");
406
		ProfilerController.memorySnapshot();
392 407
		return success;
393 408
	}
394 409

  
......
627 642
		}
628 643
		
629 644
		list = null;
630
		logger.warn("Taking snapshot at the end of phase 3 of taxonExport");
631
		ProfilerController.memorySnapshot();
645
		
632 646
		// Commit transaction
633 647
		commitTransaction(txStatus);
648
		
634 649
		logger.debug("Committed transaction.");
650
		logger.warn("Taking snapshot at the end of phase 3 of taxonExport, number of partitions: " + partitionCount);
651
		ProfilerController.memorySnapshot();
635 652
		return success;
636 653
	}
637 654
	
......
661 678
		String inferredSynonymPluralString = "Inferred Synonyms";
662 679
		
663 680
		// Start transaction
664
		
665
		Taxon acceptedTaxon = null;
666 681
		TransactionStatus txStatus = startTransaction(true);
667 682
		logger.info("Started new transaction. Fetching some " + parentPluralString + " first (max: " + limit + ") ...");
668 683
		List<TaxonBase> taxonList = null;
......
674 689

  
675 690
			logger.info("Fetched " + taxonList.size() + " " + parentPluralString + ". Exporting...");
676 691
			inferredSynonymsDataToBeSaved.putAll(createInferredSynonymsForTaxonList(state, mapping,
677
					synRelMapping, taxonList,
678
					inferredSynonymsDataToBeSaved));
692
					synRelMapping, taxonList));
679 693
			
680 694
			doCount(count += taxonList.size(), modCount, inferredSynonymPluralString);
681 695
			// Commit transaction
......
702 716

  
703 717
			logger.info("Fetched " + taxonList.size() + " " + parentPluralString + ". Exporting...");
704 718
			inferredSynonymsDataToBeSaved.putAll(createInferredSynonymsForTaxonList(state, mapping,
705
					synRelMapping, taxonList,
706
					inferredSynonymsDataToBeSaved));
719
					synRelMapping, taxonList));
707 720
			;
708 721
			doCount(count += taxonList.size(), modCount, inferredSynonymPluralString);
709 722
			// Commit transaction
......
748 761
	 */
749 762
	private HashMap<Integer, TaxonNameBase<?, ?>> createInferredSynonymsForTaxonList(PesiExportState state,
750 763
			PesiExportMapping mapping, PesiExportMapping synRelMapping,
751
			 List<TaxonBase> taxonList,
752
			HashMap<Integer, TaxonNameBase<?, ?>> inferredSynonymsDataToBeSaved) {
764
			 List<TaxonBase> taxonList) {
753 765
		
754 766
		Taxon acceptedTaxon;
755 767
		Classification classification = null;
756 768
		List<Synonym> inferredSynonyms = null;
757 769
		boolean localSuccess = true;
758 770
		
771
		HashMap<Integer, TaxonNameBase<?,?>> inferredSynonymsDataToBeSaved = new HashMap<Integer, TaxonNameBase<?,?>>();
772
		
759 773
		for (TaxonBase<?> taxonBase : taxonList) {
760 774
		
761 775
			if (taxonBase.isInstanceOf(Taxon.class)) { // this should always be the case since we should have fetched accepted taxon only, but you never know...
......
837 851
										}
838 852
									}
839 853
									
840
									
841
									// Add Rank Data and KingdomFk to hashmap for later saving
842 854
									inferredSynonymsDataToBeSaved.put(synonym.getId(), synonym.getName());
843 855
								}
844 856
							}
......
1472 1484
			
1473 1485
			NonViralName<?> nvn = CdmBase.deproxy(taxonName, NonViralName.class);
1474 1486
			String result = cacheStrategy.getFullTitleCache(nvn, tagRules);
1475
			
1476
			
1487
			cacheStrategy = null;
1488
			nvn = null;
1477 1489
			return result.replaceAll("\\<@status@\\>.*\\</@status@\\>", "");
1478 1490
		}
1479 1491
	}
......
1510 1522
		
1511 1523
			HTMLTagRules tagRules = new HTMLTagRules().addRule(TagEnum.name, "i");
1512 1524
			NonViralName<?> nvn = CdmBase.deproxy(taxonName, NonViralName.class);
1513
			return cacheStrategy.getTitleCache(nvn, tagRules);
1525
			String result = cacheStrategy.getTitleCache(nvn, tagRules);
1526
			cacheStrategy = null;
1527
			nvn = null;
1528
			return result;
1514 1529
		}
1515 1530
	}
1516 1531

  
......
1527 1542
		NonViralName<?> nvn = CdmBase.deproxy(taxonName, NonViralName.class);
1528 1543
		NonViralNameDefaultCacheStrategy strategy = getCacheStrategy(nvn);
1529 1544
		String result = strategy.getNameCache(nvn);
1545
		strategy = null;
1546
		nvn = null;
1530 1547
		return result;
1531 1548
	}
1532 1549

  
......
1549 1566
				if (isMisappliedName(taxon)){
1550 1567
					result = result + " " + getAuthorString(taxon);
1551 1568
				}
1569
				taxon = null;
1552 1570
			}
1553 1571
		}
1572
		taxa = null;
1573
		nvn = null;
1554 1574
		return result;
1555 1575
	}
1556 1576
	
......
1934 1954
			}
1935 1955
		} catch (Exception e) {
1936 1956
			e.printStackTrace();
1957
			logger.error("An error occurs while creating idInSource..." + taxonName.getUuid() + " (" + taxonName.getTitleCache()+ e.getMessage());
1937 1958
		}
1938 1959

  
1939 1960
		if (result == null) {
......
2299 2320
		
2300 2321
	}
2301 2322
	
2302
	private static NonViralNameDefaultCacheStrategy getCacheStrategy(TaxonNameBase<?, ?> taxonName) {
2323
	protected static NonViralNameDefaultCacheStrategy getCacheStrategy(TaxonNameBase<?, ?> taxonName) {
2303 2324
		taxonName = CdmBase.deproxy(taxonName, TaxonNameBase.class);
2304 2325
		NonViralNameDefaultCacheStrategy<?> cacheStrategy;
2305 2326
		if (taxonName.isInstanceOf(ZoologicalName.class)){

Also available in: Unified diff