import org.eclipse.ui.actions.CompoundContributionItem;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
if(derivateView.isListenToSelectionChange()){
Object selectionInput = derivateView.getSelectionInput();
if(selectionInput instanceof CdmBase && ((CdmBase) selectionInput).isInstanceOf(Taxon.class)){
- final Taxon taxon = HibernateProxyHelper.deproxy(selectionInput, Taxon.class);
+ final Taxon taxon = HibernateProxyHelper.deproxy(CdmStore.getService(ITaxonService.class).load(((CdmBase)selectionInput).getUuid()), Taxon.class);
MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText("Create FieldUnit for "+taxon.getName());
item.addSelectionListener(new SelectionAdapter() {
MessagingUtils.warningDialog(DerivateView.VIEW_HAS_UNSAVED_CHANGES, this, DerivateView.YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION);
return;
}
+
FieldUnit fieldUnit = FieldUnit.NewInstance();
fieldUnit = CdmBase.deproxy(CdmStore.getService(IOccurrenceService.class).save(fieldUnit), FieldUnit.class);
IndividualsAssociation association = IndividualsAssociation.NewInstance(fieldUnit);
description = TaxonDescription.NewInstance(taxon);
}
description.addElement(association);
+ if(CdmStore.getCurrentSessionManager().isRemoting()){
+ CdmStore.getService(ITaxonService.class).merge(taxon);
+ }
+ else{
+ CdmStore.getService(ITaxonService.class).saveOrUpdate(taxon);
+ }
derivateView.getConversationHolder().commit();
derivateView.addFieldUnit(fieldUnit);