Project

General

Profile

« Previous | Next » 

Revision 892efc69

Added by Andreas Kohlbecker almost 14 years ago

merging /branches/cdmlib/SPRINT-Chichorieae1/ to trunk

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/name/NonViralNameDefaultCacheStrategy.java
217 217
	}
218 218
	
219 219
	
220

  
221
	
222
	
220 223
	@Override
221 224
	public String getFullTitleCache(T nonViralName) {
222 225
		//null
......
254 257
				NomenclaturalStatusType statusType =  ncStatus.getType();
255 258
				Language lang = Language.LATIN();
256 259
				Representation repr = statusType.getRepresentation(lang);
257
				suffix = repr.getAbbreviatedLabel();
260
				if (repr != null){
261
					suffix = repr.getAbbreviatedLabel();
262
				}else{
263
					String message = "No latin representation available for nom. status. " + statusType.getTitleCache();
264
					logger.warn(message);
265
					throw new IllegalStateException(message);
266
				}
258 267
			}else if(ncStatus.getRuleConsidered() != null && ! ncStatus.getRuleConsidered().equals("")){
259 268
				suffix = ncStatus.getRuleConsidered();
260 269
			}
......
375 384
	@Override
376 385
	public List<Object> getTaggedName(T nonViralName) {
377 386
		List<Object> tags = new ArrayList<Object>();
378
		tags.add(nonViralName.getGenusOrUninomial());
387
		if (nonViralName.getGenusOrUninomial() == null){
388
			tags.add(nonViralName.getNameCache());
389
		}else{
390
			tags.add(nonViralName.getGenusOrUninomial());
391
		}
379 392
		if (nonViralName.isSpecies() || nonViralName.isInfraSpecific()){
380 393
			tags.add(nonViralName.getSpecificEpithet());			
381 394
		}
......
389 402
		if (nonViralName.isInfraGeneric()){
390 403
			//TODO choose right strategy or generic approach?
391 404
			// --- strategy 1 --- 
392
			tags.add(nonViralName.getRank());			
393
			tags.add(nonViralName.getInfraGenericEpithet());			
405
					
406
			if (nonViralName.getRank().isSpeciesAggregate()){
407
				tags.add(getSpeciesAggregateEpithet(nonViralName));
408
			}else{
409
				tags.add(nonViralName.getRank());	
410
				tags.add(nonViralName.getInfraGenericEpithet());	
411
			}
394 412
			// --- strategy 2 --- 
395 413
//			tags.add('('+nvn.getInfraGenericEpithet()+')');	
396 414
		}
397 415
		Team authorTeam = Team.NewInstance();
398 416
		authorTeam.setProtectedTitleCache(true);
399
		authorTeam.setTitleCache(nonViralName.getAuthorshipCache());
417
		authorTeam.setTitleCache(nonViralName.getAuthorshipCache(), true);
400 418
		tags.add(authorTeam);
401 419
		
402 420
		// Name is an autonym. Rank and infraspecific eitheton follow the author
......
405 423
			tags.add(nonViralName.getInfraSpecificEpithet());			
406 424
		}
407 425
		
408
		if(! "".equals(nonViralName.getAppendedPhrase())){
426
		if(! "".equals(nonViralName.getAppendedPhrase())&& (nonViralName.getAppendedPhrase() != null)){
409 427
			tags.add(nonViralName.getAppendedPhrase());
410 428
		}
411 429
		
......
413 431
	}
414 432
	
415 433

  
416
	/************** PRIVATES ****************/
434
//***************************** PRIVATES ***************************************/
417 435
		
418 436
		protected String getRanklessNameCache(NonViralName nonViralName){
419 437
			String result = "";
......
440 458
			if (rank.isSpeciesAggregate()){
441 459
				return getSpeciesAggregateCache(nonViralName);
442 460
			}
443
			String infraGenericMarker = "xxx.";
461
			String infraGenericMarker = "'unhandled infrageneric rank'";
444 462
			if (rank != null){
445 463
				try {
446 464
					infraGenericMarker = rank.getInfraGenericMarker();
......
458 476
		protected String getSpeciesAggregateCache(NonViralName nonViralName){
459 477
			String result;
460 478
			result = CdmUtils.Nz(nonViralName.getGenusOrUninomial());
461
			result += " " + CdmUtils.Nz(nonViralName.getSpecificEpithet()).trim().replace("null", "");
479
			
480
			result += " "+getSpeciesAggregateEpithet(nonViralName);
481
			/*result += " " + CdmUtils.Nz(nonViralName.getSpecificEpithet()).trim().replace("null", "");
462 482
			String marker;
463 483
			try {
464 484
				marker = nonViralName.getRank().getInfraGenericMarker();
465 485
			} catch (UnknownCdmTypeException e) {
466 486
				marker = "'unknown aggregat type'";
467 487
			}
468
			result += " " + marker;
488
			result += " " + marker;*/
469 489
			result = addAppendedPhrase(result, nonViralName).trim();
470 490
			return result;
471 491
		}
472 492
		
493
		private String getSpeciesAggregateEpithet(NonViralName nonViralName) {
494
			String result;
495
			
496
			result = CdmUtils.Nz(nonViralName.getSpecificEpithet()).trim().replace("null", "");
497
			String marker;
498
			try {
499
				marker = nonViralName.getRank().getInfraGenericMarker();
500
			} catch (UnknownCdmTypeException e) {
501
				marker = "'unknown aggregat type'";
502
			}
503
			result += " " + marker;
504
			
505
			return result;
506
		}
507
		
473 508
		protected String getSpeciesNameCache(NonViralName nonViralName){
474 509
			String result;
475 510
			result = CdmUtils.Nz(nonViralName.getGenusOrUninomial());

Also available in: Unified diff