Revision 51d6bc3c
Added by Andreas Kohlbecker about 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 | 11 |
import java.util.Arrays; |
12 |
import java.util.HashSet; |
|
12 | 13 |
import java.util.List; |
13 | 14 |
|
14 | 15 |
import eu.etaxonomy.cdm.api.service.IService; |
... | ... | |
21 | 22 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
22 | 23 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader; |
23 | 24 |
import eu.etaxonomy.cdm.vaadin.security.UserHelper; |
25 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
|
24 | 26 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
25 | 27 |
|
26 | 28 |
/** |
... | ... | |
31 | 33 |
public class NameTypeDesignationPresenter |
32 | 34 |
extends AbstractCdmEditorPresenter<NameTypeDesignation, NameTypeDesignationEditorView> { |
33 | 35 |
|
36 |
HashSet<TaxonName> typifiedNamesAsLoaded; |
|
37 |
|
|
34 | 38 |
/** |
35 | 39 |
* {@inheritDoc} |
36 | 40 |
*/ |
... | ... | |
54 | 58 |
typeDesignation = NameTypeDesignation.NewInstance(); |
55 | 59 |
} |
56 | 60 |
} |
61 |
|
|
62 |
typifiedNamesAsLoaded = new HashSet<>(typeDesignation.getTypifiedNames()); |
|
63 |
|
|
57 | 64 |
return typeDesignation; |
58 | 65 |
} |
59 | 66 |
|
... | ... | |
69 | 76 |
CdmBeanItemContainerFactory selectFactory = new CdmBeanItemContainerFactory(getRepo()); |
70 | 77 |
getView().getTypeStatusSelect().setContainerDataSource(selectFactory.buildBeanItemContainer(NameTypeDesignationStatus.class)); |
71 | 78 |
|
79 |
getView().getCitationCombobox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Reference>()); |
|
72 | 80 |
CdmFilterablePagingProvider<Reference,Reference> referencePagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(getRepo().getReferenceService()); |
73 | 81 |
getView().getCitationCombobox().loadFrom(referencePagingProvider, referencePagingProvider, referencePagingProvider.getPageSize()); |
74 | 82 |
getView().getCitationCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getCitationCombobox())); |
... | ... | |
112 | 120 |
return null; |
113 | 121 |
} |
114 | 122 |
|
123 |
|
|
124 |
/** |
|
125 |
* {@inheritDoc} |
|
126 |
*/ |
|
127 |
@Override |
|
128 |
protected NameTypeDesignation handleTransientProperties(NameTypeDesignation bean) { |
|
129 |
|
|
130 |
// the typifiedNames can only be set on the name side, so we need to |
|
131 |
// handle changes explicitly here |
|
132 |
HashSet<TaxonName> typifiedNames = new HashSet<>(bean.getTypifiedNames()); |
|
133 |
|
|
134 |
// handle adds |
|
135 |
for(TaxonName name : typifiedNames){ |
|
136 |
if(!name.getTypeDesignations().contains(bean)){ |
|
137 |
name.addTypeDesignation(bean, false); |
|
138 |
} |
|
139 |
} |
|
140 |
// handle removed |
|
141 |
for(TaxonName name : typifiedNamesAsLoaded){ |
|
142 |
if(!typifiedNames.contains(name)){ |
|
143 |
name.removeTypeDesignation(bean); |
|
144 |
} |
|
145 |
// FIXME do we need to save the names here or is the delete cascaded from the typedesignation to the name? |
|
146 |
} |
|
147 |
|
|
148 |
return bean; |
|
149 |
} |
|
150 |
|
|
151 |
|
|
152 |
|
|
115 | 153 |
} |
Also available in: Unified diff
fix #6740 NameTypeDesignationEditor save operation working