Revision f1573a7b
Added by Andreas Kohlbecker about 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.registration; |
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 |
import java.util.Arrays; |
|
12 | 13 |
import java.util.EnumSet; |
13 | 14 |
import java.util.List; |
15 |
import java.util.UUID; |
|
14 | 16 |
|
15 | 17 |
import org.springframework.beans.factory.annotation.Autowired; |
16 | 18 |
import org.springframework.context.event.EventListener; |
... | ... | |
54 | 56 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
55 | 57 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
56 | 58 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSetType; |
59 |
import eu.etaxonomy.cdm.vaadin.view.name.NameTypeDesignationPopupEditor; |
|
57 | 60 |
import eu.etaxonomy.cdm.vaadin.view.name.SpecimenTypeDesignationWorkingsetPopupEditor; |
58 | 61 |
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor; |
59 | 62 |
import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorMode; |
... | ... | |
93 | 96 |
|
94 | 97 |
private RegistrationDTO newRegistrationDTOWithExistingName; |
95 | 98 |
|
99 |
private RegistrationDTO newNameTypeDesignationTarget; |
|
100 |
|
|
96 | 101 |
|
97 | 102 |
/** |
98 | 103 |
* |
... | ... | |
381 | 386 |
popup.withDeleteButton(true); |
382 | 387 |
popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationId(), event.getEntityId())); |
383 | 388 |
if(event.getSourceComponent() != null){ |
389 |
// TODO document this !!!!!!!!!!! |
|
384 | 390 |
popup.setReadOnly(event.getSourceComponent().isReadOnly()); |
385 | 391 |
} |
386 | 392 |
} else { |
387 |
// TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET |
|
388 |
// FIXME implement NameTypeDesignationWorkingsetPopupEditor |
|
393 |
NameTypeDesignationPopupEditor popup = getNavigationManager().showInPopup(NameTypeDesignationPopupEditor.class); |
|
394 |
popup.withDeleteButton(true); |
|
395 |
popup.loadInEditor(event.getEntityId()); |
|
396 |
if(event.getSourceComponent() != null){ |
|
397 |
popup.setReadOnly(event.getSourceComponent().isReadOnly()); |
|
398 |
} |
|
399 |
newNameTypeDesignationTarget = workingset.getRegistrationDTO(event.getRegistrationId()).get(); |
|
389 | 400 |
} |
390 | 401 |
} |
391 | 402 |
|
... | ... | |
418 | 429 |
popup.loadInEditor(identifierSet); |
419 | 430 |
popup.withDeleteButton(true); |
420 | 431 |
} else { |
421 |
// TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET |
|
422 |
// FIXME implement NameTypeDesignationWorkingsetPopupEditor |
|
432 |
NameTypeDesignationPopupEditor popup = getNavigationManager().showInPopup(NameTypeDesignationPopupEditor.class); |
|
433 |
popup.withDeleteButton(true); |
|
434 |
popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
|
435 |
popup.loadInEditor(null); |
|
436 |
if(event.getSourceComponent() != null){ |
|
437 |
popup.setReadOnly(event.getSourceComponent().isReadOnly()); |
|
438 |
} |
|
439 |
newNameTypeDesignationTarget = workingset.getRegistrationDTO(event.getRegistrationId()).get(); |
|
423 | 440 |
} |
424 | 441 |
} |
425 | 442 |
|
... | ... | |
449 | 466 |
} |
450 | 467 |
// set newRegistrationDTOWithExistingName NULL in any case |
451 | 468 |
newRegistrationDTOWithExistingName = null; |
469 |
} else if(event.getPopup() instanceof NameTypeDesignationPopupEditor){ |
|
470 |
if(event.getReason().equals(Reason.SAVE)){ |
|
471 |
UUID uuid = ((NameTypeDesignationPopupEditor)event.getPopup()).getBean().getUuid(); |
|
472 |
TypeDesignationBase<?> nameTypeDesignation = getRepo().getNameService().loadTypeDesignation(uuid, null); |
|
473 |
Registration registration = getRepo().getRegistrationService().load(newNameTypeDesignationTarget.getId(), Arrays.asList("$", "typeDesignations")); |
|
474 |
registration.getTypeDesignations().add(nameTypeDesignation); |
|
475 |
getRepo().getRegistrationService().saveOrUpdate(registration); |
|
476 |
newNameTypeDesignationTarget = null; |
|
477 |
refreshView(true); |
|
478 |
} else if(event.getReason().equals(Reason.CANCEL)){ |
|
479 |
// noting to do |
|
480 |
} |
|
452 | 481 |
} |
482 |
// ignore other editors |
|
453 | 483 |
} |
454 | 484 |
|
455 | 485 |
|
... | ... | |
498 | 528 |
} else |
499 | 529 |
if(TypeDesignationBase.class.isAssignableFrom(event.getEntityType())){ |
500 | 530 |
if(workingset.getRegistrationDTOs().stream().anyMatch( |
501 |
reg -> reg.getTypeDesignations().stream().anyMatch( |
|
531 |
reg -> reg.getTypeDesignations() != null && reg.getTypeDesignations().stream().anyMatch(
|
|
502 | 532 |
td -> td.getId() == event.getEntityId() |
503 | 533 |
) |
504 | 534 |
) |
Also available in: Unified diff
ref #6740 NameTypeDesignationEditor implemented