@Deprecated
//TODO: method needs to be optimized with a direct SQL query instead of iterating over all specimens
public List<SpecimenOrObservationBase> findOccurrencesByType(IIdentifiableEntityServiceConfigurator configurator, SpecimenOrObservationType type){
- List<SpecimenOrObservationBase> occurrences = new ArrayList<SpecimenOrObservationBase>();
- for(SpecimenOrObservationBase occurrence:findOccurrences(configurator, true)){
- if(occurrence.getRecordBasis()==type){
- occurrences.add(occurrence);
+ List<SpecimenOrObservationBase> filteredOccurrences = new ArrayList<SpecimenOrObservationBase>();
+ List<SpecimenOrObservationBase> occurrences = findOccurrences(configurator, true);
+ if(type!=null){
+ for(SpecimenOrObservationBase occurrence:occurrences){
+ if(occurrence.getRecordBasis().equals(type)
+ || occurrence.getRecordBasis().isKindOf(type)
+ || type == SpecimenOrObservationType.Unknown){
+ filteredOccurrences.add(occurrence);
+ }
}
}
- return occurrences;
+ else{
+ filteredOccurrences = occurrences;
+ }
+ return filteredOccurrences;
}
public List<User> findUsers(IIdentifiableEntityServiceConfigurator configurator){