Revision fdb645e1
Added by Andreas Kohlbecker almost 7 years ago
.gitignore | ||
---|---|---|
9 | 9 |
/spy.log |
10 | 10 |
src/main/resources/test.txt |
11 | 11 |
cdmTest.lock.db |
12 |
src/test/resources/eu/etaxonomy/cdm/database/schema/*.xsd |
|
12 | 13 |
.designer |
13 | 14 |
.vaadin-designer |
14 | 15 |
.idea |
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemEditButtonGroup.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.component.registration; |
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 |
import java.util.HashSet; |
|
13 | 12 |
import java.util.List; |
14 |
import java.util.Set; |
|
15 | 13 |
|
16 | 14 |
import com.vaadin.server.FontAwesome; |
17 | 15 |
import com.vaadin.ui.Button; |
... | ... | |
36 | 34 |
/** |
37 | 35 |
* |
38 | 36 |
*/ |
39 |
private static final String DEFAULT_BUTTON_STYLES = ""; // ValoTheme.BUTTON_LINK;
|
|
37 |
private static final String DEFAULT_BUTTON_STYLES = ""; |
|
40 | 38 |
|
41 | 39 |
private static final long serialVersionUID = -5059163772392864050L; |
42 | 40 |
|
... | ... | |
44 | 42 |
|
45 | 43 |
private IdButton<TaxonName> nameIdButton = null; |
46 | 44 |
|
47 |
private List<IdSetButton<TypeDesignationWorkingSet>> typeDesignationButtons = new ArrayList<>();
|
|
45 |
private List<IdButton<TypeDesignationWorkingSet>> typeDesignationButtons = new ArrayList<>(); |
|
48 | 46 |
|
49 | 47 |
private List<Label> labels = new ArrayList<>(); |
50 | 48 |
|
... | ... | |
73 | 71 |
Button tdButton = new Button(buttonLabel + ":"); |
74 | 72 |
tdButton.setDescription("Edit the type designation working set"); |
75 | 73 |
addComponent(tdButton); |
76 |
Set<Integer> idSet = new HashSet<>(); |
|
77 |
typeDesignationWorkingSet.getTypeDesignations().forEach(td -> idSet.add(td.getId())); |
|
78 |
typeDesignationButtons.add(new IdSetButton<TypeDesignationWorkingSet>(TypeDesignationWorkingSet.class, idSet, tdButton)); |
|
74 |
// Set<Integer> idSet = new HashSet<>(); |
|
75 |
// typeDesignationWorkingSet.getTypeDesignations().forEach(td -> idSet.add(td.getId())); |
|
76 |
|
|
77 |
typeDesignationButtons.add(new IdButton<TypeDesignationWorkingSet>( |
|
78 |
TypeDesignationWorkingSet.class, |
|
79 |
typeDesignationWorkingSet.getWorkingSetId(), |
|
80 |
tdButton) |
|
81 |
); |
|
79 | 82 |
String labelText = typeDesignationWorkingSet.getRepresentation(); |
80 | 83 |
labelText = labelText.replaceAll("^[^:]+:", ""); // remove "Type:", "NameType:" from the beginning |
81 | 84 |
Label label = new Label(labelText); |
... | ... | |
99 | 102 |
return nameIdButton; |
100 | 103 |
} |
101 | 104 |
|
102 |
public List<IdSetButton<TypeDesignationWorkingSet>> getTypeDesignationButtons() {
|
|
105 |
public List<IdButton<TypeDesignationWorkingSet>> getTypeDesignationButtons() { |
|
103 | 106 |
return typeDesignationButtons; |
104 | 107 |
} |
105 | 108 |
|
... | ... | |
152 | 155 |
|
153 | 156 |
} |
154 | 157 |
|
155 |
public class IdSetButton<T> { |
|
156 |
private Set<Integer> ids; |
|
157 |
private Class<T> type; |
|
158 |
private Button button; |
|
159 |
|
|
160 |
public IdSetButton(Class<T> type, Set<Integer> ids, Button button){ |
|
161 |
this.type = type; |
|
162 |
this.ids = ids; |
|
163 |
this.button = button; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* @return the id |
|
168 |
*/ |
|
169 |
public Set<Integer> getIds() { |
|
170 |
return ids; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* @return the button |
|
175 |
*/ |
|
176 |
public Button getButton() { |
|
177 |
return button; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* @return the type |
|
182 |
*/ |
|
183 |
public Class<T> getType() { |
|
184 |
return type; |
|
185 |
} |
|
186 |
|
|
187 |
} |
|
188 |
|
|
189 | 158 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/event/TypeDesignationWorkingsetEditorAction.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.event; |
10 | 10 |
|
11 |
import java.util.Set; |
|
12 |
|
|
13 | 11 |
import com.vaadin.ui.Component; |
14 | 12 |
|
15 | 13 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
... | ... | |
22 | 20 |
*/ |
23 | 21 |
public class TypeDesignationWorkingsetEditorAction extends AbstractEditorAction { |
24 | 22 |
|
25 |
private Set<Integer> entityIds; |
|
26 |
|
|
27 | 23 |
private Class<? extends TypeDesignationBase<?>> newEntityType; |
28 | 24 |
|
25 |
private int registrationId; |
|
26 |
|
|
29 | 27 |
/** |
30 | 28 |
* @param edit |
31 | 29 |
* @param ids |
32 | 30 |
*/ |
33 |
public TypeDesignationWorkingsetEditorAction(Action action, Set<Integer> ids, Component source, AbstractView sourceView) {
|
|
34 |
super(action, null, source, sourceView);
|
|
35 |
this.entityIds = ids;
|
|
31 |
public TypeDesignationWorkingsetEditorAction(Action action, Integer typeDesignationWorkingsetId, int registrationId, Component source, AbstractView sourceView) {
|
|
32 |
super(action, typeDesignationWorkingsetId, source, sourceView);
|
|
33 |
this.registrationId = registrationId;
|
|
36 | 34 |
} |
37 | 35 |
|
38 | 36 |
/** |
39 | 37 |
* Constructor which is mainly suitable for ADD actions. |
40 | 38 |
* @param |
41 | 39 |
*/ |
42 |
public TypeDesignationWorkingsetEditorAction(Action action, Class<? extends TypeDesignationBase<?>> newEntityType, Component source, AbstractView sourceView) { |
|
40 |
public TypeDesignationWorkingsetEditorAction(Action action, Class<? extends TypeDesignationBase<?>> newEntityType, int registrationId, |
|
41 |
Component source, AbstractView sourceView) { |
|
43 | 42 |
super(action, null, source, sourceView); |
44 | 43 |
this.newEntityType = newEntityType; |
44 |
this.registrationId = registrationId; |
|
45 | 45 |
} |
46 | 46 |
|
47 |
public Set<Integer> getEntityIds() { |
|
48 |
return entityIds; |
|
49 |
} |
|
50 |
|
|
51 |
|
|
52 | 47 |
/** |
53 | 48 |
* In case of an ADD action the receiver of the event needs to know the specific type of the |
54 | 49 |
* TypeDesignationBase instance to be created. |
55 | 50 |
* |
56 | 51 |
* @return the newEntityType |
57 | 52 |
*/ |
58 |
protected Class<? extends TypeDesignationBase<?>> getNewEntityType() {
|
|
53 |
public Class<? extends TypeDesignationBase<?>> getNewEntityType() {
|
|
59 | 54 |
return newEntityType; |
60 | 55 |
} |
61 | 56 |
|
62 | 57 |
/** |
63 |
* {@inheritDoc} |
|
64 |
* @deprecated this method must not be used in TypeDesignationSetEditorAction |
|
58 |
* @return the registrationId |
|
65 | 59 |
*/ |
66 |
@Deprecated |
|
67 |
@Override |
|
68 |
public Integer getEntityId() { |
|
69 |
throw new RuntimeException("getEntityId() is not supported, use getEntityIds() instead."); |
|
60 |
public int getRegistrationId() { |
|
61 |
return registrationId; |
|
70 | 62 |
} |
71 | 63 |
|
72 | 64 |
|
73 | 65 |
|
74 | 66 |
|
75 | 67 |
|
76 |
|
|
77 | 68 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/model/TypedEntityReference.java | ||
---|---|---|
15 | 15 |
* @since Jun 12, 2017 |
16 | 16 |
* |
17 | 17 |
*/ |
18 |
public class TypedEntityReference extends EntityReference { |
|
18 |
public class TypedEntityReference<T> extends EntityReference {
|
|
19 | 19 |
|
20 | 20 |
/** |
21 | 21 |
* @param id |
22 | 22 |
* @param label |
23 | 23 |
*/ |
24 |
public TypedEntityReference(Class type, int id, String label) { |
|
24 |
public TypedEntityReference(Class<T> type, int id, String label) {
|
|
25 | 25 |
super(id, label); |
26 | 26 |
this.type = type; |
27 | 27 |
} |
... | ... | |
29 | 29 |
/** |
30 | 30 |
* @return the type |
31 | 31 |
*/ |
32 |
public Class getType() { |
|
32 |
public Class<T> getType() {
|
|
33 | 33 |
return type; |
34 | 34 |
} |
35 | 35 |
|
36 | 36 |
/** |
37 | 37 |
* @param type the type to set |
38 | 38 |
*/ |
39 |
public void setType(Class type) { |
|
39 |
public void setType(Class<T> type) {
|
|
40 | 40 |
this.type = type; |
41 | 41 |
} |
42 | 42 |
|
43 |
private Class type; |
|
43 |
private Class<T> type;
|
|
44 | 44 |
|
45 | 45 |
|
46 | 46 |
|
... | ... | |
58 | 58 |
/** |
59 | 59 |
* {@inheritDoc} |
60 | 60 |
*/ |
61 |
@SuppressWarnings("rawtypes") |
|
61 | 62 |
@Override |
62 | 63 |
public boolean equals(Object obj) { |
63 | 64 |
try { |
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/SpecimenTypeDesignationWorkingSetDTO.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.model.registration; |
|
10 |
|
|
11 |
import java.util.List; |
|
12 |
import java.util.Set; |
|
13 |
|
|
14 |
import org.joda.time.Partial; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
17 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
|
18 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
|
19 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
20 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
21 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
22 |
|
|
23 |
/** |
|
24 |
* @author a.kohlbecker |
|
25 |
* @since Jun 16, 2017 |
|
26 |
* |
|
27 |
*/ |
|
28 |
public class SpecimenTypeDesignationWorkingSetDTO { |
|
29 |
|
|
30 |
FieldUnit fieldUnit; |
|
31 |
|
|
32 |
VersionableEntity baseEntity; |
|
33 |
|
|
34 |
List<SpecimenTypeDesignation> specimenTypeDesignations; |
|
35 |
|
|
36 |
VersionableEntity owner; |
|
37 |
|
|
38 |
/** |
|
39 |
* @param fieldUnit |
|
40 |
* @param derivedUnits |
|
41 |
*/ |
|
42 |
public SpecimenTypeDesignationWorkingSetDTO(VersionableEntity owner, VersionableEntity baseEntity, List<SpecimenTypeDesignation> specimenTypeDesignations) { |
|
43 |
super(); |
|
44 |
this.owner = owner; |
|
45 |
this.baseEntity = baseEntity; |
|
46 |
if(baseEntity instanceof FieldUnit){ |
|
47 |
this.fieldUnit = (FieldUnit) baseEntity; |
|
48 |
} |
|
49 |
this.specimenTypeDesignations = specimenTypeDesignations; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* @return the fieldUnit |
|
54 |
* <code>null</code> if the base baseEntity is a not a fieldUnit |
|
55 |
*/ |
|
56 |
public FieldUnit getFieldUnit() { |
|
57 |
return fieldUnit; |
|
58 |
} |
|
59 |
|
|
60 |
|
|
61 |
/** |
|
62 |
* |
|
63 |
* @return the baseEntity |
|
64 |
* <code>null</code> if the base baseEntity is a fieldUnit |
|
65 |
*/ |
|
66 |
public VersionableEntity getBaseEntity() { |
|
67 |
return baseEntity; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* @return the derivedUnits |
|
72 |
*/ |
|
73 |
public List<SpecimenTypeDesignation> getSpecimenTypeDesignations() { |
|
74 |
return specimenTypeDesignations; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* The IdentifiableEntity which contains the DerivedUnit in this working set. |
|
79 |
* |
|
80 |
* |
|
81 |
* @return |
|
82 |
*/ |
|
83 |
public VersionableEntity getOwner() { |
|
84 |
return owner; |
|
85 |
} |
|
86 |
|
|
87 |
// ====== FieldUnit Wrapper methods ====== // |
|
88 |
public Person getPrimaryCollector() { |
|
89 |
return fieldUnit.getPrimaryCollector(); |
|
90 |
} |
|
91 |
|
|
92 |
public String getFieldNumber() { |
|
93 |
return fieldUnit.getFieldNumber(); |
|
94 |
} |
|
95 |
|
|
96 |
public void setFieldNumber(String fieldNumber) { |
|
97 |
this.fieldUnit.setFieldNumber(fieldNumber); |
|
98 |
} |
|
99 |
|
|
100 |
public String getFieldNotes() { |
|
101 |
return fieldUnit.getFieldNotes(); |
|
102 |
} |
|
103 |
|
|
104 |
// ====== GateringEvent Wrapper methods ====== // |
|
105 |
|
|
106 |
public LanguageString getLocality(){ |
|
107 |
return fieldUnit.getGatheringEvent().getLocality(); |
|
108 |
} |
|
109 |
|
|
110 |
public void setLocality(LanguageString locality){ |
|
111 |
fieldUnit.getGatheringEvent().setLocality(locality); |
|
112 |
} |
|
113 |
public NamedArea getCountry() { |
|
114 |
return fieldUnit.getGatheringEvent().getCountry(); |
|
115 |
} |
|
116 |
|
|
117 |
public void setCountry(NamedArea country) { |
|
118 |
fieldUnit.getGatheringEvent().setCountry(country); |
|
119 |
} |
|
120 |
|
|
121 |
public Integer getAbsoluteElevation() { |
|
122 |
return fieldUnit.getGatheringEvent().getAbsoluteElevation(); |
|
123 |
} |
|
124 |
|
|
125 |
public void setAbsoluteElevation(Integer absoluteElevation) { |
|
126 |
fieldUnit.getGatheringEvent().setAbsoluteElevation(absoluteElevation); |
|
127 |
} |
|
128 |
|
|
129 |
public Integer getAbsoluteElevationMax() { |
|
130 |
return fieldUnit.getGatheringEvent().getAbsoluteElevationMax(); |
|
131 |
} |
|
132 |
|
|
133 |
public void setAbsoluteElevationMax(Integer absoluteElevationMax) { |
|
134 |
fieldUnit.getGatheringEvent().setAbsoluteElevationMax(absoluteElevationMax); |
|
135 |
} |
|
136 |
|
|
137 |
public String getAbsoluteElevationText() { |
|
138 |
return fieldUnit.getGatheringEvent().getAbsoluteElevationText(); |
|
139 |
} |
|
140 |
|
|
141 |
public void setAbsoluteElevationText(String absoluteElevationText) { |
|
142 |
fieldUnit.getGatheringEvent().setAbsoluteElevationText(absoluteElevationText); |
|
143 |
} |
|
144 |
|
|
145 |
public Double getDistanceToWaterSurface() { |
|
146 |
return fieldUnit.getGatheringEvent().getDistanceToWaterSurface(); |
|
147 |
} |
|
148 |
|
|
149 |
public void setDistanceToWaterSurface(Double distanceToWaterSurface) { |
|
150 |
fieldUnit.getGatheringEvent().setDistanceToWaterSurface(distanceToWaterSurface); |
|
151 |
} |
|
152 |
|
|
153 |
public Double getDistanceToWaterSurfaceMax() { |
|
154 |
return fieldUnit.getGatheringEvent().getDistanceToWaterSurfaceMax(); |
|
155 |
} |
|
156 |
|
|
157 |
public void setDistanceToWaterSurfaceMax(Double distanceToWaterSurfaceMax) { |
|
158 |
fieldUnit.getGatheringEvent().setDistanceToWaterSurfaceMax(distanceToWaterSurfaceMax); |
|
159 |
} |
|
160 |
|
|
161 |
public String getDistanceToWaterSurfaceText() { |
|
162 |
return fieldUnit.getGatheringEvent().getDistanceToWaterSurfaceText(); |
|
163 |
} |
|
164 |
|
|
165 |
public void setDistanceToWaterSurfaceText(String distanceToWaterSurfaceText) { |
|
166 |
fieldUnit.getGatheringEvent().setDistanceToWaterSurfaceText(distanceToWaterSurfaceText); |
|
167 |
} |
|
168 |
|
|
169 |
|
|
170 |
public Double getDistanceToGround() { |
|
171 |
return fieldUnit.getGatheringEvent().getDistanceToGround(); |
|
172 |
} |
|
173 |
|
|
174 |
public void setDistanceToGround(Double distanceToGround) { |
|
175 |
fieldUnit.getGatheringEvent().setDistanceToGround(distanceToGround); |
|
176 |
} |
|
177 |
|
|
178 |
public Double getDistanceToGroundMax() { |
|
179 |
return fieldUnit.getGatheringEvent().getDistanceToGroundMax(); |
|
180 |
} |
|
181 |
|
|
182 |
public void setDistanceToGroundMax(Double distanceToGroundMax) { |
|
183 |
fieldUnit.getGatheringEvent().setDistanceToGroundMax(distanceToGroundMax); |
|
184 |
} |
|
185 |
|
|
186 |
public String getDistanceToGroundText() { |
|
187 |
return fieldUnit.getGatheringEvent().getDistanceToGroundText(); |
|
188 |
} |
|
189 |
|
|
190 |
public void setDistanceToGroundText(String distanceToGroundText) { |
|
191 |
fieldUnit.getGatheringEvent().setDistanceToWaterSurfaceText(distanceToGroundText); |
|
192 |
} |
|
193 |
|
|
194 |
/** |
|
195 |
* WARNING: This method returns only one of the possibly multiple areas which can |
|
196 |
* be hold by the GatheringEvent. |
|
197 |
* |
|
198 |
* @return |
|
199 |
*/ |
|
200 |
public NamedArea getCollectingArea() { |
|
201 |
try { |
|
202 |
return fieldUnit.getGatheringEvent().getCollectingAreas().iterator().next(); |
|
203 |
} catch (Exception e){ |
|
204 |
return null; |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
public void setCollectingArea(NamedArea collectingArea) throws Exception { |
|
209 |
if(fieldUnit.getGatheringEvent().getCollectingAreas().size() > 1){ |
|
210 |
throw new Exception("The GatheringEvent has multiple collectingAreas, use addCollectingArea() instead"); |
|
211 |
} |
|
212 |
fieldUnit.getGatheringEvent().getCollectingAreas().clear(); |
|
213 |
fieldUnit.getGatheringEvent().addCollectingArea(collectingArea); |
|
214 |
|
|
215 |
} |
|
216 |
|
|
217 |
public Set<NamedArea> getCollectingAreas() { |
|
218 |
return fieldUnit.getGatheringEvent().getCollectingAreas(); |
|
219 |
} |
|
220 |
|
|
221 |
public Partial getGatheringDate(){ |
|
222 |
return fieldUnit.getGatheringEvent().getGatheringDate(); |
|
223 |
} |
|
224 |
|
|
225 |
public void getGatheringDate(Partial gatheringDate){ |
|
226 |
fieldUnit.getGatheringEvent().setGatheringDate(gatheringDate); |
|
227 |
} |
|
228 |
|
|
229 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/DataIntegrityException.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.util.converter; |
|
10 |
|
|
11 |
/** |
|
12 |
* @author a.kohlbecker |
|
13 |
* @since Jun 19, 2017 |
|
14 |
* |
|
15 |
*/ |
|
16 |
public class DataIntegrityException extends Exception { |
|
17 |
|
|
18 |
/** |
|
19 |
* @param string |
|
20 |
*/ |
|
21 |
public DataIntegrityException(String string) { |
|
22 |
super(string); |
|
23 |
} |
|
24 |
|
|
25 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationConverter.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy; |
24 | 24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
25 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
25 | 26 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
27 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
|
26 | 28 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
27 | 29 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
28 | 30 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
... | ... | |
64 | 66 |
*/ |
65 | 67 |
private LinkedHashMap<TypedEntityReference, TypeDesignationWorkingSet> orderedByTypesByBaseEntity; |
66 | 68 |
|
67 |
|
|
68 | 69 |
private EntityReference typifiedName; |
69 | 70 |
|
70 | 71 |
private String finalString = null; |
71 | 72 |
|
72 | 73 |
final NullTypeDesignationStatus NULL_STATUS = new NullTypeDesignationStatus(); |
73 | 74 |
|
75 |
private List<String> probelms = new ArrayList<>(); |
|
76 |
|
|
74 | 77 |
/** |
75 | 78 |
* @param taxonName |
76 | 79 |
* @throws RegistrationValidationException |
... | ... | |
90 | 93 |
|
91 | 94 |
TypeDesignationStatusBase<?> status = td.getTypeStatus(); |
92 | 95 |
|
93 |
final TypedEntityReference baseEntityReference = baseEntityReference(td); |
|
96 |
try { |
|
97 |
final IdentifiableEntity<?> baseEntity = baseEntity(td); |
|
98 |
final TypedEntityReference<IdentifiableEntity<?>> baseEntityReference = makeEntityReference(baseEntity); |
|
94 | 99 |
|
95 |
EntityReference typeDesignationEntityReference = new EntityReference(td.getId(), stringify(td)); |
|
100 |
EntityReference typeDesignationEntityReference = new EntityReference(td.getId(), stringify(td));
|
|
96 | 101 |
|
97 |
TypeDesignationWorkingSet typedesignationWorkingSet; |
|
98 |
if(!byBaseEntityByTypeStatus.containsKey(baseEntityReference)){ |
|
99 |
TypedEntityReference containigEntityReference = new TypedEntityReference(containgEntity.getClass(), containgEntity.getId(), containgEntity.toString()); |
|
100 |
byBaseEntityByTypeStatus.put(baseEntityReference, new TypeDesignationWorkingSet(containigEntityReference, baseEntityReference));
|
|
101 |
} |
|
102 |
TypeDesignationWorkingSet typedesignationWorkingSet;
|
|
103 |
if(!byBaseEntityByTypeStatus.containsKey(baseEntityReference)){
|
|
104 |
TypedEntityReference containigEntityReference = new TypedEntityReference(containgEntity.getClass(), containgEntity.getId(), containgEntity.toString());
|
|
105 |
byBaseEntityByTypeStatus.put(baseEntityReference, new TypeDesignationWorkingSet(containigEntityReference, baseEntity, baseEntityReference));
|
|
106 |
}
|
|
102 | 107 |
|
103 |
typedesignationWorkingSet = byBaseEntityByTypeStatus.get(baseEntityReference); |
|
104 |
typedesignationWorkingSet.insert(status, typeDesignationEntityReference); |
|
108 |
typedesignationWorkingSet = byBaseEntityByTypeStatus.get(baseEntityReference); |
|
109 |
typedesignationWorkingSet.insert(status, typeDesignationEntityReference); |
|
110 |
} catch (DataIntegrityException e){ |
|
111 |
probelms.add(e.getMessage()); |
|
112 |
} |
|
105 | 113 |
} |
106 | 114 |
|
107 | 115 |
/** |
108 | 116 |
* @param td |
109 | 117 |
* @return |
118 |
* @throws DataIntegrityException |
|
110 | 119 |
*/ |
111 |
protected TypedEntityReference baseEntityReference(TypeDesignationBase<?> td) {
|
|
120 |
protected IdentifiableEntity<?> baseEntity(TypeDesignationBase<?> td) throws DataIntegrityException {
|
|
112 | 121 |
|
113 |
CdmBase baseEntity = null; |
|
114 |
String label = ""; |
|
122 |
IdentifiableEntity<?> baseEntity = null; |
|
115 | 123 |
if(td instanceof SpecimenTypeDesignation){ |
116 | 124 |
SpecimenTypeDesignation std = (SpecimenTypeDesignation) td; |
117 | 125 |
FieldUnit fu = findFieldUnit(std); |
118 | 126 |
if(fu != null){ |
119 | 127 |
baseEntity = fu; |
120 |
label = fu.getTitleCache(); |
|
121 | 128 |
} else if(((SpecimenTypeDesignation) td).getTypeSpecimen() != null){ |
122 | 129 |
baseEntity = ((SpecimenTypeDesignation) td).getTypeSpecimen(); |
123 |
label = ""; // empty label to avoid repeating the DerivedUnit details |
|
124 | 130 |
} |
125 | 131 |
} else if(td instanceof NameTypeDesignation){ |
126 | 132 |
baseEntity = ((NameTypeDesignation)td).getTypeName(); |
127 |
label = ""; |
|
128 | 133 |
} |
129 | 134 |
if(baseEntity == null) { |
130 |
baseEntity = td; |
|
131 |
label = "INCOMPLETE DATA"; |
|
135 |
throw new DataIntegrityException("Incomplete TypeDesignation, no type missin in " + td.toString()); |
|
132 | 136 |
} |
137 |
return baseEntity; |
|
138 |
} |
|
133 | 139 |
|
134 |
TypedEntityReference baseEntityReference = new TypedEntityReference(baseEntity.getClass(), baseEntity.getId(), label); |
|
140 |
/** |
|
141 |
* @param td |
|
142 |
* @return |
|
143 |
*/ |
|
144 |
protected TypedEntityReference<IdentifiableEntity<?>> makeEntityReference(IdentifiableEntity<?> baseEntity) { |
|
145 |
; |
|
146 |
String label = ""; |
|
147 |
if(baseEntity instanceof FieldUnit){ |
|
148 |
label = ((FieldUnit)baseEntity).getTitleCache(); |
|
149 |
} |
|
150 |
|
|
151 |
TypedEntityReference<IdentifiableEntity<?>> baseEntityReference = new TypedEntityReference(baseEntity.getClass(), baseEntity.getId(), label); |
|
135 | 152 |
|
136 | 153 |
return baseEntityReference; |
137 | 154 |
} |
... | ... | |
188 | 205 |
} |
189 | 206 |
}); |
190 | 207 |
// new LinkedHashMap for the ordered TypeDesignationStatusBase keys |
191 |
TypeDesignationWorkingSet orderedStringsByOrderedTypes = new TypeDesignationWorkingSet(typeDesignationWorkingSet.getContainigEntityReference(), baseEntityRef); |
|
208 |
TypeDesignationWorkingSet orderedStringsByOrderedTypes = new TypeDesignationWorkingSet(typeDesignationWorkingSet.getContainigEntityReference(), |
|
209 |
typeDesignationWorkingSet.getBaseEntity(), |
|
210 |
baseEntityRef); |
|
192 | 211 |
orderedStringsByOrderedTypes.setWorkingSetId(typeDesignationWorkingSet.workingSetId); // preserve original workingSetId |
193 | 212 |
keyList.forEach(key -> orderedStringsByOrderedTypes.put(key, typeDesignationWorkingSet.get(key))); |
194 | 213 |
stringsOrderedbyBaseEntityOrderdByType.put(baseEntityRef, orderedStringsByOrderedTypes); |
... | ... | |
501 | 520 |
|
502 | 521 |
String workingSetRepresentation = null; |
503 | 522 |
|
504 |
TypedEntityReference containigEntityReference; |
|
523 |
TypedEntityReference<?> containigEntityReference; |
|
524 |
|
|
525 |
TypedEntityReference<IdentifiableEntity<?>> baseEntityReference; |
|
526 |
|
|
527 |
IdentifiableEntity<?> baseEntity; |
|
505 | 528 |
|
506 |
TypedEntityReference baseEntityReference;
|
|
529 |
List<DerivedUnit> derivedUnits = null;
|
|
507 | 530 |
|
508 | 531 |
int workingSetId = workingSetIdAutoIncrement++; |
509 | 532 |
|
510 | 533 |
/** |
511 | 534 |
* @param baseEntityReference |
512 | 535 |
*/ |
513 |
public TypeDesignationWorkingSet(TypedEntityReference containigEntityReference, TypedEntityReference baseEntityReference) {
|
|
536 |
public TypeDesignationWorkingSet(TypedEntityReference<? extends VersionableEntity> containigEntityReference, IdentifiableEntity<?> baseEntity, TypedEntityReference<IdentifiableEntity<?>> baseEntityReference) {
|
|
514 | 537 |
this.containigEntityReference = containigEntityReference; |
538 |
this.baseEntity = baseEntity; |
|
515 | 539 |
this.baseEntityReference = baseEntityReference; |
516 | 540 |
} |
517 | 541 |
|
542 |
/** |
|
543 |
* @return |
|
544 |
*/ |
|
545 |
public IdentifiableEntity<?> getBaseEntity() { |
|
546 |
return baseEntity; |
|
547 |
} |
|
548 |
|
|
518 | 549 |
public List<EntityReference> getTypeDesignations() { |
519 | 550 |
List<EntityReference> typeDesignations = new ArrayList<>(); |
520 | 551 |
this.values().forEach(typeDesignationReferences -> typeDesignationReferences.forEach(td -> typeDesignations.add(td))); |
... | ... | |
592 | 623 |
* @return |
593 | 624 |
*/ |
594 | 625 |
public boolean isSpecimenTypeDesigationWorkingSet() { |
595 |
return baseEntityReference.getType().isAssignableFrom(SpecimenOrObservationBase.class);
|
|
626 |
return SpecimenOrObservationBase.class.isAssignableFrom(baseEntityReference.getType());
|
|
596 | 627 |
} |
597 | 628 |
|
598 | 629 |
} |
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 eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationConverter.TypeDesignationWorkingSet; |
|
11 |
import java.util.Set; |
|
12 |
|
|
13 |
import org.hibernate.Session; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.model.common.VersionableEntity; |
|
16 |
import eu.etaxonomy.cdm.model.name.Registration; |
|
17 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
18 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
|
19 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent; |
|
20 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEventType; |
|
21 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
22 |
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent; |
|
23 |
import eu.etaxonomy.cdm.vaadin.model.TypedEntityReference; |
|
24 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
|
25 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
|
12 | 26 |
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter; |
13 | 27 |
|
14 | 28 |
/** |
29 |
* SpecimenTypeDesignationWorkingsetPopupEditorView implementation must override the showInEditor() method, |
|
30 |
* see {@link #prepareAsFieldGroupDataSource()} for details. |
|
31 |
* |
|
15 | 32 |
* @author a.kohlbecker |
16 | 33 |
* @since Jun 13, 2017 |
17 | 34 |
* |
18 | 35 |
*/ |
19 | 36 |
public class SpecimenTypeDesignationWorkingsetEditorPresenter |
20 |
extends AbstractEditorPresenter<TypeDesignationWorkingSet , SpecimenTypeDesignationWorkingsetPopupEditorView> {
|
|
37 |
extends AbstractEditorPresenter<SpecimenTypeDesignationWorkingSetDTO , SpecimenTypeDesignationWorkingsetPopupEditorView> {
|
|
21 | 38 |
|
22 | 39 |
private static final long serialVersionUID = 4255636253714476918L; |
40 |
private Registration registration; |
|
41 |
|
|
42 |
|
|
43 |
|
|
23 | 44 |
|
24 | 45 |
/** |
25 | 46 |
* {@inheritDoc} |
47 |
* |
|
48 |
* see also {@link SpecimenTypeDesignationWorkingsetPopupEditor#showInEditor()} |
|
26 | 49 |
*/ |
27 | 50 |
@Override |
28 |
protected void saveBean(TypeDesignationWorkingSet bean) { |
|
29 |
// TODO Auto-generated method stub |
|
51 |
protected SpecimenTypeDesignationWorkingSetDTO prepareAsFieldGroupDataSource(SpecimenTypeDesignationWorkingSetDTO bean) { |
|
52 |
if(bean.getFieldUnit() == null){ |
|
53 |
// in case the base unit of the working set is not a FieldUnit all contained TypeDesignations must be modified |
|
54 |
// so that they are based on an empty FieldUnit with an associated Gathering Event |
|
55 |
if(Registration.class.isAssignableFrom(bean.getOwner().getClass())){ |
|
56 |
// FIXME open Dialog to warn user about adding an empty fieldUnit to the typeDesignations |
|
57 |
logger.info("Basing all typeDesignations on a new fieldUnit"); |
|
58 |
Session session = getSession(); |
|
59 |
Registration reg = getRepo().getRegistrationService().find(bean.getOwner().getId()); |
|
60 |
RegistrationDTO regDTO = new RegistrationDTO(reg); |
|
61 |
|
|
62 |
FieldUnit fieldUnit = FieldUnit.NewInstance(); |
|
63 |
GatheringEvent gatheringEvent = GatheringEvent.NewInstance(); |
|
64 |
fieldUnit.setGatheringEvent(gatheringEvent); |
|
65 |
getRepo().getOccurrenceService().save(fieldUnit); |
|
66 |
|
|
67 |
VersionableEntity baseEntity = bean.getBaseEntity(); |
|
68 |
Set<TypeDesignationBase> typeDesignations = regDTO.getTypeDesignationsInWorkingSet( |
|
69 |
new TypedEntityReference(baseEntity.getClass(), baseEntity.getId(), baseEntity.toString()) |
|
70 |
); |
|
71 |
for(TypeDesignationBase td : typeDesignations){ |
|
72 |
DerivationEvent de = DerivationEvent.NewInstance();// |
|
73 |
de.addOriginal(fieldUnit); |
|
74 |
de.addDerivative(((SpecimenTypeDesignation)td).getTypeSpecimen()); |
|
75 |
de.setType(DerivationEventType.GATHERING_IN_SITU()); |
|
76 |
} |
|
30 | 77 |
|
78 |
getRepo().getRegistrationService().saveOrUpdate(reg); |
|
79 |
session.flush(); |
|
80 |
session.close(); |
|
81 |
} else { |
|
82 |
throw new RuntimeException("Usupported owner type " + bean.getOwner().getClass() + ", needs to be implemented."); |
|
83 |
} |
|
84 |
} |
|
85 |
return super.prepareAsFieldGroupDataSource(bean); |
|
31 | 86 |
} |
32 | 87 |
|
88 |
|
|
89 |
|
|
33 | 90 |
/** |
34 | 91 |
* {@inheritDoc} |
35 | 92 |
*/ |
36 | 93 |
@Override |
37 |
protected void deleteBean(TypeDesignationWorkingSet bean) {
|
|
94 |
protected void saveBean(SpecimenTypeDesignationWorkingSetDTO bean) {
|
|
38 | 95 |
// TODO Auto-generated method stub |
39 | 96 |
|
40 | 97 |
} |
41 | 98 |
|
99 |
/** |
|
100 |
* {@inheritDoc} |
|
101 |
*/ |
|
102 |
@Override |
|
103 |
protected void deleteBean(SpecimenTypeDesignationWorkingSetDTO bean) { |
|
104 |
// TODO Auto-generated method stub |
|
105 |
|
|
106 |
} |
|
42 | 107 |
|
43 | 108 |
|
44 | 109 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetPopupEditor.java | ||
---|---|---|
14 | 14 |
|
15 | 15 |
import com.vaadin.ui.GridLayout; |
16 | 16 |
|
17 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
|
17 | 18 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
18 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationConverter.TypeDesignationWorkingSet; |
|
19 | 19 |
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor; |
20 | 20 |
|
21 | 21 |
/** |
... | ... | |
23 | 23 |
* @since May 15, 2017 |
24 | 24 |
* |
25 | 25 |
*/ |
26 |
public class SpecimenTypeDesignationWorkingsetPopupEditor extends AbstractPopupEditor<TypeDesignationWorkingSet, SpecimenTypeDesignationWorkingsetEditorPresenter>
|
|
26 |
public class SpecimenTypeDesignationWorkingsetPopupEditor extends AbstractPopupEditor<SpecimenTypeDesignationWorkingSetDTO, SpecimenTypeDesignationWorkingsetEditorPresenter>
|
|
27 | 27 |
implements SpecimenTypeDesignationWorkingsetPopupEditorView, AccessRestrictedView { |
28 | 28 |
|
29 |
private static final long serialVersionUID = 5418275817834009509L; |
|
30 |
|
|
29 |
/** |
|
30 |
* @param layout |
|
31 |
* @param dtoType |
|
32 |
*/ |
|
31 | 33 |
public SpecimenTypeDesignationWorkingsetPopupEditor() { |
32 |
super(new GridLayout(), TypeDesignationWorkingSet.class); |
|
34 |
super(new GridLayout(), SpecimenTypeDesignationWorkingSetDTO.class); |
|
35 |
GridLayout grid = (GridLayout) getFieldLayout(); |
|
36 |
grid.setMargin(true); |
|
37 |
grid.setSpacing(true); |
|
33 | 38 |
} |
34 | 39 |
|
40 |
private static final long serialVersionUID = 5418275817834009509L; |
|
41 |
|
|
42 |
|
|
35 | 43 |
/** |
36 | 44 |
* {@inheritDoc} |
37 | 45 |
*/ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationDTO.java | ||
---|---|---|
13 | 13 |
import java.util.HashSet; |
14 | 14 |
import java.util.LinkedHashMap; |
15 | 15 |
import java.util.List; |
16 |
import java.util.Optional; |
|
16 | 17 |
import java.util.Set; |
17 | 18 |
import java.util.UUID; |
18 | 19 |
|
... | ... | |
20 | 21 |
import org.apache.log4j.Logger; |
21 | 22 |
import org.joda.time.DateTime; |
22 | 23 |
|
24 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
23 | 25 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
24 | 26 |
import eu.etaxonomy.cdm.model.name.Registration; |
25 | 27 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus; |
28 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
26 | 29 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
27 | 30 |
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; |
28 | 31 |
import eu.etaxonomy.cdm.model.reference.IReference; |
29 | 32 |
import eu.etaxonomy.cdm.vaadin.model.EntityReference; |
30 | 33 |
import eu.etaxonomy.cdm.vaadin.model.TypedEntityReference; |
34 |
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO; |
|
31 | 35 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationConverter; |
32 | 36 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationConverter.TypeDesignationWorkingSet; |
33 | 37 |
|
... | ... | |
236 | 240 |
return typeDesignationConverter != null ? typeDesignationConverter.getOrderdTypeDesignationWorkingSets() : null; |
237 | 241 |
} |
238 | 242 |
|
243 |
/** |
|
244 |
* @param baseEntityReference |
|
245 |
*/ |
|
246 |
public TypeDesignationWorkingSet getTypeDesignationWorkingSet(TypedEntityReference baseEntityReference) { |
|
247 |
return typeDesignationConverter != null ? typeDesignationConverter.getOrderdTypeDesignationWorkingSets().get(baseEntityReference) : null; |
|
248 |
|
|
249 |
} |
|
250 |
|
|
251 |
/** |
|
252 |
* @param baseEntityReference |
|
253 |
*/ |
|
254 |
public Set<TypeDesignationBase> getTypeDesignationsInWorkingSet(TypedEntityReference baseEntityReference) { |
|
255 |
Set<TypeDesignationBase> typeDesignations = new HashSet<>(); |
|
256 |
TypeDesignationWorkingSet workingSet = getTypeDesignationWorkingSet(baseEntityReference); |
|
257 |
for(EntityReference ref : workingSet.getTypeDesignations()){ |
|
258 |
typeDesignations.add(findTypeDesignation(ref)); |
|
259 |
} |
|
260 |
return typeDesignations; |
|
261 |
} |
|
262 |
|
|
263 |
public SpecimenTypeDesignationWorkingSetDTO getSpecimenTypeDesignationWorkingSetDTO(TypedEntityReference baseEntityReference) { |
|
264 |
Set<TypeDesignationBase> typeDesignations = getTypeDesignationsInWorkingSet(baseEntityReference); |
|
265 |
List<SpecimenTypeDesignation> specimenTypeDesignations = new ArrayList<>(typeDesignations.size()); |
|
266 |
typeDesignations.forEach(td -> specimenTypeDesignations.add((SpecimenTypeDesignation)td)); |
|
267 |
IdentifiableEntity<?> baseEntity = getTypeDesignationWorkingSet(baseEntityReference).getBaseEntity(); |
|
268 |
SpecimenTypeDesignationWorkingSetDTO dto = new SpecimenTypeDesignationWorkingSetDTO(reg, baseEntity, specimenTypeDesignations); |
|
269 |
return dto; |
|
270 |
} |
|
271 |
|
|
272 |
/** |
|
273 |
* |
|
274 |
* @param workingSetId |
|
275 |
* @return the TypeDesignationWorkingSet in this DTO with the matching workingSetId or NULL |
|
276 |
*/ |
|
277 |
public TypeDesignationWorkingSet getTypeDesignationWorkingSet(int workingSetId) { |
|
278 |
Optional<TypeDesignationWorkingSet> workingSetOptional = getOrderdTypeDesignationWorkingSets().values().stream().filter(workingSet -> workingSet.getWorkingSetId() == workingSetId).findFirst(); |
|
279 |
if(workingSetOptional.isPresent()){ |
|
280 |
return workingSetOptional.get(); |
|
281 |
} |
|
282 |
return null; |
|
283 |
|
|
284 |
} |
|
285 |
|
|
286 |
/** |
|
287 |
* @param ref |
|
288 |
* @return |
|
289 |
*/ |
|
290 |
private TypeDesignationBase findTypeDesignation(EntityReference ref) { |
|
291 |
return typeDesignationConverter != null ? typeDesignationConverter.findTypeDesignation(ref) : null; |
|
292 |
} |
|
293 |
|
|
239 | 294 |
public Collection<TypeDesignationBase> getTypeDesignations() { |
240 | 295 |
return typeDesignationConverter != null ? typeDesignationConverter.getTypeDesignations() : null; |
241 | 296 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowPresenter.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import eu.etaxonomy.cdm.model.name.Rank; |
25 | 25 |
import eu.etaxonomy.cdm.model.name.Registration; |
26 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
27 | 28 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
28 | 29 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
... | ... | |
37 | 38 |
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction; |
38 | 39 |
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent; |
39 | 40 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet; |
41 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationConverter.TypeDesignationWorkingSet; |
|
42 |
import eu.etaxonomy.cdm.vaadin.view.name.SpecimenTypeDesignationWorkingsetPopupEditor; |
|
40 | 43 |
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor; |
41 | 44 |
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor; |
42 | 45 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
... | ... | |
148 | 151 |
public void onTaxonNameEditorAction(TaxonNameEditorAction event) { |
149 | 152 |
TransactionStatus tx = getRepo().startTransaction(false); |
150 | 153 |
// FIXME optional: |
151 |
// A) allow full initialization of the entity here the Preseneter of the Editor should
|
|
152 |
// provide the intiStratirey via a static method so that it can be used
|
|
153 |
// B) only pass the identifier (Object) to the View and the Presenter is reponsible for |
|
154 |
// loading and initializing the entitiy
|
|
155 |
TaxonName taxonName = getRepo().getNameService().find(event.getEntityId());
|
|
154 |
// A) allow full initialization of the entity here, the Presenter of the Editor should
|
|
155 |
// provide the intiStrategy via a static method so that it can be used
|
|
156 |
// B) only pass the identifier (Object) to the View and the Presenter is responsible for
|
|
157 |
// loading and initializing the entity |
|
158 |
TaxonName taxonName = getRepo().getNameService().find(event.getEntityId());
|
|
156 | 159 |
TaxonNamePopupEditor popup = getNavigationManager().showInPopup(TaxonNamePopupEditor.class); |
157 | 160 |
popup.showInEditor(taxonName); |
158 | 161 |
popup.withDeleteButton(true); |
... | ... | |
162 | 165 |
} |
163 | 166 |
|
164 | 167 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT && #event.sourceComponent == null") |
165 |
public void onTypedesignationsEditorAction(TypeDesignationWorkingsetEditorAction event) { |
|
166 |
TransactionStatus tx = getRepo().startTransaction(false); |
|
167 |
TaxonName taxonName = getRepo().getNameService().find(event.getEntityId()); |
|
168 |
TaxonNamePopupEditor popup = getNavigationManager().showInPopup(TaxonNamePopupEditor.class); |
|
169 |
popup.showInEditor(taxonName); |
|
170 |
popup.withDeleteButton(true); |
|
171 |
// in the registration application inReferences should only edited centrally |
|
172 |
popup.getNomReferenceCombobox().setEnabled(false); |
|
173 |
getRepo().commitTransaction(tx); |
|
168 |
public void onTypeDesignationsEditorActionEdit(TypeDesignationWorkingsetEditorAction event) { |
|
169 |
|
|
170 |
TransactionStatus tx = getRepo().startTransaction(false); |
|
171 |
Registration reg = getRepo().getRegistrationService().find(event.getRegistrationId()); |
|
172 |
RegistrationDTO regDTO = new RegistrationDTO(reg); |
|
173 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDTO.getTypeDesignationWorkingSet(event.getEntityId()); |
|
174 |
if(typeDesignationWorkingSet.isSpecimenTypeDesigationWorkingSet()){ |
|
175 |
// check SpecimenTypeDesignation |
|
176 |
SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class); |
|
177 |
popup.showInEditor(regDTO.getSpecimenTypeDesignationWorkingSetDTO(typeDesignationWorkingSet.getBaseEntityReference())); |
|
178 |
} else { |
|
179 |
// FIXME implement NameTypeDesignationWorkingsetPopupEditor |
|
180 |
} |
|
181 |
getRepo().commitTransaction(tx); |
|
182 |
} |
|
183 |
|
|
184 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD && #event.sourceComponent == null") |
|
185 |
public void onTypeDesignationsEditorActionAdd(TypeDesignationWorkingsetEditorAction event) { |
|
186 |
|
|
187 |
if(event.getNewEntityType().equals(SpecimenTypeDesignation.class)){ |
|
188 |
TransactionStatus tx = getRepo().startTransaction(false); |
|
189 |
Registration reg = getRepo().getRegistrationService().find(event.getRegistrationId()); |
|
190 |
RegistrationDTO regDTO = new RegistrationDTO(reg); |
|
191 |
SpecimenTypeDesignationWorkingsetPopupEditor popup = getNavigationManager().showInPopup(SpecimenTypeDesignationWorkingsetPopupEditor.class); |
|
192 |
popup.showInEditor(null); |
|
193 |
popup.withDeleteButton(true); |
|
194 |
getRepo().commitTransaction(tx); |
|
195 |
} |
|
174 | 196 |
} |
175 | 197 |
|
176 | 198 |
@EventListener(classes=ShowDetailsEvent.class, condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet)") |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java | ||
---|---|---|
11 | 11 |
import java.util.ArrayList; |
12 | 12 |
import java.util.Collection; |
13 | 13 |
import java.util.List; |
14 |
import java.util.Set; |
|
15 | 14 |
import java.util.UUID; |
16 | 15 |
|
17 | 16 |
import org.springframework.security.core.GrantedAuthority; |
... | ... | |
42 | 41 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
43 | 42 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem; |
44 | 43 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup; |
45 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup.IdSetButton;
|
|
44 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup.IdButton; |
|
46 | 45 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles; |
47 | 46 |
import eu.etaxonomy.cdm.vaadin.component.registration.TypeStateLabel; |
48 | 47 |
import eu.etaxonomy.cdm.vaadin.component.registration.WorkflowSteps; |
... | ... | |
309 | 308 |
getEventBus().publishEvent(new TaxonNameEditorAction( |
310 | 309 |
AbstractEditorAction.Action.EDIT, |
311 | 310 |
nameId, |
312 |
null, //e.getButton(), |
|
311 |
null, //e.getButton(), the listener method expects this to be null
|
|
313 | 312 |
this |
314 | 313 |
) |
315 | 314 |
); |
316 | 315 |
}); |
317 | 316 |
|
318 |
for(IdSetButton idSetButton : editButtonGroup.getTypeDesignationButtons()){ |
|
319 |
idSetButton.getButton().addClickListener(e -> { |
|
320 |
Set<Integer> ids = idSetButton.getIds(); |
|
317 |
for(IdButton idButton : editButtonGroup.getTypeDesignationButtons()){ |
|
318 |
idButton.getButton().addClickListener(e -> { |
|
319 |
Integer typeDesignationWorkingsetId = idButton.getId(); |
|
320 |
Integer registrationEntityID = dto.getId(); |
|
321 | 321 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
322 | 322 |
AbstractEditorAction.Action.EDIT, |
323 |
ids, |
|
324 |
null, //e.getButton(), |
|
323 |
typeDesignationWorkingsetId, |
|
324 |
registrationEntityID, |
|
325 |
null, //e.getButton(), the listener method expects this to be null |
|
325 | 326 |
this |
326 | 327 |
) |
327 | 328 |
); |
... | ... | |
329 | 330 |
} |
330 | 331 |
|
331 | 332 |
editButtonGroup.getAddTypeDesignationButton().addClickListener( |
332 |
e -> chooseNewTypeRegistrationWorkingset(e.getButton()) |
|
333 |
e -> chooseNewTypeRegistrationWorkingset(e.getButton(), dto.getId())
|
|
333 | 334 |
); |
334 | 335 |
} |
335 | 336 |
regItem = editButtonGroup; |
... | ... | |
346 | 347 |
|
347 | 348 |
/** |
348 | 349 |
* @param button |
350 |
* @param registrationEntityId |
|
349 | 351 |
* |
350 | 352 |
*/ |
351 |
protected void chooseNewTypeRegistrationWorkingset(Button button) { |
|
353 |
protected void chooseNewTypeRegistrationWorkingset(Button button, Integer registrationEntityId) {
|
|
352 | 354 |
|
353 | 355 |
Window typeDesignationTypeCooser = new Window(); |
354 | 356 |
typeDesignationTypeCooser.setModal(true); |
... | ... | |
356 | 358 |
typeDesignationTypeCooser.setCaption("Add new type designation"); |
357 | 359 |
Label label = new Label("Please select kind of type designation to be created."); |
358 | 360 |
Button newSpecimenTypeDesignationButton = new Button("Specimen type designation", |
359 |
e -> addNewTypeRegistrationWorkingset(SpecimenTypeDesignation.class, typeDesignationTypeCooser)); |
|
361 |
e -> addNewTypeRegistrationWorkingset(SpecimenTypeDesignation.class, registrationEntityId, typeDesignationTypeCooser));
|
|
360 | 362 |
Button newNameTypeDesignationButton = new Button("Name type designation", |
361 |
e -> addNewTypeRegistrationWorkingset(NameTypeDesignation.class, typeDesignationTypeCooser)); |
|
363 |
e -> addNewTypeRegistrationWorkingset(NameTypeDesignation.class, registrationEntityId, typeDesignationTypeCooser));
|
|
362 | 364 |
newNameTypeDesignationButton.setEnabled(false); |
363 | 365 |
|
364 | 366 |
VerticalLayout layout = new VerticalLayout(label, newSpecimenTypeDesignationButton, newNameTypeDesignationButton); |
... | ... | |
368 | 370 |
layout.setComponentAlignment(newNameTypeDesignationButton, Alignment.MIDDLE_CENTER); |
369 | 371 |
typeDesignationTypeCooser.setContent(layout); |
370 | 372 |
UI.getCurrent().addWindow(typeDesignationTypeCooser); |
371 |
|
|
372 | 373 |
} |
373 | 374 |
|
374 | 375 |
/** |
375 | 376 |
* @param button |
376 | 377 |
* |
377 | 378 |
*/ |
378 |
protected void addNewTypeRegistrationWorkingset(Class<? extends TypeDesignationBase<?>> newEntityType, Window typeDesignationTypeCooser) { |
|
379 |
protected void addNewTypeRegistrationWorkingset(Class<? extends TypeDesignationBase<?>> newEntityType, Integer registrationEntityId, Window typeDesignationTypeCooser) {
|
|
379 | 380 |
UI.getCurrent().removeWindow(typeDesignationTypeCooser); |
380 | 381 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
381 | 382 |
AbstractEditorAction.Action.ADD, |
382 | 383 |
newEntityType, |
384 |
registrationEntityId, |
|
383 | 385 |
null, |
384 | 386 |
this |
385 | 387 |
)); |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java | ||
---|---|---|
528 | 528 |
public void showInEditor(DTO beanToEdit) { |
529 | 529 |
|
530 | 530 |
DTO preparedBean = getPresenter().prepareAsFieldGroupDataSource(beanToEdit); |
531 |
fieldGroup.setItemDataSource(preparedBean);
|
|
531 |
fieldGroup.setItemDataSource(preparedBean);
|
|
532 | 532 |
afterItemDataSourceSet(); |
533 | 533 |
} |
534 | 534 |
|
Also available in: Unified diff
ref #6724 implementing SpecimenTypeDesignationWorkingSetDTO as editor dto and modifying the TypeDesignationConverter accordingly