Revision b0fdf0ab
Added by Andreas Kohlbecker about 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/phycobank/ListPresenter.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 | 12 |
import java.util.Collection; |
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 | 13 |
|
16 |
import org.joda.time.DateTime;
|
|
14 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
17 | 15 |
|
18 | 16 |
import com.vaadin.spring.annotation.SpringComponent; |
19 | 17 |
import com.vaadin.spring.annotation.ViewScope; |
20 | 18 |
|
21 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
19 |
import eu.etaxonomy.cdm.mock.Registration; |
|
20 |
import eu.etaxonomy.cdm.mock.RegistrationService; |
|
22 | 21 |
import eu.etaxonomy.cdm.vaadin.view.phycobank.ListView; |
23 | 22 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
24 | 23 |
|
... | ... | |
31 | 30 |
@ViewScope |
32 | 31 |
public class ListPresenter extends AbstractPresenter<ListView> { |
33 | 32 |
|
33 |
@Autowired |
|
34 |
private RegistrationService serviceMock; |
|
35 |
|
|
34 | 36 |
@Override |
35 | 37 |
public void onViewEnter() { |
36 | 38 |
super.onViewEnter(); |
... | ... | |
41 | 43 |
* @return |
42 | 44 |
*/ |
43 | 45 |
private Collection<RegistrationDTO> listRegistrations() { |
44 |
List<TaxonNameBase> names = getRepo().getNameService().list(TaxonNameBase.class, 500, 0, null, null);
|
|
45 |
Collection<RegistrationDTO> dtos = new ArrayList<>(names.size());
|
|
46 |
names.forEach(name -> { dtos.add(new RegistrationDTO(name)); });
|
|
46 |
Collection<Registration> registrations = serviceMock.list();
|
|
47 |
Collection<RegistrationDTO> dtos = new ArrayList<>(registrations.size());
|
|
48 |
registrations.forEach(reg -> { dtos.add(new RegistrationDTO(reg)); });
|
|
47 | 49 |
return dtos; |
48 | 50 |
} |
49 | 51 |
|
50 |
private static int idAutoincrement = 100000; |
|
51 |
|
|
52 |
public class RegistrationDTO{ |
|
53 |
|
|
54 |
private String summary; |
|
55 |
private UUID registeredEntityUuid; |
|
56 |
|
|
57 |
private RegistrationType registrationType; |
|
58 |
private RegistrationStatus status; |
|
59 |
private String registrationId; |
|
60 |
private String internalRegId; |
|
61 |
private DateTime registrationDate = null; |
|
62 |
private DateTime created = null; |
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
/** |
|
67 |
* @param name |
|
68 |
*/ |
|
69 |
public RegistrationDTO(TaxonNameBase name) { |
|
70 |
summary = name.getTitleCache(); |
|
71 |
registeredEntityUuid = name.getUuid(); |
|
72 |
|
|
73 |
registrationType = RegistrationType.values()[(int) (Math.random() * RegistrationType.values().length)]; |
|
74 |
status = RegistrationStatus.values()[(int) (Math.random() * RegistrationStatus.values().length)]; |
|
75 |
internalRegId = Integer.toString(ListPresenter.idAutoincrement++); |
|
76 |
registrationId = "http://pyhcobank.org/" + internalRegId; |
|
77 |
created = DateTime.now(); |
|
78 |
|
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* @return the summary |
|
83 |
*/ |
|
84 |
public String getSummary() { |
|
85 |
return summary; |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
/** |
|
90 |
* @param summary the summary to set |
|
91 |
*/ |
|
92 |
public void setSummary(String summary) { |
|
93 |
this.summary = summary; |
|
94 |
} |
|
95 |
|
|
96 |
|
|
97 |
/** |
|
98 |
* @return the registrationType |
|
99 |
*/ |
|
100 |
public RegistrationType getRegistrationType() { |
|
101 |
return registrationType; |
|
102 |
} |
|
103 |
|
|
104 |
|
|
105 |
/** |
|
106 |
* @param registrationType the registrationType to set |
|
107 |
*/ |
|
108 |
public void setRegistrationType(RegistrationType registrationType) { |
|
109 |
this.registrationType = registrationType; |
|
110 |
} |
|
111 |
|
|
112 |
|
|
113 |
/** |
|
114 |
* @return the status |
|
115 |
*/ |
|
116 |
public RegistrationStatus getStatus() { |
|
117 |
return status; |
|
118 |
} |
|
119 |
|
|
120 |
|
|
121 |
/** |
|
122 |
* @param status the status to set |
|
123 |
*/ |
|
124 |
public void setStatus(RegistrationStatus status) { |
|
125 |
this.status = status; |
|
126 |
} |
|
127 |
|
|
128 |
|
|
129 |
/** |
|
130 |
* @return the registrationId |
|
131 |
*/ |
|
132 |
public String getRegistrationId() { |
|
133 |
return registrationId; |
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
/** |
|
138 |
* @param registrationId the registrationId to set |
|
139 |
*/ |
|
140 |
public void setRegistrationId(String registrationId) { |
|
141 |
this.registrationId = registrationId; |
|
142 |
} |
|
143 |
|
|
144 |
|
|
145 |
/** |
|
146 |
* @return the internalRegId |
|
147 |
*/ |
|
148 |
public String getInternalRegId() { |
|
149 |
return internalRegId; |
|
150 |
} |
|
151 |
|
|
152 |
|
|
153 |
/** |
|
154 |
* @param internalRegId the internalRegId to set |
|
155 |
*/ |
|
156 |
public void setInternalRegId(String internalRegId) { |
|
157 |
this.internalRegId = internalRegId; |
|
158 |
} |
|
159 |
|
|
160 |
|
|
161 |
/** |
|
162 |
* @return the registeredEntityUuid |
|
163 |
*/ |
|
164 |
public UUID getRegisteredEntityUuid() { |
|
165 |
return registeredEntityUuid; |
|
166 |
} |
|
167 |
|
|
168 |
|
|
169 |
/** |
|
170 |
* @param registeredEntityUuid the registeredEntityUuid to set |
|
171 |
*/ |
|
172 |
public void setRegisteredEntityUuid(UUID registeredEntityUuid) { |
|
173 |
this.registeredEntityUuid = registeredEntityUuid; |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* @return the registrationDate |
|
178 |
*/ |
|
179 |
public DateTime getRegistrationDate() { |
|
180 |
return registrationDate; |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* @return the created |
|
185 |
*/ |
|
186 |
public DateTime getCreated() { |
|
187 |
return created; |
|
188 |
} |
|
189 |
|
|
190 |
} |
|
191 |
|
|
192 |
public enum RegistrationStatus { |
|
193 |
|
|
194 |
preparation,// A new record which is being edited by the Author |
|
195 |
curation, //A record ready for the curator to be validated. |
|
196 |
ready, //The record has passed the validation by the curator and is ready for publication. |
|
197 |
published, //The name or typification has finally been published. |
|
198 |
rejected //The registration has been rejected, the process is aborted and the record is preserved. |
|
199 |
} |
|
200 |
|
|
201 | 52 |
} |
Also available in: Unified diff
ref #6169 mock service for registrations