Project

General

Profile

Download (1.83 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 eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
12
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
13
import eu.etaxonomy.cdm.model.occurrence.DerivationEventType;
14

    
15
/**
16
 * @author k.luther
17
 * @since 22.06.2018
18
 */
19
public class DerivationEventDTO extends EventDTO<DerivationEvent> {
20

    
21
    private static final long serialVersionUID = 6338657672281702600L;
22

    
23
    private String institute;
24

    
25
    protected DerivationEventType eventType;
26

    
27
    private DerivationEventDTO(DerivationEvent entity) {
28
        super(entity);
29
        eventType = entity.getType();
30
        if(eventType != null) {
31
            eventType.getRepresentations(); // force initialization
32
        }
33
        if(entity.getActor() != null) {
34
            this.actor = entity.getActor().getTitleCache();
35
        }
36
        if(entity.getInstitution() != null) {
37
            this.institute = entity.getInstitution().getTitleCache();
38
        }
39
    }
40

    
41
    public static EventDTO<DerivationEvent> fromEntity(DerivationEvent entity) {
42
        if (entity != null) {
43
            entity = HibernateProxyHelper.deproxy(entity, DerivationEvent.class);
44
            return new DerivationEventDTO(entity);
45
        } else {
46
            return null;
47
        }
48
    }
49

    
50
    public String getInstitute() {
51
        return institute;
52
    }
53

    
54
    public void setInstitute(String institute) {
55
        this.institute = institute;
56
    }
57

    
58
    public DerivationEventType getEventType() {
59
        return eventType;
60
    }
61

    
62
    public void setEventType(DerivationEventType eventType) {
63
        this.eventType = eventType;
64
    }
65

    
66
}
(8-8/45)