First draft of interface for natural language generation functions.
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / INameService.java
index db24686a452b519e1c99a66d2ff1328439f3fce2..751b4c1b7944f329dade5067f0a8cdd5bce9f430 100644 (file)
@@ -1,3 +1,4 @@
+// $Id$\r
 /**\r
 * Copyright (C) 2007 EDIT\r
 * European Distributed Institute of Taxonomy \r
@@ -12,70 +13,269 @@ package eu.etaxonomy.cdm.api.service;
 import java.util.Collection;\r
 import java.util.List;\r
 import java.util.Map;\r
+import java.util.Set;\r
 import java.util.UUID;\r
 \r
+import org.hibernate.criterion.Criterion;\r
+\r
+import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;\r
+import eu.etaxonomy.cdm.api.service.pager.Pager;\r
 import eu.etaxonomy.cdm.model.common.CdmBase;\r
 import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;\r
+import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;\r
+import eu.etaxonomy.cdm.model.common.RelationshipBase;\r
 import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
-import eu.etaxonomy.cdm.model.name.*;\r
+import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;\r
+import eu.etaxonomy.cdm.model.name.BotanicalName;\r
+import eu.etaxonomy.cdm.model.name.HomotypicalGroup;\r
+import eu.etaxonomy.cdm.model.name.HybridRelationship;\r
+import eu.etaxonomy.cdm.model.name.HybridRelationshipType;\r
+import eu.etaxonomy.cdm.model.name.NameRelationship;\r
+import eu.etaxonomy.cdm.model.name.NameRelationshipType;\r
+import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;\r
+import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import eu.etaxonomy.cdm.model.name.Rank;\r
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;\r
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
+import eu.etaxonomy.cdm.model.name.TypeDesignationBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;\r
+import eu.etaxonomy.cdm.persistence.query.MatchMode;\r
+import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
 \r
 public interface INameService extends IIdentifiableEntityService<TaxonNameBase> {\r
 \r
+\r
+       public Map<UUID, TypeDesignationBase> saveTypeDesignationAll(Collection<TypeDesignationBase> typeDesignationCollection);\r
+\r
+       public Map<UUID, ReferencedEntityBase> saveReferencedEntitiesAll(Collection<ReferencedEntityBase> referencedEntityCollection);\r
+               \r
+       public Map<UUID, HomotypicalGroup> saveAllHomotypicalGroups(Collection<HomotypicalGroup> homotypicalGroups);\r
+\r
+       public List<NomenclaturalStatus> getAllNomenclaturalStatus(int limit, int start);\r
+\r
+       public List<TypeDesignationBase> getAllTypeDesignations(int limit, int start);\r
+       \r
        /**\r
-        * @param uuid\r
+        * @param name\r
         * @return\r
         */\r
-       public abstract TaxonNameBase getTaxonNameByUuid(UUID uuid);\r
-\r
+       public List<TaxonNameBase> getNamesByName(String name);\r
+       \r
        /**\r
-        * @param taxonName\r
+        * Returns all NonViralNames with a name cache that matches the given string\r
+        * @param name\r
         * @return\r
         */\r
-       public abstract UUID saveTaxonName(TaxonNameBase taxonName);\r
+       public List<NonViralName> getNamesByNameCache(String nameCache);\r
 \r
        /**\r
-        * Saves a collection of  TaxonNames and return its UUID@param taxonCollection\r
+        * @param name\r
+        * @param sessionObject An object that is attached to the session before executing the query\r
         * @return\r
         */\r
-       public abstract Map<UUID, TaxonNameBase> saveTaxonNameAll(Collection<TaxonNameBase> taxonCollection);\r
-\r
+       public List getNamesByName(String name, CdmBase sessionObject);\r
+       \r
+       // TODO: Remove getNamesByName() methods. Use findNamesByTitle() instead.\r
+       \r
+       // FIXME candidate for harmonization?\r
+       public List findNamesByTitle(String title);\r
+       \r
+       public List findNamesByTitle(String title, CdmBase sessionObject);\r
+       \r
        /**\r
-        * @param limit\r
-        * @param start\r
+        * Finds taxon name(s) according to specifications in configurator\r
+        * \r
+        * @param configurator\r
         * @return\r
         */\r
-       public abstract List<TaxonNameBase> getAllNames(int limit, int start);\r
+       public List<TaxonNameBase> findByTitle(IIdentifiableEntityServiceConfigurator config);\r
 \r
+    public List<HomotypicalGroup> getAllHomotypicalGroups(int limit, int start);\r
+\r
+       @Deprecated\r
+    public List<RelationshipBase> getAllRelationships(int limit, int start);\r
+    \r
        /**\r
-        * @param name\r
+        * Returns all Ranks\r
         * @return\r
+        * @deprecated use TermService#getVocabulary(VocabularyType) instead\r
         */\r
-       public abstract List<TaxonNameBase> getNamesByName(String name);\r
-\r
+       public OrderedTermVocabulary<Rank> getRankVocabulary();\r
+       \r
        /**\r
-        * @param name\r
-        * @param sessionObject An object that is attached to the session before executing the query\r
+        * Returns all NomenclaturalStatusTypes\r
         * @return\r
+        * @deprecated use TermService#getVocabulary(VocabularyType) instead\r
         */\r
-       public abstract List getNamesByName(String name, CdmBase sessionObject);\r
-               \r
+       public TermVocabulary<NomenclaturalStatusType> getStatusTypeVocabulary();\r
        \r
        /**\r
-        * Returns all Ranks.\r
+        * Returns TypeDesignationStatus vocabulary\r
         * @return\r
+        * @deprecated use TermService#getVocabulary(VocabularyType) instead\r
         */\r
-       public abstract OrderedTermVocabulary<Rank> getRankVocabulary();\r
-       \r
+       public TermVocabulary<SpecimenTypeDesignationStatus> getSpecimenTypeDesignationStatusVocabulary();\r
+               \r
+       /**\r
+        * Returns TypeDesignationStatus ordered vocabulary\r
+        * @return\r
+        * @deprecated use TermService#getVocabulary(VocabularyType) instead\r
+        */\r
+       public OrderedTermVocabulary<SpecimenTypeDesignationStatus> getSpecimenTypeDesignationVocabulary();\r
+\r
        /**\r
-        * Returns all NomenclaturalStatusTypes.\r
+        * Returns all NameRelationshipTypes\r
         * @return\r
+        * @deprecated use TermService#getVocabulary(VocabularyType) instead\r
         */\r
-       public abstract TermVocabulary<NomenclaturalStatusType> getStatusTypeVocabulary();\r
+       public TermVocabulary<NameRelationshipType> getNameRelationshipTypeVocabulary();\r
        \r
+       /**\r
+        * Return a List of relationships in which this name is related to another name, optionally filtered \r
+        * by relationship type\r
+        * \r
+        * @param name the name on the <i>"from side"</i> of the relationship\r
+        * @param type the relationship type (or null to return all relationships) \r
+        * @param pageSize The maximum number of relationships returned (can be null for all relationships)\r
+        * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+        * @param orderHints may be null\r
+        * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}\r
+        * @return a Pager of NameRelationship instances\r
+        */\r
+       public List<NameRelationship> listFromNameRelationships(TaxonNameBase name,  NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
        \r
        /**\r
-        * Returns all NameRelationshipTypes.\r
-        * @return\r
+        * Return a List of relationships in which this name is related to another name, optionally filtered \r
+        * by relationship type\r
+        * \r
+        * @param name the name on the <i>"from side"</i> of the relationship\r
+        * @param type the relationship type (or null to return all relationships) \r
+        * @param pageSize The maximum number of relationships returned (can be null for all relationships)\r
+        * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+        * @param orderHints may be null\r
+        * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}\r
+        * @return a Pager of NameRelationship instances\r
+        */\r
+       public Pager<NameRelationship> pageFromNameRelationships(TaxonNameBase name,  NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
+       \r
+       /**\r
+        * Return a List of relationships in which another name is related to this name, optionally filtered \r
+        * by relationship type\r
+        * \r
+        * @param name the name on the <i>"to side"</i> of the relationship \r
+        * @param type the relationship type (or null to return all relationships) \r
+        * @param pageSize The maximum number of relationships returned (can be null for all relationships)\r
+        * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+        * @param orderHints may be null\r
+        * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}\r
+        * @return a Pager of NameRelationship instances\r
+        */\r
+       public List<NameRelationship> listToNameRelationships(TaxonNameBase name,  NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
+       \r
+       /**\r
+        * Return a List of relationships in which another name is related to this name, optionally filtered \r
+        * by relationship type\r
+        * \r
+        * @param name the name on the <i>"to side"</i> of the relationship \r
+        * @param type the relationship type (or null to return all relationships) \r
+        * @param pageSize The maximum number of relationships returned (can be null for all relationships)\r
+        * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+        * @param orderHints may be null\r
+        * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}\r
+        * @return a Pager of NameRelationship instances\r
+        */\r
+       public Pager<NameRelationship> pageToNameRelationships(TaxonNameBase name,  NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
+       \r
+       \r
+       /**\r
+        * Return a List of hybrids related to this name, optionally filtered \r
+        * by hybrid relationship type\r
+        * \r
+        * @param name the name\r
+        * @param type the hybrid relationship type (or null to return all hybrids) \r
+        * @param pageSize The maximum number of hybrid relationships returned (can be null for all relationships)\r
+        * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+        * @param orderHints may be null\r
+        * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}\r
+        * @return a Pager of HybridRelationship instances\r
+        */\r
+       public Pager<HybridRelationship> getHybridNames(NonViralName name, HybridRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
+       \r
+       /**\r
+        * Return a List of types related to this name, optionally filtered \r
+        * by type designation status\r
+        * \r
+        * @param name the name\r
+        * @param status the type designation status (or null to return all types) \r
+        * @param pageSize The maximum number of types returned (can be null for all types)\r
+        * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+        * @return a Pager of TypeDesignationBase instances\r
+        */\r
+       public Pager<TypeDesignationBase> getTypeDesignations(TaxonNameBase name, \r
+                       SpecimenTypeDesignationStatus status, Integer pageSize, Integer pageNumber);\r
+       \r
+       public Pager<TypeDesignationBase> getTypeDesignations(TaxonNameBase name,\r
+                       SpecimenTypeDesignationStatus status, Integer pageSize, Integer pageNumber, List<String> propertyPaths);\r
+       \r
+       \r
+       /**\r
+        * Returns a List of TaxonNameBase instances that match the properties passed\r
+        * \r
+        * @param uninomial\r
+        * @param infraGenericEpithet\r
+        * @param specificEpithet\r
+        * @param infraspecificEpithet\r
+        * @param rank\r
+        * @param pageSize The maximum number of names returned (can be null for all names)\r
+        * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)\r
+        * @param orderHints may be null\r
+        * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}\r
+        * @return a Pager of TaxonNameBase instances\r
+        */\r
+       public Pager<TaxonNameBase> searchNames(String uninomial, String infraGenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
+       \r
+       /**\r
+        * Returns a Paged List of TaxonNameBase 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 TaxonNameBase instances)\r
+        * @param queryString\r
+        * @param pageSize The maximum number of names returned (can be null for all matching names)\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 TaxonNameBase 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<TaxonNameBase> search(Class<? extends TaxonNameBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
+\r
+       /**\r
+        * Returns a map that holds uuid, titleCache pairs of all names in the current database\r
+        * \r
+        * @return \r
+        *                      a <code>Map</code> containing uuid and titleCache of names\r
+        */\r
+       public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames();\r
+       \r
+       /**\r
+        * Return a Pager of names matching the given query string, optionally filtered by class, optionally with a particular MatchMode\r
+        * \r
+        * @param clazz filter by class - can be null to include all instances of type T\r
+        * @param queryString the query string to filter by\r
+        * @param matchmode use a particular type of matching (can be null - defaults to exact matching)\r
+        * @param criteria additional criteria to filter by\r
+        * @param pageSize The maximum number of objects returned (can be null for all objects)\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
+        * @param orderHints\r
+        *            Supports path like <code>orderHints.propertyNames</code> which\r
+        *            include *-to-one properties like createdBy.username or\r
+        *            authorTeam.persistentTitleCache\r
+        * @return a paged list of instances of type T matching the queryString\r
         */\r
-       public abstract TermVocabulary<NameRelationshipType> getNameRelationshipTypeVocabulary();\r
+    public Pager<TaxonNameBase> findByName(Class<? extends TaxonNameBase> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);\r
 }
\ No newline at end of file