Project

General

Profile

« Previous | Next » 

Revision 210b9aa6

Added by Andreas Kohlbecker about 7 years ago

better WorkflowView title, validation, some EventListeners

View differences:

src/main/java/eu/etaxonomy/cdm/mock/RegistrationService.java
16 16
import java.util.Set;
17 17
import java.util.UUID;
18 18

  
19
import org.apache.log4j.Logger;
19 20
import org.springframework.beans.factory.annotation.Autowired;
20 21
import org.springframework.beans.factory.annotation.Qualifier;
21 22
import org.springframework.stereotype.Service;
......
27 28
import eu.etaxonomy.cdm.model.name.Rank;
28 29
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
29 30
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationDTO;
31
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationValidationException;
30 32

  
31 33
/**
32 34
 * @author a.kohlbecker
......
73 75
                            Registration nameReg = new Registration();
74 76
                            nameReg.setName(name);
75 77
                            cdmEntities.add(name);
76
                            put(nameReg, new RegistrationDTO(nameReg, null));
78
                            try {
79
                                put(nameReg, new RegistrationDTO(nameReg));
80
                            } catch (RegistrationValidationException e) {
81
                                //FIXME throw  and handle Exception
82
                                Logger.getLogger(this.getClass()).error(e);
83
                            }
77 84

  
78 85
                            // typedesignation
79 86
                            Registration typedesignationReg = new Registration();
80 87
                            typedesignationReg.addTypeDesignations(name.getTypeDesignations());
81 88
                            cdmEntities.addAll(name.getTypeDesignations());
82
                            put(typedesignationReg,  new RegistrationDTO(typedesignationReg, name));
89
                            try {
90
                                put(typedesignationReg,  new RegistrationDTO(typedesignationReg));
91
                            } catch (RegistrationValidationException e) {
92
                                //FIXME throw  and handle Exception
93
                                Logger.getLogger(this.getClass()).error(e);
94
                            }
83 95
                        }
84 96
                    }
85 97
                }
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/WorkflowItem.java
32 32
        }
33 33
    }
34 34

  
35
    @Override
36
    public void setCaption(String text){
37
        this.caption.setValue(text);
38
    }
39

  
35 40
}
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/registration/RegistrationDTO.java
16 16
import eu.etaxonomy.cdm.mock.Registration;
17 17
import eu.etaxonomy.cdm.mock.RegistrationStatus;
18 18
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
19
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
19 20
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
20 21
import eu.etaxonomy.cdm.model.reference.Reference;
21 22
import eu.etaxonomy.cdm.vaadin.util.TypeDesignationConverter;
......
36 37

  
37 38
    private Set<Registration> blockedBy = new HashSet<>();
38 39

  
40
    private TaxonNameBase<?, ?> typifiedName;
41

  
39 42
    /**
40 43
     * @param reg
41 44
     * @param typifiedName should be provided in for Registrations for TypeDesignations
45
     * @throws RegistrationValidationException in case of inconsistencies in the Registration
42 46
     */
43
    public RegistrationDTO(Registration reg, TaxonNameBase typifiedName) {
47
    public RegistrationDTO(Registration reg) throws RegistrationValidationException {
44 48

  
45 49
         this.reg = reg;
46 50

  
......
53 57
                citationID = citation.getId();
54 58
            }
55 59
        } else if(registrationType.isTypification()){
60
            typifiedName = findTypifiedName();
56 61
            summary = new TypeDesignationConverter(reg.getTypeDesignations(), typifiedName)
57 62
                    .buildString().print();
58 63
            if(!reg.getTypeDesignations().isEmpty()){
......
67 72
        }
68 73
    }
69 74

  
75

  
76

  
77
    /**
78
     * @return
79
     * @throws RegistrationValidationException
80
     */
81
    private TaxonNameBase<?,?> findTypifiedName() throws RegistrationValidationException {
82

  
83
        StringBuffer problems = new StringBuffer();
84

  
85
        TaxonNameBase<?,?> typifiedName = null;
86

  
87
        for(TypeDesignationBase<?> typeDesignation : reg.getTypeDesignations()){
88
            typeDesignation.getTypifiedNames();
89
            if(typeDesignation.getTypifiedNames().isEmpty()){
90

  
91
                //TODO instead throw RegistrationValidationException()
92
                problems.append(" - Missing typifiedName in " + typeDesignation.toString()).append("\n");
93
                continue;
94
            }
95
            if(typeDesignation.getTypifiedNames().size() > 1){
96
              //TODO instead throw RegistrationValidationException()
97
                problems.append(" - Multiple typifiedName in " + typeDesignation.toString()).append("\n");
98
                continue;
99
            }
100
            if(typifiedName == null){
101
                // remember
102
                typifiedName = typeDesignation.getTypifiedNames().iterator().next();
103
            } else {
104
                // compare
105
                TaxonNameBase<?,?> otherTypifiedName = typeDesignation.getTypifiedNames().iterator().next();
106
                if(typifiedName.getId() != otherTypifiedName.getId()){
107
                  //TODO instead throw RegistrationValidationException()
108
                    problems.append(" - Multiple typifiedName in " + typeDesignation.toString()).append("\n");
109
                }
110
            }
111

  
112
        }
113
        if(problems.length() > 0){
114
            throw new RegistrationValidationException("Inconsistent Registration entity. " + reg.toString() + " Problems:\n" + problems.toString());
115
        }
116

  
117
        return typifiedName;
118
    }
119

  
120

  
70 121
    /**
71 122
     * @return the summary
72 123
     */
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/registration/RegistrationWorkflowPresenter.java
19 19
import eu.etaxonomy.cdm.mock.RegistrationService;
20 20
import eu.etaxonomy.cdm.model.name.Rank;
21 21
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
22
import eu.etaxonomy.cdm.vaadin.event.ReferenceEvent;
22 23
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
23 24
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationWorkflowView;
24 25
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
......
55 56
        if(e.isStart()) {
56 57
            registration = new Registration();
57 58
            registration.setName(TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()));
59
            getView().setHeaderText("New " + e.getType().name().toString()+ " Registration");
58 60
        } else {
59 61
            registration = serviceMock.loadByRegistrationID(e.getRegistrationID());
62
            getView().setHeaderText("Registration " + registration.getIdentifier());
60 63
        }
61 64
        if(registration != null){
62 65
            // getView().getTitle().setValue("Workflow for a " + registrationType().name());
......
64 67
        }
65 68
    }
66 69

  
70
//    @EventListener(condition = "#event.eventType ==T(eu.etaxonomy.cdm.vaadin.event.EventType).ADD")
71
//    public void onReferenceAddEvent(ReferenceEvent event) {
72
//        getView().openReferenceEditor(null);
73
//    }
74

  
75
    @EventListener(condition = "#event.eventType ==T(eu.etaxonomy.cdm.vaadin.event.EventType).EDIT")
76
    public void onReferenceEditEvent(ReferenceEvent event) {
77
        getView().openReferenceEditor(null);
78
    }
79

  
80

  
67 81
    /**
68 82
     * @return
69 83
     */
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowView.java
31 31
     * given otherwise a blank editor will open if the  nameUuid is null.
32 32
     *
33 33
     * @param nameUuid can be null
34
     * @deprecated will be handled by the WorkflowItem
35 34
     */
36
    @Deprecated
37 35
    void openNameEditor(UUID nameUuid);
38 36

  
37
    /**
38
     * Open a popup editor for an existing Reference if the referenceUuid is
39
     * given otherwise a blank editor will open if the  referenceUuid is null.
40
     *
41
     * @param referenceUuid can be null
42
     */
43
    void openReferenceEditor(UUID referenceUuid);
44

  
39 45
    public void makeWorflow(RegistrationType type);
40 46

  
47

  
48
    /**
49
     * @param subheaderText
50
     */
51
    void setSubheaderText(String subheaderText);
52

  
53
    /**
54
     * @param subheaderText
55
     */
56
    void setHeaderText(String subheaderText);
57

  
58

  
59

  
41 60
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java
18 18
import com.vaadin.ui.CssLayout;
19 19

  
20 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;
21 24
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent;
22 25
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationType;
23 26
import eu.etaxonomy.cdm.vaadin.presenter.registration.RegistrationWorkflowPresenter;
......
32 35
public class RegistrationWorkflowViewBean extends AbstractPageView<RegistrationWorkflowPresenter>
33 36
    implements RegistrationWorkflowView, View {
34 37

  
35
    /**
36
     *
37
     */
38
    private static final String CSS_CLASS_WORKFLOW = "workflow-container";
39 38

  
40
    private static final String SUBHEADER_PREFIX = "Advance step by step through the registration workflow for scientific names.";
39
    public static final String CSS_CLASS_WORKFLOW = "workflow-container";
41 40

  
42
    private static final String HEADER_PREFIX = "Registration of the ...";
41
    public static final String SUBHEADER_DEEFAULT = "Advance step by step through the registration workflow.";
43 42

  
44 43
    private static final long serialVersionUID = -213040114015958970L;
45 44

  
......
53 52

  
54 53
    CssLayout workflow;
55 54

  
56
    String headerSuffix = "";
55
    private String headerText = "-- empty --";
56
    private String subheaderText = SUBHEADER_DEEFAULT;
57 57

  
58 58
    public RegistrationWorkflowViewBean() {
59 59
        super();
......
74 74

  
75 75
           if(params[0].equals(ACTION_NEW)) {
76 76
               regType = RegistrationType.valueOf(params[1]);
77
               headerSuffix = regType.name() + " ...";
77
               headerText = regType.name() + " ...";
78 78
               eventBus.publishEvent(new RegistrationWorkflowEvent(regType));
79 79

  
80 80
           } else if( params[0].equals(ACTION_EDIT)) {
81
               headerSuffix = params[1];
81
               headerText = params[1];
82 82
               eventBus.publishEvent(new RegistrationWorkflowEvent(Integer.parseInt(params[1])));
83 83
           }
84 84
           updateHeader();
......
104 104
    */
105 105
   private void addNameWorkflow() {
106 106
       WorkflowSteps steps = new WorkflowSteps();
107
       steps.appendNewWorkflowItem(1, "Nomenclatural reference", null);
108
       steps.appendNewWorkflowItem(2, "Name", null);
109
       steps.appendNewWorkflowItem(3, "Publisher Details", null);
110
       steps.appendNewWorkflowItem(4, "Data curation", null);
111
       steps.appendNewWorkflowItem(5, "Awaiting publication", null);
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);
112 113
       getWorkflow().addComponent(steps);
113 114
   }
114 115

  
......
117 118
   */
118 119
  private void addTypificationWorkflow() {
119 120
      WorkflowSteps steps = new WorkflowSteps();
120
      steps.appendNewWorkflowItem(1, "Name", null);
121
      steps.appendNewWorkflowItem(2, "Type information", null);
122
      steps.appendNewWorkflowItem(3, "Publisher Details", null);
123
      steps.appendNewWorkflowItem(4, "Data curation", null);
124
      steps.appendNewWorkflowItem(5, "Awaiting publication", null);
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);
125 127
      getWorkflow().addComponent(steps);
126 128
  }
127 129

  
......
134 136
        setPresenter(presenter);
135 137
    }
136 138

  
139
    /**
140
     * {@inheritDoc}
141
     */
142
    @Override
143
    public void openReferenceEditor(UUID referenceUuid) {
144
        // TODO Auto-generated method stub
145

  
146
    }
147

  
137 148
    /**
138 149
     * {@inheritDoc}
139 150
     */
......
148 159
     */
149 160
    @Override
150 161
    protected String getHeaderText() {
151
        return HEADER_PREFIX + " " + headerSuffix;
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;
152 187
    }
153 188

  
154 189
    /**
......
156 191
     */
157 192
    @Override
158 193
    protected String getSubHeaderText() {
159
        return SUBHEADER_PREFIX;
194
        return subheaderText;
160 195
    }
161 196

  
162 197
    /**

Also available in: Unified diff