#5946 Implement/fix referencing objets label provider for TaxonNode and DerivationEvent
authorAndreas Müller <a.mueller@bgbm.org>
Mon, 4 Jul 2016 11:52:24 +0000 (13:52 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Mon, 4 Jul 2016 11:52:39 +0000 (13:52 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java

index d0e40abf68006e300d5f00fde9c6d83fca3e0a93..441e6af712d88cc36035279a8d060e0fda98ecf4 100644 (file)
@@ -61,10 +61,12 @@ import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
 import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
+import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -245,6 +247,8 @@ public class DescriptionHelper {
                        return getCache((HomotypicalGroup) element);
                }else if (element instanceof TaxonNode) {
                        return getCache((TaxonNode) element);
+               }else if (element instanceof DeterminationEvent) {
+                       return getCache((DeterminationEvent) element);
                }else if (element instanceof Marker) {
                        Marker marker = (Marker) element;
                        MarkerType type = marker.getMarkerType();
@@ -262,6 +266,28 @@ public class DescriptionHelper {
        }
 
 
+       private static String getCache(DeterminationEvent detEvent) {
+               //taxon
+               String taxonStr = "no taxon";
+               TaxonNameBase<?,?> taxonName = detEvent.getTaxonName();
+               TaxonBase<?> taxon = detEvent.getTaxon();
+               if (taxonName != null){
+                       taxonStr = taxonName.getTitleCache();
+               }else if (taxon != null){
+                       taxonStr = taxon.getTitleCache();
+               }
+               //unit
+               String unitStr = "no unit";
+               SpecimenOrObservationBase<?> unit = detEvent.getIdentifiedUnit();
+               if (unit != null){
+                       unitStr = unit.getTitleCache();
+               }
+               
+               String result = CdmUtils.concat(" determined as ", unitStr, taxonStr);
+
+               return result;
+       }
+
        private static String getCache(TaxonNode taxonNode) {
                String result = "";
                Classification classification = taxonNode.getClassification();
@@ -291,7 +317,7 @@ public class DescriptionHelper {
                }
                result = CdmUtils.concat(": ", result, parentStr);
                
-               return null;
+               return result;
        }
 
        private static String getCache(TypeDesignationBase<?> designation) {
@@ -360,18 +386,10 @@ public class DescriptionHelper {
                                toMethod.setAccessible(true);
                                from = (IdentifiableEntity<?>)fromMethod.invoke(rel);
                                to = (IdentifiableEntity<?>)toMethod.invoke(rel);
-                       } catch (NoSuchMethodException e) {
-                               throw new RuntimeException(e);
-                       } catch (SecurityException e) {
-                               throw new RuntimeException(e);
-                       } catch (IllegalAccessException e) {
-                               throw new RuntimeException(e);
-                       } catch (IllegalArgumentException e) {
-                               throw new RuntimeException(e);
-                       } catch (InvocationTargetException e) {
+                       } catch (NoSuchMethodException | SecurityException | IllegalAccessException
+                               | IllegalArgumentException | InvocationTargetException e) {
                                throw new RuntimeException(e);
                        }
-                       
                }
                String typeLabel = null;
                if (type != null){