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.phycobank;
|
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
|
import com.vaadin.ui.Label;
|
20
|
|
21
|
import eu.etaxonomy.cdm.vaadin.component.phycobank.RegistrationWorkflowComponent;
|
22
|
import eu.etaxonomy.cdm.vaadin.component.phycobank.WorkflowSteps;
|
23
|
import eu.etaxonomy.cdm.vaadin.event.phycobank.RegistrationWorkflowEvent;
|
24
|
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationType;
|
25
|
import eu.etaxonomy.cdm.vaadin.presenter.phycobank.RegistrationWorkflowPresenter;
|
26
|
import eu.etaxonomy.vaadin.mvp.AbstractView;
|
27
|
|
28
|
/**
|
29
|
* @author a.kohlbecker
|
30
|
* @since Mar 2, 2017
|
31
|
*
|
32
|
*/
|
33
|
@SpringView(name=RegistrationWorkflowViewBean.NAME)
|
34
|
public class RegistrationWorkflowViewBean extends AbstractView<RegistrationWorkflowPresenter>
|
35
|
implements RegistrationWorkflowView, View {
|
36
|
|
37
|
private static final long serialVersionUID = -213040114015958970L;
|
38
|
|
39
|
public static final String NAME = "workflow";
|
40
|
|
41
|
public static final String ACTION_NEW = "new";
|
42
|
|
43
|
public static final String ACTION_EDIT = "edit";
|
44
|
|
45
|
public RegistrationType regType = null;
|
46
|
|
47
|
RegistrationWorkflowComponent design;
|
48
|
|
49
|
public RegistrationWorkflowViewBean() {
|
50
|
design = new RegistrationWorkflowComponent();
|
51
|
setCompositionRoot(design);
|
52
|
}
|
53
|
|
54
|
/**
|
55
|
* {@inheritDoc}
|
56
|
*/
|
57
|
@Override
|
58
|
public void enter(ViewChangeEvent event) {
|
59
|
if(event.getParameters() != null){
|
60
|
String[] params = event.getParameters().split("/");
|
61
|
|
62
|
if(params[0].equals(ACTION_NEW)) {
|
63
|
regType = RegistrationType.valueOf(params[1]);
|
64
|
design.getTitle().setValue(design.getTitle().getValue() + " " + regType.name() + " ...");
|
65
|
eventBus.publishEvent(new RegistrationWorkflowEvent(regType));
|
66
|
|
67
|
} else if( params[0].equals(ACTION_EDIT)) {
|
68
|
design.getTitle().setValue(design.getTitle().getValue() + " " + params[1]);
|
69
|
eventBus.publishEvent(new RegistrationWorkflowEvent(Integer.parseInt(params[1])));
|
70
|
}
|
71
|
|
72
|
}
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
public void makeWorflow(RegistrationType type){
|
77
|
switch (type) {
|
78
|
case name:
|
79
|
addNameWorkflow();
|
80
|
break;
|
81
|
case typification:
|
82
|
addTypificationWorkflow();
|
83
|
break;
|
84
|
default:
|
85
|
break;
|
86
|
}
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
*
|
91
|
*/
|
92
|
private void addNameWorkflow() {
|
93
|
WorkflowSteps steps = new WorkflowSteps();
|
94
|
steps.appendNewWorkflowItem(1, "Nomenclatural reference", null);
|
95
|
steps.appendNewWorkflowItem(2, "Name", null);
|
96
|
steps.appendNewWorkflowItem(3, "Publisher Details", null);
|
97
|
steps.appendNewWorkflowItem(4, "Data curation", null);
|
98
|
steps.appendNewWorkflowItem(5, "Awaiting publication", null);
|
99
|
getWorkflow().addComponent(steps);
|
100
|
}
|
101
|
|
102
|
/**
|
103
|
*
|
104
|
*/
|
105
|
private void addTypificationWorkflow() {
|
106
|
WorkflowSteps steps = new WorkflowSteps();
|
107
|
steps.appendNewWorkflowItem(1, "Name", null);
|
108
|
steps.appendNewWorkflowItem(2, "Type information", null);
|
109
|
steps.appendNewWorkflowItem(3, "Publisher Details", null);
|
110
|
steps.appendNewWorkflowItem(4, "Data curation", null);
|
111
|
steps.appendNewWorkflowItem(5, "Awaiting publication", null);
|
112
|
getWorkflow().addComponent(steps);
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* {@inheritDoc}
|
117
|
*/
|
118
|
@Autowired
|
119
|
@Override
|
120
|
protected void injectPresenter(RegistrationWorkflowPresenter presenter) {
|
121
|
setPresenter(presenter);
|
122
|
}
|
123
|
|
124
|
/* ------- RegistrationWorkflowView implementation ------- */
|
125
|
|
126
|
/**
|
127
|
* @return the title
|
128
|
*/
|
129
|
@Override
|
130
|
public Label getTitle() {
|
131
|
return design.getTitle();
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
* @return the workflow
|
136
|
*/
|
137
|
@Override
|
138
|
public CssLayout getWorkflow() {
|
139
|
return design.getWorkflow();
|
140
|
}
|
141
|
|
142
|
/**
|
143
|
* {@inheritDoc}
|
144
|
*/
|
145
|
@Override
|
146
|
public void openNameEditor(UUID nameUuid) {
|
147
|
// TODO Auto-generated method stub
|
148
|
|
149
|
}
|
150
|
|
151
|
}
|