ref #7095 Enhance quicker service for taxon associated specimens
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / IOccurrenceService.java
index 61d295cdac2b200cdfa697bd1c2ad133e8125a94..40a4d2a503ca54206a25f978f28ef9872a5f40bc 100644 (file)
@@ -18,6 +18,7 @@ import java.util.UUID;
 \r
 import org.apache.lucene.index.CorruptIndexException;\r
 import org.hibernate.search.spatial.impl.Rectangle;\r
+import org.springframework.transaction.annotation.Transactional;\r
 \r
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;\r
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;\r
@@ -30,7 +31,6 @@ import eu.etaxonomy.cdm.api.service.pager.Pager;
 import eu.etaxonomy.cdm.api.service.search.LuceneParseException;\r
 import eu.etaxonomy.cdm.api.service.search.SearchResult;\r
 import eu.etaxonomy.cdm.api.service.util.TaxonRelationshipEdge;\r
-import eu.etaxonomy.cdm.model.common.ICdmBase;\r
 import eu.etaxonomy.cdm.model.common.Language;\r
 import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
@@ -42,18 +42,21 @@ import eu.etaxonomy.cdm.model.molecular.DnaSample;
 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.TaxonNameBase;\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
 \r
@@ -133,7 +136,7 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      *            properties to be initialized\r
      * @return\r
      */\r
-    public Pager<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonNameBase determinedAs, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+    public Pager<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonName determinedAs, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
     /**\r
      * Returns a List of Media that are associated with a given occurence\r
@@ -217,7 +220,7 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      * {@link DerivedUnit}s found in the data base.\r
      * @return a list of {@link UuidAndTitleCache}\r
      */\r
-    public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache();\r
+    public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache(Integer limit, String pattern);\r
 \r
     public DerivedUnitFacade getDerivedUnitFacade(DerivedUnit derivedUnit, List<String> propertyPaths) throws DerivedUnitFacadeNotSupportedException;\r
 \r
@@ -257,6 +260,28 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
     public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,\r
             Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
 \r
+    /**\r
+     * The method will search for specimen associated with the taxon nodes.<br>\r
+     * It will search for 3 possible association types: <br>\r
+     * - via IndividualAssociations of the taxon<br>\r
+     *  - via TypeDesignations of the taxon name<br>\r
+     *  - via Determinations of the taxon or taxon name<br>\r
+     * <br>\r
+     * more are covered in\r
+     * {@link IOccurrenceService#findByTitle(IIdentifiableEntityServiceConfigurator)}\r
+     * @param taxonNodeUuids\r
+     *            a list of {@link UUID}s of the taxon nodes\r
+     * @param limit\r
+     * @param start\r
+     * @param orderHints\r
+     * @return a list of {@link SpecimenNodeWrapper} containing the\r
+     *         {@link TaxonNode} and the corresponding {@link UuidAndTitleCache}\r
+     *         object for the specimen found for this taxon node\r
+     */\r
+    public List<SpecimenNodeWrapper> listUuidAndTitleCacheByAssociatedTaxon(List<UUID> taxonNodeUuids,\r
+            Integer limit, Integer start, List<OrderHint> orderHints);\r
+\r
+\r
     /**\r
      * Lists all instances of {@link FieldUnit} which are\r
      * associated <b>directly or indirectly</b>with the <code>taxon</code> specified\r
@@ -317,10 +342,11 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
     /**\r
      * Retrieves all {@link FieldUnit}s for the {@link SpecimenOrObservationBase} with the given {@link UUID}.<br>\r
      * @param specimenUuid the UUID of the specimen\r
+     * @param propertyPaths the property path\r
      * @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);\r
+    public Collection<FieldUnit> getFieldUnits(UUID specimenUuid, List<String> propertyPaths);\r
 \r
     /**\r
      * @param clazz\r
@@ -408,13 +434,6 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      */\r
     public PreservedSpecimenDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit);\r
 \r
-    /**\r
-     * Returns a collection of {@link ICdmBase}s that are not persisted via cascading when saving the given specimen (mostly DefinedTerms).\r
-     * @param specimen the specimen that is checked for non-cascaded elements.\r
-     * @return collection of non-cascaded element associated with the specimen\r
-     */\r
-    public Collection<ICdmBase> getNonCascadedAssociatedElements(SpecimenOrObservationBase<?> specimen);\r
-\r
     /**\r
      * Deletes the specified specimen according to the setting in the {@link SpecimenDeleteConfigurator}.<br>\r
      * @param specimen the specimen which shoul be deleted\r
@@ -622,4 +641,22 @@ public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenO
      */\r
     public List<DerivedUnit> getAllChildDerivatives(UUID specimenUuid);\r
 \r
+    /**\r
+     * Returns all {@link FieldUnit}s that are referencing this {@link GatheringEvent}\r
+     * @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
+\r
+\r
+    /**\r
+     * Returns a list of {@link UuidAndTitleCache} for the specimens found with the\r
+     * given configurator\r
+     * @param config the configurator for the search\r
+     * @return a list of UuidAndTitleCache object\r
+     */\r
+    @Transactional(readOnly = true)\r
+    public Pager<UuidAndTitleCache<SpecimenOrObservationBase>> findByTitleUuidAndTitleCache(\r
+            FindOccurrencesConfigurator config);\r
+\r
 }\r