1
|
/**
|
2
|
* Copyright (C) 2017 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.view.registration;
|
10
|
|
11
|
import java.util.Arrays;
|
12
|
import java.util.List;
|
13
|
|
14
|
import eu.etaxonomy.cdm.api.service.IRegistrationService;
|
15
|
import eu.etaxonomy.cdm.model.agent.Institution;
|
16
|
import eu.etaxonomy.cdm.model.common.User;
|
17
|
import eu.etaxonomy.cdm.model.name.Registration;
|
18
|
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
|
19
|
import eu.etaxonomy.cdm.vaadin.security.UserHelper;
|
20
|
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
|
21
|
|
22
|
/**
|
23
|
* @author a.kohlbecker
|
24
|
* @since May 15, 2017
|
25
|
*
|
26
|
*/
|
27
|
public class RegistrationEditorPresenter extends AbstractCdmEditorPresenter<Registration, RegistrationPopEditorView> {
|
28
|
|
29
|
private static final long serialVersionUID = 6930557602995331944L;
|
30
|
|
31
|
/**
|
32
|
* {@inheritDoc}
|
33
|
*/
|
34
|
@Override
|
35
|
protected IRegistrationService getService() {
|
36
|
return getRepo().getRegistrationService();
|
37
|
}
|
38
|
|
39
|
/**
|
40
|
* {@inheritDoc}
|
41
|
*/
|
42
|
@Override
|
43
|
protected Registration loadCdmEntityById(Integer identifier) {
|
44
|
|
45
|
Registration reg;
|
46
|
if(identifier != null){
|
47
|
List<String> initStrategy = Arrays.asList(new String[] {"$"});
|
48
|
reg = getRepo().getRegistrationService().load(identifier, initStrategy );
|
49
|
} else {
|
50
|
reg = Registration.NewInstance();
|
51
|
}
|
52
|
return reg;
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* {@inheritDoc}
|
57
|
*/
|
58
|
@Override
|
59
|
protected void guaranteePerEntityCRUDPermissions(Integer identifier) {
|
60
|
if(crud != null){
|
61
|
newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, identifier, crud, null);
|
62
|
}
|
63
|
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* {@inheritDoc}
|
68
|
*/
|
69
|
@Override
|
70
|
protected void guaranteePerEntityCRUDPermissions(Registration bean) {
|
71
|
if(crud != null){
|
72
|
newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
|
73
|
}
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* {@inheritDoc}
|
78
|
*/
|
79
|
@Override
|
80
|
public void handleViewEntered() {
|
81
|
super.handleViewEntered();
|
82
|
|
83
|
CdmBeanItemContainerFactory selectFieldFactory = new CdmBeanItemContainerFactory(getRepo());
|
84
|
|
85
|
getView().getInstitutionField().setContainerDataSource(selectFieldFactory.buildBeanItemContainer(Institution.class));
|
86
|
getView().getInstitutionField().setItemCaptionPropertyId("titleCache");
|
87
|
|
88
|
getView().getSubmitterField().setContainerDataSource(selectFieldFactory.buildBeanItemContainer(User.class));
|
89
|
getView().getSubmitterField().setItemCaptionPropertyId("username");
|
90
|
}
|
91
|
|
92
|
|
93
|
|
94
|
}
|