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.view.registration;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.List;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
|
17
|
import com.vaadin.navigator.View;
|
18
|
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
|
19
|
import com.vaadin.server.FontAwesome;
|
20
|
import com.vaadin.server.GenericFontIcon;
|
21
|
import com.vaadin.server.Page;
|
22
|
import com.vaadin.spring.annotation.SpringView;
|
23
|
import com.vaadin.ui.Button;
|
24
|
import com.vaadin.ui.Component;
|
25
|
import com.vaadin.ui.CssLayout;
|
26
|
import com.vaadin.ui.GridLayout;
|
27
|
import com.vaadin.ui.Label;
|
28
|
import com.vaadin.ui.Notification;
|
29
|
import com.vaadin.ui.Panel;
|
30
|
import com.vaadin.ui.TabSheet;
|
31
|
import com.vaadin.ui.TabSheet.Tab;
|
32
|
import com.vaadin.ui.themes.ValoTheme;
|
33
|
|
34
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
|
35
|
import eu.etaxonomy.cdm.vaadin.component.registration.TypeStateLabel;
|
36
|
import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps;
|
37
|
import eu.etaxonomy.cdm.vaadin.event.EntityEventType;
|
38
|
import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
|
39
|
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEvent;
|
40
|
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
|
41
|
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
|
42
|
import eu.etaxonomy.cdm.vaadin.model.registration.WorkflowStep;
|
43
|
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO;
|
44
|
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationType;
|
45
|
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationWorkflowPresenter;
|
46
|
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
|
47
|
|
48
|
/**
|
49
|
* @author a.kohlbecker
|
50
|
* @since Mar 2, 2017
|
51
|
*
|
52
|
*/
|
53
|
@SpringView(name=RegistrationWorkflowViewBean.NAME)
|
54
|
public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationWorkflowPresenter>
|
55
|
implements RegistrationWorkflowView, View {
|
56
|
|
57
|
|
58
|
public static final String CSS_CLASS_WORKFLOW = "workflow-container";
|
59
|
|
60
|
public static final String SUBHEADER_DEEFAULT = "Advance step by step through the registration workflow.";
|
61
|
|
62
|
private static final long serialVersionUID = -213040114015958970L;
|
63
|
|
64
|
public static final String NAME = "workflow";
|
65
|
|
66
|
public static final String ACTION_NEW = "new";
|
67
|
|
68
|
public static final String ACTION_EDIT = "edit";
|
69
|
|
70
|
public RegistrationType regType = null;
|
71
|
|
72
|
private CssLayout workflow;
|
73
|
|
74
|
private List<CssLayout> registrations = new ArrayList<>();
|
75
|
|
76
|
private String headerText = "-- empty --";
|
77
|
private String subheaderText = SUBHEADER_DEEFAULT;
|
78
|
|
79
|
|
80
|
public RegistrationWorkflowViewBean() {
|
81
|
super();
|
82
|
|
83
|
workflow = new CssLayout();
|
84
|
workflow.setSizeFull();
|
85
|
workflow.setId(CSS_CLASS_WORKFLOW);
|
86
|
getLayout().addComponent(workflow);
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* {@inheritDoc}
|
91
|
*/
|
92
|
@Override
|
93
|
public void enter(ViewChangeEvent event) {
|
94
|
if(event.getParameters() != null){
|
95
|
String[] params = event.getParameters().split("/");
|
96
|
|
97
|
if(params[0].equals(ACTION_NEW)) {
|
98
|
regType = RegistrationType.valueOf(params[1]);
|
99
|
headerText = regType.name() + " ...";
|
100
|
eventBus.publishEvent(new RegistrationWorkflowEvent(regType));
|
101
|
|
102
|
} else if( params[0].equals(ACTION_EDIT)) {
|
103
|
headerText = params[1];
|
104
|
eventBus.publishEvent(new RegistrationWorkflowEvent(Integer.parseInt(params[1])));
|
105
|
}
|
106
|
updateHeader();
|
107
|
}
|
108
|
}
|
109
|
|
110
|
/**
|
111
|
* {@inheritDoc}
|
112
|
*/
|
113
|
@Override
|
114
|
public void setWorkingset(RegistrationWorkingSet workingset) {
|
115
|
|
116
|
CssLayout registration = new CssLayout();
|
117
|
registration.setWidth(100, Unit.PERCENTAGE);
|
118
|
|
119
|
Panel namesTypesPanel = createNamesAndTypesList(workingset);
|
120
|
namesTypesPanel.setCaption("Names & Types");
|
121
|
|
122
|
registration.addComponent(createWorkflowTabSheet(workingset, null));
|
123
|
registration.addComponent(new RegistrationItem(workingset, this));
|
124
|
registration.addComponent(namesTypesPanel);
|
125
|
|
126
|
registrations.add(registration);
|
127
|
workflow.addComponent(registration);
|
128
|
|
129
|
}
|
130
|
|
131
|
/**
|
132
|
* {@inheritDoc}
|
133
|
*/
|
134
|
@Override
|
135
|
public void addBlockingRegistration(RegistrationDTO blocking) {
|
136
|
if(registrations == null) {
|
137
|
throw new RuntimeException("A Workingset must be present prior adding blocking registrations.");
|
138
|
}
|
139
|
// add the blocking registration
|
140
|
|
141
|
}
|
142
|
|
143
|
private Component createWorkflowTabSheet(RegistrationWorkingSet workingset, Component namesTypesPanel){
|
144
|
|
145
|
if(namesTypesPanel == null){
|
146
|
namesTypesPanel = new CssLayout();
|
147
|
}
|
148
|
Component citationComponent = new CssLayout(); // new Label(workingset.getCitation());
|
149
|
Component curationComponent = new CssLayout(); // new Label("Curation in progress ...")
|
150
|
Component releaseComponent = new CssLayout(); // new Label("Not yet published")
|
151
|
|
152
|
GenericFontIcon tabIcon = new GenericFontIcon("IcoMoon", 0xe900);
|
153
|
TabSheet tabsheet = new TabSheet();
|
154
|
// tabsheet.addStyleName(ValoTheme.TABSHEET_FRAMED);
|
155
|
//tabsheet.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
|
156
|
tabsheet.addStyleName("workflow-tabsheet");
|
157
|
|
158
|
Tab pubDetailsTab = tabsheet.addTab(citationComponent, WorkflowStep.PUBLICATION_DETAILS.getRepresentation(), tabIcon);
|
159
|
Tab namesTypesTab = tabsheet.addTab(namesTypesPanel, WorkflowStep.NAMES_N_TYPES.getRepresentation(), tabIcon);
|
160
|
Tab curationTab = tabsheet.addTab(curationComponent, WorkflowStep.CURATION.getRepresentation(), tabIcon);
|
161
|
Tab awaitingPubTab = tabsheet.addTab(releaseComponent, WorkflowStep.AWAITING_PUBLICATION.getRepresentation(), tabIcon);
|
162
|
|
163
|
pubDetailsTab.setStyleName("bg-status-" + WorkflowStep.PUBLICATION_DETAILS.name());
|
164
|
namesTypesTab.setStyleName("bg-status-" + WorkflowStep.NAMES_N_TYPES.name());
|
165
|
curationTab.setStyleName("bg-status-" + WorkflowStep.CURATION.name());
|
166
|
awaitingPubTab.setStyleName("bg-status-" + WorkflowStep.AWAITING_PUBLICATION.name());
|
167
|
|
168
|
return tabsheet;
|
169
|
}
|
170
|
|
171
|
/**
|
172
|
* @param workingset
|
173
|
* @return
|
174
|
*/
|
175
|
public Panel createNamesAndTypesList(RegistrationWorkingSet workingset) {
|
176
|
// prepare name and type list
|
177
|
GridLayout namesTypesList = new GridLayout(4, workingset.getRegistrationDTOs().size());
|
178
|
int row = 0;
|
179
|
for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
|
180
|
Button commentButton = new Button(FontAwesome.COMMENT);
|
181
|
commentButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
|
182
|
Button editButton = new Button(FontAwesome.EDIT);
|
183
|
editButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
|
184
|
|
185
|
namesTypesList.addComponent(new TypeStateLabel().update(dto.getRegistrationType(), dto.getStatus()), 0, row);
|
186
|
namesTypesList.addComponent(new Label(dto.getSummary()), 1, row);
|
187
|
namesTypesList.addComponent(commentButton, 2, row);
|
188
|
namesTypesList.addComponent(editButton, 3, row);
|
189
|
row++;
|
190
|
}
|
191
|
namesTypesList.setSizeUndefined();
|
192
|
Panel namesTypesPanel = new Panel(namesTypesList);
|
193
|
namesTypesPanel.setHeight("300px");
|
194
|
return namesTypesPanel;
|
195
|
}
|
196
|
|
197
|
|
198
|
/**
|
199
|
*
|
200
|
*/
|
201
|
private void addBulletWorkflowName() {
|
202
|
WorkflowSteps steps = new WorkflowSteps();
|
203
|
steps.appendNewWorkflowItem(1, "Publication details including the publisher.",
|
204
|
e -> eventBus.publishEvent(new ReferenceEvent(EntityEventType.EDIT)));
|
205
|
steps.appendNewWorkflowItem(2, "One or multiple published scientific new names.",
|
206
|
e -> eventBus.publishEvent(new TaxonNameEvent(EntityEventType.EDIT)));
|
207
|
steps.appendNewWorkflowItem(3, "Request for data curation and await approval.", null);
|
208
|
steps.appendNewWorkflowItem(4, "Awaiting publication", null);
|
209
|
getWorkflow().addComponent(steps);
|
210
|
}
|
211
|
|
212
|
/**
|
213
|
*
|
214
|
*/
|
215
|
private void addBulletWorkflowTypification() {
|
216
|
WorkflowSteps steps = new WorkflowSteps();
|
217
|
steps.appendNewWorkflowItem(1, "Publication details including the publisher.",
|
218
|
e -> eventBus.publishEvent(new ReferenceEvent(EntityEventType.EDIT)));
|
219
|
steps.appendNewWorkflowItem(2, "One or multiple published typifications.",
|
220
|
e -> eventBus.publishEvent(new TaxonNameEvent(EntityEventType.EDIT)));
|
221
|
steps.appendNewWorkflowItem(3, "Request for data curation and await approval.", null);
|
222
|
steps.appendNewWorkflowItem(4, "Awaiting publication", null);
|
223
|
getWorkflow().addComponent(steps);
|
224
|
}
|
225
|
|
226
|
/**
|
227
|
* {@inheritDoc}
|
228
|
*/
|
229
|
@Autowired
|
230
|
@Override
|
231
|
protected void injectPresenter(RegistrationWorkflowPresenter presenter) {
|
232
|
setPresenter(presenter);
|
233
|
}
|
234
|
|
235
|
/**
|
236
|
* {@inheritDoc}
|
237
|
*/
|
238
|
@Override
|
239
|
public void openReferenceEditor(UUID referenceUuid) {
|
240
|
// TODO Auto-generated method stub
|
241
|
|
242
|
}
|
243
|
|
244
|
/**
|
245
|
* {@inheritDoc}
|
246
|
*/
|
247
|
@Override
|
248
|
public void openNameEditor(UUID nameUuid) {
|
249
|
// TODO Auto-generated method stub
|
250
|
|
251
|
}
|
252
|
|
253
|
/**
|
254
|
* {@inheritDoc}
|
255
|
*/
|
256
|
@Override
|
257
|
protected String getHeaderText() {
|
258
|
return headerText;
|
259
|
}
|
260
|
|
261
|
/**
|
262
|
* {@inheritDoc}
|
263
|
*/
|
264
|
@Override
|
265
|
public void setHeaderText(String text) {
|
266
|
this.headerText = text;
|
267
|
|
268
|
}
|
269
|
|
270
|
/**
|
271
|
* @return the subheaderText
|
272
|
*/
|
273
|
public String getSubheaderText() {
|
274
|
return subheaderText;
|
275
|
}
|
276
|
|
277
|
/**
|
278
|
* {@inheritDoc}
|
279
|
*/
|
280
|
@Override
|
281
|
public void setSubheaderText(String text) {
|
282
|
subheaderText = text;
|
283
|
}
|
284
|
|
285
|
/**
|
286
|
* {@inheritDoc}
|
287
|
*/
|
288
|
@Override
|
289
|
protected String getSubHeaderText() {
|
290
|
return subheaderText;
|
291
|
}
|
292
|
|
293
|
/**
|
294
|
* {@inheritDoc}
|
295
|
*/
|
296
|
@Override
|
297
|
public CssLayout getWorkflow() {
|
298
|
return workflow;
|
299
|
}
|
300
|
|
301
|
/**
|
302
|
* {@inheritDoc}
|
303
|
*/
|
304
|
@Override
|
305
|
public void openDetailsPopup(String caption, List<String> messages) {
|
306
|
StringBuffer sb = new StringBuffer();
|
307
|
sb.append("<div class=\"details-popup-content\">");
|
308
|
messages.forEach(s -> sb.append(s).append("</br>"));
|
309
|
sb.append("</div>");
|
310
|
new Notification(caption, sb.toString(), Notification.Type.HUMANIZED_MESSAGE, true).show(Page.getCurrent());
|
311
|
}
|
312
|
|
313
|
}
|