Project

General

Profile

Revision 5791a9f1

ID5791a9f15472523ac1555a8a24892a7ea847e216
Parent 0748ebca
Child ece99302

Added by Andreas Kohlbecker about 4 years ago

ref #6724 converter to deproxy hibernate beans

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java
23 23
import eu.etaxonomy.cdm.model.agent.Team;
24 24
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
25 25
import eu.etaxonomy.cdm.vaadin.security.UserHelper;
26
import eu.etaxonomy.cdm.vaadin.util.converter.CdmBaseDeproxyConverter;
26 27
import eu.etaxonomy.vaadin.component.CompositeCustomField;
27 28
import eu.etaxonomy.vaadin.component.SwitchableTextField;
28 29
import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesListSelect;
......
73 74
        addSizedComponent(titleField);
74 75
        addSizedComponent(nomenclaturalTitleField);
75 76
        addSizedComponent(personsListEditor);
77

  
78
        setConverter(new CdmBaseDeproxyConverter<TeamOrPersonBase<?>>());
76 79
    }
77 80

  
78 81
    /**
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/CdmBaseDeproxyConverter.java
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
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetPopupEditor.java
147 147

  
148 148
        row++;
149 149

  
150
        // FIXME: can we use the Grid instaed?
150
        // FIXME: can we use the Grid instead?
151 151
        typeDesignationsCollectionField = new ElementCollectionField<>(
152 152
                SpecimenTypeDesignationDTO.class,
153 153
                SpecimenTypeDesignationDTORow.class

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)