Revision bd6037c5
Added by Andreas Kohlbecker about 3 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/event/ToOneRelatedEntityReloader.java | ||
---|---|---|
87 | 87 |
onSettingReloadedEntity = false; |
88 | 88 |
} |
89 | 89 |
} else { |
90 |
throw new RuntimeException("The cache must not be null. See loadBeanById() in AbstractCdmEditorPresenter");
|
|
90 |
throw new RuntimeException("The cache must not be null. See loadBeanById() in CdmEditorPresenterBase");
|
|
91 | 91 |
} |
92 | 92 |
} |
93 | 93 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/event/TypeDesignationWorkingsetEditorAction.java | ||
---|---|---|
78 | 78 |
this.context.push(new EditorActionContext(new TypedEntityReference<Registration>(Registration.class, registrationUuid), sourceView)); |
79 | 79 |
} |
80 | 80 |
|
81 |
|
|
82 |
|
|
83 |
/** |
|
84 |
* |
|
85 |
* @return |
|
86 |
*/ |
|
87 | 81 |
public TypeDesignationWorkingSetType getWorkingSetType() { |
88 | 82 |
return workingSetType; |
89 | 83 |
} |
90 | 84 |
|
91 |
/** |
|
92 |
* @return the registrationUuid |
|
93 |
*/ |
|
94 | 85 |
public UUID getRegistrationUuid() { |
95 | 86 |
return registrationUuid; |
96 | 87 |
} |
... | ... | |
99 | 90 |
return getEntityUuid(); |
100 | 91 |
} |
101 | 92 |
|
102 |
/** |
|
103 |
* @return the baseEntityRef |
|
104 |
*/ |
|
105 | 93 |
public TypedEntityReference<IdentifiableEntity<?>> getBaseEntityRef() { |
106 | 94 |
return baseEntityRef; |
107 | 95 |
} |
108 | 96 |
|
109 |
/** |
|
110 |
* @return the typifiedNameUuid |
|
111 |
*/ |
|
112 | 97 |
public UUID getTypifiedNameUuid() { |
113 | 98 |
return typifiedNameUuid; |
114 | 99 |
} |
115 | 100 |
|
116 |
|
|
117 | 101 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationEditorView.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 |
import java.util.Optional; |
|
12 |
|
|
11 | 13 |
import com.vaadin.ui.NativeSelect; |
12 | 14 |
|
13 | 15 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
16 |
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase; |
|
14 | 17 |
import eu.etaxonomy.cdm.model.reference.Reference; |
15 | 18 |
import eu.etaxonomy.cdm.vaadin.view.AnnotationsEditor; |
16 | 19 |
import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesComboboxSelect; |
... | ... | |
36 | 39 |
|
37 | 40 |
boolean isShowTypeFlags(); |
38 | 41 |
|
42 |
|
|
43 |
/** |
|
44 |
* possible values: |
|
45 |
* |
|
46 |
* <ul> |
|
47 |
* <li>NULL: undecided, should be treated like <code>false</code>. This can happen in cases when the typified name is missing the nomref</li> |
|
48 |
* <li>false: the typification is published in an nomenclatural act in which no new name or new combination is being published. |
|
49 |
* The available {@link TypeDesignationStatusBase} should be limited to those with |
|
50 |
* <code>{@link TypeDesignationStatusBase#hasDesignationSource() hasDesignationSource} == true</code></li> |
|
51 |
* <li>true: only status with <code>{@link TypeDesignationStatusBase#hasDesignationSource() hasDesignationSource} == true</li> |
|
52 |
* </ul> |
|
53 |
*/ |
|
54 |
public void setInTypedesignationOnlyAct(Optional<Boolean> isInTypedesignationOnlyAct); |
|
55 |
|
|
56 |
/** |
|
57 |
* possible values: |
|
58 |
* |
|
59 |
* <ul> |
|
60 |
* <li>NULL: undecided, should be treated like <code>false</code>. This can happen in cases when the typified name is missing the nomref</li> |
|
61 |
* <li>false: the typification is published in an nomenclatural act in which no new name or new combination is being published. |
|
62 |
* The available {@link TypeDesignationStatusBase} should be limited to those with |
|
63 |
* <code>{@link TypeDesignationStatusBase#hasDesignationSource() hasDesignationSource} == true</code></li> |
|
64 |
* <li>true: only status with <code>{@link TypeDesignationStatusBase#hasDesignationSource() hasDesignationSource} == true</li> |
|
65 |
* </ul> |
|
66 |
*/ |
|
67 |
public Optional<Boolean> isInTypedesignationOnlyAct(); |
|
68 |
|
|
39 | 69 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPopupEditor.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 |
import java.util.Optional; |
|
12 |
|
|
11 | 13 |
import org.springframework.context.annotation.Scope; |
12 | 14 |
|
13 | 15 |
import com.vaadin.spring.annotation.SpringComponent; |
... | ... | |
45 | 47 |
public class NameTypeDesignationPopupEditor extends AbstractCdmPopupEditor<NameTypeDesignation, NameTypeDesignationPresenter> |
46 | 48 |
implements NameTypeDesignationEditorView { |
47 | 49 |
|
50 |
private static final String TYPE_STATUS_OR_FLAG_MUST_BE_SET = "Either \"Type status\" must be set or any of the \"Conserved type\", \"Rejected type\" or \"Not designated\" flags must be set."; |
|
51 |
|
|
52 |
private static final String TYPE_STATUS_MUST_BE_SET = "\"Type status\" must be set."; |
|
53 |
|
|
48 | 54 |
private static final long serialVersionUID = 8233876984579344340L; |
49 | 55 |
|
50 | 56 |
private static final int GRID_COLS = 4; |
... | ... | |
66 | 72 |
|
67 | 73 |
private boolean showTypeFlags = true; |
68 | 74 |
|
75 |
Optional<Boolean> inTypedesignationOnlyAct = Optional.empty(); |
|
69 | 76 |
|
70 | 77 |
private FilterableAnnotationsField annotationsListField; |
71 | 78 |
|
... | ... | |
148 | 155 |
typeStatusSelect.setNullSelectionAllowed(false); |
149 | 156 |
typeStatusSelect.setWidth(100, Unit.PERCENTAGE); |
150 | 157 |
typeStatusSelect.setRequired(true); |
151 |
typeStatusSelect.setRequiredError("Either \"Type status\" must be set or any of the \"Conserved type\", \"Rejected type\" or \"Not designated\" flags must be set.");
|
|
158 |
typeStatusSelect.setRequiredError(TYPE_STATUS_OR_FLAG_MUST_BE_SET);
|
|
152 | 159 |
addField(typeStatusSelect, "typeStatus", 0, row, 1, row); |
153 | 160 |
grid.setComponentAlignment(typeStatusSelect, Alignment.TOP_RIGHT); |
154 | 161 |
typeStatusSelect.addValueChangeListener(e -> { |
... | ... | |
232 | 239 |
boolean hasDesignationSource = typeStatusSelect.getValue() != null && ((NameTypeDesignationStatus)typeStatusSelect.getValue()).hasDesignationSource(); |
233 | 240 |
designationReferenceDetailField.setVisible(hasDesignationSource); |
234 | 241 |
designationReferenceCombobox.setVisible(hasDesignationSource); |
242 |
designationReferenceCombobox.setRequired(hasDesignationSource); |
|
235 | 243 |
// NOTE: For better usability we only hide these fields here, |
236 | 244 |
// NameTypeDesignationPresenter.preSaveBean(NameTypeDesignation bean) will empty them in needed |
237 | 245 |
|
238 |
boolean typeStatusRequired = !(conservedTypeField.getValue().booleanValue() || rejectedTypeField.getValue().booleanValue() || notDesignatedField.getValue().booleanValue()); |
|
239 |
typeStatusSelect.setRequired(typeStatusRequired); |
|
246 |
boolean isInTypedesignationOnlyAct = !isInTypedesignationOnlyAct().isPresent() || isInTypedesignationOnlyAct().get(); |
|
247 |
boolean typeStatusRequired = !(conservedTypeField.getValue().booleanValue() |
|
248 |
|| rejectedTypeField.getValue().booleanValue() |
|
249 |
|| notDesignatedField.getValue().booleanValue()); |
|
250 |
// need to check for isInTypedesignationOnlyAct also, otherwise the reference field will not show up |
|
251 |
// and the type designation might not be associated with the registration |
|
252 |
// TODO discuss with Henning |
|
253 |
typeStatusSelect.setRequired(typeStatusRequired || isInTypedesignationOnlyAct); |
|
254 |
if(typeStatusRequired && isInTypedesignationOnlyAct) { |
|
255 |
designationReferenceCombobox.setRequiredError(TYPE_STATUS_MUST_BE_SET); |
|
256 |
} else { |
|
257 |
designationReferenceCombobox.setRequiredError(TYPE_STATUS_OR_FLAG_MUST_BE_SET); |
|
258 |
} |
|
259 |
|
|
240 | 260 |
|
241 | 261 |
} |
242 | 262 |
|
243 |
/** |
|
244 |
* @return the typeNameField |
|
245 |
*/ |
|
246 | 263 |
@Override |
247 | 264 |
public ToOneRelatedEntityCombobox<TaxonName> getTypeNameField() { |
248 | 265 |
return typeNameField; |
249 | 266 |
} |
250 | 267 |
|
251 |
/** |
|
252 |
* @return the typifiedNamesComboboxSelect |
|
253 |
*/ |
|
254 | 268 |
@Override |
255 | 269 |
public ToManyRelatedEntitiesComboboxSelect<TaxonName> getTypifiedNamesComboboxSelect() { |
256 | 270 |
return typifiedNamesComboboxSelect; |
257 | 271 |
} |
258 | 272 |
|
259 |
/** |
|
260 |
* @return the typeStatusSelect |
|
261 |
*/ |
|
262 | 273 |
@Override |
263 | 274 |
public NativeSelect getTypeStatusSelect() { |
264 | 275 |
return typeStatusSelect; |
265 | 276 |
} |
266 | 277 |
|
267 |
/** |
|
268 |
* @return the citationCombobox |
|
269 |
*/ |
|
270 | 278 |
@Override |
271 | 279 |
public ToOneRelatedEntityCombobox<Reference> getDesignationReferenceCombobox() { |
272 | 280 |
return designationReferenceCombobox; |
273 | 281 |
} |
274 | 282 |
|
275 |
|
|
276 |
/** |
|
277 |
* @return the showTypeFlags |
|
278 |
*/ |
|
279 | 283 |
@Override |
280 | 284 |
public boolean isShowTypeFlags() { |
281 | 285 |
return showTypeFlags; |
282 | 286 |
} |
283 | 287 |
|
284 |
/** |
|
285 |
* @param showTypeFlags the showTypeFlags to set |
|
286 |
*/ |
|
287 | 288 |
@Override |
288 | 289 |
public void setShowTypeFlags(boolean showTypeFlags) { |
289 | 290 |
this.showTypeFlags = showTypeFlags; |
290 | 291 |
} |
291 | 292 |
|
292 |
/** |
|
293 |
* {@inheritDoc} |
|
294 |
*/ |
|
295 | 293 |
@Override |
296 | 294 |
public AnnotationType[] getEditableAnotationTypes() { |
297 | 295 |
return editableAnotationTypes; |
298 | 296 |
} |
299 | 297 |
|
300 |
/** |
|
301 |
* {@inheritDoc} |
|
302 |
*/ |
|
298 |
|
|
303 | 299 |
@Override |
304 | 300 |
public void setEditableAnotationTypes(AnnotationType... editableAnotationTypes) { |
305 | 301 |
this.editableAnotationTypes = editableAnotationTypes; |
306 | 302 |
} |
307 | 303 |
|
308 |
/** |
|
309 |
* {@inheritDoc} |
|
310 |
*/ |
|
304 |
|
|
311 | 305 |
@Override |
312 | 306 |
public FilterableAnnotationsField getAnnotationsField() { |
313 | 307 |
return annotationsListField; |
314 | 308 |
} |
309 |
|
|
310 |
@Override |
|
311 |
public void setInTypedesignationOnlyAct(Optional<Boolean> isInTypedesignationOnlyAct) { |
|
312 |
this.inTypedesignationOnlyAct = isInTypedesignationOnlyAct; |
|
313 |
} |
|
314 |
|
|
315 |
@Override |
|
316 |
public Optional<Boolean> isInTypedesignationOnlyAct() { |
|
317 |
return inTypedesignationOnlyAct; |
|
318 |
} |
|
315 | 319 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import eu.etaxonomy.cdm.api.service.DeleteResult; |
30 | 30 |
import eu.etaxonomy.cdm.api.service.IService; |
31 |
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO; |
|
32 |
import eu.etaxonomy.cdm.api.service.name.TypeDesignationWorkingSet; |
|
33 | 31 |
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService; |
32 |
import eu.etaxonomy.cdm.api.service.registration.RegistrationWorkingSetService; |
|
34 | 33 |
import eu.etaxonomy.cdm.format.reference.ReferenceEllypsisFormatter; |
35 | 34 |
import eu.etaxonomy.cdm.format.reference.ReferenceEllypsisFormatter.LabelType; |
36 | 35 |
import eu.etaxonomy.cdm.model.common.Annotation; |
... | ... | |
39 | 38 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
40 | 39 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus; |
41 | 40 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
42 |
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase; |
|
43 | 41 |
import eu.etaxonomy.cdm.model.permission.CRUD; |
44 | 42 |
import eu.etaxonomy.cdm.model.reference.Reference; |
45 | 43 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
... | ... | |
83 | 81 |
@Autowired |
84 | 82 |
private IRegistrationWorkingSetService registrationWorkingSetService; |
85 | 83 |
|
84 |
|
|
86 | 85 |
HashSet<TaxonName> typifiedNamesAsLoaded; |
87 | 86 |
|
88 | 87 |
private TaxonName typifiedNameInContext; |
... | ... | |
94 | 93 |
*/ |
95 | 94 |
private DescriptionElementSource publishedUnit; |
96 | 95 |
|
97 |
/** |
|
98 |
* possible values: |
|
99 |
* |
|
100 |
* <ul> |
|
101 |
* <li>NULL: undecided, should be treaded like <code>false</code></li> |
|
102 |
* <li>false: the typification is published in an nomenclatural act in which no new name or new combination is being published. |
|
103 |
* The available {@link TypeDesignationStatusBase} should be limited to those with |
|
104 |
* <code>{@link TypeDesignationStatusBase#hasDesignationSource() hasDesignationSource} == true</code></li> |
|
105 |
* <li>true: only status with <code>{@link TypeDesignationStatusBase#hasDesignationSource() hasDesignationSource} == true</li> |
|
106 |
* </ul> |
|
107 |
*/ |
|
108 |
private Optional<Boolean> isInTypedesignationOnlyAct = Optional.empty(); |
|
109 |
|
|
110 |
|
|
111 | 96 |
protected static BeanInstantiator<NameTypeDesignation> defaultBeanInstantiator = new BeanInstantiator<NameTypeDesignation>() { |
112 | 97 |
|
113 | 98 |
@Override |
... | ... | |
126 | 111 |
return defaultBeanInstantiator; |
127 | 112 |
} |
128 | 113 |
|
129 |
/** |
|
130 |
* {@inheritDoc} |
|
131 |
*/ |
|
114 |
|
|
132 | 115 |
@Override |
133 | 116 |
protected NameTypeDesignation loadBeanById(Object identifier) { |
134 | 117 |
NameTypeDesignation bean; |
135 | 118 |
|
136 | 119 |
NameTypeDesignationWorkingsetIds idset = (NameTypeDesignationWorkingsetIds)identifier; |
137 |
RegistrationDTO regDTO = registrationWorkingSetService.loadDtoByUuid(idset.registrationUuid); |
|
138 |
typifiedNameInContext = regDTO.typifiedName(); |
|
139 |
// find the working set |
|
140 |
if(idset.baseEntityRef != null) { |
|
141 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDTO.getTypeDesignationWorkingSet(idset.baseEntityRef); |
|
142 |
if(!typeDesignationWorkingSet.getBaseEntityReference().getType().equals(NameTypeDesignation.class)){ |
|
143 |
throw new RuntimeException("TypeDesignationWorkingsetEditorIdSet references not a NameTypeDesignation"); |
|
144 |
} else { |
|
145 |
// TypeDesignationWorkingSet for NameTyped only contain one item!!! |
|
146 |
UUID nameTypeDesignationUuid = typeDesignationWorkingSet.getTypeDesignations().get(0).getUuid(); |
|
147 |
bean = super.loadBeanById(nameTypeDesignationUuid); |
|
120 |
|
|
121 |
if(idset.isForNewTypeDesignation()) { |
|
122 |
Reference reference = getRepo().getReferenceService().load(idset.getPublishedUnitUuid()); |
|
123 |
try { |
|
124 |
setPublishedUnit(DescriptionElementSource.NewPrimarySourceInstance(reference, null)); |
|
125 |
} catch(Exception e) { |
|
126 |
throw new RuntimeException("Refernce of invalid type passed via NameTypeDesignationWorkingsetIds as publishedUnitUuid ", e); |
|
148 | 127 |
} |
128 |
EntityInitStrategy initstrategy = RegistrationWorkingSetService.NAME_INIT_STRATEGY |
|
129 |
.clone() |
|
130 |
.extend("typeDesignations", RegistrationWorkingSetService.TYPEDESIGNATION_INIT_STRATEGY, true); |
|
131 |
typifiedNameInContext = getRepo().getNameService().load(idset.getTypifiedNameUuid(), initstrategy.getPropertyPaths()); |
|
132 |
bean = super.loadBeanById(null); |
|
149 | 133 |
} else { |
150 |
bean = super.loadBeanById(null); |
|
134 |
bean = super.loadBeanById(idset.getBaseEntityRef().getUuid()); |
|
135 |
// TODO prevent from errors due to inconsistent data, two options: |
|
136 |
// 1. handle error condition here |
|
137 |
// 2. always set typifiedNameUuid in NameTypeDesignationWorkingsetIds |
|
138 |
typifiedNameInContext = bean.getTypifiedNames().iterator().next(); |
|
139 |
try { |
|
140 |
setPublishedUnit(bean.getTypifiedNames().iterator().next().getNomenclaturalSource()); |
|
141 |
} catch (Exception e) { |
|
142 |
// FIXME report error state instead |
|
143 |
logger.error("Error on finding published unit in " + bean, e); |
|
144 |
} |
|
151 | 145 |
} |
152 |
isInTypedesignationOnlyAct = Optional.of(Boolean.valueOf(regDTO.getNameRef() == null)); |
|
153 | 146 |
|
154 |
try { |
|
155 |
setPublishedUnit(bean.getTypifiedNames().iterator().next().getNomenclaturalSource()); |
|
156 |
} catch (Exception e) { |
|
157 |
// FIXME report error state instead |
|
158 |
logger.error("Error on finding published unit in " + bean, e); |
|
147 |
Reference typifiedNameNomRef = typifiedNameInContext.getNomenclaturalReference(); |
|
148 |
while(typifiedNameNomRef.getType().equals(ReferenceType.Section) |
|
149 |
|| typifiedNameNomRef.getInReference() == null) { |
|
150 |
typifiedNameNomRef = typifiedNameNomRef.getInReference(); |
|
159 | 151 |
} |
152 |
getView().setInTypedesignationOnlyAct(Optional.of(typifiedNameNomRef != null && !typifiedNameNomRef.equals(getPublishedUnit().getCitation()))); |
|
153 |
|
|
160 | 154 |
|
161 | 155 |
if (getPublishedUnit() != null) { |
162 | 156 |
// reduce available references to those which are sections of |
... | ... | |
164 | 158 |
referencePagingProvider.getCriteria() |
165 | 159 |
.add(Restrictions.or( |
166 | 160 |
Restrictions.and( |
167 |
Restrictions.eq("inReference", publishedUnit.getCitation()),
|
|
161 |
Restrictions.eq("inReference", getPublishedUnit().getCitation()),
|
|
168 | 162 |
Restrictions.eq("type", ReferenceType.Section)), |
169 | 163 |
Restrictions.idEq(publishedUnit.getCitation().getId())) |
170 | 164 |
); |
... | ... | |
174 | 168 |
@Override |
175 | 169 |
public Reference createNewBean() { |
176 | 170 |
Reference newRef = ReferenceFactory.newSection(); |
177 |
newRef.setInReference(publishedUnit.getCitation());
|
|
171 |
newRef.setInReference(getPublishedUnit().getCitation());
|
|
178 | 172 |
return newRef; |
179 | 173 |
} |
180 | 174 |
}; |
... | ... | |
186 | 180 |
} |
187 | 181 |
|
188 | 182 |
|
189 |
/** |
|
190 |
* {@inheritDoc} |
|
191 |
*/ |
|
192 | 183 |
@Override |
193 | 184 |
protected NameTypeDesignation loadCdmEntity(UUID uuid) { |
194 | 185 |
EntityInitStrategy initStrategy = new EntityInitStrategy(Arrays.asList(new String []{ |
... | ... | |
219 | 210 |
|
220 | 211 |
protected BeanItemContainer<NameTypeDesignationStatus> provideTypeStatusTermItemContainer() { |
221 | 212 |
|
213 |
Optional<Boolean> isInTypedesignationOnlyAct = getView().isInTypedesignationOnlyAct(); |
|
222 | 214 |
BeanItemContainer<NameTypeDesignationStatus> container = cdmBeanItemContainerFactory.buildBeanItemContainer(NameTypeDesignationStatus.class); |
223 | 215 |
List<NameTypeDesignationStatus> filteredItems = container.getItemIds().stream().filter(tsb -> |
224 | 216 |
!isInTypedesignationOnlyAct.isPresent() |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationWorkingsetIds.java | ||
---|---|---|
19 | 19 |
*/ |
20 | 20 |
public class NameTypeDesignationWorkingsetIds extends TypeDesignationWorkingsetIds<NameTypeDesignation> { |
21 | 21 |
|
22 |
public NameTypeDesignationWorkingsetIds(UUID registrationUuid, TypedEntityReference<NameTypeDesignation> baseEntityRef) {
|
|
23 |
super(registrationUuid, baseEntityRef, null);
|
|
22 |
public static NameTypeDesignationWorkingsetIds forNewTypeDesignation(UUID publishedUnitUuid, UUID typifiedNameUuid) {
|
|
23 |
return new NameTypeDesignationWorkingsetIds(publishedUnitUuid, typifiedNameUuid);
|
|
24 | 24 |
} |
25 | 25 |
|
26 |
public NameTypeDesignationWorkingsetIds(UUID registrationUuid, UUID typifiedNameUuid) {
|
|
27 |
super(registrationUuid, null, typifiedNameUuid);
|
|
26 |
public static Object forExistingTypeDesignation(UUID publishedUnitUuid, TypedEntityReference<NameTypeDesignation> baseEntityRef) {
|
|
27 |
return new NameTypeDesignationWorkingsetIds(publishedUnitUuid, baseEntityRef);
|
|
28 | 28 |
} |
29 |
|
|
30 |
|
|
31 |
private NameTypeDesignationWorkingsetIds(UUID publishedUnitUuid, TypedEntityReference<NameTypeDesignation> baseEntityRef) { |
|
32 |
super(null, baseEntityRef, null); |
|
33 |
this.publishedUnitUuid = publishedUnitUuid; |
|
34 |
} |
|
35 |
|
|
36 |
private NameTypeDesignationWorkingsetIds(UUID publishedUnitUuid, UUID typifiedNameUuid) { |
|
37 |
super(null, null, typifiedNameUuid); |
|
38 |
this.publishedUnitUuid = publishedUnitUuid; |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* @return |
|
43 |
*/ |
|
44 |
public boolean isForNewTypeDesignation() { |
|
45 |
return getBaseEntityRef() == null; |
|
46 |
} |
|
47 |
|
|
29 | 48 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TypeDesignationWorkingsetIds.java | ||
---|---|---|
18 | 18 |
protected UUID registrationUuid; |
19 | 19 |
protected TypedEntityReference<BASE_T> baseEntityRef; |
20 | 20 |
protected UUID typifiedNameUuid; |
21 |
/** |
|
22 |
* The UUID of the article, book, book section in which the type designation is being published. |
|
23 |
* Never a section. This information is only relevant for type designation to be initially created. |
|
24 |
*/ |
|
25 |
protected UUID publishedUnitUuid; |
|
26 |
|
|
21 | 27 |
|
22 | 28 |
public TypeDesignationWorkingsetIds(UUID registrationUuid, TypedEntityReference<BASE_T> baseEntityRef, UUID typifiedNameUuid) { |
23 | 29 |
this.registrationUuid = registrationUuid; |
... | ... | |
37 | 43 |
return baseEntityRef; |
38 | 44 |
} |
39 | 45 |
|
46 |
public UUID getPublishedUnitUuid() { |
|
47 |
return publishedUnitUuid; |
|
48 |
} |
|
49 |
|
|
50 |
|
|
40 | 51 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
147 | 147 |
private List<Registration> newNameBlockingRegistrations = new ArrayList<>(); |
148 | 148 |
|
149 | 149 |
/** |
150 |
* TODO is this still needed? The regitration UUID should be accessible in the popup editor context, |
|
150 |
* TODO is this still needed? The registration UUID should be accessible in the popup editor context,
|
|
151 | 151 |
* see findRegistrationInContext() |
152 | 152 |
*/ |
153 | 153 |
private Map<NameTypeDesignationPopupEditor, UUID> nameTypeDesignationPopupEditorRegistrationUUIDMap = new HashMap<>(); |
... | ... | |
554 | 554 |
return; |
555 | 555 |
} |
556 | 556 |
|
557 |
RegistrationDTO registrationDTO = workingset.getRegistrationDTO(event.getRegistrationUuid()).get(); |
|
558 |
|
|
557 | 559 |
if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET ){ |
558 | 560 |
SpecimenTypeDesignationWorkingsetPopupEditor popup = openPopupEditor(SpecimenTypeDesignationWorkingsetPopupEditor.class, event); |
559 | 561 |
popup.setParentEditorActionContext(event.getContext(), event.getTarget()); |
... | ... | |
569 | 571 |
NameTypeDesignationPopupEditor popup = openPopupEditor(NameTypeDesignationPopupEditor.class, event); |
570 | 572 |
popup.setParentEditorActionContext(event.getContext(), event.getTarget()); |
571 | 573 |
popup.withDeleteButton(true); |
572 |
popup.loadInEditor(new NameTypeDesignationWorkingsetIds(
|
|
573 |
event.getRegistrationUuid(),
|
|
574 |
popup.loadInEditor(NameTypeDesignationWorkingsetIds.forExistingTypeDesignation(
|
|
575 |
registrationDTO.getCitationUuid(),
|
|
574 | 576 |
event.getBaseEntityRef().castTo(NameTypeDesignation.class)) |
575 | 577 |
); |
576 | 578 |
popup.getTypifiedNamesComboboxSelect().setEnabled(false); |
... | ... | |
589 | 591 |
return; |
590 | 592 |
} |
591 | 593 |
|
594 |
RegistrationDTO registrationDTO = workingset.getRegistrationDTO(event.getRegistrationUuid()).get(); |
|
595 |
|
|
592 | 596 |
if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET){ |
593 | 597 |
SpecimenTypeDesignationWorkingsetPopupEditor popup = openPopupEditor(SpecimenTypeDesignationWorkingsetPopupEditor.class, event); |
594 | 598 |
popup.setParentEditorActionContext(event.getContext(), event.getTarget()); |
595 |
UUID typifiedNameUuid; |
|
596 |
|
|
597 |
RegistrationDTO registrationDTO = workingset.getRegistrationDTO(event.getRegistrationUuid()).get(); |
|
598 | 599 |
TypedEntityReference<TaxonName> typifiedNameRef; |
599 | 600 |
if(registrationDTO.getTypifiedNameRef() != null){ |
600 | 601 |
// case for registrations without name, in which case the typifiedName is only defined via the typedesignations |
... | ... | |
637 | 638 |
} |
638 | 639 |
}); |
639 | 640 |
popup.withDeleteButton(false); |
640 |
popup.loadInEditor(new NameTypeDesignationWorkingsetIds(
|
|
641 |
event.getRegistrationUuid(),
|
|
641 |
popup.loadInEditor(NameTypeDesignationWorkingsetIds.forNewTypeDesignation(
|
|
642 |
registrationDTO.getCitationUuid(),
|
|
642 | 643 |
event.getTypifiedNameUuid() |
643 | 644 |
) |
644 | 645 |
); |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractEditorPresenter.java | ||
---|---|---|
44 | 44 |
|
45 | 45 |
/** |
46 | 46 |
* Load the bean to be edited in the editor freshly from the persistent storage. |
47 |
* Ore create an new empty instance in case the supplied <code>identifier</code> is <code>null</code>.
|
|
47 |
* Or create an new empty instance in case the supplied <code>identifier</code> is <code>null</code>. |
|
48 | 48 |
* |
49 | 49 |
* @param identifier |
50 | 50 |
* @return |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java | ||
---|---|---|
944 | 944 |
return context; |
945 | 945 |
} |
946 | 946 |
|
947 |
/** |
|
948 |
* Attempts to find an item in the context of editor actions for this editor, |
|
949 |
* having a parentView matching the <code>viewType</code> by {@link Class#isAssignableFrom(Class)}. |
|
950 |
*/ |
|
951 |
@SuppressWarnings("unchecked") |
|
952 |
public <VIEW extends AbstractView> Optional<VIEW> findViewInEditorActionContext(Class<VIEW> viewType) { |
|
953 |
Stack<EditorActionContext> ctxt = getEditorActionContext(); |
|
954 |
for(int i = ctxt.size(); i > 0; --i) { |
|
955 |
if(viewType.isAssignableFrom(ctxt.get(i).getParentView().getClass())){ |
|
956 |
return Optional.of((VIEW) ctxt.get(i).getParentView()); |
|
957 |
} |
|
958 |
} |
|
959 |
return Optional.empty(); |
|
960 |
} |
|
961 |
|
|
947 | 962 |
/** |
948 | 963 |
* Set the context of editor actions parent to this editor |
949 | 964 |
* |
src/main/java/eu/etaxonomy/vaadin/mvp/CdmEditorPresenterBase.java | ||
---|---|---|
113 | 113 |
guaranteePerEntityCRUDPermissions(cdmEntitiy); |
114 | 114 |
} |
115 | 115 |
} |
116 |
DTO dto = initializeCache(cdmEntitiy); |
|
117 |
|
|
118 |
return dto; |
|
119 |
} |
|
120 |
|
|
121 |
|
|
122 |
/** |
|
123 |
* @param cdmEntitiy the CDM entity to initialize the cache with. |
|
124 |
*/ |
|
125 |
protected final DTO initializeCache(CDM cdmEntitiy) { |
|
116 | 126 |
cache = new CdmTransientEntityAndUuidCacher(this); |
117 | 127 |
// need to use load but put see #7214 |
118 | 128 |
cdmEntitiy = cache.load(cdmEntitiy); |
119 | 129 |
addRootEntity(cdmEntitiy); |
120 | 130 |
|
121 | 131 |
DTO dto = createDTODecorator(cdmEntitiy); |
122 |
|
|
123 | 132 |
return dto; |
124 | 133 |
} |
125 | 134 |
|
Also available in: Unified diff
ref #9475 fixing problems caused by implementation for #9324 - changing NameTypeDesignationWorkingsetIds strategy again