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!=null && 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;
}
- String mostSignificantIdentifier = CdmStore.getService(IOccurrenceService.class).getMostSignificantIdentifier(derivedUnit);
+ String mostSignificantIdentifier = derivedUnit.getMostSignificantIdentifier();
label += mostSignificantIdentifier!=null?mostSignificantIdentifier+separator:emptyString;
}
else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.TissueSample){
boolean hasCharacterData = false;
if(cdmBase.isInstanceOf(SpecimenOrObservationBase.class)){
SpecimenOrObservationBase<?> specimen = HibernateProxyHelper.deproxy(cdmBase, SpecimenOrObservationBase.class);
- if(!CdmStore.getService(IOccurrenceService.class).getCharacterDataForSpecimen(specimen.getUuid()).isEmpty()){
+ if(specimen.hasCharacterData()){
hasCharacterData = true;
}
}