Revision 1ff11053
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemEditButtonGroup.java | ||
---|---|---|
63 | 63 |
addComponents(nameIdButton.getButton(), nameLabel); |
64 | 64 |
} else { |
65 | 65 |
// no name in the registration! we only show the typified name as label |
66 |
addComponent(new Label(regDto.getTypifiedName().getLabel())); |
|
66 |
if(regDto.getTypifiedName() != null){ |
|
67 |
addComponent(new Label(regDto.getTypifiedName().getLabel())); |
|
68 |
} |
|
67 | 69 |
} |
68 | 70 |
if(regDto.getOrderdTypeDesignationWorkingSets() != null){ |
69 | 71 |
for(TypedEntityReference baseEntityRef : regDto.getOrderdTypeDesignationWorkingSets().keySet()) { |
... | ... | |
90 | 92 |
} |
91 | 93 |
} |
92 | 94 |
addTypeDesignationButton = new Button(FontAwesome.PLUS); |
93 |
addTypeDesignationButton.setDescription("Add a new type designation"); |
|
95 |
addTypeDesignationButton.setDescription("Add a new type designation workingset");
|
|
94 | 96 |
addComponent(addTypeDesignationButton); |
95 | 97 |
|
96 | 98 |
|
... | ... | |
117 | 119 |
@Override |
118 | 120 |
protected void addDefaultStyles() { |
119 | 121 |
addStyleName(STYLE_NAMES); |
120 |
nameIdButton.getButton().addStyleName(DEFAULT_BUTTON_STYLES); |
|
122 |
if(nameIdButton != null){ |
|
123 |
nameIdButton.getButton().addStyleName(DEFAULT_BUTTON_STYLES); |
|
124 |
} |
|
121 | 125 |
typeDesignationButtons.forEach(idb -> idb.getButton().addStyleName(DEFAULT_BUTTON_STYLES)); |
122 | 126 |
addTypeDesignationButton.addStyleName(DEFAULT_BUTTON_STYLES); |
123 | 127 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/event/TypeDesignationWorkingsetEditorAction.java | ||
---|---|---|
70 | 70 |
return registrationId; |
71 | 71 |
} |
72 | 72 |
|
73 |
public Integer getTypeDesignationWorkingsetId(){ |
|
74 |
return getEntityId(); |
|
75 |
} |
|
76 |
|
|
73 | 77 |
|
74 | 78 |
|
75 | 79 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/RegistrationWorkingSet.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.model.registration; |
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 |
import java.util.Arrays; |
|
12 | 13 |
import java.util.HashSet; |
13 | 14 |
import java.util.List; |
15 |
import java.util.Optional; |
|
14 | 16 |
import java.util.Set; |
15 | 17 |
|
16 | 18 |
import org.joda.time.DateTime; |
17 | 19 |
|
18 | 20 |
import eu.etaxonomy.cdm.model.name.Registration; |
19 | 21 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus; |
22 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
20 | 23 |
import eu.etaxonomy.cdm.model.reference.Reference; |
21 | 24 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
22 | 25 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationValidationException; |
... | ... | |
68 | 71 |
* all validation problems. |
69 | 72 |
* |
70 | 73 |
* @param candidates |
71 |
* @param problems Problems detected in prior validation and processing passed to this method to be completed. |
|
74 |
* @param problems |
|
75 |
* Problems detected in prior validation and processing passed to this method to be completed. Can be <code>null</code>. |
|
72 | 76 |
* @throws RegistrationValidationException |
73 | 77 |
*/ |
74 | 78 |
private void validateAndAddDTOs(List<RegistrationDTO> candidates, List<String> problems) throws RegistrationValidationException { |
... | ... | |
107 | 111 |
validateAndAdd(candidates); |
108 | 112 |
} |
109 | 113 |
|
114 |
public void add(RegistrationDTO regDTO) throws RegistrationValidationException { |
|
115 |
validateAndAddDTOs(Arrays.asList(regDTO), null); |
|
116 |
} |
|
117 |
|
|
110 | 118 |
/** |
111 | 119 |
* @return the registrations |
112 | 120 |
*/ |
... | ... | |
154 | 162 |
return registrationDTOs; |
155 | 163 |
} |
156 | 164 |
|
165 |
public Optional<RegistrationDTO> getRegistrationDTO(int registrationId) { |
|
166 |
return registrationDTOs.stream().filter(r -> r.getId() == registrationId).findFirst(); |
|
167 |
} |
|
168 |
|
|
157 | 169 |
/** |
158 | 170 |
* @return the citationId |
159 | 171 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/SpecimenTypeDesignationDTO.java | ||
---|---|---|
52 | 52 |
|
53 | 53 |
SpecimenTypeDesignation std; |
54 | 54 |
|
55 |
/** |
|
56 |
* @return the std |
|
57 |
*/ |
|
58 |
public SpecimenTypeDesignation asSpecimenTypeDesignation() { |
|
59 |
return std; |
|
60 |
} |
|
61 |
|
|
55 | 62 |
/** |
56 | 63 |
* Creates an new new instance of SpecimenTypeDesignationDTO which is backed up |
57 | 64 |
* by an newly instantiated <code>SpecimenTypeDesignation.typeSpecimen.derivedFrom.type</code> object graph. |
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/SpecimenTypeDesignationWorkingSetDTO.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
VersionableEntity baseEntity; |
37 | 37 |
|
38 |
List<SpecimenTypeDesignation> specimenTypeDesignations; |
|
38 |
List<SpecimenTypeDesignation> specimenTypeDesignations = new ArrayList<>();
|
|
39 | 39 |
|
40 | 40 |
List<SpecimenTypeDesignationDTO> specimenTypeDesignationsDTOs = new ArrayList<>(); |
41 | 41 |
|
42 | 42 |
VersionableEntity owner; |
43 | 43 |
|
44 | 44 |
/** |
45 |
* @param fieldUnit |
|
46 |
* @param derivedUnits |
|
45 |
* |
|
46 |
* @param owner |
|
47 |
* @param baseEntity |
|
48 |
* @param specimenTypeDesignations can be <code>null</code> |
|
47 | 49 |
*/ |
48 | 50 |
public SpecimenTypeDesignationWorkingSetDTO(VersionableEntity owner, VersionableEntity baseEntity, List<SpecimenTypeDesignation> specimenTypeDesignations) { |
49 | 51 |
super(); |
... | ... | |
55 | 57 |
fieldUnit.setGatheringEvent(GatheringEvent.NewInstance()); |
56 | 58 |
} |
57 | 59 |
} |
58 |
this.specimenTypeDesignations = specimenTypeDesignations; |
|
59 |
specimenTypeDesignations.forEach(std -> specimenTypeDesignationsDTOs.add(new SpecimenTypeDesignationDTO(std))); |
|
60 |
if(specimenTypeDesignations != null){ |
|
61 |
this.specimenTypeDesignations = specimenTypeDesignations; |
|
62 |
this.specimenTypeDesignations.forEach(std -> specimenTypeDesignationsDTOs.add(new SpecimenTypeDesignationDTO(std))); |
|
63 |
} |
|
60 | 64 |
} |
61 | 65 |
|
62 | 66 |
/** |
... | ... | |
80 | 84 |
/** |
81 | 85 |
* @return the derivedUnits |
82 | 86 |
*/ |
83 |
public List<SpecimenTypeDesignation> getSpecimenTypeDesignations() {
|
|
87 |
protected List<SpecimenTypeDesignation> getSpecimenTypeDesignations() {
|
|
84 | 88 |
return specimenTypeDesignations; |
85 | 89 |
} |
86 | 90 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationSetManager.java | ||
---|---|---|
557 | 557 |
} |
558 | 558 |
|
559 | 559 |
/** |
560 |
* Groups the EntityReferences for TypeDesignations by the according TypeDesignationStatus. |
|
560 |
* TypeDesignations which refer to the same FieldUnit (SpecimenTypeDesignation) or TaxonName |
|
561 |
* (NameTypeDesignation) form a working set. The <code>TypeDesignationWorkingSet</code> internally |
|
562 |
* works with EnityReferences to the actual TypeDesignations. |
|
563 |
* |
|
564 |
* The EntityReferences for TypeDesignations are grouped by the according TypeDesignationStatus. |
|
561 | 565 |
* The TypeDesignationStatusBase keys can be ordered by the term order defined in the vocabulary. |
566 |
* |
|
567 |
* A workingset can be referenced by the <code>workingSetId</code>, this is a autoincrement |
|
568 |
* value which is created during the process of determining the workingsets in a collection of |
|
569 |
* TypeDesignations. |
|
570 |
* |
|
571 |
* TODO: consider using a concatenation of baseEntity.getClass() + baseEntity.getId() as workingset identifier |
|
562 | 572 |
*/ |
563 | 573 |
public class TypeDesignationWorkingSet extends LinkedHashMap<TypeDesignationStatusBase<?>, Collection<EntityReference>> { |
564 | 574 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/RegistrationAndWorkingsetId.java | ||
---|---|---|
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.name; |
|
10 |
|
|
11 |
public class RegistrationAndWorkingsetId { |
|
12 |
Integer registrationId; |
|
13 |
Integer workingsetId; |
|
14 |
/** |
|
15 |
* @param registrationId |
|
16 |
* @param specimentId |
|
17 |
*/ |
|
18 |
public RegistrationAndWorkingsetId(Integer registrationId, Integer specimentId) { |
|
19 |
super(); |
|
20 |
this.registrationId = registrationId; |
|
21 |
this.workingsetId = specimentId; |
|
22 |
} |
|
23 |
|
|
24 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 |
import java.util.ArrayList;
|
|
11 |
import java.util.Arrays;
|
|
12 | 12 |
import java.util.HashSet; |
13 | 13 |
import java.util.Iterator; |
14 |
import java.util.List; |
|
15 | 14 |
import java.util.Set; |
16 | 15 |
|
17 | 16 |
import org.hibernate.Session; |
... | ... | |
22 | 21 |
import eu.etaxonomy.cdm.model.location.Country; |
23 | 22 |
import eu.etaxonomy.cdm.model.name.Registration; |
24 | 23 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
24 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
25 | 25 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
26 | 26 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
27 | 27 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent; |
... | ... | |
37 | 37 |
import eu.etaxonomy.cdm.vaadin.model.TypedEntityReference; |
38 | 38 |
import eu.etaxonomy.cdm.vaadin.model.registration.DerivationEventTypes; |
39 | 39 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationTermLists; |
40 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationDTO; |
|
40 | 41 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
41 | 42 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
42 | 43 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSet; |
... | ... | |
57 | 58 |
|
58 | 59 |
CdmStore<Registration, IRegistrationService> store; |
59 | 60 |
|
61 |
private Reference citation; |
|
62 |
|
|
63 |
private TaxonName typifiedName; |
|
64 |
|
|
60 | 65 |
protected CdmStore<Registration, IRegistrationService> getStore() { |
61 | 66 |
if(store == null){ |
62 | 67 |
store = new CdmStore<>(getRepo(), getRepo().getRegistrationService()); |
... | ... | |
66 | 71 |
|
67 | 72 |
|
68 | 73 |
/** |
69 |
* {@inheritDoc} |
|
74 |
* Loads an existing working set from the database. This process actually involves |
|
75 |
* loading the Registration specified by the <code>RegistrationAndWorkingsetId.registrationId</code> and in |
|
76 |
* a second step to find the workingset by the <code>registrationAndWorkingsetId.workingsetId</code>. |
|
77 |
* <p> |
|
78 |
* The <code>identifier</code> must be of the type {@link TypeDesignationWorkingsetEditorIdSet} whereas the field <code>egistrationId</code> |
|
79 |
* must be present, the field <code>workingsetId</code>, however can be null. I this case a new workingset with a new {@link FieldUnit} as |
|
80 |
* base entity is being created. |
|
81 |
* |
|
82 |
* @param identifier a {@link TypeDesignationWorkingsetEditorIdSet} |
|
70 | 83 |
*/ |
71 | 84 |
@Override |
72 | 85 |
protected SpecimenTypeDesignationWorkingSetDTO loadBeanById(Object identifier) { |
73 | 86 |
|
74 |
SpecimenTypeDesignationWorkingSetDTO workingSet; |
|
87 |
SpecimenTypeDesignationWorkingSetDTO workingSetDto;
|
|
75 | 88 |
if(identifier != null){ |
76 |
RegistrationAndWorkingsetId registrationAndWorkingsetId = (RegistrationAndWorkingsetId)identifier; |
|
77 |
List<Integer> ids = new ArrayList<>(); |
|
78 |
ids.add(registrationAndWorkingsetId.registrationId); |
|
79 |
Registration reg = getRepo().getRegistrationService().loadByIds(ids, null).get(0); |
|
80 |
RegistrationDTO regDTO = new RegistrationDTO(reg); |
|
81 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDTO.getTypeDesignationWorkingSet(registrationAndWorkingsetId.workingsetId); |
|
82 |
workingSet = regDTO.getSpecimenTypeDesignationWorkingSetDTO(typeDesignationWorkingSet.getBaseEntityReference()); |
|
89 |
TypeDesignationWorkingsetEditorIdSet idset = (TypeDesignationWorkingsetEditorIdSet)identifier; |
|
90 |
Registration reg = getRepo().getRegistrationService().loadByIds(Arrays.asList(idset.registrationId), null).get(0); |
|
91 |
if(idset.workingsetId != null){ |
|
92 |
RegistrationDTO regDTO = new RegistrationDTO(reg); |
|
93 |
// find the working set |
|
94 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDTO.getTypeDesignationWorkingSet(idset.workingsetId); |
|
95 |
workingSetDto = regDTO.getSpecimenTypeDesignationWorkingSetDTO(typeDesignationWorkingSet.getBaseEntityReference()); |
|
96 |
citation = (Reference) regDTO.getCitation(); |
|
97 |
} else { |
|
98 |
// create a new workingset, for a new fieldunit which is the base for the workingset |
|
99 |
FieldUnit newfieldUnit = FieldUnit.NewInstance(); |
|
100 |
workingSetDto = new SpecimenTypeDesignationWorkingSetDTO(reg, newfieldUnit, null); |
|
101 |
citation = getRepo().getReferenceService().find(idset.publicationId); |
|
102 |
typifiedName = getRepo().getNameService().find(idset.typifiedNameId); |
|
103 |
} |
|
83 | 104 |
} else { |
84 |
workingSet = null; |
|
105 |
workingSetDto = null;
|
|
85 | 106 |
} |
86 |
return workingSet; |
|
107 |
return workingSetDto;
|
|
87 | 108 |
} |
88 | 109 |
|
89 | 110 |
|
... | ... | |
217 | 238 |
// associate all type designations with the fieldUnit |
218 | 239 |
// 1. new ones are not yet associated |
219 | 240 |
// 2. ones which had incomplete data are also not connected |
220 |
for(SpecimenTypeDesignation std : dto.getSpecimenTypeDesignations()){
|
|
241 |
for(SpecimenTypeDesignationDTO stdDTO : dto.getSpecimenTypeDesignationDTOs()){
|
|
221 | 242 |
try { |
222 |
SpecimenOrObservationBase<?> original = findEarliestOriginal(std.getTypeSpecimen()); |
|
243 |
SpecimenOrObservationBase<?> original = findEarliestOriginal(stdDTO.asSpecimenTypeDesignation().getTypeSpecimen());
|
|
223 | 244 |
if(original instanceof DerivedUnit){ |
224 | 245 |
DerivedUnit du = (DerivedUnit)original; |
225 | 246 |
du.getDerivedFrom().addOriginal(dto.getFieldUnit()); |
... | ... | |
232 | 253 |
|
233 | 254 |
// add newly added typeDesignations |
234 | 255 |
Set<SpecimenTypeDesignation> addCandidates = new HashSet<>(); |
235 |
for(SpecimenTypeDesignation std : dto.getSpecimenTypeDesignations()){ |
|
236 |
if(!reg.getTypeDesignations().stream().filter(td -> td.equals(std)).findFirst().isPresent()){ |
|
256 |
for(SpecimenTypeDesignationDTO stdDTO : dto.getSpecimenTypeDesignationDTOs()){ |
|
257 |
SpecimenTypeDesignation std = stdDTO.asSpecimenTypeDesignation(); |
|
258 |
if(reg.getTypeDesignations().isEmpty() || !reg.getTypeDesignations().stream().filter(td -> td.equals(std)).findFirst().isPresent()){ |
|
259 |
std.setCitation(citation); |
|
260 |
typifiedName.addTypeDesignation(std, false); |
|
237 | 261 |
addCandidates.add(std); |
238 | 262 |
} |
239 | 263 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TypeDesignationWorkingsetEditorIdSet.java | ||
---|---|---|
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.name; |
|
10 |
|
|
11 |
public class TypeDesignationWorkingsetEditorIdSet { |
|
12 |
Integer registrationId; |
|
13 |
Integer workingsetId; |
|
14 |
Integer publicationId; |
|
15 |
Integer typifiedNameId; |
|
16 |
|
|
17 |
/** |
|
18 |
* @param registrationId |
|
19 |
* must be present |
|
20 |
* @param workingsetId |
|
21 |
* can <code>null</code>. In this case the <code>publicationId</code> |
|
22 |
* and and typifiedNameId must be set. |
|
23 |
* <code>RegistrationAndWorkingsetId</code> refers to a not yet |
|
24 |
* existing working set, which should be created by the code in |
|
25 |
* case this makes sense. |
|
26 |
* @param publicationId |
|
27 |
* Can <code>null</code> if the <code>workingsetId</code> is given. |
|
28 |
* @param typifiedNameId |
|
29 |
* Can <code>null</code> if the <code>workingsetId</code> is given |
|
30 |
*/ |
|
31 |
protected TypeDesignationWorkingsetEditorIdSet(Integer registrationId, Integer workingsetId, Integer publicationId, Integer typifiedNameId) { |
|
32 |
this.registrationId = registrationId; |
|
33 |
this.workingsetId = workingsetId; |
|
34 |
this.publicationId = publicationId; |
|
35 |
this.typifiedNameId = typifiedNameId; |
|
36 |
if(workingsetId == null && publicationId == null|| workingsetId == null && typifiedNameId == null){ |
|
37 |
throw new NullPointerException("When workingsetId is null, publicationId and typifiedNameId must be non null."); |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
public TypeDesignationWorkingsetEditorIdSet(Integer registrationId, Integer workingsetId) { |
|
42 |
this(registrationId, workingsetId, null, null); |
|
43 |
} |
|
44 |
|
|
45 |
public TypeDesignationWorkingsetEditorIdSet(Integer registrationId, Integer publicationId, Integer typifiedNameId) { |
|
46 |
this(registrationId, null, publicationId, typifiedNameId); |
|
47 |
} |
|
48 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java | ||
---|---|---|
123 | 123 |
* @param registrationItems |
124 | 124 |
* @return |
125 | 125 |
*/ |
126 |
@Deprecated |
|
126 | 127 |
private GeneratedPropertyContainer buildGeneratedProperties( |
127 | 128 |
BeanContainer<String, RegistrationDTO> registrationItems) { |
128 | 129 |
GeneratedPropertyContainer gpContainer = new GeneratedPropertyContainer(registrationItems); |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationDTO.java | ||
---|---|---|
26 | 26 |
import eu.etaxonomy.cdm.model.name.Registration; |
27 | 27 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus; |
28 | 28 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
29 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
29 | 30 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
30 | 31 |
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; |
31 | 32 |
import eu.etaxonomy.cdm.model.reference.IReference; |
33 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
32 | 34 |
import eu.etaxonomy.cdm.vaadin.model.EntityReference; |
33 | 35 |
import eu.etaxonomy.cdm.vaadin.model.TypedEntityReference; |
34 | 36 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
... | ... | |
101 | 103 |
case TYPIFICATION: |
102 | 104 |
default: |
103 | 105 |
try { |
104 |
typeDesignationManager = new TypeDesignationSetManager(reg, reg.getTypeDesignations());
|
|
106 |
typeDesignationManager = new TypeDesignationSetManager(reg.getTypeDesignations()); |
|
105 | 107 |
summary = typeDesignationManager.buildString().print(); |
106 | 108 |
} catch (RegistrationValidationException e) { |
107 | 109 |
messages.add("Validation errors: " + e.getMessage()); |
... | ... | |
114 | 116 |
|
115 | 117 |
} |
116 | 118 |
|
119 |
/** |
|
120 |
* To create an initially empty DTO for which only the <code>typifiedName</code> and the <code>publication</code> are defined. |
|
121 |
* All TypeDesignations added to the <code>Registration</code> need to refer to the same <code>typifiedName</code> and must be |
|
122 |
* published in the same <code>publication</code>. |
|
123 |
* |
|
124 |
* @param reg |
|
125 |
* @param typifiedName |
|
126 |
*/ |
|
127 |
public RegistrationDTO(Registration reg, TaxonName typifiedName, Reference publication) { |
|
128 |
this.reg = reg; |
|
129 |
citation = publication; |
|
130 |
// create a TypeDesignationSetManager with only a reference to the typifiedName for validation |
|
131 |
typeDesignationManager = new TypeDesignationSetManager(typifiedName); |
|
132 |
} |
|
133 |
|
|
117 | 134 |
/** |
118 | 135 |
* @param reg |
119 | 136 |
* @return |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowPresenter.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
29 | 29 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
30 | 30 |
import eu.etaxonomy.cdm.model.reference.Reference; |
31 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
|
31 | 32 |
import eu.etaxonomy.cdm.service.CdmStore; |
32 | 33 |
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService; |
33 | 34 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
... | ... | |
36 | 37 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
37 | 38 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction; |
38 | 39 |
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction; |
40 |
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent; |
|
39 | 41 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet; |
42 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
|
40 | 43 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSetType; |
41 |
import eu.etaxonomy.cdm.vaadin.view.name.RegistrationAndWorkingsetId; |
|
42 | 44 |
import eu.etaxonomy.cdm.vaadin.view.name.SpecimenTypeDesignationWorkingsetPopupEditor; |
43 | 45 |
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor; |
46 |
import eu.etaxonomy.cdm.vaadin.view.name.TypeDesignationWorkingsetEditorIdSet; |
|
44 | 47 |
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor; |
45 | 48 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
46 | 49 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
... | ... | |
70 | 73 |
|
71 | 74 |
private RegistrationWorkingSet workingset; |
72 | 75 |
|
73 |
private TaxonName newTaxonNameForRegistration; |
|
76 |
private TaxonName newTaxonNameForRegistration = null; |
|
77 |
|
|
78 |
private RegistrationDTO newRegistrationDTOWithExistingName; |
|
74 | 79 |
|
75 | 80 |
|
76 | 81 |
/** |
... | ... | |
99 | 104 |
} |
100 | 105 |
|
101 | 106 |
|
107 |
/** |
|
108 |
* @param taxonNameId |
|
109 |
* @return |
|
110 |
*/ |
|
111 |
protected Registration createNewRegistrationForName(Integer taxonNameId) { |
|
112 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
113 |
// move into RegistrationWorkflowStateMachine |
|
114 |
long identifier = System.currentTimeMillis(); |
|
115 |
Registration reg = Registration.NewInstance( |
|
116 |
"http://phycobank.org/" + identifier, |
|
117 |
"" + identifier, |
|
118 |
taxonNameId != null ? getRepo().getNameService().find(taxonNameId) : null, |
|
119 |
null); |
|
120 |
Authentication authentication = currentSecurityContext().getAuthentication(); |
|
121 |
reg.setSubmitter((User)authentication.getPrincipal()); |
|
122 |
EntityChangeEvent event = getRegistrationStore().saveBean(reg); |
|
123 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
124 |
return getRepo().getRegistrationService().find(event.getEntityId()); |
|
125 |
} |
|
126 |
|
|
127 |
|
|
128 |
/** |
|
129 |
* |
|
130 |
*/ |
|
131 |
protected void refreshView() { |
|
132 |
getConversationHolder().getSession().clear(); |
|
133 |
presentWorkingSet(workingset.getCitationId()); |
|
134 |
} |
|
135 |
|
|
136 |
|
|
102 | 137 |
/** |
103 | 138 |
* {@inheritDoc} |
104 | 139 |
*/ |
... | ... | |
106 | 141 |
public void handleViewEntered() { |
107 | 142 |
|
108 | 143 |
super.handleViewEntered(); |
144 |
|
|
109 | 145 |
presentWorkingSet(getView().getCitationID()); |
146 |
|
|
147 |
CdmFilterablePagingProvider<TaxonName> pagingProvider = new CdmFilterablePagingProvider<TaxonName>( |
|
148 |
getRepo().getNameService(), this); |
|
149 |
CdmTitleCacheCaptionGenerator<TaxonName> titleCacheGenrator = new CdmTitleCacheCaptionGenerator<TaxonName>(); |
|
150 |
getView().getAddExistingNameCombobox().setCaptionGenerator(titleCacheGenrator); |
|
151 |
getView().getAddExistingNameCombobox().loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize()); |
|
110 | 152 |
} |
111 | 153 |
|
112 | 154 |
/** |
155 |
* Loads the WorkingSet from the data base and passes it to the view. |
|
156 |
* |
|
113 | 157 |
* @param registrationID |
114 | 158 |
*/ |
115 | 159 |
private void presentWorkingSet(Integer referenceID) { |
... | ... | |
122 | 166 |
Reference citation = getRepo().getReferenceService().find(referenceID); |
123 | 167 |
workingset = new RegistrationWorkingSet(citation); |
124 | 168 |
} |
125 |
getView().setHeaderText("Registration for " + workingset.getCitation()); |
|
169 |
getView().setHeaderText("Registrations for " + workingset.getCitation());
|
|
126 | 170 |
getView().setWorkingset(workingset); |
127 | 171 |
} |
128 | 172 |
|
... | ... | |
171 | 215 |
popup.getNomReferenceCombobox().setEnabled(false); |
172 | 216 |
} |
173 | 217 |
|
218 |
/** |
|
219 |
* Creates a new <code>Registration</code> for a new name that has just been edited |
|
220 |
* using the <code>TaxonNamePopupEditor</code>. The new name was previously created |
|
221 |
* in this presenter as <code>newTaxonNameForRegistration</code> (see {@link #onTaxonNameEditorActionAdd(TaxonNameEditorAction)}) |
|
222 |
* and is either filled with data (<code>Reason.SAVE</code>) or it is still empty |
|
223 |
* (<code>Reason.CANCEL</code>). |
|
224 |
* |
|
225 |
* |
|
226 |
* @param event |
|
227 |
* @throws RegistrationValidationException |
|
228 |
*/ |
|
174 | 229 |
@EventListener |
175 | 230 |
public void onDoneWithTaxonnameEditor(DoneWithPopupEvent event) throws RegistrationValidationException{ |
176 | 231 |
if(event.getPopup() instanceof TaxonNamePopupEditor){ |
177 | 232 |
if(newTaxonNameForRegistration != null && event.getReason().equals(Reason.SAVE)){ |
178 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
179 |
// move into RegistrationWorkflowStateMachine |
|
180 |
long identifier = System.currentTimeMillis(); |
|
181 |
Registration reg = Registration.NewInstance( |
|
182 |
"http://phycobank.org/" + identifier, |
|
183 |
"" + identifier, |
|
184 |
getRepo().getNameService().find(newTaxonNameForRegistration.getId()), |
|
185 |
null); |
|
186 |
Authentication authentication = currentSecurityContext().getAuthentication(); |
|
187 |
reg.setSubmitter((User)authentication.getPrincipal()); |
|
188 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
189 |
|
|
190 |
getRegistrationStore().saveBean(reg); |
|
191 |
|
|
233 |
int taxonNameId = newTaxonNameForRegistration.getId(); |
|
234 |
Registration reg = createNewRegistrationForName(taxonNameId); |
|
192 | 235 |
workingset.add(reg); |
193 | 236 |
refreshView(); |
194 | 237 |
} else if(event.getReason().equals(Reason.CANCEL)){ |
... | ... | |
197 | 240 |
} |
198 | 241 |
newTaxonNameForRegistration = null; |
199 | 242 |
} |
243 |
} |
|
244 |
|
|
245 |
|
|
246 |
/** |
|
247 |
* Creates a new Registration for an exiting (previously published name). |
|
248 |
* |
|
249 |
* @param event |
|
250 |
* @throws RegistrationValidationException |
|
251 |
*/ |
|
252 |
@EventListener(condition = "#event.action == T(eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent.Action).start") |
|
253 |
public void onRegistrationWorkflowEventActionStart(RegistrationWorkflowEvent event) throws RegistrationValidationException { |
|
254 |
|
|
255 |
getView().getAddExistingNameCombobox().commit(); |
|
256 |
TaxonName typifiedName = getView().getAddExistingNameCombobox().getValue(); |
|
257 |
if(typifiedName != null){ |
|
258 |
Registration newRegistrationWithExistingName = createNewRegistrationForName(null); |
|
259 |
Reference citation = getRepo().getReferenceService().find(workingset.getCitationId()); |
|
260 |
newRegistrationDTOWithExistingName = new RegistrationDTO(newRegistrationWithExistingName, typifiedName, citation); |
|
261 |
workingset.add(newRegistrationDTOWithExistingName); |
|
262 |
// tell the view to update the workingset |
|
263 |
getView().setWorkingset(workingset); |
|
264 |
getView().getAddExistingNameRegistrationButton().setEnabled(false); |
|
265 |
getView().getAddExistingNameRegistrationButton().setDescription("You first need to add a type designation to the previously created registration."); |
|
266 |
} else { |
|
267 |
logger.error("Seletced name is NULL"); |
|
268 |
} |
|
200 | 269 |
|
201 | 270 |
} |
271 |
|
|
202 | 272 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT && #event.sourceComponent == null") |
203 | 273 |
public void onTypeDesignationsEditorActionEdit(TypeDesignationWorkingsetEditorAction event) { |
204 | 274 |
|
205 | 275 |
if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET ){ |
206 | 276 |
SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class); |
207 |
popup.loadInEditor(new RegistrationAndWorkingsetId(event.getRegistrationId(), event.getEntityId()));
|
|
277 |
popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationId(), event.getEntityId()));
|
|
208 | 278 |
} else { |
209 | 279 |
// TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET |
210 | 280 |
// FIXME implement NameTypeDesignationWorkingsetPopupEditor |
211 | 281 |
} |
212 |
|
|
213 | 282 |
} |
214 | 283 |
|
215 | 284 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD && #event.sourceComponent == null") |
216 |
public void onTypeDesignationsEditorActionAdd(TypeDesignationWorkingsetEditorAction event) {
|
|
285 |
public void onAddNewTypeDesignationWorkingset(TypeDesignationWorkingsetEditorAction event) {
|
|
217 | 286 |
|
218 | 287 |
if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET){ |
219 | 288 |
SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class); |
220 |
popup.loadInEditor(null); |
|
289 |
TypeDesignationWorkingsetEditorIdSet identifierSet; |
|
290 |
Integer typifiedNameId; |
|
291 |
if(newRegistrationDTOWithExistingName != null){ |
|
292 |
typifiedNameId = newRegistrationDTOWithExistingName.getTypifiedName().getId(); |
|
293 |
} else { |
|
294 |
typifiedNameId = workingset.getRegistrationDTO(event.getRegistrationId()) |
|
295 |
.get() |
|
296 |
.getTypifiedName() |
|
297 |
.getId(); |
|
298 |
} |
|
299 |
identifierSet = new TypeDesignationWorkingsetEditorIdSet( |
|
300 |
event.getRegistrationId(), |
|
301 |
getView().getCitationID(), |
|
302 |
typifiedNameId |
|
303 |
); |
|
304 |
popup.loadInEditor(identifierSet |
|
305 |
); |
|
221 | 306 |
popup.withDeleteButton(true); |
307 |
} else { |
|
308 |
// TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET |
|
309 |
// FIXME implement NameTypeDesignationWorkingsetPopupEditor |
|
222 | 310 |
} |
223 | 311 |
} |
224 | 312 |
|
313 |
/** |
|
314 |
* Performs final actions after a TypeDesignationEditor which has been |
|
315 |
* opened to add a TypeDesignation to a Registration object which was |
|
316 |
* created for an previously published name. Prior adding a typedesignation, |
|
317 |
* the according Registration object is dangling, that has no association to |
|
318 |
* any entity denoting an nomenclatural act which has a reference to a |
|
319 |
* publication. This means that the registration object is not in the |
|
320 |
* working set. |
|
321 |
* |
|
322 |
* |
|
323 |
* @param event |
|
324 |
* @throws RegistrationValidationException |
|
325 |
*/ |
|
326 |
@EventListener |
|
327 |
public void onDoneWithTypeDesignationEditor(DoneWithPopupEvent event) throws RegistrationValidationException{ |
|
328 |
if(event.getPopup() instanceof SpecimenTypeDesignationWorkingsetPopupEditor){ |
|
329 |
if(event.getReason().equals(Reason.SAVE)){ |
|
330 |
refreshView(); |
|
331 |
} else if(event.getReason().equals(Reason.CANCEL)){ |
|
332 |
// clean up |
|
333 |
if(newRegistrationDTOWithExistingName != null){ |
|
334 |
getRegistrationStore().deleteBean(newRegistrationDTOWithExistingName.registration()); |
|
335 |
} |
|
336 |
} |
|
337 |
// set newRegistrationDTOWithExistingName NULL in any case |
|
338 |
newRegistrationDTOWithExistingName = null; |
|
339 |
} |
|
340 |
} |
|
341 |
|
|
342 |
|
|
225 | 343 |
@EventListener(classes=ShowDetailsEvent.class, condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet)") |
226 | 344 |
public void onShowRegistrationWorkingSetMessages(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments |
227 | 345 |
List<String> messages = new ArrayList<>(); |
... | ... | |
278 | 396 |
|
279 | 397 |
} |
280 | 398 |
|
281 |
/** |
|
282 |
* |
|
283 |
*/ |
|
284 |
protected void refreshView() { |
|
285 |
getConversationHolder().getSession().clear(); |
|
286 |
presentWorkingSet(workingset.getCitationId()); |
|
287 |
} |
|
288 |
|
|
289 | 399 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowView.java | ||
---|---|---|
11 | 11 |
import java.util.List; |
12 | 12 |
import java.util.UUID; |
13 | 13 |
|
14 |
import org.vaadin.viritin.fields.LazyComboBox; |
|
15 |
|
|
14 | 16 |
import com.vaadin.ui.Button; |
15 | 17 |
import com.vaadin.ui.CssLayout; |
16 | 18 |
|
19 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
20 |
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction; |
|
17 | 21 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet; |
18 | 22 |
import eu.etaxonomy.vaadin.mvp.ApplicationView; |
19 | 23 |
|
... | ... | |
70 | 74 |
*/ |
71 | 75 |
void openDetailsPopup(String caption, List<String> messages); |
72 | 76 |
|
73 |
Button getAddExistingNameRegistrationButton();
|
|
77 |
Button getAddNewNameRegistrationButton();
|
|
74 | 78 |
|
79 |
/** |
|
80 |
* @return |
|
81 |
*/ |
|
82 |
Button getAddExistingNameRegistrationButton(); |
|
75 | 83 |
|
76 |
Button getAddNewNameRegistrationButton();
|
|
84 |
public LazyComboBox<TaxonName> getAddExistingNameCombobox();
|
|
77 | 85 |
|
78 | 86 |
Integer getCitationID(); |
79 | 87 |
|
80 | 88 |
|
89 |
/** |
|
90 |
* selecting a type will cause a {@link TypeDesignationWorkingsetEditorAction} to be emitted. |
|
91 |
* On Cancel .. TODO |
|
92 |
* @param registrationEntityId |
|
93 |
*/ |
|
94 |
void chooseNewTypeRegistrationWorkingset(Integer registrationEntityId); |
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
81 | 101 |
|
82 | 102 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java | ||
---|---|---|
14 | 14 |
import java.util.UUID; |
15 | 15 |
|
16 | 16 |
import org.springframework.security.core.GrantedAuthority; |
17 |
import org.vaadin.viritin.fields.LazyComboBox; |
|
17 | 18 |
|
18 | 19 |
import com.vaadin.navigator.View; |
19 | 20 |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
... | ... | |
37 | 38 |
import com.vaadin.ui.Window; |
38 | 39 |
import com.vaadin.ui.themes.ValoTheme; |
39 | 40 |
|
41 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
40 | 42 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem; |
41 | 43 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup; |
42 | 44 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup.TypeDesignationWorkingSetButton; |
... | ... | |
50 | 52 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
51 | 53 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction; |
52 | 54 |
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction; |
55 |
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent; |
|
53 | 56 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet; |
54 | 57 |
import eu.etaxonomy.cdm.vaadin.model.registration.WorkflowStep; |
55 | 58 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
... | ... | |
92 | 95 |
|
93 | 96 |
private Button addNewNameRegistrationButton; |
94 | 97 |
|
95 |
private Button addExistingNameRegistrationButton; |
|
98 |
private LazyComboBox<TaxonName> existingNameCombobox; |
|
99 |
|
|
100 |
// private Button addExistingNameRegistrationButton; |
|
96 | 101 |
|
97 | 102 |
private GridLayout registrationsGrid; |
98 | 103 |
|
104 |
private Button addExistingNameButton; |
|
105 |
|
|
99 | 106 |
public RegistrationWorkflowViewBean() { |
100 | 107 |
super(); |
101 | 108 |
} |
... | ... | |
205 | 212 |
} |
206 | 213 |
|
207 | 214 |
|
208 |
Label addRegistrationLabel = new Label("Add a registration for a"); |
|
215 |
Label addRegistrationLabel_1 = new Label("Add a new registration for a"); |
|
216 |
Label addRegistrationLabel_2 = new Label("or an"); |
|
209 | 217 |
|
210 | 218 |
addNewNameRegistrationButton = new Button("new name"); |
211 | 219 |
addNewNameRegistrationButton.setDescription("A name which is newly published in this publication."); |
212 |
addNewNameRegistrationButton.addClickListener(e -> eventBus.publishEvent(new TaxonNameEditorAction(Action.ADD, addNewNameRegistrationButton))); |
|
220 |
addNewNameRegistrationButton.addClickListener( |
|
221 |
e -> eventBus.publishEvent(new TaxonNameEditorAction(Action.ADD, addNewNameRegistrationButton)) |
|
222 |
); |
|
213 | 223 |
|
214 |
addExistingNameRegistrationButton = new Button("existing name"); |
|
215 |
addExistingNameRegistrationButton.setDescription("A name which was previously published in a earlier publication."); |
|
224 |
addExistingNameButton = new Button("existing name:"); |
|
225 |
addExistingNameButton.setDescription("A name which was previously published in a earlier publication."); |
|
226 |
addExistingNameButton.setEnabled(false); |
|
227 |
addExistingNameButton.addClickListener( |
|
228 |
e -> eventBus.publishEvent(new RegistrationWorkflowEvent(citationID, RegistrationWorkflowEvent.Action.start)) |
|
229 |
); |
|
216 | 230 |
|
231 |
existingNameCombobox = new LazyComboBox<TaxonName>(TaxonName.class); |
|
232 |
existingNameCombobox.addValueChangeListener( |
|
233 |
e -> addExistingNameButton.setEnabled(e.getProperty().getValue() != null) |
|
234 |
); |
|
217 | 235 |
|
218 |
HorizontalLayout buttonContainer = new HorizontalLayout(addRegistrationLabel, addNewNameRegistrationButton, addExistingNameRegistrationButton);
|
|
236 |
HorizontalLayout buttonContainer = new HorizontalLayout(addRegistrationLabel_1, addNewNameRegistrationButton, addRegistrationLabel_2, addExistingNameButton, existingNameCombobox);
|
|
219 | 237 |
buttonContainer.setSpacing(true); |
220 | 238 |
buttonContainer.setWidth(100, Unit.PERCENTAGE); |
221 |
buttonContainer.setComponentAlignment(addRegistrationLabel, Alignment.MIDDLE_LEFT); |
|
239 |
buttonContainer.setComponentAlignment(addRegistrationLabel_1, Alignment.MIDDLE_LEFT); |
|
240 |
buttonContainer.setComponentAlignment(addRegistrationLabel_2, Alignment.MIDDLE_LEFT); |
|
222 | 241 |
registrationsGrid.addComponent(buttonContainer, 1, row, 1, row); |
223 | 242 |
|
224 | 243 |
Panel namesTypesPanel = new Panel(registrationsGrid); |
... | ... | |
312 | 331 |
Component regItem; |
313 | 332 |
if(REG_ITEM_AS_BUTTON_GROUP){ |
314 | 333 |
RegistrationItemEditButtonGroup editButtonGroup = new RegistrationItemEditButtonGroup(dto); |
315 |
if(editButtonGroup.getNameButton() != null){ |
|
316 | 334 |
|
335 |
if(editButtonGroup.getNameButton() != null){ |
|
317 | 336 |
editButtonGroup.getNameButton().getButton().addClickListener(e -> { |
318 | 337 |
Integer nameId = editButtonGroup.getNameButton().getId(); |
319 | 338 |
getEventBus().publishEvent(new TaxonNameEditorAction( |
... | ... | |
324 | 343 |
) |
325 | 344 |
); |
326 | 345 |
}); |
346 |
} |
|
327 | 347 |
|
328 |
for(TypeDesignationWorkingSetButton workingsetButton : editButtonGroup.getTypeDesignationButtons()){ |
|
329 |
workingsetButton.getButton().addClickListener(e -> { |
|
330 |
Integer typeDesignationWorkingsetId = workingsetButton.getId(); |
|
331 |
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType(); |
|
332 |
Integer registrationEntityID = dto.getId(); |
|
333 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
|
334 |
AbstractEditorAction.Action.EDIT, |
|
335 |
typeDesignationWorkingsetId, |
|
336 |
workingsetType, |
|
337 |
registrationEntityID, |
|
338 |
null, //e.getButton(), the listener method expects this to be null |
|
339 |
this |
|
340 |
) |
|
341 |
); |
|
342 |
}); |
|
343 |
} |
|
344 |
|
|
345 |
editButtonGroup.getAddTypeDesignationButton().addClickListener( |
|
346 |
e -> chooseNewTypeRegistrationWorkingset(e.getButton(), dto.getId()) |
|
348 |
for(TypeDesignationWorkingSetButton workingsetButton : editButtonGroup.getTypeDesignationButtons()){ |
|
349 |
workingsetButton.getButton().addClickListener(e -> { |
|
350 |
Integer typeDesignationWorkingsetId = workingsetButton.getId(); |
|
351 |
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType(); |
|
352 |
Integer registrationEntityID = dto.getId(); |
|
353 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
|
354 |
AbstractEditorAction.Action.EDIT, |
|
355 |
typeDesignationWorkingsetId, |
|
356 |
workingsetType, |
|
357 |
registrationEntityID, |
|
358 |
null, //e.getButton(), the listener method expects this to be null |
|
359 |
this |
|
360 |
) |
|
347 | 361 |
); |
362 |
}); |
|
348 | 363 |
} |
364 |
|
|
365 |
editButtonGroup.getAddTypeDesignationButton().addClickListener( |
|
366 |
e -> chooseNewTypeRegistrationWorkingset(dto.getId()) |
|
367 |
); |
|
349 | 368 |
regItem = editButtonGroup; |
350 | 369 |
} else { |
351 | 370 |
regItem = new Label(dto.getSummary()); |
... | ... | |
363 | 382 |
* @param registrationEntityId |
364 | 383 |
* |
365 | 384 |
*/ |
366 |
protected void chooseNewTypeRegistrationWorkingset(Button button, Integer registrationEntityId) { |
|
385 |
@Override |
|
386 |
public void chooseNewTypeRegistrationWorkingset(Integer registrationEntityId) { |
|
367 | 387 |
|
368 | 388 |
Window typeDesignationTypeCooser = new Window(); |
369 | 389 |
typeDesignationTypeCooser.setModal(true); |
... | ... | |
371 | 391 |
typeDesignationTypeCooser.setCaption("Add new type designation"); |
372 | 392 |
Label label = new Label("Please select kind of type designation to be created."); |
373 | 393 |
Button newSpecimenTypeDesignationButton = new Button("Specimen type designation", |
374 |
e -> addNewTypeRegistrationWorkingset(TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET, registrationEntityId, typeDesignationTypeCooser));
|
|
394 |
e -> addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET, registrationEntityId, typeDesignationTypeCooser));
|
|
375 | 395 |
Button newNameTypeDesignationButton = new Button("Name type designation", |
376 |
e -> addNewTypeRegistrationWorkingset(TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET, registrationEntityId, typeDesignationTypeCooser));
|
|
396 |
e -> addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET, registrationEntityId, typeDesignationTypeCooser));
|
|
377 | 397 |
newNameTypeDesignationButton.setEnabled(false); |
378 | 398 |
|
379 | 399 |
VerticalLayout layout = new VerticalLayout(label, newSpecimenTypeDesignationButton, newNameTypeDesignationButton); |
... | ... | |
389 | 409 |
* @param button |
390 | 410 |
* |
391 | 411 |
*/ |
392 |
protected void addNewTypeRegistrationWorkingset(TypeDesignationWorkingSetType newWorkingsetType, Integer registrationEntityId, Window typeDesignationTypeCooser) {
|
|
412 |
protected void addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType newWorkingsetType, Integer registrationEntityId, Window typeDesignationTypeCooser) {
|
|
393 | 413 |
UI.getCurrent().removeWindow(typeDesignationTypeCooser); |
394 | 414 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
395 | 415 |
AbstractEditorAction.Action.ADD, |
... | ... | |
533 | 553 |
return addNewNameRegistrationButton; |
534 | 554 |
} |
535 | 555 |
|
536 |
/** |
|
537 |
* @return the addExistingNameRegistrationButton |
|
538 |
*/ |
|
539 | 556 |
@Override |
540 | 557 |
public Button getAddExistingNameRegistrationButton() { |
541 |
return addExistingNameRegistrationButton; |
|
558 |
return addExistingNameButton; |
|
559 |
} |
|
560 |
|
|
561 |
@Override |
|
562 |
public LazyComboBox<TaxonName> getAddExistingNameCombobox() { |
|
563 |
return existingNameCombobox; |
|
542 | 564 |
} |
543 | 565 |
|
544 | 566 |
/** |
Also available in: Unified diff
ref #6169 feature completed: adding new type designation workingsets