Revision 9d5ae601
Added by Andreas Kohlbecker almost 7 years ago
src/main/java/eu/etaxonomy/cdm/mock/RegistrationService.java | ||
---|---|---|
232 | 232 |
return null; |
233 | 233 |
} |
234 | 234 |
|
235 |
/** |
|
236 |
* {@inheritDoc} |
|
237 |
*/ |
|
238 |
@Override |
|
239 |
public RegistrationWorkingSet loadWorkingSetByReferenceID(Integer referenceID) { |
|
240 |
// TODO Auto-generated method stub |
|
241 |
return null; |
|
242 |
} |
|
243 |
|
|
235 | 244 |
|
236 | 245 |
} |
src/main/java/eu/etaxonomy/cdm/service/IRegistrationWorkingSetService.java | ||
---|---|---|
38 | 38 |
* @param id the CDM Entity id |
39 | 39 |
* @return |
40 | 40 |
* @throws RegistrationValidationException |
41 |
* @deprecated use other method working sets should only be addressed by the referenceID |
|
41 | 42 |
*/ |
43 |
@Deprecated |
|
42 | 44 |
public RegistrationWorkingSet loadWorkingSetByRegistrationID(Integer id) throws RegistrationValidationException; |
43 | 45 |
|
44 | 46 |
public static final String ACTIVE_IMPL = "registrationWorkingSetService"; |
45 | 47 |
|
48 |
/** |
|
49 |
* @param referenceID |
|
50 |
* @return |
|
51 |
*/ |
|
52 |
public RegistrationWorkingSet loadWorkingSetByReferenceID(Integer referenceID) throws RegistrationValidationException; |
|
53 |
|
|
46 | 54 |
} |
src/main/java/eu/etaxonomy/cdm/service/RegistrationWorkingSetService.java | ||
---|---|---|
97 | 97 |
return makeDTOs(pager.getRecords()); |
98 | 98 |
} |
99 | 99 |
|
100 |
/** |
|
101 |
* {@inheritDoc} |
|
102 |
* @throws RegistrationValidationException |
|
103 |
*/ |
|
104 |
@Override |
|
105 |
public RegistrationWorkingSet loadWorkingSetByReferenceID(Integer referenceID) throws RegistrationValidationException { |
|
106 |
Reference reference = repo.getReferenceService().find(referenceID); |
|
107 |
Pager<Registration> pager = repo.getRegistrationService().page(Optional.of(reference), null, null, null, null); |
|
108 |
return new RegistrationWorkingSet(makeDTOs(pager.getRecords())); |
|
109 |
} |
|
110 |
|
|
100 | 111 |
/** |
101 | 112 |
* @param id the CDM Entity id |
102 | 113 |
* @return |
103 | 114 |
* @throws RegistrationValidationException |
115 |
* @deprecated use other method working sets should only be addressed by the referenceID |
|
104 | 116 |
*/ |
117 |
@Deprecated |
|
105 | 118 |
@Override |
106 | 119 |
public RegistrationWorkingSet loadWorkingSetByRegistrationID(Integer id) throws RegistrationValidationException { |
107 | 120 |
|
108 | 121 |
RegistrationDTO dto = loadDtoById(id); |
109 |
|
|
110 | 122 |
Pager<Registration> pager = repo.getRegistrationService().page(Optional.of((Reference)dto.getCitation()), null, null, null, null); |
111 |
|
|
112 | 123 |
return new RegistrationWorkingSet(makeDTOs(pager.getRecords())); |
113 | 124 |
} |
114 | 125 |
|
... | ... | |
126 | 137 |
|
127 | 138 |
|
128 | 139 |
|
140 |
|
|
141 |
|
|
129 | 142 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.LABEL_NOWRAP; |
12 | 12 |
|
13 |
import java.util.Collection; |
|
14 |
|
|
13 | 15 |
import org.joda.time.DateTime; |
14 | 16 |
import org.joda.time.format.ISODateTimeFormat; |
15 | 17 |
|
... | ... | |
19 | 21 |
import com.vaadin.shared.ui.label.ContentMode; |
20 | 22 |
import com.vaadin.ui.Alignment; |
21 | 23 |
import com.vaadin.ui.Button; |
24 |
import com.vaadin.ui.Button.ClickListener; |
|
22 | 25 |
import com.vaadin.ui.CssLayout; |
23 | 26 |
import com.vaadin.ui.GridLayout; |
24 | 27 |
import com.vaadin.ui.Label; |
... | ... | |
75 | 78 |
private Label publishedLabel = new Label(); |
76 | 79 |
private Label releasedLabel = new Label(); |
77 | 80 |
|
78 |
private String citationString; |
|
79 |
// -------------------------------------------------- |
|
80 |
|
|
81 | 81 |
/** |
82 | 82 |
* |
83 | 83 |
*/ |
... | ... | |
154 | 154 |
public void setItem(RegistrationDTO regDto, AbstractView<?> parentView){ |
155 | 155 |
this.parentView = parentView; |
156 | 156 |
|
157 |
NavigationEvent openButtonEvent = new NavigationEvent(
|
|
157 |
NavigationEvent navigationEvent = new NavigationEvent(
|
|
158 | 158 |
RegistrationWorkflowViewBean.NAME, |
159 | 159 |
RegistrationWorkflowViewBean.ACTION_EDIT, |
160 | 160 |
Integer.toString(regDto.getId()) |
161 | 161 |
); |
162 | 162 |
|
163 | 163 |
updateUI(regDto.getBibliographicCitationString(), regDto.getCreated(), regDto.getDatePublished(), regDto.getMessages().size(), |
164 |
openButtonEvent, null, regDto);
|
|
164 |
navigationEvent, null, regDto);
|
|
165 | 165 |
} |
166 | 166 |
|
167 | 167 |
public void setWorkingSet(RegistrationWorkingSet workingSet, AbstractView<?> parentView){ |
168 | 168 |
this.parentView = parentView; |
169 |
ReferenceEditorAction openButtonEvent; |
|
169 |
|
|
170 |
ReferenceEditorAction referenceEditorAction; |
|
170 | 171 |
if(workingSet.getCitationId() != null){ |
171 |
openButtonEvent = new ReferenceEditorAction(Type.EDIT, workingSet.getCitationId());
|
|
172 |
referenceEditorAction = new ReferenceEditorAction(Type.EDIT, workingSet.getCitationId());
|
|
172 | 173 |
} else { |
173 |
openButtonEvent = new ReferenceEditorAction(Type.ADD);
|
|
174 |
referenceEditorAction = new ReferenceEditorAction(Type.ADD);
|
|
174 | 175 |
} |
175 | 176 |
TimePeriod datePublished = workingSet.getRegistrationDTOs().get(0).getDatePublished(); |
176 | 177 |
updateUI(workingSet.getCitation(), workingSet.getCreated(), datePublished, workingSet.messagesCount(), |
177 |
openButtonEvent, FontAwesome.EDIT, null);
|
|
178 |
referenceEditorAction, FontAwesome.EDIT, null);
|
|
178 | 179 |
} |
179 | 180 |
|
180 |
|
|
181 | 181 |
/** |
182 | 182 |
* |
183 | 183 |
*/ |
... | ... | |
217 | 217 |
if(openButtonEvent != null){ |
218 | 218 |
// Buttons |
219 | 219 |
getOpenButton().setVisible(true); |
220 |
Collection<?> removeCandidates = getOpenButton().getListeners(ClickListener.class); |
|
221 |
removeCandidates.forEach(l -> getOpenButton().removeClickListener((ClickListener)l)); |
|
220 | 222 |
getOpenButton().addClickListener(e -> publishEvent(openButtonEvent)); |
221 | 223 |
} |
222 | 224 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/event/EntityChangeEvent.java | ||
---|---|---|
21 | 21 |
REMOVED; |
22 | 22 |
} |
23 | 23 |
|
24 |
private Class<?> entityType; |
|
25 |
|
|
24 | 26 |
/** |
25 | 27 |
* @param type |
26 | 28 |
* @param entityId |
27 | 29 |
*/ |
28 |
public EntityChangeEvent(Type type, Integer entityId) {
|
|
30 |
public EntityChangeEvent(Class<?> entityType, Integer entityId, Type type) {
|
|
29 | 31 |
super(type, entityId); |
32 |
this.entityType = entityType; |
|
30 | 33 |
} |
31 | 34 |
|
35 |
/** |
|
36 |
* @return the entityType |
|
37 |
*/ |
|
38 |
public Class<?> getEntityType() { |
|
39 |
return entityType; |
|
40 |
} |
|
32 | 41 |
|
33 | 42 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import eu.etaxonomy.cdm.model.common.User; |
23 | 23 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus; |
24 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
24 | 25 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.Role; |
25 | 26 |
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService; |
27 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
|
26 | 28 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
27 | 29 |
import eu.etaxonomy.cdm.vaadin.security.RolesAndPermissions; |
28 | 30 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
... | ... | |
92 | 94 |
} |
93 | 95 |
} |
94 | 96 |
|
97 |
@EventListener |
|
98 |
public void onEntityChangeEvent(EntityChangeEvent event){ |
|
99 |
if(event.getEntityType().isAssignableFrom(Reference.class)){ |
|
100 |
// TODO update component showing the according reference, is there a Vaadin event supporting this? |
|
101 |
} |
|
102 |
|
|
103 |
} |
|
104 |
|
|
95 | 105 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowPresenter.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.cdm.model.reference.Reference; |
28 | 28 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
29 | 29 |
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService; |
30 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
|
30 | 31 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
31 | 32 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
32 | 33 |
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent; |
... | ... | |
76 | 77 |
} catch (RegistrationValidationException error) { |
77 | 78 |
getView().getWorkflow().setComponentError(new SystemError(error)); |
78 | 79 |
} |
80 |
getView().setWorkingset(workingset); |
|
79 | 81 |
} else { |
80 |
try { |
|
81 |
workingset = workingSetService.loadWorkingSetByRegistrationID(event.getRegistrationID()); |
|
82 |
} catch (RegistrationValidationException error) { |
|
83 |
getView().getWorkflow().setComponentError(new SystemError(error)); |
|
84 |
} |
|
85 |
getView().setHeaderText("Registration for " + workingset.getCitation()); |
|
82 |
Integer registrationID = event.getRegistrationID(); |
|
83 |
presentWorkingSetByRegID(registrationID); |
|
86 | 84 |
} |
87 |
if(workingset != null){ |
|
88 |
getView().setWorkingset(workingset); |
|
89 |
//TODO add Blocking registrations to view |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* @param registrationID |
|
90 |
* @deprecated use other method working sets should only be addressed by the referenceID |
|
91 |
*/ |
|
92 |
@Deprecated |
|
93 |
private void presentWorkingSetByRegID(Integer registrationID) { |
|
94 |
try { |
|
95 |
workingset = workingSetService.loadWorkingSetByRegistrationID(registrationID); |
|
96 |
} catch (RegistrationValidationException error) { |
|
97 |
getView().getWorkflow().setComponentError(new SystemError(error)); |
|
90 | 98 |
} |
99 |
getView().setHeaderText("Registration for " + workingset.getCitation()); |
|
100 |
getView().setWorkingset(workingset); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* @param registrationID |
|
105 |
*/ |
|
106 |
private void presentWorkingSet(Integer referenceID) { |
|
107 |
try { |
|
108 |
workingset = workingSetService.loadWorkingSetByReferenceID(referenceID); |
|
109 |
} catch (RegistrationValidationException error) { |
|
110 |
getView().getWorkflow().setComponentError(new SystemError(error)); |
|
111 |
} |
|
112 |
getView().setHeaderText("Registration for " + workingset.getCitation()); |
|
113 |
getView().setWorkingset(workingset); |
|
91 | 114 |
} |
92 | 115 |
|
93 | 116 |
@EventListener(condition = "#event.eventType ==T(eu.etaxonomy.cdm.vaadin.event.EntityEventType).ADD") |
... | ... | |
126 | 149 |
} |
127 | 150 |
} |
128 | 151 |
|
152 |
@EventListener |
|
153 |
public void onEntityChangeEvent(EntityChangeEvent event){ |
|
154 |
if(event.getEntityType().isAssignableFrom(Reference.class)){ |
|
155 |
if(workingset.getCitationId().equals(event.getEntityId())){ |
|
156 |
presentWorkingSet(event.getEntityId()); |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
} |
|
161 |
|
|
129 | 162 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmEditorPresenter.java | ||
---|---|---|
17 | 17 |
import com.vaadin.data.util.BeanItem; |
18 | 18 |
|
19 | 19 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
20 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
|
21 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent.Type; |
|
20 | 22 |
|
21 | 23 |
/** |
22 | 24 |
* @author a.kohlbecker |
... | ... | |
46 | 48 |
// the bean is now updated with the changes made by the user |
47 | 49 |
// merge the bean into the session, ... |
48 | 50 |
DTO bean = mergedBean(saveEvent.getCommitEvent()); |
51 |
Type changeEventType; |
|
52 |
if(bean.getId() > 1){ |
|
53 |
changeEventType = Type.MODIFIED; |
|
54 |
} else { |
|
55 |
changeEventType = Type.CREATED; |
|
56 |
} |
|
49 | 57 |
getRepo().getCommonService().saveOrUpdate(bean); |
50 | 58 |
getSession().flush(); |
51 | 59 |
getRepo().commitTransaction(tx); |
52 | 60 |
tx = null; |
61 |
eventBus.publishEvent(new EntityChangeEvent(bean.getClass(), bean.getId(), changeEventType)); |
|
53 | 62 |
} |
54 | 63 |
|
55 | 64 |
/** |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractEditorPresenter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.vaadin.mvp; |
10 | 10 |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
import org.springframework.context.ApplicationEventPublisher; |
|
11 | 13 |
import org.springframework.context.event.EventListener; |
12 | 14 |
|
13 | 15 |
import com.vaadin.data.fieldgroup.BeanFieldGroup; |
... | ... | |
22 | 24 |
|
23 | 25 |
private static final long serialVersionUID = -6677074110764145236L; |
24 | 26 |
|
27 |
@Autowired |
|
28 |
protected ApplicationEventPublisher eventBus; |
|
29 |
|
|
25 | 30 |
@EventListener |
26 | 31 |
public void onEditorPreSaveEvent(EditorPreSaveEvent preSaveEvent){ |
27 | 32 |
|
Also available in: Unified diff
ref #6612 updating UI components on modified References