Revision b38e19e0
Added by Andreas Kohlbecker almost 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationConverter.java | ||
---|---|---|
73 | 73 |
* @throws RegistrationValidationException |
74 | 74 |
* |
75 | 75 |
*/ |
76 |
public TypeDesignationConverter(Collection<TypeDesignationBase> typeDesignations) throws RegistrationValidationException { |
|
76 |
public TypeDesignationConverter(CdmBase containgEntity, Collection<TypeDesignationBase> typeDesignations) throws RegistrationValidationException {
|
|
77 | 77 |
this.typeDesignations = typeDesignations; |
78 | 78 |
Map<TypedEntityReference, TypeDesignationWorkingSet> byBaseEntityByTypeStatus = new HashMap<>(); |
79 |
typeDesignations.forEach(td -> mapTypeDesignation(byBaseEntityByTypeStatus, td)); |
|
79 |
typeDesignations.forEach(td -> mapTypeDesignation(containgEntity, byBaseEntityByTypeStatus, td));
|
|
80 | 80 |
orderedByTypesByBaseEntity = orderByTypeByBaseEntity(byBaseEntityByTypeStatus); |
81 | 81 |
this.typifiedName = findTypifiedName(); |
82 | 82 |
} |
83 | 83 |
|
84 | 84 |
|
85 |
private void mapTypeDesignation(Map<TypedEntityReference, TypeDesignationWorkingSet> byBaseEntityByTypeStatus, |
|
85 |
private void mapTypeDesignation(CdmBase containgEntity, Map<TypedEntityReference, TypeDesignationWorkingSet> byBaseEntityByTypeStatus,
|
|
86 | 86 |
TypeDesignationBase<?> td){ |
87 | 87 |
|
88 | 88 |
TypeDesignationStatusBase<?> status = td.getTypeStatus(); |
... | ... | |
93 | 93 |
|
94 | 94 |
TypeDesignationWorkingSet typedesignationWorkingSet; |
95 | 95 |
if(!byBaseEntityByTypeStatus.containsKey(baseEntityReference)){ |
96 |
byBaseEntityByTypeStatus.put(baseEntityReference, new TypeDesignationWorkingSet()); |
|
96 |
TypedEntityReference containigEntityReference = new TypedEntityReference(containgEntity.getClass(), containgEntity.getId(), containgEntity.toString()); |
|
97 |
byBaseEntityByTypeStatus.put(baseEntityReference, new TypeDesignationWorkingSet(containigEntityReference, baseEntityReference)); |
|
97 | 98 |
} |
98 | 99 |
|
99 | 100 |
typedesignationWorkingSet = byBaseEntityByTypeStatus.get(baseEntityReference); |
... | ... | |
163 | 164 |
} |
164 | 165 |
}); |
165 | 166 |
// new LinkedHashMap for the ordered TypeDesignationStatusBase keys |
166 |
TypeDesignationWorkingSet orderedStringsByOrderedTypes = new TypeDesignationWorkingSet(); |
|
167 |
TypeDesignationWorkingSet orderedStringsByOrderedTypes = new TypeDesignationWorkingSet(typeDesignationWorkingSet.getContainigEntityReference(), baseEntityRef);
|
|
167 | 168 |
keyList.forEach(key -> orderedStringsByOrderedTypes.put(key, typeDesignationWorkingSet.get(key))); |
168 | 169 |
stringsOrderedbyBaseEntityOrderdByType.put(baseEntityRef, orderedStringsByOrderedTypes); |
169 | 170 |
} |
... | ... | |
472 | 473 |
|
473 | 474 |
String workingSetRepresentation = null; |
474 | 475 |
|
476 |
TypedEntityReference containigEntityReference; |
|
477 |
|
|
478 |
TypedEntityReference baseEntityReference; |
|
475 | 479 |
|
476 | 480 |
private static final long serialVersionUID = -1329007606500890729L; |
477 | 481 |
|
482 |
/** |
|
483 |
* @param baseEntityReference |
|
484 |
*/ |
|
485 |
public TypeDesignationWorkingSet(TypedEntityReference containigEntityReference, TypedEntityReference baseEntityReference) { |
|
486 |
this.containigEntityReference = containigEntityReference; |
|
487 |
this.baseEntityReference = baseEntityReference; |
|
488 |
} |
|
489 |
|
|
478 | 490 |
public List<EntityReference> getTypeDesignations() { |
479 | 491 |
List<EntityReference> typeDesignations = new ArrayList<>(); |
480 | 492 |
this.values().forEach(typeDesignationReferences -> typeDesignationReferences.forEach(td -> typeDesignations.add(td))); |
... | ... | |
494 | 506 |
put(status, new ArrayList<EntityReference>()); |
495 | 507 |
} |
496 | 508 |
get(status).add(typeDesignationEntityReference); |
497 |
|
|
498 | 509 |
} |
499 | 510 |
|
500 | 511 |
public String getRepresentation() { |
... | ... | |
505 | 516 |
this.workingSetRepresentation = representation; |
506 | 517 |
} |
507 | 518 |
|
519 |
/** |
|
520 |
* A reference to the entity which is the common base entity for all TypeDesignations in this workingset. |
|
521 |
* For a {@link SpecimenTypeDesignation} this is usually the {@link FieldUnit} if it is present. Otherwise it can also be |
|
522 |
* a {@link DerivedUnit} or something else depending on the specific use case. |
|
523 |
* |
|
524 |
* @return the baseEntityReference |
|
525 |
*/ |
|
526 |
public TypedEntityReference getBaseEntityReference() { |
|
527 |
return baseEntityReference; |
|
528 |
} |
|
529 |
|
|
530 |
/** |
|
531 |
* A reference to the entity which contains the TypeDesignations bundled in this working set. |
|
532 |
* This can be for example a {@link TaxonName} or a {@link Registration} entity. |
|
533 |
* |
|
534 |
* @return the baseEntityReference |
|
535 |
*/ |
|
536 |
public TypedEntityReference getContainigEntityReference() { |
|
537 |
return containigEntityReference; |
|
538 |
} |
|
539 |
|
|
508 | 540 |
@Override |
509 | 541 |
public String toString(){ |
510 | 542 |
if(workingSetRepresentation != null){ |
Also available in: Unified diff
ref #6724 initial trunk implementation for a SpecimenTypeDesignationWorkingsetEditor