Revision b8853d8d
Added by Andreas Kohlbecker over 6 years ago
pom.xml | ||
---|---|---|
506 | 506 |
<artifactId>cdmlib-remote</artifactId> |
507 | 507 |
<scope>compile</scope> |
508 | 508 |
</dependency> |
509 |
<dependency> |
|
510 |
<groupId>eu.etaxonomy</groupId> |
|
511 |
<artifactId>cdmlib-cache</artifactId> |
|
512 |
<version>${cdmlib.version}</version> |
|
513 |
</dependency> |
|
509 | 514 |
<dependency> |
510 | 515 |
<groupId>eu.etaxonomy</groupId> |
511 | 516 |
<artifactId>cdmlib-test</artifactId> |
src/main/java/eu/etaxonomy/cdm/addon/config/CdmVaadinConfiguration.java | ||
---|---|---|
41 | 41 |
import eu.etaxonomy.cdm.api.application.AbstractDataInserter; |
42 | 42 |
import eu.etaxonomy.cdm.api.application.CdmRepository; |
43 | 43 |
import eu.etaxonomy.cdm.api.application.DummyDataInserter; |
44 |
import eu.etaxonomy.cdm.api.cache.CdmCacher; |
|
44 | 45 |
import eu.etaxonomy.cdm.api.service.idminter.RegistrationIdentifierMinter; |
46 |
import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher; |
|
45 | 47 |
import eu.etaxonomy.cdm.common.ConfigFileUtil; |
46 | 48 |
import eu.etaxonomy.cdm.dataInserter.RegistrationRequiredDataInserter; |
47 | 49 |
import eu.etaxonomy.cdm.opt.config.DataSourceConfigurer; |
... | ... | |
93 | 95 |
@Autowired |
94 | 96 |
private SessionFactory sessionFactory; |
95 | 97 |
|
98 |
@Autowired |
|
99 |
private void setTermCacher(CdmCacher termCacher){ |
|
100 |
CdmTransientEntityCacher.setDefaultCacher(termCacher); |
|
101 |
} |
|
102 |
|
|
96 | 103 |
private boolean registrationUiHibernateEventListenersDone = false; |
97 | 104 |
|
98 | 105 |
/* |
src/main/java/eu/etaxonomy/cdm/vaadin/debug/EntityCacheDebugger.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.vaadin.debug; |
|
10 |
|
|
11 |
import java.lang.reflect.InvocationTargetException; |
|
12 |
import java.lang.reflect.Method; |
|
13 |
import java.util.Optional; |
|
14 |
|
|
15 |
import org.apache.log4j.Logger; |
|
16 |
import org.springframework.context.annotation.Profile; |
|
17 |
import org.springframework.context.event.EventListener; |
|
18 |
import org.springframework.stereotype.Component; |
|
19 |
|
|
20 |
import com.vaadin.event.ShortcutAction; |
|
21 |
import com.vaadin.event.ShortcutListener; |
|
22 |
import com.vaadin.navigator.View; |
|
23 |
import com.vaadin.navigator.ViewChangeListener; |
|
24 |
import com.vaadin.ui.UI; |
|
25 |
import com.vaadin.ui.Window; |
|
26 |
|
|
27 |
import eu.etaxonomy.cdm.vaadin.view.name.CachingPresenter; |
|
28 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor; |
|
29 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
|
30 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
|
31 |
import eu.etaxonomy.vaadin.ui.view.PopEditorOpenedEvent; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author a.kohlbecker |
|
35 |
* @since Jan 22, 2018 |
|
36 |
* |
|
37 |
*/ |
|
38 |
@Component |
|
39 |
@Profile("debug") |
|
40 |
public class EntityCacheDebugger implements ViewChangeListener { |
|
41 |
|
|
42 |
Logger logger = Logger.getLogger(EntityCacheDebugger.class); |
|
43 |
|
|
44 |
EntityCacheDebuggerShortcutListener shortcutListener; |
|
45 |
|
|
46 |
public EntityCacheDebugger(){ |
|
47 |
shortcutListener = new EntityCacheDebuggerShortcutListener("Debug Entities", |
|
48 |
ShortcutAction.KeyCode.SPACEBAR, |
|
49 |
ShortcutAction.ModifierKey.CTRL); |
|
50 |
} |
|
51 |
|
|
52 |
public void openFor(AbstractView view){ |
|
53 |
|
|
54 |
if(view != null){ |
|
55 |
|
|
56 |
try { |
|
57 |
AbstractPresenter presenter; |
|
58 |
Method getPresenterMethod = AbstractView.class.getDeclaredMethod("getPresenter"); |
|
59 |
getPresenterMethod.setAccessible(true); |
|
60 |
presenter = (AbstractPresenter) getPresenterMethod.invoke(view); |
|
61 |
if(CachingPresenter.class.isAssignableFrom(presenter.getClass())){ |
|
62 |
open(view, (CachingPresenter)presenter); |
|
63 |
} else { |
|
64 |
logger.warn("can only operate on CachingPresenters"); |
|
65 |
} |
|
66 |
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException |
|
67 |
| InvocationTargetException e) { |
|
68 |
logger.error(e); |
|
69 |
} |
|
70 |
|
|
71 |
} else { |
|
72 |
logger.warn("view is null"); |
|
73 |
} |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* @param view |
|
79 |
* @param presenter |
|
80 |
*/ |
|
81 |
private void open(AbstractView view, CachingPresenter presenter) { |
|
82 |
|
|
83 |
EntityCacheDebuggerComponent content = new EntityCacheDebuggerComponent(presenter); |
|
84 |
|
|
85 |
if(view instanceof AbstractCdmPopupEditor){ |
|
86 |
findWindow((AbstractCdmPopupEditor)view).setModal(false); |
|
87 |
} |
|
88 |
Window window = new Window(); |
|
89 |
window.setCaption("Entity Cache Debugger"); |
|
90 |
window.setResizable(true); |
|
91 |
window.setModal(false); |
|
92 |
content.setSizeFull(); |
|
93 |
window.setContent(content); |
|
94 |
window.setWidth("500px"); |
|
95 |
window.setHeight("500px"); |
|
96 |
UI.getCurrent().addWindow(window); |
|
97 |
|
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* {@inheritDoc} |
|
102 |
*/ |
|
103 |
@Override |
|
104 |
public boolean beforeViewChange(ViewChangeEvent event) { |
|
105 |
return true; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* {@inheritDoc} |
|
110 |
*/ |
|
111 |
@Override |
|
112 |
public void afterViewChange(ViewChangeEvent event) { |
|
113 |
View newView = event.getNewView(); |
|
114 |
if(newView instanceof AbstractView){ |
|
115 |
((AbstractView)newView).addShortcutListener(shortcutListener); |
|
116 |
} |
|
117 |
if(event.getOldView() instanceof AbstractView){ |
|
118 |
((AbstractView)event.getOldView()).removeShortcutListener(shortcutListener); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
@EventListener |
|
123 |
public void onPopEditorOpenedEvent(PopEditorOpenedEvent event){ |
|
124 |
if(event.getPopupView() != null && event.getPopupView() instanceof AbstractCdmPopupEditor){ |
|
125 |
findWindow(((AbstractCdmPopupEditor)event.getPopupView())).addShortcutListener(shortcutListener); |
|
126 |
} |
|
127 |
|
|
128 |
} |
|
129 |
|
|
130 |
private Window findWindow(AbstractCdmPopupEditor view){ |
|
131 |
Optional<Window> popUpWindow = UI.getCurrent().getWindows().stream().filter(w -> w.getContent().equals(view)).findFirst(); |
|
132 |
if(popUpWindow.isPresent()){ |
|
133 |
return popUpWindow.get(); |
|
134 |
} else { |
|
135 |
return null; |
|
136 |
} |
|
137 |
|
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* @return the shortcutListener |
|
142 |
*/ |
|
143 |
public EntityCacheDebuggerShortcutListener getShortcutListener() { |
|
144 |
return shortcutListener; |
|
145 |
} |
|
146 |
|
|
147 |
|
|
148 |
private class EntityCacheDebuggerShortcutListener extends ShortcutListener { |
|
149 |
|
|
150 |
private static final long serialVersionUID = -8727949764189908851L; |
|
151 |
|
|
152 |
/** |
|
153 |
* @param caption |
|
154 |
* @param keyCode |
|
155 |
* @param modifierKeys |
|
156 |
*/ |
|
157 |
public EntityCacheDebuggerShortcutListener( |
|
158 |
String caption, |
|
159 |
int keyCode, |
|
160 |
int modifierKey) { |
|
161 |
super(caption, keyCode, new int[]{modifierKey}); |
|
162 |
} |
|
163 |
|
|
164 |
|
|
165 |
public EntityCacheDebuggerShortcutListener( |
|
166 |
String caption, |
|
167 |
int keyCode) { |
|
168 |
super(caption, new int[]{keyCode}); |
|
169 |
} |
|
170 |
|
|
171 |
@Override |
|
172 |
public void handleAction(Object sender, Object target) { |
|
173 |
if(sender instanceof AbstractView) { |
|
174 |
EntityCacheDebugger.this.openFor((AbstractView)sender); |
|
175 |
} |
|
176 |
if(sender instanceof Window && ((Window)sender).getContent() instanceof AbstractCdmPopupEditor) { |
|
177 |
EntityCacheDebugger.this.openFor((AbstractCdmPopupEditor)((Window)sender).getContent()); |
|
178 |
} |
|
179 |
|
|
180 |
} |
|
181 |
}; |
|
182 |
|
|
183 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/debug/EntityCacheDebuggerComponent.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.vaadin.debug; |
|
10 |
|
|
11 |
import java.util.List; |
|
12 |
|
|
13 |
import com.vaadin.data.util.HierarchicalContainer; |
|
14 |
import com.vaadin.data.util.IndexedContainer; |
|
15 |
import com.vaadin.data.util.filter.SimpleStringFilter; |
|
16 |
import com.vaadin.ui.CustomComponent; |
|
17 |
import com.vaadin.ui.TextArea; |
|
18 |
import com.vaadin.ui.TextField; |
|
19 |
import com.vaadin.ui.Tree; |
|
20 |
import com.vaadin.ui.VerticalLayout; |
|
21 |
import com.vaadin.ui.VerticalSplitPanel; |
|
22 |
|
|
23 |
import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher; |
|
24 |
import eu.etaxonomy.cdm.cache.EntityCacherDebugResult; |
|
25 |
import eu.etaxonomy.cdm.cache.EntityCacherDebugResult.CdmEntityInfo; |
|
26 |
import eu.etaxonomy.cdm.vaadin.component.TextFieldNFix; |
|
27 |
import eu.etaxonomy.cdm.vaadin.view.name.CachingPresenter; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author a.kohlbecker |
|
31 |
* @since Jan 22, 2018 |
|
32 |
* |
|
33 |
*/ |
|
34 |
public class EntityCacheDebuggerComponent extends CustomComponent { |
|
35 |
|
|
36 |
CachingPresenter presenter; |
|
37 |
CdmTransientEntityCacher cacher; |
|
38 |
EntityCacherDebugResult debugResults; |
|
39 |
|
|
40 |
VerticalLayout layout = new VerticalLayout(); |
|
41 |
VerticalSplitPanel splitPanel = new VerticalSplitPanel(); |
|
42 |
|
|
43 |
private Tree entityTree; |
|
44 |
|
|
45 |
public EntityCacheDebuggerComponent(CachingPresenter presenter){ |
|
46 |
|
|
47 |
this.presenter = presenter; |
|
48 |
this.cacher = (CdmTransientEntityCacher) presenter.getCache(); |
|
49 |
debugResults = new EntityCacherDebugResult(cacher, presenter.getRootEntities()); |
|
50 |
initContent(); |
|
51 |
} |
|
52 |
|
|
53 |
private void initContent() { |
|
54 |
|
|
55 |
|
|
56 |
// VerticalLayout filterTree = new VerticalLayout(); |
|
57 |
// filterTree.setSizeFull(); |
|
58 |
|
|
59 |
TextField filterField = new TextFieldNFix(); |
|
60 |
filterField.setInputPrompt("Enter filter text"); |
|
61 |
filterField.addTextChangeListener(e -> filterTree(e.getText())); |
|
62 |
filterField.setWidth("100%"); |
|
63 |
|
|
64 |
// filterTree.addComponent(filterField); |
|
65 |
|
|
66 |
// Panel treePanel = new Panel(); |
|
67 |
entityTree = new Tree("Cache Content"); |
|
68 |
buildTree(entityTree, debugResults.getRootElements()); |
|
69 |
|
|
70 |
// treePanel.setContent(entityTree); |
|
71 |
// treePanel.setWidth("100%"); |
|
72 |
// filterTree.addComponents(filterField, treePanel); |
|
73 |
//treePanel.setHeight("200px"); |
|
74 |
// filterTree.addComponent(treePanel); |
|
75 |
// filterTree.setExpandRatio(treePanel, 1.0f); |
|
76 |
|
|
77 |
TextArea debugInformation = new TextArea("Debug Information"); |
|
78 |
debugInformation.setValue(debugResults.toString()); |
|
79 |
|
|
80 |
setCompositionRoot(layout); |
|
81 |
|
|
82 |
entityTree.setSizeUndefined(); |
|
83 |
debugInformation.setSizeUndefined(); |
|
84 |
debugInformation.setWidth("100%"); |
|
85 |
debugInformation.setRows(100); |
|
86 |
debugInformation.setReadOnly(true); |
|
87 |
splitPanel.setFirstComponent(entityTree); |
|
88 |
splitPanel.setSecondComponent(debugInformation); |
|
89 |
splitPanel.setSplitPosition(50, Unit.PERCENTAGE); |
|
90 |
splitPanel.setSizeFull(); |
|
91 |
|
|
92 |
layout.addComponents(filterField, splitPanel); |
|
93 |
layout.setSizeFull(); |
|
94 |
layout.setExpandRatio(splitPanel, 1.0f); |
|
95 |
|
|
96 |
|
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* @param value |
|
101 |
* @return |
|
102 |
*/ |
|
103 |
private void filterTree(String text) { |
|
104 |
IndexedContainer indexedContainer = (IndexedContainer)entityTree.getContainerDataSource(); |
|
105 |
indexedContainer.removeAllContainerFilters(); |
|
106 |
|
|
107 |
if(!text.isEmpty()){ |
|
108 |
SimpleStringFilter filter = new SimpleStringFilter("label", text, true, false); |
|
109 |
indexedContainer.addContainerFilter(filter); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* @param entityTree |
|
115 |
* @param rootElements |
|
116 |
*/ |
|
117 |
private void buildTree(Tree tree, List<CdmEntityInfo> childElements) { |
|
118 |
|
|
119 |
HierarchicalContainer container = new HierarchicalContainer(); |
|
120 |
|
|
121 |
container.addContainerProperty("label", String.class, ""); |
|
122 |
tree.setItemCaptionPropertyId("label"); |
|
123 |
buildTree(container, childElements, null); |
|
124 |
|
|
125 |
tree.setContainerDataSource(container); |
|
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
private void buildTree(HierarchicalContainer container, List<CdmEntityInfo> childElements, Object parentItemId) { |
|
130 |
for(CdmEntityInfo cei : childElements){ |
|
131 |
String itemId = cei.getLabel(); |
|
132 |
container.addItem(itemId); |
|
133 |
container.getItem(itemId).getItemProperty("label").setValue(itemId); |
|
134 |
if(parentItemId != null){ |
|
135 |
container.setParent(itemId, parentItemId); |
|
136 |
} |
|
137 |
if(cei.getChildren().isEmpty()){ |
|
138 |
container.setChildrenAllowed(itemId, false); |
|
139 |
} else { |
|
140 |
buildTree(container, cei.getChildren(), itemId); |
|
141 |
} |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/event/ToOneRelatedEntityReloader.java | ||
---|---|---|
12 | 12 |
import com.vaadin.data.Property.ValueChangeListener; |
13 | 13 |
import com.vaadin.ui.Field; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.cache.EntityCache; |
|
16 | 15 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
16 |
import eu.etaxonomy.cdm.model.ICdmCacher; |
|
17 | 17 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
18 | 18 |
import eu.etaxonomy.cdm.vaadin.view.name.CachingPresenter; |
19 | 19 |
|
... | ... | |
65 | 65 |
return; |
66 | 66 |
} |
67 | 67 |
|
68 |
EntityCache cache = cachingPresenter.getCache();
|
|
68 |
ICdmCacher cache = cachingPresenter.getCache();
|
|
69 | 69 |
if(cache != null){ |
70 |
cache.update(); |
|
71 |
CDM cachedEntity = cache.findAndUpdate(value); |
|
72 |
if(cachedEntity == null){ |
|
73 |
cache.add(value); |
|
74 |
} else if( |
|
70 |
CDM cachedEntity = (CDM) cache.load(value); |
|
71 |
if(cachedEntity != null && |
|
75 | 72 |
// pure object comparison is not reliable since the entity may have been changed |
76 | 73 |
cachedEntity.getId() == value.getId() && cachedEntity.getClass() == value.getClass() |
77 | 74 |
){ |
src/main/java/eu/etaxonomy/cdm/vaadin/ui/RegistrationUI.java | ||
---|---|---|
31 | 31 |
import com.vaadin.ui.UI; |
32 | 32 |
import com.vaadin.ui.themes.ValoTheme; |
33 | 33 |
|
34 |
import eu.etaxonomy.cdm.vaadin.debug.EntityCacheDebugger; |
|
34 | 35 |
import eu.etaxonomy.cdm.vaadin.toolbar.Toolbar; |
35 | 36 |
import eu.etaxonomy.cdm.vaadin.view.RedirectToLoginView; |
36 | 37 |
import eu.etaxonomy.cdm.vaadin.view.registration.DashBoardView; |
... | ... | |
69 | 70 |
@Autowired |
70 | 71 |
NavigationManagerBean navigator; |
71 | 72 |
|
73 |
@Autowired(required = false) |
|
74 |
EntityCacheDebugger entityCacheDebugger = null; |
|
75 |
|
|
72 | 76 |
protected void configureAccessDeniedView() { |
73 | 77 |
viewProvider.setAccessDeniedViewClass(RedirectToLoginView.class); |
74 | 78 |
} |
... | ... | |
138 | 142 |
((ToolbarDisplay)viewDisplay).setToolbar(toolbar); |
139 | 143 |
} |
140 | 144 |
|
145 |
|
|
141 | 146 |
eventBus.publishEvent(new UIInitializedEvent()); |
142 | 147 |
|
143 | 148 |
String brand = "phycobank"; |
... | ... | |
152 | 157 |
|
153 | 158 |
navigator.setDefaultViewName(INITIAL_VIEW); |
154 | 159 |
|
160 |
if(entityCacheDebugger != null){ |
|
161 |
addShortcutListener(entityCacheDebugger.getShortcutListener()); |
|
162 |
} |
|
155 | 163 |
//navigate to initial view |
156 | 164 |
// String state = pageFragmentAsState(); |
157 | 165 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/CachingPresenter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 |
import eu.etaxonomy.cdm.cache.EntityCache; |
|
11 |
import java.util.Collection; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.ICdmCacher; |
|
14 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
12 | 15 |
|
13 | 16 |
/** |
14 | 17 |
* @author a.kohlbecker |
... | ... | |
17 | 20 |
*/ |
18 | 21 |
public interface CachingPresenter { |
19 | 22 |
|
20 |
public EntityCache getCache();
|
|
23 |
public ICdmCacher getCache();
|
|
21 | 24 |
|
22 | 25 |
public boolean isCacheInitialized(); |
23 | 26 |
|
27 |
public Collection<CdmBase> getRootEntities(); |
|
28 |
|
|
24 | 29 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
11 | 12 |
import java.util.Arrays; |
12 | 13 |
import java.util.EnumSet; |
13 | 14 |
import java.util.HashSet; |
... | ... | |
18 | 19 |
import org.vaadin.viritin.fields.AbstractElementCollection; |
19 | 20 |
|
20 | 21 |
import eu.etaxonomy.cdm.api.service.IRegistrationService; |
21 |
import eu.etaxonomy.cdm.cache.CdmEntityCache;
|
|
22 |
import eu.etaxonomy.cdm.cache.EntityCache;
|
|
22 |
import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher;
|
|
23 |
import eu.etaxonomy.cdm.model.ICdmCacher;
|
|
23 | 24 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
24 | 25 |
import eu.etaxonomy.cdm.model.agent.Person; |
25 | 26 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
27 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
26 | 28 |
import eu.etaxonomy.cdm.model.location.Country; |
27 | 29 |
import eu.etaxonomy.cdm.model.name.Registration; |
28 | 30 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
... | ... | |
80 | 82 |
*/ |
81 | 83 |
private EnumSet<CRUD> crud = null; |
82 | 84 |
|
83 |
private CdmEntityCache cache = null;
|
|
85 |
private ICdmCacher cache = new CdmTransientEntityCacher(this);
|
|
84 | 86 |
|
85 | 87 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingSetDto; |
86 | 88 |
|
... | ... | |
90 | 92 |
|
91 | 93 |
private ReferencePopupEditor referencePopupEditor; |
92 | 94 |
|
95 |
private java.util.Collection<CdmBase> rootEntities = new ArrayList<>(); |
|
96 |
|
|
93 | 97 |
protected CdmStore<Registration, IRegistrationService> getStore() { |
94 | 98 |
if(store == null){ |
95 | 99 |
store = new CdmStore<>(getRepo(), getRepo().getRegistrationService()); |
... | ... | |
124 | 128 |
// This method must go again into the presenter !!!! |
125 | 129 |
logger.info("Basing all typeDesignations on a new fieldUnit"); |
126 | 130 |
} |
127 |
cache = new CdmEntityCache(workingSetDto.getOwner()); |
|
131 |
cache.put(workingSetDto.getOwner()); |
|
132 |
rootEntities.add(workingSetDto.getOwner()); |
|
128 | 133 |
} else { |
129 | 134 |
// create a new workingset, for a new fieldunit which is the base for the workingset |
130 | 135 |
workingSetDto = specimenTypeDesignationWorkingSetService.create(idset.registrationId, idset.publicationId, idset.typifiedNameId); |
131 |
cache = new CdmEntityCache(workingSetDto.getOwner()); |
|
136 |
cache.put(workingSetDto.getOwner()); |
|
137 |
rootEntities.add(workingSetDto.getOwner()); |
|
132 | 138 |
} |
133 | 139 |
|
134 | 140 |
} else { |
... | ... | |
287 | 293 |
* {@inheritDoc} |
288 | 294 |
*/ |
289 | 295 |
@Override |
290 |
public EntityCache getCache() {
|
|
296 |
public ICdmCacher getCache() {
|
|
291 | 297 |
return cache; |
292 |
// if(((AbstractPopupEditor)getView()).isBeanLoaded()){ |
|
293 |
// } else { |
|
294 |
// return null; |
|
295 |
// } |
|
296 | 298 |
} |
297 | 299 |
|
298 | 300 |
/** |
... | ... | |
328 | 330 |
public void onCollectionEvent(EntityChangeEvent event){ |
329 | 331 |
|
330 | 332 |
Collection newCollection = getRepo().getCollectionService().load(event.getEntityId(), Arrays.asList(new String[]{"$.institute"})); |
331 |
cache.findAndUpdate(newCollection);
|
|
333 |
cache.getFromCache(newCollection);
|
|
332 | 334 |
|
333 | 335 |
for( CollectionRowItemCollection row : collectionPopuEditorSourceRows) { |
334 | 336 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 2); |
... | ... | |
359 | 361 |
public void onReferenceEvent(EntityChangeEvent event){ |
360 | 362 |
|
361 | 363 |
Reference newRef = getRepo().getReferenceService().load(event.getEntityId(), Arrays.asList(new String[]{"$"})); |
362 |
cache.findAndUpdate(newRef);
|
|
364 |
cache.getFromCache(newRef);
|
|
363 | 365 |
|
364 | 366 |
for( CollectionRowItemCollection row : collectionPopuEditorSourceRows) { |
365 | 367 |
ToOneRelatedEntityCombobox<Collection> combobox = row.getComponent(ToOneRelatedEntityCombobox.class, 6); |
... | ... | |
368 | 370 |
} |
369 | 371 |
|
370 | 372 |
|
373 |
/** |
|
374 |
* {@inheritDoc} |
|
375 |
*/ |
|
376 |
@Override |
|
377 |
public java.util.Collection<CdmBase> getRootEntities() { |
|
378 |
return rootEntities ; |
|
379 |
} |
|
380 |
|
|
381 |
|
|
371 | 382 |
|
372 | 383 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java | ||
---|---|---|
59 | 59 |
/** |
60 | 60 |
* |
61 | 61 |
*/ |
62 |
private static final List<String> BASIONYM_INIT_STRATEGY = Arrays.asList("$", "relationsFromThisName", "homotypicalGroup.typifiedNames"); |
|
62 |
private static final List<String> BASIONYM_INIT_STRATEGY = Arrays.asList("$", "relationsFromThisName", "relationsToThisName.type", "homotypicalGroup.typifiedNames");
|
|
63 | 63 |
|
64 | 64 |
private static final long serialVersionUID = -3538980627079389221L; |
65 | 65 |
|
... | ... | |
148 | 148 |
"relationsToThisName.fromName.relationsFromThisName", |
149 | 149 |
|
150 | 150 |
"relationsFromThisName", |
151 |
//"relationsToThisName", |
|
152 | 151 |
"homotypicalGroup.typifiedNames" |
153 | 152 |
|
154 | 153 |
} |
... | ... | |
268 | 267 |
basiopca.setShowHashCodes(true); |
269 | 268 |
basiopca.printEntityGraph(System.err); |
270 | 269 |
|
271 |
TaxonName cachedName = getCache().find(addBasionymName);
|
|
270 |
TaxonName cachedName = (TaxonName) getCache().getFromCache(addBasionymName);
|
|
272 | 271 |
if(cachedName != null){ |
273 | 272 |
System.err.println("====== Cached Basionym ======"); |
274 | 273 |
PersistentContextAnalyzer cahedbasiopca = new PersistentContextAnalyzer(addBasionymName, getRepo().getSession()); |
... | ... | |
353 | 352 |
|
354 | 353 |
// TODO the bean contained in the popup editor is not yet updated at this point. |
355 | 354 |
// so re reload it using the uuid since new beans will not have an Id at this point. |
356 |
modifiedTaxonName = getRepo().getNameService().load(modifiedTaxonName.getUuid()); //, BASIONYM_INIT_STRATEGY);
|
|
355 |
modifiedTaxonName = getRepo().getNameService().load(modifiedTaxonName.getUuid(), BASIONYM_INIT_STRATEGY); |
|
357 | 356 |
basionymSourceField.setValue(modifiedTaxonName); |
358 | 357 |
|
359 | 358 |
// TODO create blocking registration |
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java | ||
---|---|---|
184 | 184 |
getField("inReference").setVisible(value.isPrintedUnit() || value.isSection()); |
185 | 185 |
getField("pages").setVisible(value.isSection()); |
186 | 186 |
|
187 |
EnumSet<ReferenceType> hideNomTitle = EnumSet.of(ReferenceType.Article, ReferenceType.Section, ReferenceType.BookSection, ReferenceType.InProceedings, ReferenceType.PrintSeries); |
|
188 |
EnumSet<ReferenceType> hideTitle = EnumSet.of(ReferenceType.Section, ReferenceType.BookSection); |
|
189 |
getField("abbrevTitle").setVisible(!hideNomTitle.contains(value)); |
|
190 |
getField("title").setVisible(!hideTitle.contains(value)); |
|
191 |
|
|
187 | 192 |
return null; |
188 | 193 |
} |
189 | 194 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
210 | 210 |
} |
211 | 211 |
|
212 | 212 |
ReferencePopupEditor popup = getNavigationManager().showInPopup(ReferencePopupEditor.class); |
213 |
popup.withReferenceTypes(RegistrationUIDefaults.PRINTPUB_REFERENCE_TYPES); |
|
213 | 214 |
popup.loadInEditor(null); |
214 | 215 |
} |
215 | 216 |
|
... | ... | |
220 | 221 |
return; |
221 | 222 |
} |
222 | 223 |
ReferencePopupEditor popup = getNavigationManager().showInPopup(ReferencePopupEditor.class); |
224 |
popup.withReferenceTypes(RegistrationUIDefaults.PRINTPUB_REFERENCE_TYPES); |
|
223 | 225 |
popup.withDeleteButton(true); |
224 | 226 |
popup.loadInEditor(event.getEntityId()); |
225 | 227 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmEditorPresenter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.vaadin.mvp; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.Collection; |
|
11 | 13 |
import java.util.EnumSet; |
12 | 14 |
|
13 | 15 |
import org.apache.log4j.Logger; |
... | ... | |
15 | 17 |
import org.springframework.context.event.EventListener; |
16 | 18 |
|
17 | 19 |
import eu.etaxonomy.cdm.api.service.IService; |
18 |
import eu.etaxonomy.cdm.cache.CdmEntityCache; |
|
19 |
import eu.etaxonomy.cdm.cache.EntityCache; |
|
20 |
import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher; |
|
20 | 21 |
import eu.etaxonomy.cdm.debug.PersistentContextAnalyzer; |
22 |
import eu.etaxonomy.cdm.model.ICdmCacher; |
|
21 | 23 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
22 | 24 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
23 | 25 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority; |
... | ... | |
49 | 51 |
protected EnumSet<CRUD> crud = null; |
50 | 52 |
|
51 | 53 |
|
52 |
private CdmEntityCache cache = null; |
|
54 |
private ICdmCacher cache = new CdmTransientEntityCacher(this); |
|
55 |
|
|
56 |
private java.util.Collection<CdmBase> rootEntities = new ArrayList<>(); |
|
53 | 57 |
|
54 | 58 |
public AbstractCdmEditorPresenter() { |
55 | 59 |
super(); |
... | ... | |
84 | 88 |
} |
85 | 89 |
} |
86 | 90 |
|
87 |
cache = new CdmEntityCache(cdmEntitiy); |
|
91 |
cache.put(cdmEntitiy); |
|
92 |
rootEntities.add(cdmEntitiy); |
|
88 | 93 |
|
89 | 94 |
return cdmEntitiy; |
90 | 95 |
} |
... | ... | |
228 | 233 |
* {@inheritDoc} |
229 | 234 |
*/ |
230 | 235 |
@Override |
231 |
public EntityCache getCache() {
|
|
236 |
public ICdmCacher getCache() {
|
|
232 | 237 |
return cache; |
233 |
// if(((AbstractPopupEditor)getView()).isBeanLoaded()){ |
|
234 |
// } else { |
|
235 |
// return null; |
|
236 |
// } |
|
238 |
} |
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
/** |
|
243 |
* {@inheritDoc} |
|
244 |
*/ |
|
245 |
@Override |
|
246 |
public Collection<CdmBase> getRootEntities() { |
|
247 |
return rootEntities; |
|
237 | 248 |
} |
238 | 249 |
|
239 | 250 |
/** |
src/main/java/eu/etaxonomy/vaadin/ui/navigation/NavigationManagerBean.java | ||
---|---|---|
29 | 29 |
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor; |
30 | 30 |
import eu.etaxonomy.vaadin.ui.UIInitializedEvent; |
31 | 31 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
32 |
import eu.etaxonomy.vaadin.ui.view.PopEditorOpenedEvent; |
|
32 | 33 |
import eu.etaxonomy.vaadin.ui.view.PopupEditorFactory; |
33 | 34 |
import eu.etaxonomy.vaadin.ui.view.PopupView; |
34 | 35 |
|
... | ... | |
50 | 51 |
private SpringViewProvider viewProvider; |
51 | 52 |
|
52 | 53 |
@Autowired |
53 |
private ViewChangeListener viewChangeListener;
|
|
54 |
private List<ViewChangeListener> viewChangeListeners;
|
|
54 | 55 |
|
55 | 56 |
@Autowired |
56 | 57 |
private PojoEventListenerManager eventListenerManager; |
... | ... | |
114 | 115 |
@EventListener |
115 | 116 |
protected void onUIInitialized(UIInitializedEvent e) { |
116 | 117 |
init(UI.getCurrent(), uriFragmentManager, viewDisplay); |
117 |
addViewChangeListener(viewChangeListener);
|
|
118 |
viewChangeListeners.forEach(vcl -> addViewChangeListener(vcl));
|
|
118 | 119 |
} |
119 | 120 |
|
120 | 121 |
public void navigateTo(String navigationState, boolean fireNavigationEvent) { |
... | ... | |
172 | 173 |
UI.getCurrent().addWindow(window); |
173 | 174 |
popupView.viewEntered(); |
174 | 175 |
popupView.focusFirst(); |
176 |
eventBus.publishEvent(new PopEditorOpenedEvent(this, popupView)); |
|
175 | 177 |
|
176 | 178 |
popupMap.put(popupView, window); |
177 | 179 |
|
src/main/java/eu/etaxonomy/vaadin/ui/navigation/ViewChangeListenerBean.java | ||
---|---|---|
11 | 11 |
import com.vaadin.spring.annotation.SpringComponent; |
12 | 12 |
import com.vaadin.spring.annotation.UIScope; |
13 | 13 |
|
14 |
@SpringComponent |
|
14 |
@SpringComponent("viewChangeListenerBean")
|
|
15 | 15 |
@UIScope |
16 | 16 |
class ViewChangeListenerBean implements ViewChangeListener { |
17 | 17 |
private static final long serialVersionUID = 1913421359807383L; |
src/main/java/eu/etaxonomy/vaadin/ui/view/PopEditorOpenedEvent.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.vaadin.ui.view; |
|
10 |
|
|
11 |
import org.springframework.context.ApplicationEvent; |
|
12 |
|
|
13 |
/** |
|
14 |
* @author a.kohlbecker |
|
15 |
* @since Jan 22, 2018 |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class PopEditorOpenedEvent extends ApplicationEvent { |
|
19 |
|
|
20 |
private static final long serialVersionUID = -1258659977737677080L; |
|
21 |
|
|
22 |
private PopupView popupView; |
|
23 |
|
|
24 |
/** |
|
25 |
* @param source |
|
26 |
*/ |
|
27 |
public PopEditorOpenedEvent(Object source, PopupView popupView) { |
|
28 |
super(source); |
|
29 |
this.popupView = popupView; |
|
30 |
} |
|
31 |
|
|
32 |
public PopupView getPopupView(){ |
|
33 |
return popupView; |
|
34 |
} |
|
35 |
|
|
36 |
} |
src/main/webapp/WEB-INF/applicationContext.xml | ||
---|---|---|
74 | 74 |
<property name="cacheManager" ref="cacheManager" /> |
75 | 75 |
<property name="serializableFactory" ref="serializableFactory"/> |
76 | 76 |
</bean> |
77 |
|
|
77 |
|
|
78 |
<!-- for cdmTermCacher see CdmVaadinConfiguration.setTermCacher() --> |
|
79 |
<bean id="cdmTermCacher" class="eu.etaxonomy.cdm.api.cache.CdmTermCacher" /> |
|
78 | 80 |
</beans> |
Also available in: Unified diff
ref #7206 replacing CdmEntityCache by CdmTransientEntityCacher and implementing EntityCacheDebugger