Revision e5e64d18
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/cdm/service/CdmStore.java | ||
---|---|---|
210 | 210 |
session.flush(); |
211 | 211 |
commitTransction(); |
212 | 212 |
|
213 |
return new EntityChangeEvent(mergedBean.getClass(), mergedBean.getId(), changeEventType, view);
|
|
213 |
return new EntityChangeEvent(mergedBean, changeEventType, view); |
|
214 | 214 |
} |
215 | 215 |
|
216 | 216 |
/** |
... | ... | |
229 | 229 |
getSession().flush(); |
230 | 230 |
commitTransction(); |
231 | 231 |
logger.trace(this._toString() + ".deleteBean - transaction comitted"); |
232 |
return new EntityChangeEvent(bean.getClass(), bean.getId(), Type.REMOVED, view);
|
|
232 |
return new EntityChangeEvent(bean, Type.REMOVED, view); |
|
233 | 233 |
} else { |
234 | 234 |
handleDeleteresultInError(result); |
235 | 235 |
txStatus = null; |
src/main/java/eu/etaxonomy/cdm/vaadin/event/EntityChangeEvent.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.event; |
10 | 10 |
|
11 |
import java.util.EnumSet; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
11 | 14 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
12 | 15 |
|
13 | 16 |
/** |
... | ... | |
15 | 18 |
* @since May 10, 2017 |
16 | 19 |
* |
17 | 20 |
*/ |
18 |
public class EntityChangeEvent extends AbstractEntityEvent<EntityChangeEvent.Type> { |
|
21 |
public class EntityChangeEvent<T extends CdmBase> extends AbstractEntityEvent<EntityChangeEvent.Type> {
|
|
19 | 22 |
|
20 | 23 |
public enum Type { |
21 | 24 |
CREATED, |
... | ... | |
23 | 26 |
REMOVED; |
24 | 27 |
} |
25 | 28 |
|
26 |
private Class<?> entityType;
|
|
29 |
public static final EnumSet<Type> CREATE_OR_MODIFIED = EnumSet.of(EntityChangeEvent.Type.CREATED, EntityChangeEvent.Type.MODIFIED);
|
|
27 | 30 |
|
28 |
/** |
|
29 |
* @param type |
|
30 |
* @param entityId |
|
31 |
*/ |
|
32 |
public EntityChangeEvent(Class<?> entityType, Integer entityId, Type type, AbstractView sourceView) { |
|
33 |
super(type, entityId, sourceView); |
|
34 |
this.entityType = entityType; |
|
31 |
private Class<T> entityType; |
|
32 |
|
|
33 |
private T entity; |
|
34 |
|
|
35 |
public EntityChangeEvent(T entity, Type type, AbstractView sourceView) { |
|
36 |
super(type, entity.getId(), sourceView); |
|
37 |
this.entityType = (Class<T>) entity.getClass(); |
|
38 |
this.entity = entity; |
|
35 | 39 |
} |
36 | 40 |
|
37 | 41 |
/** |
... | ... | |
41 | 45 |
return entityType; |
42 | 46 |
} |
43 | 47 |
|
48 |
/** |
|
49 |
* @return the entity |
|
50 |
*/ |
|
51 |
public T getEntity() { |
|
52 |
return entity; |
|
53 |
} |
|
54 |
|
|
55 |
public boolean isCreateOrModifiedType() { |
|
56 |
return CREATE_OR_MODIFIED.contains(type); |
|
57 |
} |
|
58 |
|
|
59 |
public boolean isRemovedType() { |
|
60 |
return Type.REMOVED.equals(type); |
|
61 |
} |
|
62 |
|
|
44 | 63 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java | ||
---|---|---|
42 | 42 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
43 | 43 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
44 | 44 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
45 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
|
46 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason; |
|
47 | 45 |
|
48 | 46 |
/** |
49 | 47 |
* @author a.kohlbecker |
... | ... | |
184 | 182 |
// deleteTypedesignation(uuid, uuid) needs to be called so the name is loaded in the transaction of the method and is saved. |
185 | 183 |
DeleteResult deletResult = getRepo().getNameService().deleteTypeDesignation(typifiedNameInContext.getUuid(), bean.getUuid()); |
186 | 184 |
if(deletResult.isOk()){ |
187 |
EntityChangeEvent changeEvent = new EntityChangeEvent(bean.getClass(), bean.getId(), Type.REMOVED, (AbstractView) getView());
|
|
185 |
EntityChangeEvent changeEvent = new EntityChangeEvent(bean, Type.REMOVED, (AbstractView) getView()); |
|
188 | 186 |
viewEventBus.publish(this, changeEvent); |
189 | 187 |
} else { |
190 | 188 |
CdmStore.handleDeleteresultInError(deletResult); |
... | ... | |
258 | 256 |
} |
259 | 257 |
|
260 | 258 |
@EventBusListenerMethod |
261 |
public void onDoneWithPopupEvent(DoneWithPopupEvent event){
|
|
259 |
public void onEntityChangeEvent(EntityChangeEvent<?>event){
|
|
262 | 260 |
|
263 |
if(event.getPopup() == typeNamePopup){
|
|
264 |
if(event.getReason() == Reason.SAVE){
|
|
265 |
getCache().load(typeNamePopup.getBean());
|
|
261 |
if(event.getSourceView() == typeNamePopup){
|
|
262 |
if(event.isCreateOrModifiedType()){
|
|
263 |
getCache().load(event.getEntity());
|
|
266 | 264 |
getView().getTypeNameField().reload(); |
267 | 265 |
} |
268 |
if(event.getReason() == Reason.DELETE){
|
|
266 |
if(event.isRemovedType()){
|
|
269 | 267 |
getView().getTypeNameField().selectNewItem(null); |
270 | 268 |
} |
271 | 269 |
typeNamePopup = null; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java | ||
---|---|---|
38 | 38 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
39 | 39 |
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory; |
40 | 40 |
import eu.etaxonomy.cdm.vaadin.event.EditorActionTypeFilter; |
41 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
|
41 | 42 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
42 | 43 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction; |
43 | 44 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
... | ... | |
49 | 50 |
import eu.etaxonomy.vaadin.component.ReloadableSelect; |
50 | 51 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
51 | 52 |
import eu.etaxonomy.vaadin.mvp.BeanInstantiator; |
52 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
|
53 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason; |
|
54 | 53 |
|
55 | 54 |
/** |
56 | 55 |
* @author a.kohlbecker |
... | ... | |
327 | 326 |
} |
328 | 327 |
|
329 | 328 |
@EventBusListenerMethod |
330 |
public void onDoneWithPopupEvent(DoneWithPopupEvent event){
|
|
329 |
public void onEntityChangeEvent(EntityChangeEvent<?> event){
|
|
331 | 330 |
|
332 |
if(event.getPopup() == referenceEditorPopup){
|
|
333 |
if(event.getReason() == Reason.SAVE){
|
|
331 |
if(event.getSourceView() == referenceEditorPopup){
|
|
332 |
if(event.isCreateOrModifiedType()){
|
|
334 | 333 |
|
335 |
getCache().load(referenceEditorPopup.getBean());
|
|
334 |
getCache().load(event.getEntity());
|
|
336 | 335 |
getView().getNomReferenceCombobox().reload(); // refreshSelectedValue(modifiedReference); |
337 | 336 |
getView().getCombinationAuthorshipField().discard(); //refresh from the datasource |
338 | 337 |
getView().updateAuthorshipFields(); |
... | ... | |
340 | 339 |
|
341 | 340 |
referenceEditorPopup = null; |
342 | 341 |
} |
343 |
if(event.getPopup() == basionymNamePopup){
|
|
344 |
if(event.getReason() == Reason.SAVE){
|
|
342 |
if(event.getSourceView() == basionymNamePopup){
|
|
343 |
if(event.isCreateOrModifiedType()){
|
|
345 | 344 |
|
346 |
getCache().load(basionymNamePopup.getBean());
|
|
345 |
getCache().load(event.getEntity());
|
|
347 | 346 |
((ReloadableSelect)basionymSourceField).reload(); |
348 | 347 |
getView().getBasionymAuthorshipField().discard(); //refresh from the datasource |
349 | 348 |
getView().getExBasionymAuthorshipField().discard(); //refresh from the datasource |
350 | 349 |
getView().updateAuthorshipFields(); |
351 | 350 |
|
352 | 351 |
} |
353 |
if(event.getReason() == Reason.DELETE){
|
|
352 |
if(event.isRemovedType()){
|
|
354 | 353 |
basionymSourceField.setValue(null); |
354 |
getView().updateAuthorshipFields(); |
|
355 | 355 |
} |
356 | 356 |
|
357 | 357 |
basionymNamePopup = null; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/occurrence/CollectionEditorPresenter.java | ||
---|---|---|
21 | 21 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
22 | 22 |
import eu.etaxonomy.cdm.vaadin.event.CollectionEditorAction; |
23 | 23 |
import eu.etaxonomy.cdm.vaadin.event.EditorActionTypeFilter; |
24 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
|
24 | 25 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader; |
25 | 26 |
import eu.etaxonomy.cdm.vaadin.security.UserHelper; |
26 | 27 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
27 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
|
28 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason; |
|
29 | 28 |
|
30 | 29 |
/** |
31 | 30 |
* @author a.kohlbecker |
... | ... | |
135 | 134 |
} |
136 | 135 |
|
137 | 136 |
@EventBusListenerMethod() |
138 |
public void onDoneWithPopupEvent(DoneWithPopupEvent event){
|
|
139 |
if(event.getPopup() == collectionPopuEditor){
|
|
140 |
if(event.getReason() == Reason.SAVE){
|
|
137 |
public void onEntityChangeEvent(EntityChangeEvent<?> event){
|
|
138 |
if(event.getSourceView() == collectionPopuEditor){
|
|
139 |
if(event.isCreateOrModifiedType()){
|
|
141 | 140 |
|
142 |
Collection newCollection = collectionPopuEditor.getBean();
|
|
141 |
Collection newCollection = (Collection) event.getEntity();
|
|
143 | 142 |
getCache().load(newCollection); |
144 | 143 |
getView().getSuperCollectionCombobox().getSelect().setValue(newCollection); |
145 | 144 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java | ||
---|---|---|
25 | 25 |
import eu.etaxonomy.cdm.model.reference.Reference; |
26 | 26 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
27 | 27 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
28 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
|
28 | 29 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
29 | 30 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
30 | 31 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader; |
31 | 32 |
import eu.etaxonomy.cdm.vaadin.security.UserHelper; |
32 | 33 |
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityField; |
33 | 34 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
34 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
|
35 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason; |
|
36 | 35 |
|
37 | 36 |
/** |
38 | 37 |
* @author a.kohlbecker |
... | ... | |
161 | 160 |
} |
162 | 161 |
|
163 | 162 |
@EventBusListenerMethod |
164 |
public void onDoneWithPopupEvent(DoneWithPopupEvent event){
|
|
163 |
public void onEntityChangeEvent(EntityChangeEvent<?> event){
|
|
165 | 164 |
|
166 |
if(event.getPopup().equals(inReferencePopup)){
|
|
167 |
if(event.getReason().equals(Reason.SAVE)){
|
|
168 |
getCache().load(inReferencePopup.getBean());
|
|
169 |
getView().getInReferenceCombobox().reload(); //refreshSelectedValue(bean);
|
|
165 |
if(event.getSourceView() == inReferencePopup){
|
|
166 |
if(event.isCreateOrModifiedType()){
|
|
167 |
getCache().load(event.getEntity());
|
|
168 |
getView().getInReferenceCombobox().reload(); |
|
170 | 169 |
} |
171 |
if(event.getReason().equals(Reason.DELETE)){
|
|
170 |
if(event.isRemovedType()){
|
|
172 | 171 |
getView().getInReferenceCombobox().selectNewItem(null); |
173 | 172 |
} |
174 | 173 |
inReferencePopup = null; |
Also available in: Unified diff
ref #7344 updating presenter entity caches with beans modified in popup editors and refreshing teamOrPerson Fields (2)