Revision 73984434
Added by Andreas Kohlbecker about 6 years ago
- ID 739844349fa94d49455288671711f0217ddc8204
- Parent 51d6bc3c
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationDTO.java | ||
---|---|---|
13 | 13 |
import java.util.HashSet; |
14 | 14 |
import java.util.LinkedHashMap; |
15 | 15 |
import java.util.List; |
16 |
import java.util.Optional; |
|
17 | 16 |
import java.util.Set; |
18 | 17 |
import java.util.UUID; |
19 | 18 |
|
... | ... | |
23 | 22 |
|
24 | 23 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
25 | 24 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
25 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
|
26 | 26 |
import eu.etaxonomy.cdm.model.name.Registration; |
27 | 27 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus; |
28 | 28 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
... | ... | |
299 | 299 |
return dto; |
300 | 300 |
} |
301 | 301 |
|
302 |
public NameTypeDesignation getNameTypeDesignation(TypedEntityReference baseEntityReference) { |
|
303 |
Set<TypeDesignationBase> typeDesignations = getTypeDesignationsInWorkingSet(baseEntityReference); |
|
304 |
if(typeDesignations.size() == 1){ |
|
305 |
TypeDesignationBase item = typeDesignations.iterator().next(); |
|
306 |
return (NameTypeDesignation)item ; |
|
307 |
} |
|
308 |
if(typeDesignations.size() == 0){ |
|
309 |
return null; |
|
310 |
} |
|
311 |
if(typeDesignations.size() > 1){ |
|
312 |
throw new RuntimeException("Workingsets of NameTypeDesignations must contain exactly one item."); |
|
313 |
} |
|
314 |
return null; |
|
315 |
} |
|
316 |
|
|
302 | 317 |
/** |
303 | 318 |
* |
304 | 319 |
* @param workingSetId |
305 | 320 |
* @return the TypeDesignationWorkingSet in this DTO with the matching workingSetId or NULL |
306 | 321 |
*/ |
307 | 322 |
public TypeDesignationWorkingSet getTypeDesignationWorkingSet(int workingSetId) { |
308 |
Optional<TypeDesignationWorkingSet> workingSetOptional = getOrderdTypeDesignationWorkingSets().values().stream().filter(workingSet -> workingSet.getWorkingSetId() == workingSetId).findFirst(); |
|
309 |
if(workingSetOptional.isPresent()){ |
|
310 |
return workingSetOptional.get(); |
|
323 |
for(TypeDesignationWorkingSet workingSet : getOrderdTypeDesignationWorkingSets().values()){ |
|
324 |
logger.debug("WorkingSet:" + workingSet.getWorkingsetType() + "#" + workingSet.getWorkingSetId()); |
|
325 |
if(workingSet.getWorkingSetId() == workingSetId){ |
|
326 |
return workingSet; |
|
327 |
} |
|
311 | 328 |
} |
312 | 329 |
return null; |
313 | 330 |
|
Also available in: Unified diff
#6740 service methods to load NameTypeDesignations for Registrations