Revision 3b17b230
Added by Andreas Kohlbecker about 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemEditButtonGroup.java | ||
---|---|---|
12 | 12 |
import java.util.EnumSet; |
13 | 13 |
import java.util.List; |
14 | 14 |
|
15 |
import org.apache.log4j.Logger; |
|
16 |
|
|
15 | 17 |
import com.vaadin.server.ExternalResource; |
16 | 18 |
import com.vaadin.server.FontAwesome; |
17 | 19 |
import com.vaadin.ui.Button; |
... | ... | |
39 | 41 |
*/ |
40 | 42 |
public class RegistrationItemEditButtonGroup extends CompositeStyledComponent { |
41 | 43 |
|
44 |
private final static Logger logger = Logger.getLogger(RegistrationItemEditButtonGroup.class); |
|
45 |
|
|
42 | 46 |
|
43 |
/** |
|
44 |
* |
|
45 |
*/ |
|
46 | 47 |
private static final String DEFAULT_BUTTON_STYLES = ""; |
47 | 48 |
|
48 | 49 |
private static final long serialVersionUID = -5059163772392864050L; |
... | ... | |
92 | 93 |
if(regDto.getOrderdTypeDesignationWorkingSets() != null){ |
93 | 94 |
for(TypedEntityReference<TypeDesignationBase<?>> baseEntityRef : regDto.getOrderdTypeDesignationWorkingSets().keySet()) { |
94 | 95 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDto.getOrderdTypeDesignationWorkingSets().get(baseEntityRef); |
96 |
logger.debug("WorkingSet:" + typeDesignationWorkingSet.getWorkingsetType() + "#" + typeDesignationWorkingSet.getWorkingSetId()); |
|
95 | 97 |
String buttonLabel = SpecimenOrObservationBase.class.isAssignableFrom(baseEntityRef.getType()) ? "Type": "NameType"; |
96 | 98 |
Button tdButton = new Button(buttonLabel + ":"); |
97 | 99 |
tdButton.setDescription("Edit the type designation working set"); |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java | ||
---|---|---|
12 | 12 |
import java.util.HashSet; |
13 | 13 |
import java.util.List; |
14 | 14 |
|
15 |
import org.springframework.beans.factory.annotation.Autowired; |
|
16 |
|
|
15 | 17 |
import eu.etaxonomy.cdm.api.service.IService; |
16 | 18 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
17 | 19 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus; |
18 | 20 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
19 | 21 |
import eu.etaxonomy.cdm.model.reference.Reference; |
20 | 22 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
23 |
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService; |
|
21 | 24 |
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory; |
22 | 25 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
23 | 26 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader; |
24 | 27 |
import eu.etaxonomy.cdm.vaadin.security.UserHelper; |
25 | 28 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
29 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSet; |
|
30 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
|
26 | 31 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
27 | 32 |
|
28 | 33 |
/** |
... | ... | |
33 | 38 |
public class NameTypeDesignationPresenter |
34 | 39 |
extends AbstractCdmEditorPresenter<NameTypeDesignation, NameTypeDesignationEditorView> { |
35 | 40 |
|
41 |
@Autowired |
|
42 |
private IRegistrationWorkingSetService registrationWorkingSetService; |
|
43 |
|
|
36 | 44 |
HashSet<TaxonName> typifiedNamesAsLoaded; |
37 | 45 |
|
46 |
|
|
47 |
/** |
|
48 |
* {@inheritDoc} |
|
49 |
*/ |
|
50 |
@Override |
|
51 |
protected NameTypeDesignation loadBeanById(Object identifier) { |
|
52 |
if(identifier instanceof Integer || identifier == null){ |
|
53 |
return super.loadBeanById(identifier); |
|
54 |
} else { |
|
55 |
TypeDesignationWorkingsetEditorIdSet idset = (TypeDesignationWorkingsetEditorIdSet)identifier; |
|
56 |
RegistrationDTO regDTO = registrationWorkingSetService.loadDtoById(idset.registrationId); |
|
57 |
// find the working set |
|
58 |
TypeDesignationWorkingSet typeDesignationWorkingSet = regDTO.getTypeDesignationWorkingSet(idset.workingsetId); |
|
59 |
int nameTypeDesignationId = typeDesignationWorkingSet.getBaseEntityReference().getId(); |
|
60 |
// NameTypeDesignation bameTypeDesignation = regDTO.getNameTypeDesignation(typeDesignationWorkingSet.getBaseEntityReference()); |
|
61 |
if(!typeDesignationWorkingSet.getBaseEntityReference().getType().equals(NameTypeDesignation.class)){ |
|
62 |
throw new RuntimeException("TypeDesignationWorkingsetEditorIdSet references not a NameTypeDesignation"); |
|
63 |
} |
|
64 |
return super.loadBeanById(nameTypeDesignationId); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
|
|
38 | 69 |
/** |
39 | 70 |
* {@inheritDoc} |
40 | 71 |
*/ |
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; |
|
17 | 16 |
import java.util.Set; |
18 | 17 |
import java.util.UUID; |
19 | 18 |
|
... | ... | |
23 | 22 |
|
24 | 23 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
25 | 24 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
25 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
|
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; |
... | ... | |
299 | 299 |
return dto; |
300 | 300 |
} |
301 | 301 |
|
302 |
public NameTypeDesignation getNameTypeDesignation(TypedEntityReference baseEntityReference) { |
|
303 |
Set<TypeDesignationBase> typeDesignations = getTypeDesignationsInWorkingSet(baseEntityReference); |
|
304 |
if(typeDesignations.size() == 1){ |
|
305 |
TypeDesignationBase item = typeDesignations.iterator().next(); |
|
306 |
return (NameTypeDesignation)item ; |
|
307 |
} |
|
308 |
if(typeDesignations.size() == 0){ |
|
309 |
return null; |
|
310 |
} |
|
311 |
if(typeDesignations.size() > 1){ |
|
312 |
throw new RuntimeException("Workingsets of NameTypeDesignations must contain exactly one item."); |
|
313 |
} |
|
314 |
return null; |
|
315 |
} |
|
316 |
|
|
302 | 317 |
/** |
303 | 318 |
* |
304 | 319 |
* @param workingSetId |
305 | 320 |
* @return the TypeDesignationWorkingSet in this DTO with the matching workingSetId or NULL |
306 | 321 |
*/ |
307 | 322 |
public TypeDesignationWorkingSet getTypeDesignationWorkingSet(int workingSetId) { |
308 |
Optional<TypeDesignationWorkingSet> workingSetOptional = getOrderdTypeDesignationWorkingSets().values().stream().filter(workingSet -> workingSet.getWorkingSetId() == workingSetId).findFirst(); |
|
309 |
if(workingSetOptional.isPresent()){ |
|
310 |
return workingSetOptional.get(); |
|
323 |
for(TypeDesignationWorkingSet workingSet : getOrderdTypeDesignationWorkingSets().values()){ |
|
324 |
logger.debug("WorkingSet:" + workingSet.getWorkingsetType() + "#" + workingSet.getWorkingSetId()); |
|
325 |
if(workingSet.getWorkingSetId() == workingSetId){ |
|
326 |
return workingSet; |
|
327 |
} |
|
311 | 328 |
} |
312 | 329 |
return null; |
313 | 330 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
82 | 82 |
private static final long serialVersionUID = 1L; |
83 | 83 |
|
84 | 84 |
@Autowired |
85 |
private IRegistrationWorkingSetService workingSetService;
|
|
85 |
private IRegistrationWorkingSetService regWorkingSetService;
|
|
86 | 86 |
|
87 | 87 |
@Autowired |
88 | 88 |
private RegistrationIdentifierMinter minter; |
89 | 89 |
|
90 | 90 |
/** |
91 |
* @return the workingSetService
|
|
91 |
* @return the regWorkingSetService
|
|
92 | 92 |
*/ |
93 | 93 |
public IRegistrationWorkingSetService getWorkingSetService() { |
94 |
return workingSetService;
|
|
94 |
return regWorkingSetService;
|
|
95 | 95 |
} |
96 | 96 |
|
97 | 97 |
private RegistrationWorkingSet workingset; |
... | ... | |
396 | 396 |
} else { |
397 | 397 |
NameTypeDesignationPopupEditor popup = getNavigationManager().showInPopup(NameTypeDesignationPopupEditor.class); |
398 | 398 |
popup.withDeleteButton(true); |
399 |
popup.loadInEditor(event.getEntityId());
|
|
399 |
popup.loadInEditor(new TypeDesignationWorkingsetEditorIdSet(event.getRegistrationId(), event.getEntityId()));
|
|
400 | 400 |
|
401 | 401 |
popup.getCitationCombobox().setEnabled(false); |
402 | 402 |
popup.getTypifiedNamesComboboxSelect().setEnabled(false); |
... | ... | |
530 | 530 |
|
531 | 531 |
@EventListener(classes=ShowDetailsEvent.class, condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO)") |
532 | 532 |
public void onShowRegistrationMessages(ShowDetailsEvent<?,?> event) { // WARNING don't use more specific generic type arguments |
533 |
RegistrationDTO regDto = workingSetService.loadDtoById((Integer)event.getIdentifier());
|
|
533 |
RegistrationDTO regDto = regWorkingSetService.loadDtoById((Integer)event.getIdentifier());
|
|
534 | 534 |
if(event.getProperty().equals("messages")){ |
535 | 535 |
if(getView() != null){ |
536 | 536 |
getView().openDetailsPopup("Messages", regDto.getMessages()); |
src/main/java/eu/etaxonomy/vaadin/ui/view/PopupEditorFactory.java | ||
---|---|---|
28 | 28 |
import com.vaadin.spring.annotation.UIScope; |
29 | 29 |
|
30 | 30 |
import eu.etaxonomy.cdm.api.application.CdmRepository; |
31 |
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService; |
|
31 | 32 |
import eu.etaxonomy.cdm.service.ISpecimenTypeDesignationWorkingSetService; |
33 |
import eu.etaxonomy.cdm.vaadin.view.name.NameTypeDesignationPresenter; |
|
32 | 34 |
import eu.etaxonomy.cdm.vaadin.view.name.SpecimenTypeDesignationWorkingsetEditorPresenter; |
33 | 35 |
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter; |
34 | 36 |
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor; |
... | ... | |
67 | 69 |
@Autowired |
68 | 70 |
private ISpecimenTypeDesignationWorkingSetService specimenTypeDesignationWorkingSetService; |
69 | 71 |
|
72 |
@Autowired |
|
73 |
private IRegistrationWorkingSetService registrationWorkingSetService; |
|
74 |
|
|
70 | 75 |
@Autowired |
71 | 76 |
@Lazy |
72 | 77 |
private NavigationManager navigationManager; |
... | ... | |
79 | 84 |
private Field specimenTypeDesignationWorkingSetServiceField; |
80 | 85 |
private Method viewInjectPresenterMethod; |
81 | 86 |
|
87 |
private Field Field; |
|
88 |
|
|
82 | 89 |
private Method viewInitMethod; |
83 | 90 |
|
84 | 91 |
public PopupEditorFactory(){ |
... | ... | |
113 | 120 |
specimenTypeDesignationWorkingSetServiceField = SpecimenTypeDesignationWorkingsetEditorPresenter.class.getDeclaredField("specimenTypeDesignationWorkingSetService"); |
114 | 121 |
specimenTypeDesignationWorkingSetServiceField.setAccessible(true); |
115 | 122 |
|
123 |
Field = NameTypeDesignationPresenter.class.getDeclaredField("registrationWorkingSetService"); |
|
124 |
Field.setAccessible(true); |
|
125 |
|
|
116 | 126 |
} catch (NoSuchFieldException | SecurityException | NoSuchMethodException e) { |
117 | 127 |
throw new RuntimeException("Severe error during initialization. Please check the classes AbstractPresenter, AbstractEditorPresenter, AbstractView for modificactions.", e); |
118 | 128 |
} |
... | ... | |
167 | 177 |
if(SpecimenTypeDesignationWorkingsetEditorPresenter.class.equals(presenterClass)){ |
168 | 178 |
specimenTypeDesignationWorkingSetServiceField.set(presenter, specimenTypeDesignationWorkingSetService); |
169 | 179 |
} |
180 |
if(NameTypeDesignationPresenter.class.equals(presenterClass)){ |
|
181 |
Field.set(presenter, registrationWorkingSetService); |
|
182 |
} |
|
170 | 183 |
} |
171 | 184 |
|
172 | 185 |
/** |
Also available in: Unified diff
ref #6740 service methods to load NameTypeDesignations for Registrations