private static final long serialVersionUID = -1996365248431425021L;
-
/**
* {@inheritDoc}
*/
if(identifier != null){
bean = (Institution) getRepo().getAgentService().load(identifier, initStrategy);
} else {
- bean = Institution.NewInstance();
+ bean = cdmEntityInstantiator.createNewBean();
}
return bean;
}
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
import eu.etaxonomy.vaadin.mvp.AbstractView;
+import eu.etaxonomy.vaadin.mvp.BeanInstantiator;
import eu.etaxonomy.vaadin.mvp.BoundField;
import eu.etaxonomy.vaadin.ui.view.PopupView;
private TaxonName typifiedNameInContext;
+ protected static BeanInstantiator<NameTypeDesignation> defaultBeanInstantiator = new BeanInstantiator<NameTypeDesignation>() {
+
+ @Override
+ public NameTypeDesignation createNewBean() {
+ return NameTypeDesignation.NewInstance();
+ }
+ };
+
+
+ @Override
+ protected BeanInstantiator<NameTypeDesignation> defaultBeanInstantiator(){
+ return defaultBeanInstantiator;
+ }
/**
* {@inheritDoc}
if(uuid != null){
typeDesignation = (NameTypeDesignation) getRepo().getNameService().loadTypeDesignation(uuid, initStrategy);
} else {
- if(beanInstantiator != null){
- typeDesignation = beanInstantiator.createNewBean();
- } else {
- typeDesignation = NameTypeDesignation.NewInstance();
- }
+ typeDesignation = createNewBean();
}
typifiedNamesAsLoaded = new HashSet<>(typeDesignation.getTypifiedNames());
if(identifier != null){
taxonName = getRepo().getNameService().load(identifier, initStrategy);
} else {
- taxonName = TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
+ if(cdmEntityInstantiator != null) {
+ taxonName = cdmEntityInstantiator.createNewBean();
+ } else {
+ taxonName = TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
+ }
}
if(getView().isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY)){
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
import eu.etaxonomy.cdm.vaadin.view.common.InstitutionPopupEditor;
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
+import eu.etaxonomy.vaadin.mvp.BeanInstantiator;
import eu.etaxonomy.vaadin.mvp.BoundField;
import eu.etaxonomy.vaadin.ui.view.PopupView;
private static final long serialVersionUID = -1996365248431425021L;
+ protected static BeanInstantiator<Collection> defaultBeanInstantiator = new BeanInstantiator<Collection>() {
+
+ @Override
+ public Collection createNewBean() {
+ return Collection.NewInstance();
+ }
+ };
+
+
+ @Override
+ protected BeanInstantiator<Collection> defaultBeanInstantiator(){
+ return defaultBeanInstantiator;
+ }
/**
* {@inheritDoc}
if(identifier != null){
bean = getRepo().getCollectionService().load(identifier, initStrategy);
} else {
- bean = Collection.NewInstance();
+ bean = createNewBean();
}
return bean;
}
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityField;
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
+import eu.etaxonomy.vaadin.mvp.BeanInstantiator;
/**
* @author a.kohlbecker
AnnotationType.EDITORIAL().getUuid(), AnnotationType.TECHNICAL().getUuid()));
}
+
+ protected static BeanInstantiator<Reference> defaultBeanInstantiator = new BeanInstantiator<Reference>() {
+
+ @Override
+ public Reference createNewBean() {
+ return ReferenceFactory.newGeneric();
+ }
+ };
+
+
+ @Override
+ protected BeanInstantiator<Reference> defaultBeanInstantiator(){
+ return defaultBeanInstantiator;
+ }
+
+
/**
* {@inheritDoc}
*/
if(identifier != null){
reference = getRepo().getReferenceService().load(identifier, initStrategy);
} else {
- reference = createNewReference();
+ reference = createNewBean();
}
return reference;
}
- /**
- * TODO this should better go into {@link AbstractCdmEditorPresenter}
- *
- * @return
- */
- protected Reference createNewReference() {
- if(this.beanInstantiator != null){
- return beanInstantiator.createNewBean();
- }
- return ReferenceFactory.newGeneric();
- }
/**
* {@inheritDoc}
import eu.etaxonomy.cdm.service.UserHelperAccess;
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
+import eu.etaxonomy.vaadin.mvp.BeanInstantiator;
/**
* @author a.kohlbecker
return getRepo().getRegistrationService();
}
+
+ protected static BeanInstantiator<Registration> defaultBeanInstantiator = new BeanInstantiator<Registration>() {
+
+ @Override
+ public Registration createNewBean() {
+ return Registration.NewInstance();
+ }
+ };
+
+
+ @Override
+ protected BeanInstantiator<Registration> defaultBeanInstantiator(){
+ return defaultBeanInstantiator;
+ }
+
/**
* {@inheritDoc}
*/
List<String> initStrategy = Arrays.asList(new String[] {"$", "typeDesignations"});
reg = getRepo().getRegistrationService().load(identifier, initStrategy );
} else {
- reg = Registration.NewInstance();
+ reg = createNewBean();
}
return reg;
}
*/
@Override
protected void saveBean(RegistrationDTO bean) {
- // TODO Auto-generated method stub
-
+ // not needed //
}
/**
*/
@Override
protected void deleteBean(RegistrationDTO bean) {
- // TODO Auto-generated method stub
-
+ // not needed //
}
}
private static final long serialVersionUID = -6315824180341694825L;
+ protected BeanInstantiator<CDM> cdmEntityInstantiator = null;
+
+ @Override
+ protected BeanInstantiator<DTO> defaultBeanInstantiator(){
+ // not needed in the AbstractCdmDTOEditorPresenter since replaced by cdmEntityInstantiator
+ return null;
+ }
+
@Override
protected CDM cdmEntity(DTO dto) {
}
+ /**
+ * @param cdmEntityInstantiator the cdmEntityInstantiator to set
+ */
+ public void setCdmEntityInstantiator(BeanInstantiator<CDM> cdmEntityInstantiator) {
+ this.cdmEntityInstantiator = cdmEntityInstantiator;
+ }
+
+
}
\ No newline at end of file
getPresenter().setGrantsForCurrentUser(crud);
}
-
-
}
FlushMode previousPreSaveEvenFlushMode = null;
- protected BeanInstantiator<DTO> beanInstantiator = null;
-
/**
* Load the bean to be edited in the editor freshly from the persistent storage.
* Ore create an new empty instance in case the supplied <code>identifier</code> is <code>null</code>.
}
- /**
- * @param beanInstantiator the beanInstantiator to set
- */
- public void setBeanInstantiator(BeanInstantiator<DTO> beanInstantiator) {
- this.beanInstantiator = beanInstantiator;
- }
@EventBusListenerMethod
public void onEditorPreSaveEvent(EditorPreSaveEvent<DTO> preSaveEvent){
* @param beanInstantiator
*/
public final void setBeanInstantiator(BeanInstantiator<DTO> beanInstantiator) {
- getPresenter().setBeanInstantiator(beanInstantiator);
+ if(AbstractCdmEditorPresenter.class.isAssignableFrom(getPresenter().getClass())){
+ ((CdmEditorPresenterBase)getPresenter()).setBeanInstantiator(beanInstantiator);
+ } else {
+ throw new RuntimeException("BeanInstantiator can only be set for popup editors with a peresenter of the type CdmEditorPresenterBase");
+ }
}
/**
private static final Logger logger = Logger.getLogger(CdmEditorPresenterBase.class);
+ protected BeanInstantiator<DTO> beanInstantiator = null;
+
+
+ /**
+ * @param beanInstantiator the beanInstantiator to set
+ */
+ public void setBeanInstantiator(BeanInstantiator<DTO> beanInstantiator) {
+ this.beanInstantiator = beanInstantiator;
+ }
+
+
+ protected DTO createNewBean() {
+ if(this.beanInstantiator != null){
+ return beanInstantiator.createNewBean();
+ }
+ return defaultBeanInstantiator().createNewBean();
+ }
+
+ /**
+ * @return
+ */
+ protected abstract BeanInstantiator<DTO> defaultBeanInstantiator();
+
/**
* if not null, this CRUD set is to be used to create a CdmAuthoritiy for the base entity which will be
* granted to the current use as long this grant is not assigned yet.