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;
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;
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;