Project

General

Profile

Download (3.54 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.vaadin.presenter.phycobank;
10

    
11
import java.util.HashSet;
12
import java.util.Set;
13

    
14
import org.joda.time.DateTime;
15

    
16
import eu.etaxonomy.cdm.mock.Registration;
17
import eu.etaxonomy.cdm.mock.RegistrationStatus;
18
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
19
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
20
import eu.etaxonomy.cdm.model.reference.Reference;
21
import eu.etaxonomy.cdm.vaadin.util.TypeDesignationConverter;
22

    
23
public class RegistrationDTO{
24

    
25
    private String summary = "";
26

    
27
    private String citationString = "";
28

    
29
    private int citationID;
30

    
31
    private RegistrationType registrationType;
32

    
33
    private Registration reg;
34

    
35
    static int idAutoincrement = 100000;
36

    
37
    private Set<Registration> blockedBy = new HashSet<>();
38

    
39
    /**
40
     * @param reg
41
     * @param typifiedName should be provided in for Registrations for TypeDesignations
42
     */
43
    public RegistrationDTO(Registration reg, TaxonNameBase typifiedName) {
44

    
45
         this.reg = reg;
46

    
47
        registrationType = RegistrationType.from(reg);
48
        if(registrationType.isName()){
49
            summary = reg.getName().getTitleCache();
50
            INomenclaturalReference citation = reg.getName().getNomenclaturalReference();
51
            if(citation != null){
52
                citationString = citation.generateTitle();
53
                citationID = citation.getId();
54
            }
55
        } else if(registrationType.isTypification()){
56
            summary = new TypeDesignationConverter(reg.getTypeDesignations(), typifiedName)
57
                    .buildString().print();
58
            if(!reg.getTypeDesignations().isEmpty()){
59
                Reference citation = reg.getTypeDesignations().iterator().next().getCitation();
60
                if(citation != null) {
61
                    citationString = citation.generateTitle();
62
                    citationID = citation.getId();
63
                }
64
            }
65
        } else {
66
            summary = "- INVALID REGISTRATION -";
67
        }
68
    }
69

    
70
    /**
71
     * @return the summary
72
     */
73
    public String getSummary() {
74
        return summary;
75
    }
76

    
77

    
78
    /**
79
     * @return the registrationType
80
     */
81
    public RegistrationType getRegistrationType() {
82
        return registrationType;
83
    }
84

    
85

    
86
    /**
87
     * @return the status
88
     */
89
    public RegistrationStatus getStatus() {
90
        return reg.getStatus();
91
    }
92

    
93

    
94
    /**
95
     * @return the registrationId
96
     */
97
    public String getRegistrationId() {
98
        return reg.getIdentifier();
99
    }
100

    
101

    
102
    /**
103
     * @return the specificIdentifier
104
     */
105
    public String getSpecificIdentifier() {
106
        return reg.getSpecificIdentifier();
107
    }
108

    
109
    /**
110
     * @return the registrationDate
111
     */
112
    public DateTime getRegistrationDate() {
113
        return reg.getRegistrationDate();
114
    }
115

    
116
    /**
117
     * @return the created
118
     */
119
    public DateTime getCreated() {
120
        return reg.getCreated();
121
    }
122

    
123
    public String getCitation() {
124
        return citationString;
125
    }
126

    
127
    /**
128
     * @return the blockedBy
129
     */
130
    public Set<Registration> getBlockedBy() {
131
        return blockedBy;
132
    }
133

    
134
    /**
135
     * @return the citationString
136
     */
137
    public String getCitationString() {
138
        return citationString;
139
    }
140

    
141
    /**
142
     * @return the citationID
143
     */
144
    public int getCitationID() {
145
        return citationID;
146
    }
147

    
148
}
(2-2/4)