Project

General

Profile

Download (2.61 KB) Statistics
| Branch: | Tag: | Revision:
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 eu.etaxonomy.cdm.api.service.IRegistrationService;
12
import eu.etaxonomy.cdm.model.agent.Institution;
13
import eu.etaxonomy.cdm.model.common.User;
14
import eu.etaxonomy.cdm.model.name.Registration;
15
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
16
import eu.etaxonomy.cdm.vaadin.security.UserHelper;
17
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
18

    
19
/**
20
 * @author a.kohlbecker
21
 * @since May 15, 2017
22
 *
23
 */
24
public class RegistrationEditorPresenter extends AbstractCdmEditorPresenter<Registration, RegistrationPopEditorView> {
25

    
26
    private static final long serialVersionUID = 6930557602995331944L;
27

    
28
    /**
29
     * {@inheritDoc}
30
     */
31
    @Override
32
    protected IRegistrationService getService() {
33
        return getRepo().getRegistrationService();
34
    }
35

    
36
    /**
37
     * {@inheritDoc}
38
     */
39
    @Override
40
    protected Registration loadCdmEntityById(Integer identifier) {
41

    
42
        Registration reg;
43
        if(identifier != null){
44
            reg = getRepo().getRegistrationService().find(identifier);
45
        } else {
46
            reg = Registration.NewInstance();
47
        }
48
        return reg;
49
    }
50

    
51
    /**
52
     * {@inheritDoc}
53
     */
54
    @Override
55
    protected void guaranteePerEntityCRUDPermissions(Integer identifier) {
56
        if(crud != null){
57
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, identifier, crud, null);
58
        }
59

    
60
    }
61

    
62
    /**
63
     * {@inheritDoc}
64
     */
65
    @Override
66
    protected void guaranteePerEntityCRUDPermissions(Registration bean) {
67
        if(crud != null){
68
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
69
        }
70
    }
71

    
72
    /**
73
     * {@inheritDoc}
74
     */
75
    @Override
76
    public void handleViewEntered() {
77
        super.handleViewEntered();
78

    
79
        CdmBeanItemContainerFactory selectFieldFactory = new CdmBeanItemContainerFactory(getRepo());
80

    
81
        getView().getInstitutionField().setContainerDataSource(selectFieldFactory.buildBeanItemContainer(Institution.class));
82
        getView().getInstitutionField().setItemCaptionPropertyId("titleCache");
83

    
84
        getView().getSubmitterField().setContainerDataSource(selectFieldFactory.buildBeanItemContainer(User.class));
85
        getView().getSubmitterField().setItemCaptionPropertyId("username");
86
    }
87

    
88

    
89

    
90
}
(6-6/19)