#5242, #5223 Improve performance of derivate loading and editing
authorCherian Mathew <c.mathew@bgbm.org>
Mon, 14 Sep 2015 14:21:43 +0000 (16:21 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Mon, 14 Sep 2015 14:21:43 +0000 (16:21 +0200)
12 files changed:
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/CdmAuthorityEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/AbstractIdentificationEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateViewEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/CreateFieldUnitHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/CdmEntitySessionInput.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/LanguageStringWithLabelElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitGeneralDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateContentProvider.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateLabelProvider.java

index 664035344691867fae48a1e4a3e91aab11ef56a9..150e3b1aac446277e6e8b579bd454626221ae664 100644 (file)
@@ -60,7 +60,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> extends CdmEnt
        private static Class serviceClass;
 
        public AbstractBulkEditorInput() {
-
+           super(true);
        }
 
        /**
index c59e0f2fe7628eb14567c9bdc2f1182a2e63e5fc..7fbb22736445c6afed82ae5c2abb5d11b432da8b 100644 (file)
@@ -67,6 +67,7 @@ public class TaxonEditorInput  extends CdmEntitySessionInput implements IEditorI
     }
 
     private TaxonEditorInput(UUID uuid, CdmType type) {
+        super(true);
         this.conversation = CdmStore.createConversation();
         switch(type) {
         case PARENT_TAXON_NODE:
index 92b9ec996c0b2731cdd91c7b0bc93ce26b7d2b0e..5dad6bd57bc347055a13dd23845b541c73bc69e5 100644 (file)
@@ -37,6 +37,7 @@ public class CdmAuthorityEditorInput extends CdmEntitySessionInput implements IE
        private Group group;
 
        protected CdmAuthorityEditorInput(ConversationHolder conversation, Group group) {
+           super(true);
                this.conversation = conversation;
                this.group = group;
 
index 0a1f60ffedeedfde2a26f5514c57269595939bf9..15c75555946e302a0acfcbfec2ddb64a4c3d26b3 100644 (file)
@@ -23,6 +23,7 @@ public abstract class AbstractIdentificationEditorInput<T extends IIdentificatio
        private final ConversationHolder conversation;
 
        protected AbstractIdentificationEditorInput(ConversationHolder conversation) {
+           super(true);
                this.conversation = conversation;
        }
 
index 8029f92937e9dd9b7637b86508d05fc917243c80..d50ca2fce04ae8360f810c1f38b79e316878b7bd 100644 (file)
@@ -2,11 +2,8 @@ package eu.etaxonomy.taxeditor.editor.view.derivate;
 
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-import java.util.UUID;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.action.MenuManager;
@@ -34,7 +31,6 @@ import org.eclipse.ui.part.EditorPart;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.molecular.Sequence;
@@ -48,8 +44,6 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
 import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
@@ -60,7 +54,7 @@ import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
  */
 public class DerivateView extends EditorPart implements IPartContentHasFactualData, IDirtyMarkable,
         IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
-        ISelectionChangedListener, IPostOperationEnabled , ICdmEntitySessionEnabled {
+        ISelectionChangedListener, IPostOperationEnabled{
 
     public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$
 
@@ -81,7 +75,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
 
     private ISelection selection = null;
 
-    private final ICdmEntitySession cdmEntitySession;
 
     private DerivateContentProvider contentProvider;
 
@@ -89,7 +82,6 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
      * Default constructor
      */
     public DerivateView() {
-        cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
     }
 
     @Override
@@ -116,13 +108,13 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         generateMultiLinkSingleReads();
         labelProvider.setMultiLinkSingleReads(multiLinkSingleReads);
         IEditorInput editorInput = getEditorInput();
-        viewer.setInput(((DerivateViewEditorInput) editorInput).getRootUUIDs());
+        viewer.setInput(((DerivateViewEditorInput) editorInput).getRootEntities());
         //set selection to selected derivate if only one was selected
         if(editorInput instanceof DerivateViewEditorInput){
-            Set<UUID> derivateUUIDs = ((DerivateViewEditorInput) editorInput).getDerivateUUIDs();
-            if(derivateUUIDs.size()==1){
-                SpecimenOrObservationBase<?> specimen = CdmStore.getService(IOccurrenceService.class).load(derivateUUIDs.iterator().next());
-                if(specimen!=null){
+            Set<SpecimenOrObservationBase<?>> derivateEntities = ((DerivateViewEditorInput) editorInput).getDerivateEntities();
+            if(derivateEntities.size()==1){
+                SpecimenOrObservationBase<?> specimen = derivateEntities.iterator().next();
+                if(specimen != null){
                     viewer.setSelection(new StructuredSelection(new TreeNode(specimen)));
                 }
             }
@@ -149,7 +141,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
 
         // commit the conversation and start a new transaction immediately
         conversation.commit(true);
-        CdmStore.getService(IOccurrenceService.class).merge(getRootEntities());
+        ((DerivateViewEditorInput) getEditorInput()).merge();
         monitor.worked(1);
 
         this.setDirty(false);
@@ -207,7 +199,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         if(!conversation.isBound()){
             conversation.bind();
         }
-        cdmEntitySession.bind();
+        ((DerivateViewEditorInput) getEditorInput()).bind();
     }
 
     @Override
@@ -306,34 +298,10 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
 
     @Override
     public void dispose() {
-        cdmEntitySession.dispose();
+        ((DerivateViewEditorInput) getEditorInput()).dispose();
         super.dispose();
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
-     */
-    @Override
-    public ICdmEntitySession getCdmEntitySession() {
-       return cdmEntitySession;
-    }
-
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
-     */
-    @Override
-    public List<SpecimenOrObservationBase>  getRootEntities() {
-        return contentProvider.getRootElements();
-    }
-
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
-     */
-    @Override
-    public Map<Object, List<String>> getPropertyPathsMap() {
-        // TODO Auto-generated method stub
-        return null;
-    }
 
     @Override
     public boolean canAttachMedia() {
index 3527fe5edae30a358c3304dc47172eb03968da75..ced5ad3fa462d63939ba9a608aea09c4879c0663 100644 (file)
@@ -9,7 +9,12 @@
 */
 package eu.etaxonomy.taxeditor.editor.view.derivate;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
@@ -17,11 +22,13 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
 
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.Messages;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
@@ -36,19 +43,36 @@ import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
  * @date 25.11.2013
  *
  */
-public class DerivateViewEditorInput implements IEditorInput{
+public class DerivateViewEditorInput extends CdmEntitySessionInput implements IEditorInput {
 
     /**
      * The selected derivate {@link UUID}s
      */
-    private final Set<UUID> derivateUUIDs;
+    private final Set<SpecimenOrObservationBase<?>> derivateEntities;
     /**
      * List of the {@link UUID}s of the root elements of the hierarchy (may be the same objects as the derivates)
      */
+    private Set<SpecimenOrObservationBase<?>> rootEntities;
     private Set<UUID> rootUUIDs;
 
     private final ConversationHolder conversationHolder;
 
+    private static final List<String> SPECIMEN_INIT_STRATEGY = Arrays.asList(new String[] {
+            "descriptions",
+            "annotations",
+            "markers",
+            "credits",
+            "extensions",
+            "rights",
+            "sources",
+            "derivationEvents.derivatives.annotations",
+            "derivationEvents.derivatives.markers",
+            "derivationEvents.derivatives.credits",
+            "derivationEvents.derivatives.extensions",
+            "derivationEvents.derivatives.rights",
+            "derivationEvents.derivatives.sources"
+    });
+
     /**
      * Creates an editor input for the {@link DerivateView} with the currently selected derivates and the
      * corresponding {@link FieldUnit}s (both may be the same object).
@@ -56,28 +80,37 @@ public class DerivateViewEditorInput implements IEditorInput{
      * @param rootUUIDs the root of the hierarchy
      */
     public DerivateViewEditorInput(Set<UUID> derivateUuids) {
-        super();
+        super(false);
+        rootUUIDs = derivateUuids;
+        //FIXME:Remoting temporary hack for making the sessions work
+        //This should ideally be changed to initializing the
+        //super class with a collection of (id) objects which can
+        //then be used for the hashCode, equals methods
+        initSession();
         this.conversationHolder = CdmStore.createConversation();
-        this.derivateUUIDs = derivateUuids;
-        this.rootUUIDs = new HashSet<UUID>();
+        this.derivateEntities = new HashSet<SpecimenOrObservationBase<?>>();
+        this.rootEntities = new HashSet<SpecimenOrObservationBase<?>>();
         for (UUID uuid : derivateUuids) {
-            SpecimenOrObservationBase<?> derivate = CdmStore.getService(IOccurrenceService.class).load(uuid);
+            SpecimenOrObservationBase<?> derivate = CdmStore.getService(IOccurrenceService.class).load(uuid, SPECIMEN_INIT_STRATEGY);
+            derivateEntities.add(derivate);
             if(derivate instanceof FieldUnit){
-                rootUUIDs.add(uuid);
+                rootEntities.add(derivate);
             }
             else if(derivate instanceof DerivedUnit){
                 SpecimenOrObservationBase<?> topMostDerivate = EditorUtil.getTopMostDerivate(derivate);
                 if(topMostDerivate!=null){
-                    rootUUIDs.add(topMostDerivate.getUuid());
+                    rootEntities.add(topMostDerivate);
                 }
             }
         }
-        if(rootUUIDs.isEmpty()){
-            rootUUIDs = derivateUUIDs;
+        if(rootEntities.isEmpty()){
+            rootEntities = derivateEntities;
         }
-        if(rootUUIDs.isEmpty()){
+        if(rootEntities.isEmpty()){
             MessagingUtils.messageDialog(Messages.DerivateViewEditorInput_FAIL_INIT, DerivateViewEditorInput.class, Messages.DerivateViewEditorInput_NO_ROOT);
         }
+
+
     }
 
     /* (non-Javadoc)
@@ -132,8 +165,7 @@ public class DerivateViewEditorInput implements IEditorInput{
 
     private String getEditorName() {
         String name = null;
-        for(UUID uuid:rootUUIDs){
-            SpecimenOrObservationBase<?> specimen = CdmStore.getService(IOccurrenceService.class).load(uuid);
+        for( SpecimenOrObservationBase<?> specimen : rootEntities){
             if(specimen!=null){
                 if(name==null){
                     name = DerivateLabelProvider.getDerivateText(specimen, conversationHolder);
@@ -146,16 +178,17 @@ public class DerivateViewEditorInput implements IEditorInput{
         return name;
     }
 
-    public Set<UUID> getRootUUIDs() {
-        return rootUUIDs;
+    @Override
+    public Set<SpecimenOrObservationBase<?>> getRootEntities() {
+        return rootEntities;
     }
 
-    public Set<UUID> getDerivateUUIDs() {
-        return derivateUUIDs;
+    public Set<SpecimenOrObservationBase<?>> getDerivateEntities() {
+        return derivateEntities;
     }
 
-    public void addRootUuid(UUID root){
-        rootUUIDs.add(root);
+    public void addRootEntity(SpecimenOrObservationBase<?> root){
+        rootEntities.add(root);
     }
 
 
@@ -199,5 +232,35 @@ public class DerivateViewEditorInput implements IEditorInput{
         return true;
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
+     */
+    @Override
+    public void merge() {
+       List<SpecimenOrObservationBase> mergedEntities = CdmApplicationState.getCurrentAppConfig().getOccurrenceService().merge(new ArrayList(getRootEntities()));
+
+    }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
+     */
+    @Override
+    public Map<Object, List<String>> getPropertyPathsMap() {
+        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
+                "descriptions",
+                "derivationEvents.derivates",
+                "annotations",
+                "markers",
+                "credits",
+                "extensions",
+                "rights",
+                "sources"
+        });
+        Map<Object, List<String>> specimenPropertyPathMap =
+                new HashMap<Object, List<String>>();
+        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
+        return specimenPropertyPathMap;
+    }
+
 
 }
index e57cbfbf728e562f367b2b2657fb5176270cea01..5129e44c572cd4673ad5cc1673b9a785f622a50c 100644 (file)
@@ -5,6 +5,7 @@ import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
@@ -23,10 +24,10 @@ public class CreateFieldUnitHandler extends AbstractHandler {
                 return null;
             }
             FieldUnit fieldUnit = FieldUnit.NewInstance();
-            CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
+            fieldUnit = CdmBase.deproxy(CdmStore.getService(IOccurrenceService.class).save(fieldUnit), FieldUnit.class);
             derivateView.getConversationHolder().commit();
             DerivateViewEditorInput input = (DerivateViewEditorInput) derivateView.getEditorInput();
-            input.addRootUuid(fieldUnit.getUuid());
+            input.addRootEntity(fieldUnit);
             derivateView.refreshTree();
         }
         return null;
index 7b83c4bce264183c308a6f3f0aaf2fb9b7f0b0d1..8b9362d184130bd9d939671ebb3e509e39d2adba 100644 (file)
@@ -23,9 +23,15 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public abstract class CdmEntitySessionInput implements ICdmEntitySessionEnabled {
 
-    private final ICdmEntitySession cdmEntitySession;
+    private ICdmEntitySession cdmEntitySession;
 
-    public CdmEntitySessionInput() {
+    public CdmEntitySessionInput(boolean init) {
+        if(init) {
+            initSession();
+        }
+    }
+
+    protected void initSession() {
         cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
     }
 
index 084e57634898a1c62b232015b441ad2413d5b0d7..8c3993f4357b2f06ada76761dcbb605a663d6353 100644 (file)
@@ -75,6 +75,14 @@ public class LanguageStringWithLabelElement extends TextWithLabelElement {
                return languageString;
        }
 
+       public LanguageString updateLanguageString(LanguageString ls) {
+           if(ls == null){
+            ls = LanguageString.NewInstance("", CdmStore.getDefaultLanguage());
+        }
+           ls.setText(text.getText());
+           return ls;
+       }
+
        /** {@inheritDoc} */
        @Override
        public void modifyText(ModifyEvent e) {
index e511bf6eb6af14dead8e3e255d3fbf3685a16c34..b26451ff9268ef6d64e29a66bd3fdf02a9cc1dd6 100644 (file)
@@ -112,7 +112,7 @@ public class FieldUnitGeneralDetailElement extends AbstractCdmDetailElement<Deri
         } else if (eventSource == selection_country) {
             getEntity().setCountry(selection_country.getSelection());
         } else if (eventSource == languageText_locality) {
-            LanguageString locality = languageText_locality.getLanguageString();
+            LanguageString locality = languageText_locality.updateLanguageString(getEntity().getLocality());
             getEntity().setLocality(locality);
         } else if (eventSource == element_point) {
             getEntity().setExactLocation(element_point.getPoint());
index 070344b8c7749e576f396c969bf5178d7a6664b1..d1ad70eac4ed661f35769d54f51e9bafeb4ad82e 100644 (file)
@@ -4,13 +4,11 @@ import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.UUID;
 
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.jface.viewers.Viewer;
 
-import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.model.molecular.DnaSample;
 import eu.etaxonomy.cdm.model.molecular.Sequence;
 import eu.etaxonomy.cdm.model.molecular.SingleRead;
@@ -18,7 +16,6 @@ import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
-import eu.etaxonomy.taxeditor.store.CdmStore;
 
 public class DerivateContentProvider implements ITreeContentProvider {
 
@@ -50,9 +47,8 @@ public class DerivateContentProvider implements ITreeContentProvider {
            rootNodes = new ArrayList<TreeNode>();
            if(inputElement instanceof Set){
                for (Object o: (Set)inputElement) {
-                   if(o instanceof UUID){
-                       UUID uuid = (UUID)o;
-                       SpecimenOrObservationBase<?> rootElement = CdmStore.getService(IOccurrenceService.class).load(uuid);
+                   if(o instanceof SpecimenOrObservationBase){
+                       SpecimenOrObservationBase<?> rootElement = (SpecimenOrObservationBase<?>)o;
                        if(rootElement!=null){
                            rootNodes.add(new TreeNode(rootElement));
                        }
index 99a1d883d6fbd9410de57b2b7148bb4edf1e9d6e..98bf707de264f74204bc3354cc7d25c6e33f030c 100644 (file)
@@ -19,7 +19,6 @@ import org.eclipse.swt.graphics.Image;
 import org.hibernate.LazyInitializationException;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.DefinedTerm;
@@ -164,10 +163,6 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
             FieldUnit fieldUnit = (FieldUnit)derivate;
             if(fieldUnit.getGatheringEvent()!=null){
                 GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
-                if(CdmStore.getService(IOccurrenceService.class).exists(fieldUnit.getUuid())){
-                    fieldUnit = (FieldUnit) CdmStore.getService(IOccurrenceService.class).load(fieldUnit.getUuid());
-                    gatheringEvent = fieldUnit.getGatheringEvent();
-                }
                 label += gatheringEvent.getCountry()!=null?gatheringEvent.getCountry().getLabel()+separator:emptyString;
                 label += gatheringEvent.getLocality()!=null?gatheringEvent.getLocality().getText()+separator:emptyString;
                 label += gatheringEvent.getGatheringDate()!=null?gatheringEvent.getGatheringDate()+separator:emptyString;
@@ -220,16 +215,21 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
         else if(derivate instanceof DerivedUnit){
             DerivedUnit derivedUnit = (DerivedUnit)derivate;
             if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){
-                java.util.Collection<FieldUnit> fieldUnits = CdmStore.getService(IOccurrenceService.class).getFieldUnits(derivedUnit.getUuid());
-                if(fieldUnits!=null && !fieldUnits.isEmpty()){
-                    FieldUnit fieldUnit = fieldUnits.iterator().next();
-                    GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
-//                  gatheringEvent = HibernateProxyHelper.deproxy(gatheringEvent, GatheringEvent.class);
-                    if(gatheringEvent!=null){
-                        label += gatheringEvent.getCollector()!=null?gatheringEvent.getCollector()+separator:emptyString;
+                //java.util.Collection<FieldUnit> fieldUnits = CdmStore.getService(IOccurrenceService.class).getFieldUnits(derivedUnit.getUuid());
+                //TODO : This is not generic anymore for performance reasons
+                Set<SpecimenOrObservationBase> originals = derivedUnit.getOriginals();
+                if(originals.size() ==1) {
+                    SpecimenOrObservationBase specimen = originals.iterator().next();
+                    if(specimen instanceof FieldUnit) {
+                        FieldUnit fieldUnit = (FieldUnit)specimen;
+                        GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
+                        if(gatheringEvent!=null){
+                            label += gatheringEvent.getCollector()!=null?gatheringEvent.getCollector()+separator:emptyString;
+                        }
+                        label += fieldUnit.getFieldNumber()!=null?fieldUnit.getFieldNumber()+separator:emptyString;
                     }
-                    label += fieldUnit.getFieldNumber()!=null?fieldUnit.getFieldNumber()+separator:emptyString;
                 }
+
                 eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();
                 if(collection!=null){
                     label += collection.getCode()!=null?"("+collection.getCode()+")"+separator:emptyString;