Revision 1233268f
Added by Andreas Kohlbecker almost 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationConverter.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy; |
24 | 24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
25 |
import eu.etaxonomy.cdm.model.common.Language;
|
|
25 |
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
|
26 | 26 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
27 | 27 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
28 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus; |
|
29 | 28 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
30 | 29 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
31 | 30 |
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase; |
... | ... | |
70 | 69 |
|
71 | 70 |
private String finalString = null; |
72 | 71 |
|
72 |
final NullTypeDesignationStatus NULL_STATUS = new NullTypeDesignationStatus(); |
|
73 |
|
|
73 | 74 |
/** |
74 | 75 |
* @param taxonName |
75 | 76 |
* @throws RegistrationValidationException |
... | ... | |
239 | 240 |
sb.append(TYPE_STATUS_SEPARATOR); |
240 | 241 |
} |
241 | 242 |
boolean isPlural = typeDesignationWorkingSet.get(typeStatus).size() > 1; |
242 |
sb.append(typeStatus.getLabel()); |
|
243 |
if(isPlural){ |
|
244 |
sb.append("s: "); |
|
245 |
} else { |
|
246 |
sb.append(", "); |
|
243 |
if(!typeStatus.equals(NULL_STATUS)) { |
|
244 |
sb.append(typeStatus.getLabel()); |
|
245 |
if(isPlural){ |
|
246 |
sb.append("s: "); |
|
247 |
} else { |
|
248 |
sb.append(", "); |
|
249 |
} |
|
247 | 250 |
} |
248 | 251 |
int typeDesignationCount = 0; |
249 | 252 |
for(EntityReference typeDesignationEntityReference : typeDesignationWorkingSet.get(typeStatus)) { |
... | ... | |
358 | 361 |
return orderedByTypesByBaseEntity; |
359 | 362 |
} |
360 | 363 |
|
361 |
|
|
362 |
|
|
363 |
/** |
|
364 |
* @param key |
|
365 |
* @return |
|
366 |
*/ |
|
367 |
protected String getTypeDesignationStytusLabel(TypeDesignationStatusBase<?> key) { |
|
368 |
String typeLable; |
|
369 |
if(key.equals( SpecimenTypeDesignationStatus.TYPE())){ |
|
370 |
typeLable = "Type"; |
|
371 |
} else { |
|
372 |
typeLable = key.getPreferredRepresentation(Language.DEFAULT()).getLabel(); |
|
373 |
} |
|
374 |
return typeLable; |
|
375 |
} |
|
376 |
|
|
377 | 364 |
/** |
378 | 365 |
* @param td |
379 | 366 |
* @return |
... | ... | |
516 | 503 |
|
517 | 504 |
private static final long serialVersionUID = -1329007606500890729L; |
518 | 505 |
|
506 |
private List<String> problems = new ArrayList<>(); |
|
507 |
|
|
519 | 508 |
/** |
520 | 509 |
* @param baseEntityReference |
521 | 510 |
*/ |
... | ... | |
537 | 526 |
public void insert(TypeDesignationStatusBase<?> status, EntityReference typeDesignationEntityReference) { |
538 | 527 |
|
539 | 528 |
if(status == null){ |
540 |
status = SpecimenTypeDesignationStatus.TYPE();
|
|
529 |
status = NULL_STATUS;
|
|
541 | 530 |
} |
542 | 531 |
if(!containsKey(status)){ |
543 | 532 |
put(status, new ArrayList<EntityReference>()); |
... | ... | |
597 | 586 |
} |
598 | 587 |
} |
599 | 588 |
|
589 |
/** |
|
590 |
* @return the problems |
|
591 |
*/ |
|
592 |
public List<String> getProblems() { |
|
593 |
return problems; |
|
594 |
} |
|
595 |
|
|
596 |
/** |
|
597 |
* @param problems the problems to set |
|
598 |
*/ |
|
599 |
public void setProblems(List<String> problems) { |
|
600 |
this.problems = problems; |
|
601 |
} |
|
602 |
|
|
603 |
} |
|
604 |
|
|
605 |
class NullTypeDesignationStatus extends TypeDesignationStatusBase<NullTypeDesignationStatus>{ |
|
606 |
|
|
607 |
/** |
|
608 |
* {@inheritDoc} |
|
609 |
*/ |
|
610 |
@Override |
|
611 |
public void resetTerms() { |
|
612 |
// empty |
|
613 |
|
|
614 |
} |
|
615 |
|
|
616 |
/** |
|
617 |
* {@inheritDoc} |
|
618 |
*/ |
|
619 |
@Override |
|
620 |
protected void setDefaultTerms(TermVocabulary<NullTypeDesignationStatus> termVocabulary) { |
|
621 |
// empty |
|
622 |
} |
|
623 |
|
|
624 |
|
|
625 |
|
|
600 | 626 |
} |
601 | 627 |
|
602 | 628 |
} |
Also available in: Unified diff
ref #6719 better handling of case when statusType is null