Revision 2108e10f
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/event/TypeDesignationWorkingsetEditorAction.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
private int registrationId; |
32 | 32 |
|
33 |
private int typifiedNameId; |
|
34 |
|
|
33 | 35 |
private TypedEntityReference<IdentifiableEntity<?>> baseEntityRef; |
34 | 36 |
|
35 | 37 |
/** |
... | ... | |
42 | 44 |
* @param sourceView |
43 | 45 |
*/ |
44 | 46 |
public TypeDesignationWorkingsetEditorAction(EditorActionType action, TypedEntityReference<IdentifiableEntity<?>> baseEntityRef, |
45 |
TypeDesignationWorkingSetType workingSetType, int registrationId, Component source, AbstractView sourceView, Stack<EditorActionContext> context) { |
|
47 |
TypeDesignationWorkingSetType workingSetType, |
|
48 |
int registrationId, int typifiedNameId, |
|
49 |
Component source, AbstractView sourceView, Stack<EditorActionContext> context) { |
|
46 | 50 |
super(action, null, source, sourceView); |
47 | 51 |
this.baseEntityRef = baseEntityRef; |
48 | 52 |
this.registrationId = registrationId; |
53 |
this.typifiedNameId = typifiedNameId; |
|
49 | 54 |
this.workingSetType = workingSetType; |
50 | 55 |
this.context = context; |
51 | 56 |
|
... | ... | |
59 | 64 |
* @param source |
60 | 65 |
* @param sourceView |
61 | 66 |
*/ |
62 |
public TypeDesignationWorkingsetEditorAction(EditorActionType action, TypeDesignationWorkingSetType workingSetType, int registrationId, |
|
67 |
public TypeDesignationWorkingsetEditorAction(EditorActionType action, TypeDesignationWorkingSetType workingSetType, |
|
68 |
int registrationId, int typifiedNameId, |
|
63 | 69 |
Component source, AbstractView sourceView) { |
64 | 70 |
super(action, null, source, sourceView); |
65 | 71 |
this.workingSetType = workingSetType; |
66 | 72 |
this.registrationId = registrationId; |
73 |
this.typifiedNameId = typifiedNameId; |
|
67 | 74 |
this.context = new Stack<>(); |
68 | 75 |
this.context.push(new EditorActionContext(new TypedEntityReference<Registration>(Registration.class, registrationId), sourceView)); |
69 | 76 |
} |
... | ... | |
96 | 103 |
return baseEntityRef; |
97 | 104 |
} |
98 | 105 |
|
106 |
/** |
|
107 |
* @return the typifiedNameId |
|
108 |
*/ |
|
109 |
public int getTypifiedNameId() { |
|
110 |
return typifiedNameId; |
|
111 |
} |
|
112 |
|
|
99 | 113 |
|
100 | 114 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java | ||
---|---|---|
204 | 204 |
|
205 | 205 |
// handle adds |
206 | 206 |
for(TaxonName name : typifiedNames){ |
207 |
if(name == null){ |
|
208 |
throw new NullPointerException("typifiedName must not be null"); |
|
209 |
} |
|
207 | 210 |
if(!name.getTypeDesignations().contains(bean)){ |
208 | 211 |
name.addTypeDesignation(bean, false); |
209 | 212 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
515 | 515 |
popup.withDeleteButton(true); |
516 | 516 |
popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
517 | 517 |
newNameTypeDesignationTarget = workingset.getRegistrationDTO(event.getRegistrationId()).get(); |
518 |
|
|
519 | 518 |
popup.setBeanInstantiator(new BeanInstantiator<NameTypeDesignation>() { |
520 | 519 |
|
521 | 520 |
@Override |
522 | 521 |
public NameTypeDesignation createNewBean() { |
523 |
TaxonName typifiedName = newNameTypeDesignationTarget.getTypifiedName(); |
|
524 |
if(typifiedName == null){ |
|
525 |
// this will be the first type designation, so the nomenclatural act must contain a name |
|
526 |
typifiedName = newNameTypeDesignationTarget.registration().getName(); |
|
527 |
} |
|
522 |
|
|
523 |
TaxonName typifiedName = getRepo().getNameService().load(event.getTypifiedNameId(), Arrays.asList(new String[]{"typeDesignations", "homotypicalGroup"})); |
|
528 | 524 |
NameTypeDesignation nameTypeDesignation = NameTypeDesignation.NewInstance(); |
529 | 525 |
nameTypeDesignation.setCitation(newNameTypeDesignationTarget.getCitation()); |
530 | 526 |
nameTypeDesignation.getTypifiedNames().add(typifiedName); |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java | ||
---|---|---|
61 | 61 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction; |
62 | 62 |
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction; |
63 | 63 |
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction; |
64 |
import eu.etaxonomy.cdm.vaadin.model.EntityReference; |
|
64 | 65 |
import eu.etaxonomy.cdm.vaadin.model.TypedEntityReference; |
65 | 66 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet; |
66 | 67 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
... | ... | |
127 | 128 |
*/ |
128 | 129 |
private Map<Integer, RegistrationDetailsItem> registrationItemMap = new HashMap<>(); |
129 | 130 |
|
131 |
/** |
|
132 |
* uses the registrationId as key |
|
133 |
*/ |
|
134 |
private Map<Integer, EntityReference> typifiedNamesMap = new HashMap<>(); |
|
135 |
|
|
130 | 136 |
public RegistrationWorksetViewBean() { |
131 | 137 |
super(); |
132 | 138 |
} |
... | ... | |
266 | 272 |
|
267 | 273 |
protected int putRegistrationListComponent(int row, RegistrationDTO dto) { |
268 | 274 |
|
275 |
typifiedNamesMap.put(dto.getId(), dto.getTypifiedNameRef()); |
|
276 |
|
|
269 | 277 |
RegistrationItemNameAndTypeButtons regItemButtonGroup = new RegistrationItemNameAndTypeButtons(dto); |
270 | 278 |
Integer registrationEntityID = dto.getId(); |
271 | 279 |
|
... | ... | |
301 | 309 |
for(TypeDesignationWorkingSetButton workingsetButton : regItemButtonGroup.getTypeDesignationButtons()){ |
302 | 310 |
workingsetButton.getButton().addClickListener(e -> { |
303 | 311 |
TypedEntityReference baseEntityRef = workingsetButton.getBaseEntity(); |
312 |
EntityReference typifiedNameRef = typifiedNamesMap.get(registrationEntityID); |
|
304 | 313 |
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType(); |
305 | 314 |
getViewEventBus().publish(this, new TypeDesignationWorkingsetEditorAction( |
306 | 315 |
EditorActionType.EDIT, |
307 | 316 |
baseEntityRef, |
308 | 317 |
workingsetType, |
309 | 318 |
registrationEntityID, |
319 |
typifiedNameRef.getId(), |
|
310 | 320 |
e.getButton(), |
311 | 321 |
this, |
312 | 322 |
context |
... | ... | |
438 | 448 |
*/ |
439 | 449 |
protected void addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType newWorkingsetType, Integer registrationEntityId, Window typeDesignationTypeCooser) { |
440 | 450 |
UI.getCurrent().removeWindow(typeDesignationTypeCooser); |
451 |
EntityReference typifiedNameRef = typifiedNamesMap.get(registrationEntityId); |
|
441 | 452 |
getViewEventBus().publish(this, new TypeDesignationWorkingsetEditorAction( |
442 | 453 |
EditorActionType.ADD, |
443 | 454 |
newWorkingsetType, |
444 | 455 |
registrationEntityId, |
456 |
typifiedNameRef.getId(), |
|
445 | 457 |
null, |
446 | 458 |
this |
447 | 459 |
)); |
Also available in: Unified diff
fix #7337 adding typifiedName reference to TypeDesignationWorkingsetEditorAction