Project

General

Profile

Download (1.6 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.util.converter;
10

    
11

    
12
import java.util.Locale;
13

    
14
import com.vaadin.data.util.converter.Converter;
15

    
16
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
17
import eu.etaxonomy.cdm.model.common.CdmBase;
18

    
19
/**
20
 * Converter which cares for deproxing hibernate proxy beans
21
 *
22
 * @author a.kohlbecker
23
 * @since Jul 11, 2017
24
 *
25
 */
26
public class CdmBaseDeproxyConverter<MODEL extends CdmBase> implements Converter<MODEL, MODEL> {
27

    
28
    private static final long serialVersionUID = 1565836754627309870L;
29

    
30
    /**
31
     * {@inheritDoc}
32
     */
33
    @Override
34
    public MODEL convertToModel(MODEL value, Class<? extends MODEL> targetType, Locale locale)
35
            throws com.vaadin.data.util.converter.Converter.ConversionException {
36
        return value;
37
    }
38

    
39
    /**
40
     * {@inheritDoc}
41
     */
42
    @Override
43
    public MODEL convertToPresentation(MODEL value, Class<? extends MODEL> targetType, Locale locale)
44
            throws com.vaadin.data.util.converter.Converter.ConversionException {
45
        return HibernateProxyHelper.deproxy(value, targetType);
46
    }
47

    
48
    /**
49
     * {@inheritDoc}
50
     */
51
    @Override
52
    public Class<MODEL> getModelType() {
53
        return (Class<MODEL>)CdmBase.class;
54
    }
55

    
56
    /**
57
     * {@inheritDoc}
58
     */
59
    @Override
60
    public Class<MODEL> getPresentationType() {
61
        return (Class<MODEL>)CdmBase.class;
62
    }
63

    
64
}
(1-1/7)