Revision 06c249eb
Added by Andreas Kohlbecker almost 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationConverter.java | ||
---|---|---|
25 | 25 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
26 | 26 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
27 | 27 |
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase; |
28 |
import eu.etaxonomy.cdm.vaadin.view.registration.IdAndString;
|
|
28 |
import eu.etaxonomy.cdm.vaadin.model.EntityReference;
|
|
29 | 29 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationValidationException; |
30 | 30 |
|
31 | 31 |
/** |
... | ... | |
44 | 44 |
private final String separator = ", "; |
45 | 45 |
|
46 | 46 |
private Collection<TypeDesignationBase> typeDesignations; |
47 |
private Map<TypeDesignationStatusBase<?>, Collection<IdAndString>> orderedStringsByType;
|
|
48 |
private LinkedHashMap<String, Collection<IdAndString>> orderedRepresentations = new LinkedHashMap<>();
|
|
49 |
private IdAndString typifiedName;
|
|
47 |
private Map<TypeDesignationStatusBase<?>, Collection<EntityReference>> orderedStringsByType;
|
|
48 |
private LinkedHashMap<String, Collection<EntityReference>> orderedRepresentations = new LinkedHashMap<>();
|
|
49 |
private EntityReference typifiedName;
|
|
50 | 50 |
|
51 | 51 |
private String finalString = null; |
52 | 52 |
|
... | ... | |
60 | 60 |
public TypeDesignationConverter(Collection<TypeDesignationBase> typeDesignations) throws RegistrationValidationException { |
61 | 61 |
this.typeDesignations = typeDesignations; |
62 | 62 |
orderedStringsByType = new HashMap<>(); |
63 |
typeDesignations.forEach(td -> putString(td.getTypeStatus(), new IdAndString(td.getId(), stringify(td))));
|
|
63 |
typeDesignations.forEach(td -> putString(td.getTypeStatus(), new EntityReference(td.getId(), stringify(td))));
|
|
64 | 64 |
orderedRepresentations = buildOrderedRepresentations(); |
65 | 65 |
this.typifiedName = findTypifiedName(); |
66 | 66 |
} |
... | ... | |
106 | 106 |
return this; |
107 | 107 |
} |
108 | 108 |
|
109 |
public Map<String, Collection<IdAndString>> getOrderedTypeDesignationRepresentations() {
|
|
109 |
public Map<String, Collection<EntityReference>> getOrderedTypeDesignationRepresentations() {
|
|
110 | 110 |
return orderedRepresentations; |
111 | 111 |
} |
112 | 112 |
|
... | ... | |
116 | 116 |
* @return |
117 | 117 |
* @throws RegistrationValidationException |
118 | 118 |
*/ |
119 |
private IdAndString findTypifiedName() throws RegistrationValidationException {
|
|
119 |
private EntityReference findTypifiedName() throws RegistrationValidationException {
|
|
120 | 120 |
|
121 | 121 |
List<String> problems = new ArrayList<>(); |
122 | 122 |
|
... | ... | |
154 | 154 |
} |
155 | 155 |
|
156 | 156 |
if(typifiedName != null){ |
157 |
return new IdAndString(typifiedName.getId(), typifiedName.getTitleCache());
|
|
157 |
return new EntityReference(typifiedName.getId(), typifiedName.getTitleCache());
|
|
158 | 158 |
} |
159 | 159 |
return null; |
160 | 160 |
} |
... | ... | |
173 | 173 |
/** |
174 | 174 |
* @return the title cache of the typifying name or <code>null</code> |
175 | 175 |
*/ |
176 |
public IdAndString getTypifiedName() {
|
|
176 |
public EntityReference getTypifiedName() {
|
|
177 | 177 |
|
178 | 178 |
return typifiedName; |
179 | 179 |
|
... | ... | |
264 | 264 |
return sb.toString(); |
265 | 265 |
} |
266 | 266 |
|
267 |
private void putString(TypeDesignationStatusBase<?> status, IdAndString idAndString){
|
|
267 |
private void putString(TypeDesignationStatusBase<?> status, EntityReference idAndString){
|
|
268 | 268 |
// the cdm orderd term bases are ordered invers, fixing this for here |
269 | 269 |
if(status == null){ |
270 | 270 |
status = SpecimenTypeDesignationStatus.TYPE(); |
271 | 271 |
} |
272 | 272 |
if(!orderedStringsByType.containsKey(status)){ |
273 |
orderedStringsByType.put(status, new ArrayList<IdAndString>());
|
|
273 |
orderedStringsByType.put(status, new ArrayList<EntityReference>());
|
|
274 | 274 |
} |
275 | 275 |
orderedStringsByType.get(status).add(idAndString); |
276 | 276 |
} |
Also available in: Unified diff
ref #6169 better name for IdAndString class: EntityReference