2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.vaadin
.presenter
.registration
;
11 import org
.apache
.log4j
.Logger
;
12 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
13 import org
.springframework
.context
.event
.EventListener
;
15 import com
.vaadin
.server
.SystemError
;
16 import com
.vaadin
.spring
.annotation
.SpringComponent
;
17 import com
.vaadin
.spring
.annotation
.ViewScope
;
19 import eu
.etaxonomy
.cdm
.mock
.Registration
;
20 import eu
.etaxonomy
.cdm
.mock
.RegistrationService
;
21 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
22 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameFactory
;
23 import eu
.etaxonomy
.cdm
.vaadin
.event
.ReferenceEvent
;
24 import eu
.etaxonomy
.cdm
.vaadin
.event
.registration
.RegistrationWorkflowEvent
;
25 import eu
.etaxonomy
.cdm
.vaadin
.model
.registration
.RegistrationWorkingSet
;
26 import eu
.etaxonomy
.cdm
.vaadin
.view
.registration
.RegistrationWorkflowView
;
27 import eu
.etaxonomy
.vaadin
.mvp
.AbstractPresenter
;
30 * @author a.kohlbecker
36 public class RegistrationWorkflowPresenter
extends AbstractPresenter
<RegistrationWorkflowView
> {
40 private RegistrationService serviceMock
;
42 private RegistrationWorkingSet workingset
;
47 public RegistrationWorkflowPresenter() {
51 protected void onRegistrationStartEvent(RegistrationWorkflowEvent event
){
53 if(workingset
!= null){
54 Logger
.getLogger(RegistrationWorkflowPresenter
.class).warn("Cant start a new workflow over an existing one.");
60 workingset
= new RegistrationWorkingSet();
61 Registration reg
= new Registration();
62 reg
.setName(TaxonNameFactory
.NewBotanicalInstance(Rank
.SPECIES()));
63 getView().setHeaderText("New " + event
.getType().name().toString()+ " Registration");
66 } catch (RegistrationValidationException error
) {
67 getView().getWorkflow().setComponentError(new SystemError(error
));
71 workingset
= serviceMock
.loadWorkingSetByRegistrationID(event
.getRegistrationID());
72 } catch (RegistrationValidationException error
) {
73 getView().getWorkflow().setComponentError(new SystemError(error
));
75 getView().setHeaderText("Registration for " + workingset
.getCitation());
77 if(workingset
!= null){
78 getView().setWorkingset(workingset
);
79 //TODO add Blocking registrations to view
83 // @EventListener(condition = "#event.eventType ==T(eu.etaxonomy.cdm.vaadin.event.EventType).ADD")
84 // public void onReferenceAddEvent(ReferenceEvent event) {
85 // getView().openReferenceEditor(null);
88 @EventListener(condition
= "#event.eventType ==T(eu.etaxonomy.cdm.vaadin.event.EventType).EDIT")
89 public void onReferenceEditEvent(ReferenceEvent event
) {
90 getView().openReferenceEditor(null);