CdmFormFactory formFactory = selectionElement.getFormFactory();
CdmBase entity = (CdmBase) HibernateProxyHelper
.deproxy(selectionElement.getEntity());
- IService<CdmBase> service = CdmStore.getService(entity);
- rootElement = service.load(entity.getUuid());
+ //check if entity has already been persisted
+ if(entity.getId()==0){
+ rootElement = entity;
+ }
+ else{
+ IService<CdmBase> service = CdmStore.getService(entity);
+ rootElement = service.load(entity.getUuid());
+ }
if (rootElement.isInstanceOf(Reference.class)) {
addPage(new ReferenceWizardPage(formFactory,
selectionElement.getConversationHolder(),
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
-
- IService<T> service = CdmStore.getService(entity);
- T loadedEntity = service.load(entity.getUuid());
- if (loadedEntity==null){
- MessageDialog.openInformation(null,"Save changes", "You have made changes that must be saved before this query can be executed");
- return;
- }
WizardDialog dialog = new WizardDialog(selectionElement.getShell(),
new EditFromSelectionWizard(selectionElement));
if (dialog.open() == IStatus.OK) {
-
selectionElement.updateFromWizard();
+ //if the edited entity has already been persisted
+ //but the transient entity is still set in this
+ //EntitySelectionElement, re-load it and set it
+ IService<T> service = CdmStore.getService(entity);
+ if(entity.getId()==0){
+ T loadedEntity = service.load(entity.getUuid());
+ if(loadedEntity!=null){
+ setEntity(loadedEntity);
+ }
+ }
}
}
}