Revision 005402b8
Added by Andreas Kohlbecker almost 3 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DescriptionBaseDto.java | ||
---|---|---|
29 | 29 |
*/ |
30 | 30 |
public class DescriptionBaseDto implements Serializable{ |
31 | 31 |
|
32 |
private static final long serialVersionUID = -1578895619195062502L; |
|
33 |
|
|
32 | 34 |
private UuidAndTitleCache<Taxon> taxonUuid; |
33 | 35 |
private DerivateDTO specimenDto; |
34 | 36 |
|
... | ... | |
43 | 45 |
taxonUuid = new UuidAndTitleCache<>(taxon.getUuid(), taxon.getId(), taxon.getTitleCache()); |
44 | 46 |
}else if (description instanceof SpecimenDescription){ |
45 | 47 |
SpecimenOrObservationBase sob = ((SpecimenDescription)description).getDescribedSpecimenOrObservation(); |
46 |
specimenDto = SpecimenOrObservationDTOFactory.fromEntity((FieldUnit)sob);
|
|
48 |
specimenDto = SpecimenOrObservationDTOFactory.fromEntity(sob); |
|
47 | 49 |
}else if (description instanceof TaxonNameDescription){ |
48 | 50 |
TaxonName name = ((TaxonNameDescription)description).getTaxonName(); |
49 | 51 |
nameUuid = new UuidAndTitleCache<>(name.getUuid(), name.getId(), name.getTitleCache()); |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/SpecimenOrObservationDTOFactory.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2020 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.service.dto; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
12 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
13 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
14 |
|
|
15 |
/** |
|
16 |
* Factory for all SpecimenOrObservationBase related DTOs. |
|
17 |
* <p> |
|
18 |
* Internally this class delegates to the factory methods of the specific DTO implementations. |
|
19 |
* |
|
20 |
* @author a.kohlbecker |
|
21 |
* @since Oct 14, 2020 |
|
22 |
*/ |
|
23 |
public class SpecimenOrObservationDTOFactory { |
|
24 |
|
|
25 |
public static DerivateDTO fromEntity(SpecimenOrObservationBase entity) { |
|
26 |
if(entity == null) { |
|
27 |
return null; |
|
28 |
} |
|
29 |
if (entity instanceof FieldUnit) { |
|
30 |
return FieldUnitDTO.fromEntity((FieldUnit) entity); |
|
31 |
} else { |
|
32 |
return PreservedSpecimenDTO.fromEntity((DerivedUnit) entity); |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
public static FieldUnitDTO fromFieldUnit(FieldUnit entity){ |
|
37 |
if(entity == null) { |
|
38 |
return null; |
|
39 |
} |
|
40 |
return FieldUnitDTO.fromEntity(entity); |
|
41 |
} |
|
42 |
|
|
43 |
public static PreservedSpecimenDTO fromDerivedUnit(DerivedUnit entity){ |
|
44 |
if(entity == null) { |
|
45 |
return null; |
|
46 |
} |
|
47 |
return PreservedSpecimenDTO.fromEntity(entity); |
|
48 |
} |
|
49 |
|
|
50 |
} |
Also available in: Unified diff
ref #9252 harmonizing SpecimenOrOberservationBase related DTOs