Project

General

Profile

Download (2.26 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.io.Serializable;
12
import java.util.UUID;
13

    
14
import eu.etaxonomy.cdm.format.reference.OriginalSourceFormatter;
15
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
16
import eu.etaxonomy.cdm.model.reference.NamedSourceBase;
17

    
18
/**
19
 * @author a.kohlbecker
20
 * @since Aug 31, 2018
21
 */
22
public class SourceDTO implements Serializable{
23

    
24
    private static final long serialVersionUID = -3314135226037542122L;
25

    
26
    private UUID uuid;
27
    protected String label;
28
    String citationDetail;
29
    // can not reduce to TypedEntityReference here since the data portal requires
30
    // doi, uri, etc, see function cdm_reference_markup() in cdm_dataportal
31
    ReferenceDTO citation;
32

    
33
    public static SourceDTO fromDescriptionElementSource(NamedSourceBase entity) {
34
        if(entity == null) {
35
            return null;
36
        }
37
        SourceDTO dto = new SourceDTO();
38
        dto.uuid = entity.getUuid();
39
        dto.label = OriginalSourceFormatter.INSTANCE.format(entity);
40
        dto.citation = ReferenceDTO.fromReference(entity.getCitation());
41
        dto.citationDetail = entity.getCitationMicroReference();
42
        return dto;
43
    }
44

    
45
    public static SourceDTO fromIdentifiableSource(IdentifiableSource entity) {
46
        if(entity == null) {
47
            return null;
48
        }
49
        SourceDTO dto = new SourceDTO();
50
        dto.uuid = entity.getUuid();
51
        dto.citation = ReferenceDTO.fromReference(entity.getCitation());
52
        dto.citationDetail = entity.getCitationMicroReference();
53
        return dto;
54
    }
55

    
56

    
57
    public UUID getUuid() {
58
        return uuid;
59
    }
60

    
61

    
62
    public void setUuid(UUID uuid) {
63
        this.uuid = uuid;
64
    }
65

    
66
    public ReferenceDTO getCitation() {
67
        return citation;
68
    }
69

    
70

    
71
    public void setCitation(ReferenceDTO citation) {
72
        this.citation = citation;
73
    }
74

    
75

    
76
    public String getCitationDetail() {
77
        return citationDetail;
78
    }
79

    
80

    
81
    public void setCitationDetail(String citationDetail) {
82
        this.citationDetail = citationDetail;
83
    }
84

    
85
}
(35-35/47)