Revision 6d636c9e
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/common/InstitutionEditorPresenter.java | ||
---|---|---|
43 | 43 |
|
44 | 44 |
private static final long serialVersionUID = -1996365248431425021L; |
45 | 45 |
|
46 |
|
|
47 | 46 |
/** |
48 | 47 |
* {@inheritDoc} |
49 | 48 |
*/ |
... | ... | |
62 | 61 |
if(identifier != null){ |
63 | 62 |
bean = (Institution) getRepo().getAgentService().load(identifier, initStrategy); |
64 | 63 |
} else { |
65 |
bean = Institution.NewInstance();
|
|
64 |
bean = cdmEntityInstantiator.createNewBean();
|
|
66 | 65 |
} |
67 | 66 |
return bean; |
68 | 67 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java | ||
---|---|---|
46 | 46 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
47 | 47 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
48 | 48 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
49 |
import eu.etaxonomy.vaadin.mvp.BeanInstantiator; |
|
49 | 50 |
import eu.etaxonomy.vaadin.mvp.BoundField; |
50 | 51 |
import eu.etaxonomy.vaadin.ui.view.PopupView; |
51 | 52 |
|
... | ... | |
66 | 67 |
|
67 | 68 |
private TaxonName typifiedNameInContext; |
68 | 69 |
|
70 |
protected static BeanInstantiator<NameTypeDesignation> defaultBeanInstantiator = new BeanInstantiator<NameTypeDesignation>() { |
|
71 |
|
|
72 |
@Override |
|
73 |
public NameTypeDesignation createNewBean() { |
|
74 |
return NameTypeDesignation.NewInstance(); |
|
75 |
} |
|
76 |
}; |
|
77 |
|
|
78 |
|
|
79 |
@Override |
|
80 |
protected BeanInstantiator<NameTypeDesignation> defaultBeanInstantiator(){ |
|
81 |
return defaultBeanInstantiator; |
|
82 |
} |
|
69 | 83 |
|
70 | 84 |
/** |
71 | 85 |
* {@inheritDoc} |
... | ... | |
113 | 127 |
if(uuid != null){ |
114 | 128 |
typeDesignation = (NameTypeDesignation) getRepo().getNameService().loadTypeDesignation(uuid, initStrategy); |
115 | 129 |
} else { |
116 |
if(beanInstantiator != null){ |
|
117 |
typeDesignation = beanInstantiator.createNewBean(); |
|
118 |
} else { |
|
119 |
typeDesignation = NameTypeDesignation.NewInstance(); |
|
120 |
} |
|
130 |
typeDesignation = createNewBean(); |
|
121 | 131 |
} |
122 | 132 |
|
123 | 133 |
typifiedNamesAsLoaded = new HashSet<>(typeDesignation.getTypifiedNames()); |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java | ||
---|---|---|
217 | 217 |
if(identifier != null){ |
218 | 218 |
taxonName = getRepo().getNameService().load(identifier, initStrategy); |
219 | 219 |
} else { |
220 |
taxonName = TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES()); |
|
220 |
if(cdmEntityInstantiator != null) { |
|
221 |
taxonName = cdmEntityInstantiator.createNewBean(); |
|
222 |
} else { |
|
223 |
taxonName = TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES()); |
|
224 |
} |
|
221 | 225 |
} |
222 | 226 |
|
223 | 227 |
if(getView().isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY)){ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/occurrence/CollectionEditorPresenter.java | ||
---|---|---|
33 | 33 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader; |
34 | 34 |
import eu.etaxonomy.cdm.vaadin.view.common.InstitutionPopupEditor; |
35 | 35 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
36 |
import eu.etaxonomy.vaadin.mvp.BeanInstantiator; |
|
36 | 37 |
import eu.etaxonomy.vaadin.mvp.BoundField; |
37 | 38 |
import eu.etaxonomy.vaadin.ui.view.PopupView; |
38 | 39 |
|
... | ... | |
47 | 48 |
|
48 | 49 |
private static final long serialVersionUID = -1996365248431425021L; |
49 | 50 |
|
51 |
protected static BeanInstantiator<Collection> defaultBeanInstantiator = new BeanInstantiator<Collection>() { |
|
52 |
|
|
53 |
@Override |
|
54 |
public Collection createNewBean() { |
|
55 |
return Collection.NewInstance(); |
|
56 |
} |
|
57 |
}; |
|
58 |
|
|
59 |
|
|
60 |
@Override |
|
61 |
protected BeanInstantiator<Collection> defaultBeanInstantiator(){ |
|
62 |
return defaultBeanInstantiator; |
|
63 |
} |
|
50 | 64 |
|
51 | 65 |
/** |
52 | 66 |
* {@inheritDoc} |
... | ... | |
66 | 80 |
if(identifier != null){ |
67 | 81 |
bean = getRepo().getCollectionService().load(identifier, initStrategy); |
68 | 82 |
} else { |
69 |
bean = Collection.NewInstance();
|
|
83 |
bean = createNewBean();
|
|
70 | 84 |
} |
71 | 85 |
return bean; |
72 | 86 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java | ||
---|---|---|
37 | 37 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader; |
38 | 38 |
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityField; |
39 | 39 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
40 |
import eu.etaxonomy.vaadin.mvp.BeanInstantiator; |
|
40 | 41 |
|
41 | 42 |
/** |
42 | 43 |
* @author a.kohlbecker |
... | ... | |
89 | 90 |
AnnotationType.EDITORIAL().getUuid(), AnnotationType.TECHNICAL().getUuid())); |
90 | 91 |
} |
91 | 92 |
|
93 |
|
|
94 |
protected static BeanInstantiator<Reference> defaultBeanInstantiator = new BeanInstantiator<Reference>() { |
|
95 |
|
|
96 |
@Override |
|
97 |
public Reference createNewBean() { |
|
98 |
return ReferenceFactory.newGeneric(); |
|
99 |
} |
|
100 |
}; |
|
101 |
|
|
102 |
|
|
103 |
@Override |
|
104 |
protected BeanInstantiator<Reference> defaultBeanInstantiator(){ |
|
105 |
return defaultBeanInstantiator; |
|
106 |
} |
|
107 |
|
|
108 |
|
|
92 | 109 |
/** |
93 | 110 |
* {@inheritDoc} |
94 | 111 |
*/ |
... | ... | |
106 | 123 |
if(identifier != null){ |
107 | 124 |
reference = getRepo().getReferenceService().load(identifier, initStrategy); |
108 | 125 |
} else { |
109 |
reference = createNewReference();
|
|
126 |
reference = createNewBean();
|
|
110 | 127 |
} |
111 | 128 |
return reference; |
112 | 129 |
} |
113 | 130 |
|
114 |
/** |
|
115 |
* TODO this should better go into {@link AbstractCdmEditorPresenter} |
|
116 |
* |
|
117 |
* @return |
|
118 |
*/ |
|
119 |
protected Reference createNewReference() { |
|
120 |
if(this.beanInstantiator != null){ |
|
121 |
return beanInstantiator.createNewBean(); |
|
122 |
} |
|
123 |
return ReferenceFactory.newGeneric(); |
|
124 |
} |
|
125 | 131 |
|
126 | 132 |
/** |
127 | 133 |
* {@inheritDoc} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationEditorPresenter.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.service.UserHelperAccess; |
24 | 24 |
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory; |
25 | 25 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
26 |
import eu.etaxonomy.vaadin.mvp.BeanInstantiator; |
|
26 | 27 |
|
27 | 28 |
/** |
28 | 29 |
* @author a.kohlbecker |
... | ... | |
43 | 44 |
return getRepo().getRegistrationService(); |
44 | 45 |
} |
45 | 46 |
|
47 |
|
|
48 |
protected static BeanInstantiator<Registration> defaultBeanInstantiator = new BeanInstantiator<Registration>() { |
|
49 |
|
|
50 |
@Override |
|
51 |
public Registration createNewBean() { |
|
52 |
return Registration.NewInstance(); |
|
53 |
} |
|
54 |
}; |
|
55 |
|
|
56 |
|
|
57 |
@Override |
|
58 |
protected BeanInstantiator<Registration> defaultBeanInstantiator(){ |
|
59 |
return defaultBeanInstantiator; |
|
60 |
} |
|
61 |
|
|
46 | 62 |
/** |
47 | 63 |
* {@inheritDoc} |
48 | 64 |
*/ |
... | ... | |
54 | 70 |
List<String> initStrategy = Arrays.asList(new String[] {"$", "typeDesignations"}); |
55 | 71 |
reg = getRepo().getRegistrationService().load(identifier, initStrategy ); |
56 | 72 |
} else { |
57 |
reg = Registration.NewInstance();
|
|
73 |
reg = createNewBean();
|
|
58 | 74 |
} |
59 | 75 |
return reg; |
60 | 76 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java | ||
---|---|---|
199 | 199 |
*/ |
200 | 200 |
@Override |
201 | 201 |
protected void saveBean(RegistrationDTO bean) { |
202 |
// TODO Auto-generated method stub |
|
203 |
|
|
202 |
// not needed // |
|
204 | 203 |
} |
205 | 204 |
|
206 | 205 |
/** |
... | ... | |
208 | 207 |
*/ |
209 | 208 |
@Override |
210 | 209 |
protected void deleteBean(RegistrationDTO bean) { |
211 |
// TODO Auto-generated method stub |
|
212 |
|
|
210 |
// not needed // |
|
213 | 211 |
} |
214 | 212 |
|
215 | 213 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmDTOEditorPresenter.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
private static final long serialVersionUID = -6315824180341694825L; |
25 | 25 |
|
26 |
protected BeanInstantiator<CDM> cdmEntityInstantiator = null; |
|
27 |
|
|
28 |
@Override |
|
29 |
protected BeanInstantiator<DTO> defaultBeanInstantiator(){ |
|
30 |
// not needed in the AbstractCdmDTOEditorPresenter since replaced by cdmEntityInstantiator |
|
31 |
return null; |
|
32 |
} |
|
33 |
|
|
26 | 34 |
|
27 | 35 |
@Override |
28 | 36 |
protected CDM cdmEntity(DTO dto) { |
... | ... | |
30 | 38 |
} |
31 | 39 |
|
32 | 40 |
|
41 |
/** |
|
42 |
* @param cdmEntityInstantiator the cdmEntityInstantiator to set |
|
43 |
*/ |
|
44 |
public void setCdmEntityInstantiator(BeanInstantiator<CDM> cdmEntityInstantiator) { |
|
45 |
this.cdmEntityInstantiator = cdmEntityInstantiator; |
|
46 |
} |
|
47 |
|
|
48 |
|
|
33 | 49 |
|
34 | 50 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractCdmPopupEditor.java | ||
---|---|---|
39 | 39 |
getPresenter().setGrantsForCurrentUser(crud); |
40 | 40 |
} |
41 | 41 |
|
42 |
|
|
43 |
|
|
44 | 42 |
} |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractEditorPresenter.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
FlushMode previousPreSaveEvenFlushMode = null; |
44 | 44 |
|
45 |
protected BeanInstantiator<DTO> beanInstantiator = null; |
|
46 |
|
|
47 | 45 |
/** |
48 | 46 |
* Load the bean to be edited in the editor freshly from the persistent storage. |
49 | 47 |
* Ore create an new empty instance in case the supplied <code>identifier</code> is <code>null</code>. |
... | ... | |
63 | 61 |
|
64 | 62 |
} |
65 | 63 |
|
66 |
/** |
|
67 |
* @param beanInstantiator the beanInstantiator to set |
|
68 |
*/ |
|
69 |
public void setBeanInstantiator(BeanInstantiator<DTO> beanInstantiator) { |
|
70 |
this.beanInstantiator = beanInstantiator; |
|
71 |
} |
|
72 | 64 |
|
73 | 65 |
@EventBusListenerMethod |
74 | 66 |
public void onEditorPreSaveEvent(EditorPreSaveEvent<DTO> preSaveEvent){ |
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java | ||
---|---|---|
742 | 742 |
* @param beanInstantiator |
743 | 743 |
*/ |
744 | 744 |
public final void setBeanInstantiator(BeanInstantiator<DTO> beanInstantiator) { |
745 |
getPresenter().setBeanInstantiator(beanInstantiator); |
|
745 |
if(AbstractCdmEditorPresenter.class.isAssignableFrom(getPresenter().getClass())){ |
|
746 |
((CdmEditorPresenterBase)getPresenter()).setBeanInstantiator(beanInstantiator); |
|
747 |
} else { |
|
748 |
throw new RuntimeException("BeanInstantiator can only be set for popup editors with a peresenter of the type CdmEditorPresenterBase"); |
|
749 |
} |
|
746 | 750 |
} |
747 | 751 |
|
748 | 752 |
/** |
src/main/java/eu/etaxonomy/vaadin/mvp/CdmEditorPresenterBase.java | ||
---|---|---|
48 | 48 |
|
49 | 49 |
private static final Logger logger = Logger.getLogger(CdmEditorPresenterBase.class); |
50 | 50 |
|
51 |
protected BeanInstantiator<DTO> beanInstantiator = null; |
|
52 |
|
|
53 |
|
|
54 |
/** |
|
55 |
* @param beanInstantiator the beanInstantiator to set |
|
56 |
*/ |
|
57 |
public void setBeanInstantiator(BeanInstantiator<DTO> beanInstantiator) { |
|
58 |
this.beanInstantiator = beanInstantiator; |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
protected DTO createNewBean() { |
|
63 |
if(this.beanInstantiator != null){ |
|
64 |
return beanInstantiator.createNewBean(); |
|
65 |
} |
|
66 |
return defaultBeanInstantiator().createNewBean(); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* @return |
|
71 |
*/ |
|
72 |
protected abstract BeanInstantiator<DTO> defaultBeanInstantiator(); |
|
73 |
|
|
51 | 74 |
/** |
52 | 75 |
* if not null, this CRUD set is to be used to create a CdmAuthoritiy for the base entity which will be |
53 | 76 |
* granted to the current use as long this grant is not assigned yet. |
Also available in: Unified diff
ref #7648 generalizing bean instantiation in cdm presenters