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 org.springframework.beans.factory.annotation.Autowired;
|
12
|
import org.springframework.context.event.EventListener;
|
13
|
|
14
|
import com.vaadin.spring.annotation.SpringComponent;
|
15
|
import com.vaadin.spring.annotation.ViewScope;
|
16
|
|
17
|
import eu.etaxonomy.cdm.mock.Registration;
|
18
|
import eu.etaxonomy.cdm.mock.RegistrationService;
|
19
|
import eu.etaxonomy.cdm.model.name.Rank;
|
20
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
21
|
import eu.etaxonomy.cdm.vaadin.event.phycobank.RegistrationWorkflowEvent;
|
22
|
import eu.etaxonomy.cdm.vaadin.view.phycobank.RegistrationWorkflowView;
|
23
|
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
|
24
|
|
25
|
/**
|
26
|
* @author a.kohlbecker
|
27
|
* @since Mar 3, 2017
|
28
|
*
|
29
|
*/
|
30
|
@SpringComponent
|
31
|
@ViewScope
|
32
|
public class RegistrationWorkflowPresenter extends AbstractPresenter<RegistrationWorkflowView> {
|
33
|
|
34
|
|
35
|
@Autowired
|
36
|
private RegistrationService serviceMock;
|
37
|
|
38
|
private Registration registration;
|
39
|
|
40
|
/**
|
41
|
*
|
42
|
*/
|
43
|
public RegistrationWorkflowPresenter() {
|
44
|
}
|
45
|
|
46
|
@EventListener
|
47
|
protected void onRegistrationStartEvent(RegistrationWorkflowEvent e){
|
48
|
|
49
|
if(e.isStart()) {
|
50
|
registration = new Registration();
|
51
|
registration.setName(TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()));
|
52
|
} else {
|
53
|
registration = serviceMock.loadByRegistrationID(e.getRegistrationID());
|
54
|
}
|
55
|
if(registration != null){
|
56
|
getView().getTitle().setValue(getView().getTitle().getValue() + " " + registrationType().name());
|
57
|
getView().makeWorflow(registrationType());
|
58
|
}
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* @return
|
63
|
*/
|
64
|
private RegistrationType registrationType() {
|
65
|
return RegistrationType.from(registration);
|
66
|
}
|
67
|
|
68
|
|
69
|
|
70
|
}
|