Revision 85d748e1
Added by Andreas Kohlbecker about 3 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/CollectionDTO.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.api.service.dto; |
10 | 10 |
|
11 |
import java.util.HashSet; |
|
12 |
import java.util.Set; |
|
13 |
|
|
11 | 14 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
12 | 15 |
import eu.etaxonomy.cdm.ref.TypedEntityReference; |
13 | 16 |
|
... | ... | |
34 | 37 |
} |
35 | 38 |
|
36 | 39 |
/** |
37 |
* @param collection
|
|
40 |
* @deprecated use factory instead
|
|
38 | 41 |
*/ |
42 |
@Deprecated |
|
39 | 43 |
public CollectionDTO(Collection collection) { |
44 |
this(collection, new HashSet<>()); |
|
45 |
} |
|
46 |
|
|
47 |
private CollectionDTO(Collection collection, Set<Collection> collectionsSeen) { |
|
40 | 48 |
super(Collection.class, collection.getUuid(), collection.getTitleCache()); |
41 | 49 |
this.code = collection.getCode(); |
42 | 50 |
this.codeStandard = collection.getCodeStandard(); |
... | ... | |
44 | 52 |
this.institute = collection.getInstitute().getTitleCache(); |
45 | 53 |
} |
46 | 54 |
this.townOrLocation = collection.getTownOrLocation(); |
47 |
this.setSuperCollection(CollectionDTO.fromCollection(collection.getSuperCollection())); |
|
55 |
if(collection.getSuperCollection() != null && !collectionsSeen.contains(collection.getSuperCollection())) { |
|
56 |
collectionsSeen.add(collection.getSuperCollection()); |
|
57 |
this.setSuperCollection(new CollectionDTO(collection.getSuperCollection(), collectionsSeen)); |
|
58 |
} |
|
48 | 59 |
} |
49 | 60 |
|
50 | 61 |
public String getCode() { |
Also available in: Unified diff
fix #9470 preventing circular calls of CollectionDTO constructor