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