+// $Id$\r
/**\r
-* Copyright (C) 2008 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* Copyright (C) 2009 EDIT\r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-*/\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/ \r
\r
package eu.etaxonomy.cdm.api.service;\r
\r
import java.util.List;\r
-import java.util.Map;\r
-import java.util.UUID;\r
\r
+import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;\r
+import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
+import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;\r
+import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
+import eu.etaxonomy.cdm.model.description.IndividualsAssociation;\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;\r
import eu.etaxonomy.cdm.model.media.Media;\r
-import eu.etaxonomy.cdm.model.occurrence.Collection;\r
+import eu.etaxonomy.cdm.model.name.HomotypicalGroup;\r
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;\r
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;\r
+import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;\r
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;\r
+import eu.etaxonomy.cdm.model.occurrence.FieldObservation;\r
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;\r
+import eu.etaxonomy.cdm.model.taxon.Taxon;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;\r
+import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
\r
/**\r
* @author a.babadshanjan\r
* @created 01.09.2008\r
*/\r
public interface IOccurrenceService extends IIdentifiableEntityService<SpecimenOrObservationBase> {\r
-\r
- /**\r
- * FIXME candidate for harmonization?\r
- * Computes all specimen or observation bases.\r
- * @param limit\r
- * @param start\r
- * @return\r
- */\r
- public abstract List<SpecimenOrObservationBase> getAllSpecimenOrObservationBases(int limit, int start);\r
-\r
- /**\r
- * FIXME candidate for harmonization? \r
- * Saves a collection of specimen or observation bases.\r
- * @return Map with UUID as key and SpecimenOrObservationBase as value.\r
- */\r
- public abstract Map<UUID, ? extends SpecimenOrObservationBase> \r
- saveSpecimenOrObservationBaseAll(java.util.Collection<? extends SpecimenOrObservationBase> specimenOrObservationBaseCollection);\r
-\r
- /** \r
- * FIXME candidate for harmonizaion?\r
- * save a specimen or observation and return its UUID\r
- */\r
- public abstract UUID saveSpecimenOrObservationBase (SpecimenOrObservationBase specimenOrObservationBase);\r
\r
public WaterbodyOrCountry getCountryByIso(String iso639);\r
\r
public List<WaterbodyOrCountry> getWaterbodyOrCountryByName(String name);\r
\r
- /** */\r
- public abstract List<Collection> searchCollectionByCode(String code);\r
- \r
- public abstract UUID saveCollection(Collection collection);\r
+ /**\r
+ * Returns a paged list of occurrences that have been determined to belong\r
+ * to the taxon concept determinedAs, optionally restricted to objects\r
+ * belonging to a class that that extends SpecimenOrObservationBase.\r
+ * <p>\r
+ * In contrast to {@link #listByAnyAssociation(Class, Taxon, List)} this\r
+ * method only takes SpecimenOrObservationBase instances into account which\r
+ * are actually determined as the taxon specified by\r
+ * <code>determinedAs</code>.\r
+ * \r
+ * @param type\r
+ * The type of entities to return (can be null to count all\r
+ * entities of type <T>)\r
+ * @param determinedAs\r
+ * the taxon concept that the occurrences have been determined to\r
+ * belong to\r
+ * @param pageSize\r
+ * The maximum number of objects returned (can be null for all\r
+ * matching objects)\r
+ * @param pageNumber\r
+ * The offset (in pageSize chunks) from the start of the result\r
+ * set (0 - based, can be null, equivalent of starting at the\r
+ * beginning of the recordset)\r
+ * @param orderHints\r
+ * Supports path like <code>orderHints.propertyNames</code> which\r
+ * include *-to-one properties like createdBy.username or\r
+ * authorTeam.persistentTitleCache\r
+ * @param propertyPaths\r
+ * properties to be initialized\r
+ * @return\r
+ */\r
+ public Pager<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonBase 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
* @param occurence the occurence associated with these media\r
* @param pageSize The maximum number of media returned (can be null for all related media)\r
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+ * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}\r
* @return a Pager of media instances\r
*/\r
- public Pager<Media> getMedia(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber);\r
+ public Pager<Media> getMedia(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);\r
\r
/**\r
* Returns a List of determinations that have been made for a given occurence\r
* \r
- * @param occurence the occurence associated with these determinations\r
+ * @param occurence the occurence associated with these determinations (can be null for all occurrences)\r
+ * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)\r
* @param pageSize The maximum number of determinations returned (can be null for all related determinations)\r
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
* @return a Pager of determination instances\r
*/\r
- public Pager<DeterminationEvent> getDeterminations(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber);\r
+ public Pager<DeterminationEvent> getDeterminations(SpecimenOrObservationBase occurence, TaxonBase taxonBase, Integer pageSize, Integer pageNumber, List<String> propertyPaths);\r
\r
/**\r
* Returns a list of derivation events that have involved creating new DerivedUnits from this occurence\r
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
* @return a Pager of derivation events\r
*/\r
- public Pager<DerivationEvent> getDerivationEvents(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber);\r
+ public Pager<DerivationEvent> getDerivationEvents(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);\r
+ \r
+ /**\r
+ * Returns a Paged List of SpecimenOrObservationBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)\r
+ * \r
+ * @param clazz filter the results by class (or pass null to return all SpecimenOrObservationBase instances)\r
+ * @param queryString\r
+ * @param pageSize The maximum number of occurrences returned (can be null for all matching occurrences)\r
+ * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+ * @param orderHints\r
+ * Supports path like <code>orderHints.propertyNames</code> which\r
+ * include *-to-one properties like createdBy.username or\r
+ * authorTeam.persistentTitleCache\r
+ * @param propertyPaths properties to be initialized\r
+ * @return a Pager SpecimenOrObservationBase instances\r
+ * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>\r
+ */\r
+ public Pager<SpecimenOrObservationBase> search(Class<? extends SpecimenOrObservationBase> clazz, String query, Integer pageSize,Integer pageNumber, List<OrderHint> orderHints,List<String> propertyPaths);\r
+ \r
+ public List<UuidAndTitleCache<FieldObservation>> getFieldObservationUuidAndTitleCache();\r
+ \r
+ public List<UuidAndTitleCache<DerivedUnitBase>> getDerivedUnitBaseUuidAndTitleCache();\r
+ \r
+ public DerivedUnitFacade getDerivedUnitFacade(DerivedUnitBase derivedUnit, List<String> propertyPaths) throws DerivedUnitFacadeNotSupportedException;\r
+ \r
+ public List<DerivedUnitFacade> listDerivedUnitFacades(DescriptionBase description, List<String> propertyPaths);\r
+ \r
+ /**\r
+ * Lists all instances of {@link SpecimenOrObservationBase} which are associated with the <code>taxon</code> specified as parameter.\r
+ * SpecimenOrObservationBase instances can be associated to taxa in multiple ways, all these possible relations are taken into account:\r
+ * <ul>\r
+ * <li>The {@link IndividualsAssociation} elements in a {@link TaxonDescription} contain {@link DerivedUnitBase}s</li>\r
+ * <li>{@link SpecimenTypeDesignation}s may be associated with any {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>\r
+ * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent} of the {@link SpecimenOrObservationBase}</li> \r
+ * </ul>\r
+ * \r
+ * @param <T>\r
+ * @param type\r
+ * @param associatedTaxon\r
+ * @param limit\r
+ * @param start\r
+ * @param orderHints\r
+ * @param propertyPaths\r
+ * @return\r
+ */\r
+ public <T extends SpecimenOrObservationBase> List<T> listByAnyAssociation(Class<T> type,\r
+ Taxon associatedTaxon, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);\r
+ \r
}\r