Merge branch 'develop' of ssh://dev.e-taxonomy.eu/var/git/cdmlib into develop
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / IOccurrenceService.java
index 69c178df155ed8e9e83b0f1519172f87d443d43e..f1237765201f32c3962cec67f89b6a0f0e95083b 100644 (file)
@@ -11,12 +11,12 @@ package eu.etaxonomy.cdm.api.service;
 \r
 import java.io.IOException;\r
 import java.util.Collection;\r
+import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.Set;\r
 import java.util.UUID;\r
 \r
-import org.apache.lucene.index.CorruptIndexException;\r
 import org.hibernate.search.spatial.impl.Rectangle;\r
 import org.springframework.transaction.annotation.Transactional;\r
 \r
@@ -25,6 +25,7 @@ import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
 import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;\r
+import eu.etaxonomy.cdm.api.service.dto.DerivateDTO;\r
 import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;\r
 import eu.etaxonomy.cdm.api.service.dto.PreservedSpecimenDTO;\r
 import eu.etaxonomy.cdm.api.service.pager.Pager;\r
@@ -35,27 +36,20 @@ import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.description.IndividualsAssociation;\r
-import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
 import eu.etaxonomy.cdm.model.location.Country;\r
+import eu.etaxonomy.cdm.model.location.Point;\r
 import eu.etaxonomy.cdm.model.media.Media;\r
 import eu.etaxonomy.cdm.model.molecular.DnaSample;\r
 import eu.etaxonomy.cdm.model.molecular.Sequence;\r
-import eu.etaxonomy.cdm.model.name.HomotypicalGroup;\r
 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;\r
 import eu.etaxonomy.cdm.model.name.TaxonName;\r
 import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;\r
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;\r
 import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;\r
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;\r
-import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;\r
-import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;\r
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;\r
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;\r
-import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;\r
 import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;\r
 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;\r
 import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
@@ -167,7 +161,7 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)\r
      * @return a count of determination events\r
      */\r
-    public int countDeterminations(SpecimenOrObservationBase occurence,TaxonBase taxonbase);\r
+    public long countDeterminations(SpecimenOrObservationBase occurence,TaxonBase taxonbase);\r
 \r
     /**\r
      * Returns a List of determinations that have been made for a given occurence\r
@@ -345,7 +339,7 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      * @return either a collection of FieldUnits this specimen was derived from, the FieldUnit itself\r
      * if this was a FieldUnit or an empty collection if no FieldUnits were found\r
      */\r
-    public Collection<FieldUnit> getFieldUnits(UUID specimenUuid, List<String> propertyPaths);\r
+    public Collection<FieldUnit> findFieldUnits(UUID specimenUuid, List<String> propertyPaths);\r
 \r
     /**\r
      * @param clazz\r
@@ -417,14 +411,12 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
     public boolean moveDerivate(SpecimenOrObservationBase<?> from, SpecimenOrObservationBase<?> to, DerivedUnit derivate);\r
 \r
     /**\r
-     * Assembles a {@link FieldUnitDTO} for the given field unit uuid which is associated to the {@link Taxon}.<br>\r
-     * <br>\r
-     * For the meaning of "associated" see also {@link #listFieldUnitsByAssociatedTaxon(Set, Taxon, Integer, Integer, Integer, List, List)}\r
+     * Assembles a {@link FieldUnitDTO} for the given field unit.<br>\r
+     *\r
      * @param fieldUnit\r
-     * @param associatedTaxonUuid\r
      * @return a DTO with all the assembled information\r
      */\r
-    public FieldUnitDTO assembleFieldUnitDTO(FieldUnit fieldUnit, UUID associatedTaxonUuid);\r
+    public FieldUnitDTO assembleFieldUnitDTO(FieldUnit fieldUnit);\r
 \r
     /**\r
      * Assembles a {@link PreservedSpecimenDTO} for the given derived unit.\r
@@ -477,8 +469,13 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      * @param propertyPaths\r
      * @return a collection of associated taxa\r
      */\r
-    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, Integer limit,\r
-            Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen,\r
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+    /**\r
+      * @see #listIndividualsAssociationTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)\r
+      */\r
+    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,\r
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
     /**\r
      * Retrieves all associated taxa for the given specimen (via type designations, determination, individuals associations)\r
@@ -489,7 +486,13 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      * @param propertyPaths\r
      * @return\r
      */\r
-    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,\r
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+    /**\r
+     * @see #listAssociatedTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)axa\r
+     */\r
+    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen,\r
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
     /**\r
      * Retrieves all taxa that the given specimen is determined as\r
@@ -500,8 +503,13 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      * @param propertyPaths\r
      * @return collection of all taxa the given specimen is determined as\r
      */\r
-    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start,\r
-            List<OrderHint> orderHints, List<String> propertyPaths);\r
+    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,\r
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+    /**\r
+     * @see #listDeterminedTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)\r
+     */\r
+    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen,\r
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
     /**\r
      * Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.\r
@@ -524,8 +532,13 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      * @param propertyPaths\r
      * @return a collection of all taxa where the given specimen is the type specimen\r
      */\r
-    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, Integer limit,\r
-            Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen,\r
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+    /**\r
+     * @see #listTypeDesignationTaxa(DerivedUnit, Integer, Integer, List, List)a\r
+     */\r
+    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, boolean includeUnpublished,\r
+            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
     /**\r
      * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimens as a type specimen.\r
@@ -613,7 +626,7 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      *            authorTeam.persistentTitleCache\r
      * @return the number of found specimens\r
      */\r
-    public int countOccurrences(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> config);\r
+    public long countOccurrences(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> config);\r
 \r
     /**\r
      * Return the all {@link SpecimenOrObservationBase}s of the complete\r
@@ -645,7 +658,7 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      * @param gatheringEventUuid the {@link UUID} of the gathering event\r
      * @return a list of field units referencing the gathering event\r
      */\r
-    public List<FieldUnit> getFieldUnitsForGatheringEvent(UUID gatheringEventUuid);\r
+    public List<FieldUnit> findFieldUnitsForGatheringEvent(UUID gatheringEventUuid);\r
 \r
 \r
     /**\r
@@ -658,4 +671,59 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
     public Pager<UuidAndTitleCache<SpecimenOrObservationBase>> findByTitleUuidAndTitleCache(\r
             FindOccurrencesConfigurator config);\r
 \r
+    /**\r
+     * Returns a list of {@link PreservedSpecimenDTO} for the specimens found with the\r
+     * given configurator\r
+     * @param config the configurator for the search\r
+     * @return a list of {@link PreservedSpecimenDTO} object\r
+     */\r
+    @Transactional(readOnly = true)\r
+    public List<PreservedSpecimenDTO> findByTitlePreservedSpecimenDTO(\r
+            FindOccurrencesConfigurator config);\r
+\r
+    /**\r
+     * @param queryString\r
+     * @param propertyPaths\r
+     * @return\r
+     * @throws IOException\r
+     */\r
+    FieldUnitDTO findByAccessionNumber(\r
+             String accessionNumberString, List<OrderHint> orderHints,\r
+            List<String> propertyPaths);\r
+\r
+    /**\r
+     * @param includedRelationships\r
+     * @param associatedTaxon\r
+     * @param maxDepth\r
+     * @param pageSize\r
+     * @param pageNumber\r
+     * @param orderHints\r
+     * @param propertyPaths\r
+     * @return\r
+     */\r
+    List<FieldUnitDTO> findFieldUnitDTOByAssociatedTaxon(Set<TaxonRelationshipEdge> includedRelationships,\r
+            UUID associatedTaxonUuid);\r
+\r
+    /**\r
+     * @param derivedUnitUuid\r
+     * @param propertyPaths\r
+     * @return\r
+     */\r
+\r
+    FieldUnitDTO findFieldUnitDTO(DerivateDTO derivedUnitDTO, Collection<FieldUnitDTO> fieldUnits, HashMap<UUID, DerivateDTO> alreadyCollectedSpecimen);\r
+\r
+\r
+    /**\r
+     * @param fieldUnitUuids\r
+     * @return\r
+     */\r
+    public List<Point> findPointsForFieldUnitList(List<UUID> fieldUnitUuids);\r
+\r
+    /**\r
+     * Load the FieldUnitDTO for the given <code>derivedUnitUuid</code> with all intermediate derivatives and {@link eu.etaxonomy.cdm.api.service.dto.GatheringEventDTO}\r
+     * @param derivedUnitUuid\r
+     * @return\r
+     */\r
+    FieldUnitDTO loadFieldUnitDTO(UUID derivedUnitUuid);\r
+\r
 }\r