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.UUID;
|
12
|
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
|
15
|
import com.vaadin.navigator.View;
|
16
|
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
|
17
|
import com.vaadin.spring.annotation.SpringView;
|
18
|
import com.vaadin.ui.CssLayout;
|
19
|
|
20
|
import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps;
|
21
|
import eu.etaxonomy.cdm.vaadin.event.EntityEventType;
|
22
|
import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
|
23
|
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEvent;
|
24
|
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
|
25
|
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationType;
|
26
|
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationWorkflowPresenter;
|
27
|
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
|
28
|
|
29
|
/**
|
30
|
* @author a.kohlbecker
|
31
|
* @since Mar 2, 2017
|
32
|
*
|
33
|
*/
|
34
|
@SpringView(name=RegistrationWorkflowViewBean.NAME)
|
35
|
public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationWorkflowPresenter>
|
36
|
implements RegistrationWorkflowView, View {
|
37
|
|
38
|
|
39
|
public static final String CSS_CLASS_WORKFLOW = "workflow-container";
|
40
|
|
41
|
public static final String SUBHEADER_DEEFAULT = "Advance step by step through the registration workflow.";
|
42
|
|
43
|
private static final long serialVersionUID = -213040114015958970L;
|
44
|
|
45
|
public static final String NAME = "workflow";
|
46
|
|
47
|
public static final String ACTION_NEW = "new";
|
48
|
|
49
|
public static final String ACTION_EDIT = "edit";
|
50
|
|
51
|
public RegistrationType regType = null;
|
52
|
|
53
|
CssLayout workflow;
|
54
|
|
55
|
private String headerText = "-- empty --";
|
56
|
private String subheaderText = SUBHEADER_DEEFAULT;
|
57
|
|
58
|
public RegistrationWorkflowViewBean() {
|
59
|
super();
|
60
|
|
61
|
workflow = new CssLayout();
|
62
|
workflow.setSizeFull();
|
63
|
workflow.setId(CSS_CLASS_WORKFLOW);
|
64
|
getLayout().addComponent(workflow);
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* {@inheritDoc}
|
69
|
*/
|
70
|
@Override
|
71
|
public void enter(ViewChangeEvent event) {
|
72
|
if(event.getParameters() != null){
|
73
|
String[] params = event.getParameters().split("/");
|
74
|
|
75
|
if(params[0].equals(ACTION_NEW)) {
|
76
|
regType = RegistrationType.valueOf(params[1]);
|
77
|
headerText = regType.name() + " ...";
|
78
|
eventBus.publishEvent(new RegistrationWorkflowEvent(regType));
|
79
|
|
80
|
} else if( params[0].equals(ACTION_EDIT)) {
|
81
|
headerText = params[1];
|
82
|
eventBus.publishEvent(new RegistrationWorkflowEvent(Integer.parseInt(params[1])));
|
83
|
}
|
84
|
updateHeader();
|
85
|
}
|
86
|
}
|
87
|
|
88
|
@Override
|
89
|
public void makeWorflow(RegistrationType type){
|
90
|
switch (type) {
|
91
|
case NAME:
|
92
|
addNameWorkflow();
|
93
|
break;
|
94
|
case TYPIFICATION:
|
95
|
addTypificationWorkflow();
|
96
|
break;
|
97
|
default:
|
98
|
break;
|
99
|
}
|
100
|
}
|
101
|
|
102
|
/**
|
103
|
*
|
104
|
*/
|
105
|
private void addNameWorkflow() {
|
106
|
WorkflowSteps steps = new WorkflowSteps();
|
107
|
steps.appendNewWorkflowItem(1, "Publication details including the publisher.",
|
108
|
e -> eventBus.publishEvent(new ReferenceEvent(EntityEventType.EDIT)));
|
109
|
steps.appendNewWorkflowItem(2, "One or multiple published scientific new names.",
|
110
|
e -> eventBus.publishEvent(new TaxonNameEvent(EntityEventType.EDIT)));
|
111
|
steps.appendNewWorkflowItem(3, "Request for data curation and await approval.", null);
|
112
|
steps.appendNewWorkflowItem(4, "Awaiting publication", null);
|
113
|
getWorkflow().addComponent(steps);
|
114
|
}
|
115
|
|
116
|
/**
|
117
|
*
|
118
|
*/
|
119
|
private void addTypificationWorkflow() {
|
120
|
WorkflowSteps steps = new WorkflowSteps();
|
121
|
steps.appendNewWorkflowItem(1, "Publication details including the publisher.",
|
122
|
e -> eventBus.publishEvent(new ReferenceEvent(EntityEventType.EDIT)));
|
123
|
steps.appendNewWorkflowItem(2, "One or multiple published typifications.",
|
124
|
e -> eventBus.publishEvent(new TaxonNameEvent(EntityEventType.EDIT)));
|
125
|
steps.appendNewWorkflowItem(3, "Request for data curation and await approval.", null);
|
126
|
steps.appendNewWorkflowItem(4, "Awaiting publication", null);
|
127
|
getWorkflow().addComponent(steps);
|
128
|
}
|
129
|
|
130
|
/**
|
131
|
* {@inheritDoc}
|
132
|
*/
|
133
|
@Autowired
|
134
|
@Override
|
135
|
protected void injectPresenter(RegistrationWorkflowPresenter presenter) {
|
136
|
setPresenter(presenter);
|
137
|
}
|
138
|
|
139
|
/**
|
140
|
* {@inheritDoc}
|
141
|
*/
|
142
|
@Override
|
143
|
public void openReferenceEditor(UUID referenceUuid) {
|
144
|
// TODO Auto-generated method stub
|
145
|
|
146
|
}
|
147
|
|
148
|
/**
|
149
|
* {@inheritDoc}
|
150
|
*/
|
151
|
@Override
|
152
|
public void openNameEditor(UUID nameUuid) {
|
153
|
// TODO Auto-generated method stub
|
154
|
|
155
|
}
|
156
|
|
157
|
/**
|
158
|
* {@inheritDoc}
|
159
|
*/
|
160
|
@Override
|
161
|
protected String getHeaderText() {
|
162
|
return headerText;
|
163
|
}
|
164
|
|
165
|
/**
|
166
|
* {@inheritDoc}
|
167
|
*/
|
168
|
@Override
|
169
|
public void setHeaderText(String text) {
|
170
|
this.headerText = text;
|
171
|
|
172
|
}
|
173
|
|
174
|
/**
|
175
|
* @return the subheaderText
|
176
|
*/
|
177
|
public String getSubheaderText() {
|
178
|
return subheaderText;
|
179
|
}
|
180
|
|
181
|
/**
|
182
|
* {@inheritDoc}
|
183
|
*/
|
184
|
@Override
|
185
|
public void setSubheaderText(String text) {
|
186
|
subheaderText = text;
|
187
|
}
|
188
|
|
189
|
/**
|
190
|
* {@inheritDoc}
|
191
|
*/
|
192
|
@Override
|
193
|
protected String getSubHeaderText() {
|
194
|
return subheaderText;
|
195
|
}
|
196
|
|
197
|
/**
|
198
|
* {@inheritDoc}
|
199
|
*/
|
200
|
@Override
|
201
|
public CssLayout getWorkflow() {
|
202
|
return workflow;
|
203
|
}
|
204
|
|
205
|
|
206
|
}
|