Project

General

Profile

Download (2.73 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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 java.util.HashSet;
12
import java.util.Set;
13

    
14
import eu.etaxonomy.cdm.model.occurrence.Collection;
15
import eu.etaxonomy.cdm.ref.TypedEntityReference;
16

    
17
/**
18
 * @author k.luther
19
 * @since 21.06.2018
20
 */
21
public class CollectionDTO extends TypedEntityReference<Collection> {
22

    
23
    private static final long serialVersionUID = -1840237876297997573L;
24

    
25
    private String code;
26
    private String codeStandard;
27
    private String institute;
28
    private String townOrLocation;
29
    private CollectionDTO superCollection;
30

    
31
    public static CollectionDTO fromCollection(Collection entity) {
32
        if(entity == null) {
33
            return null;
34
        }
35
        return new CollectionDTO(entity);
36
    }
37

    
38
    /**
39
     * @deprecated use factory instead
40
     */
41
    @Deprecated
42
    public CollectionDTO(Collection collection) {
43
        this(collection, new HashSet<>());
44
    }
45

    
46
    private CollectionDTO(Collection collection, Set<Collection> collectionsSeen) {
47
        super(Collection.class, collection.getUuid(), collection.getTitleCache());
48
        this.code = collection.getCode();
49
        this.codeStandard = collection.getCodeStandard();
50
        if (collection.getInstitute() != null){
51
            this.institute = collection.getInstitute().getTitleCache();
52
        }
53
        this.townOrLocation = collection.getTownOrLocation();
54
        if(collection.getSuperCollection() != null && !collectionsSeen.contains(collection.getSuperCollection())) {
55
            collectionsSeen.add(collection.getSuperCollection());
56
            this.setSuperCollection(new CollectionDTO(collection.getSuperCollection(), collectionsSeen));
57
        }
58
    }
59

    
60
    public String getCode() {
61
        return code;
62
    }
63
    public void setCode(String code) {
64
        this.code = code;
65
    }
66
    public String getCodeStandard() {
67
        return codeStandard;
68
    }
69
    public void setCodeStandard(String codeStandard) {
70
        this.codeStandard = codeStandard;
71
    }
72
    public String getInstitute() {
73
        return institute;
74
    }
75
    public void setInstitute(String institute) {
76
        this.institute = institute;
77
    }
78
    public String getTownOrLocation() {
79
        return townOrLocation;
80
    }
81
    public void setTownOrLocation(String townOrLocation) {
82
        this.townOrLocation = townOrLocation;
83
    }
84

    
85
    public CollectionDTO getSuperCollection() {
86
        return superCollection;
87
    }
88

    
89
    public void setSuperCollection(CollectionDTO superCollection) {
90
        this.superCollection = superCollection;
91
    }
92

    
93
}
(2-2/38)