- added service method deleteDerivateHierarchy()
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ITaxonService.java
index 55923c963fadddd6830710323a59e9219ab6fa3d..b713811b9378ea80c7465bd13e58b30458f8b79a 100644 (file)
@@ -11,6 +11,7 @@
 package eu.etaxonomy.cdm.api.service;
 
 import java.io.IOException;
+import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
 import java.util.UUID;
@@ -19,13 +20,17 @@ import org.apache.lucene.index.CorruptIndexException;
 import org.apache.lucene.queryParser.ParseException;
 
 import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
+import eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration;
 import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator;
+import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;
 import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
 import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
-import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
+import eu.etaxonomy.cdm.api.service.search.LuceneMultiSearchException;
 import eu.etaxonomy.cdm.api.service.search.SearchResult;
+import eu.etaxonomy.cdm.api.service.util.TaxonRelationshipEdge;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
@@ -34,6 +39,8 @@ import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
 import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;
+import eu.etaxonomy.cdm.model.location.NamedArea;
 import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.media.MediaRepresentation;
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
@@ -48,33 +55,13 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
-import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;
+import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
 import eu.etaxonomy.cdm.persistence.fetch.CdmFetch;
 import eu.etaxonomy.cdm.persistence.query.OrderHint;
 
 
 public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
 
-    /**
-     * Computes all taxon bases.
-     * @param limit
-     * @param start
-     * @return
-     *
-     * FIXME could substitute with list(Synonym.class, limit, start)
-     */
-    public List<Synonym> getAllSynonyms(int limit, int start);
-
-    /**
-     * Computes all taxon bases.
-     * @param limit
-     * @param start
-     * @return
-     *
-     * FIXME could substitute with list(Taxon.class, limit,start)
-     */
-    public List<Taxon> getAllTaxa(int limit, int start);
-
     /**
      * Computes all Taxon instances that do not have a taxonomic parent.
      * @param sec The concept reference that the taxon belongs to
@@ -83,6 +70,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @return The List<Taxon> of root taxa.
      * @deprecated obsolete when using classification
      */
+    @Deprecated
     public List<Taxon> getRootTaxa(Reference sec, CdmFetch cdmFetch, boolean onlyWithChildren);
 
     /**
@@ -95,11 +83,12 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param propertyPaths
      *            properties to be initialized, For detailed description and
      *            examples <b>please refer to:</b>
-     *            {@link BeanInitializer#initialize(Object, List)}. <Br>
+     *            {@link IBeanInitializer#initialize(Object, List)}. <Br>
      *            Default: true.
      * @return The List<Taxon> of root taxa.
      * @deprecated obsolete when using classification
      */
+    @Deprecated
     public List<Taxon> getRootTaxa(Rank rank, Reference sec, boolean onlyWithChildren, boolean withMisapplications, List<String> propertyPaths);
 
     /**
@@ -116,6 +105,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @return
      * @deprecated use TermService#getVocabulary(VocabularyType) instead
      */
+    @Deprecated
     public OrderedTermVocabulary<TaxonRelationshipType> getTaxonRelationshipTypeVocabulary();
 
     /**
@@ -155,7 +145,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * but also it is than difficult to decide how to handle other names
      * in the homotypic group. It is up to the implementing class to
      * handle this situation via an exception or in another way.
-     * TODO Open issue: does the old synonym need to be deleted from the database?
+     *
      *
      * @param synonym
      *                                 the synonym to change into an accepted taxon
@@ -202,20 +192,50 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     public Taxon changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
 
     /**
-     * Deletes all synonym relationships of a given synonym. If taxon is given only those relationships to the taxon are deleted.
-     * @param syn the synonym
+     * TODO still needed and correct?
+     * Change a synonym into a related concept
+     *
+     * @param synonym
+     *                                 the synonym to change into the concept taxon
+     * @param toTaxon
+     *                                 the taxon the newly created concept should be related to
+     * @param taxonRelationshipType
+     *                                 the type of relationship
+     * @param reference
+     * @param microReference
+     * @return
+     *                                 the newly created concept
+     * @throws DataChangeNoRollbackException
+     */
+  public       Synonym changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
+             TaxonRelationshipType oldRelationshipType,
+            SynonymRelationshipType synonymRelationshipType) throws DataChangeNoRollbackException;
+    /**
+     * Deletes all synonym relationships of a given synonym. If taxon is given
+     * only those relationships to the taxon are deleted.
+     *
+     * @param syn
+     *            the synonym
      * @param taxon
      * @return
+     * @deprecated This method must no longer being used since the
+     *             SynonymRelationship is annotated at the {@link Taxon} and at
+     *             the {@link Synonym} with <code>orphanDelete=true</code>. Just
+     *             remove the from and to entities from the relationship and
+     *             hibernate will care for the deletion. Using this method can cause
+     *             <code>StaleStateException</code> (see http://dev.e-taxonomy.eu/trac/ticket/3797)
+     *
      */
+    @Deprecated
     public long deleteSynonymRelationships(Synonym syn, Taxon taxon);
 
     /**
      * Deletes a taxon from the underlying database according to the given {@link TaxonDeletionConfigurator configurator}.
      * @param taxon
      * @param config
-     * @throws ReferencedObjectUndeletableException
+     *
      */
-    public void deleteTaxon(Taxon taxon, TaxonDeletionConfigurator config) throws ReferencedObjectUndeletableException;
+    public DeleteResult deleteTaxon(Taxon taxon, TaxonDeletionConfigurator config, Classification classification) ;
 
     /**
      * Changes the homotypic group of a synonym into the new homotypic group.
@@ -274,7 +294,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageSize The maximum number of relationships returned (can be null for all relationships)
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * @param orderHints Properties to order by
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
+     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @return a List of TaxonRelationship instances
      */
     public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
@@ -290,7 +310,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageSize The maximum number of relationships returned (can be null for all relationships)
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * @param orderHints Properties to order by
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
+     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @return a Pager of TaxonRelationship instances
      */
     public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
@@ -304,7 +324,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageSize The maximum number of relationships returned (can be null for all relationships)
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * @param orderHints Properties to order by
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
+     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @return a List of TaxonRelationship instances
      */
     public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
@@ -319,11 +339,39 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageSize The maximum number of relationships returned (can be null for all relationships)
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * @param orderHints Properties to order by
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
+     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @return a Pager of TaxonRelationship instances
      */
     public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
+    /**
+     * lists all taxa which are related to the <code>taxon</code> given as
+     * parameter.
+     *
+     * @param taxon
+     * @param includeRelationships
+     * @param maxDepth
+     *            <code>1</code> for one level, <code>null</code> for infinite
+     *            depth, <code>0</code> will completely omit collecting related taxa.
+     * @param limit
+     * @param start
+     * @param propertyPaths
+     * @return
+     */
+    public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
+            Integer limit, Integer start, List<String> propertyPaths);
+
+    /**
+     * lists all accepted taxa for the given {@link Synonym}
+     *
+     * @param taxonBase
+     * @param limit
+     * @param start
+     * @param propertyPaths
+     * @return
+     */
+    public List<Classification> listClassifications(TaxonBase taxonBase, Integer limit, Integer start, List<String> propertyPaths);
+
     /**
      * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
      * where the supplied synonym is relatedFrom.
@@ -333,7 +381,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageSize The maximum number of relationships returned (can be null for all relationships)
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * * @param orderHints Properties to order by
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
+     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @return a Pager of SynonymRelationship instances
      */
     public Pager<SynonymRelationship> getSynonyms(Synonym synonym, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
@@ -347,11 +395,29 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageSize The maximum number of relationships returned (can be null for all relationships)
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * * @param orderHints Properties to order by
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
+     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @return a Pager of SynonymRelationship instances
      */
     public Pager<SynonymRelationship> getSynonyms(Taxon taxon, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
+    /**
+     * This method returns in the first entry the list of synonyms of the
+     * homotypic group of the accepted taxon. All other entries represent the lists of heterotypic
+     * synonym groups. For detailed information about these 2 groups see
+     * {@link #getHomotypicSynonymsByHomotypicGroup(Taxon, List)} and
+     * {@link #getHeterotypicSynonymyGroups(Taxon, List)}
+     *
+     * @see                    #getSynonyms()
+     * @see                    SynonymRelationshipType#HETEROTYPIC_SYNONYM_OF()
+     * @see                    eu.etaxonomy.cdm.model.name.HomotypicalGroup
+
+     * @param taxon the accepted taxon
+     * @param propertyPaths the property path
+     * @return the list of groups of synonyms
+     */
+    public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
+
+
     /**
      * Returns the list of all synonyms that share the same homotypical group with the given taxon.
      * Only those homotypic synonyms are returned that do have a synonym relationship with the accepted taxon.
@@ -401,6 +467,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @return a Pager Taxon instances
      * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
      */
+    @Override
     public Pager<TaxonBase> search(Class<? extends TaxonBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
@@ -446,22 +513,207 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     public Pager<IdentifiableEntity> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator);
 
     /**
+     * performes a union searches for TaxonBase instances on all available
+     * free text indexes. At the time of writing this documentation it combines
+     * {@link #findByDescriptionElementFullText(Class, String, Classification, List, List, boolean, Integer, Integer, List, List)}
+     * and {@link #findByFullText(Class, String, Classification, List, boolean, Integer, Integer, List, List)
+     *
+     * @param queryString
+     *            the query string
+     * @param classification
+     *            Additional filter criterion: If a taxonomic classification
+     *            three is specified here the result set will only contain taxa
+     *            of the given classification
+     * @param languages
+     *            Additional filter criterion: Search only in these languages.
+     *            Not all text fields in the cdm model are multilingual, thus
+     *            this setting will only apply to the multilingiual fields.
+     *            Other fields are searched nevertheless if this parameter is
+     *            set or not.
+     * @param highlightFragments
+     *            TODO
+     * @param pageSize
+     *            The maximum number of objects returned (can be null for all
+     *            objects)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param orderHints
+     *            Supports path like <code>orderHints.propertyNames</code> which
+     *            include *-to-one properties like createdBy.username or
+     *            authorTeam.persistentTitleCache
+     * @param propertyPaths
+     *            properties to initialize - see
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a paged list of instances of type T matching the queryString and
+     *         the additional filter criteria
+     * @return
+     * @throws CorruptIndexException
+     * @throws IOException
+     * @throws ParseException
+     * @throws LuceneMultiSearchException
+     * @deprecated this search should fully be covered by the new method
+     *      {@link #findTaxaAndNamesByFullText(EnumSet, String, Classification, Set, List, boolean, Integer, Integer, List, List)}
+     *      , maybe we should rename this latter method to give it a more meaningful name
+     */
+    @Deprecated
+    public Pager<SearchResult<TaxonBase>> findByEverythingFullText(String queryString,
+            Classification classification, List<Language> languages, boolean highlightFragments,
+            Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException, LuceneMultiSearchException;
+
+    /**
+     * Searches for TaxonBase instances using the TaxonBase free text index.
+     *
+     * <h4>This is an experimental feature, it may be moved, modified, or even
+     * removed in future releases!!!</h4>
+     *
+     * @param clazz
+     *            Additional filter criterion: The specific TaxonBase subclass
+     *            to search for
+     * @param queryString
+     *            the query string
+     * @param classification
+     *            Additional filter criterion: If a taxonomic classification
+     *            three is specified here the result set will only contain taxa
+     *            of the given classification
+     * @param languages
+     *            Additional filter criterion: Search only in these languages.
+     *            Not all text fields in the cdm model are multilingual, thus
+     *            this setting will only apply to the multilingiual fields.
+     *            Other fields are searched nevertheless if this parameter is
+     *            set or not.
+     * @param highlightFragments
+     *            TODO
+     * @param pageSize
+     *            The maximum number of objects returned (can be null for all
+     *            objects)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param orderHints
+     *            Supports path like <code>orderHints.propertyNames</code> which
+     *            include *-to-one properties like createdBy.username or
+     *            authorTeam.persistentTitleCache
+     * @param propertyPaths
+     *            properties to initialize - see
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a paged list of instances of type T matching the queryString and
+     *         the additional filter criteria
+     * @throws CorruptIndexException
+     * @throws IOException
+     * @throws ParseException
+     */
+    public Pager<SearchResult<TaxonBase>> findByFullText(Class<? extends TaxonBase> clazz, String queryString, Classification classification,
+            List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
+            List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException;
+
+
+    /**
+     * @param areaFilter
+     * @param statusFilter
+     * @param classification
+     *            Additional filter criterion: If a taxonomic classification
+     *            three is specified here the result set will only contain taxa
+     *            of the given classification
+     * @param highlightFragments
+     * @param pageSize
+     *            The maximum number of objects returned (can be null for all
+     *            objects)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param orderHints
+     *            Supports path like <code>orderHints.propertyNames</code> which
+     *            include *-to-one properties like createdBy.username or
+     *            authorTeam.persistentTitleCache
+     * @param propertyPath
+     *            Common properties to initialize the instances of the
+     *            CDM types ({@link Taxon} and {@link Synonym}
+     *            this method can return - see {@link IBeanInitializer#initialize(Object, List)}
+     * @return a paged list of instances of {@link Taxon} instances
+     * @throws IOException
+     * @throws ParseException
+     */
+    public Pager<SearchResult<TaxonBase>> findByDistribution(List<NamedArea> areaFilter, List<PresenceAbsenceTermBase<?>> statusFilter,
+            Classification classification,
+            Integer pageSize, Integer pageNumber,
+            List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, ParseException;
+
+    /**
+     * Searches for TaxonBase instances using the TaxonBase free text index.
+     *
+     *
+     *
+     * <h4>This is an experimental feature, it may be moved, modified, or even
+     * removed in future releases!!!</h4>
+     * @param searchModes
+     *            Additional filter criterion: defaults to [doTaxa] if set null
+     * @param queryString
+     *            the query string
+     * @param classification
+     *            Additional filter criterion: If a taxonomic classification
+     *            three is specified here the result set will only contain taxa
+     *            of the given classification
+     * @param namedAreas
+     * @param languages
+     *            Additional filter criterion: Search only in these languages.
+     *            Not all text fields in the cdm model are multilingual, thus
+     *            this setting will only apply to the multilingiual fields.
+     *            Other fields are searched nevertheless if this parameter is
+     *            set or not.
+     * @param highlightFragments
+     *            TODO
+     * @param pageSize
+     *            The maximum number of objects returned (can be null for all
+     *            objects)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param orderHints
+     *            Supports path like <code>orderHints.propertyNames</code> which
+     *            include *-to-one properties like createdBy.username or
+     *            authorTeam.persistentTitleCache
+     * @param propertyPath
+     *            Common properties to initialize the instances of the
+     *            CDM types ({@link Taxon} and {@link Synonym}
+     *            this method can return - see {@link IBeanInitializer#initialize(Object, List)}
+     * @return a paged list of instances of {@link Taxon}, {@link Synonym}, matching the queryString and
+     *         the additional filter criteria
+     * @throws CorruptIndexException
+     * @throws IOException
+     * @throws ParseException
+     * @throws LuceneMultiSearchException
+     */
+    public Pager<SearchResult<TaxonBase>> findTaxaAndNamesByFullText(
+            EnumSet<TaxaAndNamesSearchMode> searchModes,
+            String queryString, Classification classification, Set<NamedArea> namedAreas, Set<PresenceAbsenceTermBase<?>> distributionStatus,
+            List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
+            List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException, LuceneMultiSearchException;
+
+    /**
+     * Searches for TaxonBase instances by using the DescriptionElement free text index.
+     *
      * <h4>This is an experimental feature, it may be moved, modified, or even
      * removed in future releases!!!</h4>
      *
      * @param clazz
+     *            Additional filter criterion:
      * @param queryString
      *            the query string to filter by
      * @param classification
-     *            If a taxonomic classification three is specified here the
-     *            result set will only contain taxa of the given classification
-     * @param features TODO
+     *            Additional filter criterion: If a taxonomic classification
+     *            three is specified here the result set will only contain taxa
+     *            of the given classification
+     * @param features
+     *            TODO
      * @param languages
-     *            Search only in these languages. Not all text fields in the cdm
-     *            model are multilingual, thus this setting will only apply to
-     *            the multilingiual fields. Other fields are searched
-     *            nevertheless if this parameter is set or not.
-     * @param highlightFragments TODO
+     *            Additional filter criterion: Search only in these languages.
+     *            Not all text fields in the cdm model are multilingual, thus
+     *            this setting will only apply to the multilingiual fields.
+     *            Other fields are searched nevertheless if this parameter is
+     *            set or not.
+     * @param highlightFragments
+     *            TODO
      * @param pageSize
      *            The maximum number of objects returned (can be null for all
      *            objects)
@@ -474,8 +726,9 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *            authorTeam.persistentTitleCache
      * @param propertyPaths
      *            properties to initialize - see
-     *            {@link BeanInitializer#initialize(Object, List)}
-     * @return a paged list of instances of type T matching the queryString
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a paged list of instances of type T matching the queryString and
+     *         the additional filter criteria
      * @throws IOException
      * @throws CorruptIndexException
      * @throws ParseException
@@ -492,19 +745,54 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param mimeTypes
      * @return
      *
-     * FIXME candidate for harmonization - rename to listMedia()
+     * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
      */
+    @Deprecated
     public List<MediaRepresentation> getAllMedia(Taxon taxon, int size, int height, int widthOrDuration, String[] mimeTypes);
 
 
     /**
-     * Lists all Media found in an any TaxonDescription associated with this taxon.
+     * Lists all Media found in an any TaxonDescription associated with this
+     * taxon.
+     *
      * @param taxon
-     * @param limitToGalleries whether to take only TaxonDescription into account which are marked as gallery
+     * @param includeRelationships
+     *            the given list of TaxonRelationshipEdges will be taken into
+     *            account when retrieving media associated with the given taxon.
+     *            Can be NULL.
+     * @param limitToGalleries
+     *            whether to take only TaxonDescription into account which are
+     *            marked as gallery
      * @return
+     * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
      */
-    public List<Media> listTaxonDescriptionMedia(Taxon taxon, boolean limitToGalleries, List<String> propertyPath);
+    @Deprecated
+    public List<Media> listTaxonDescriptionMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, boolean limitToGalleries, List<String> propertyPath);
 
+    /**
+     * Lists all Media found in an any TaxonDescription, NameDescription,
+     * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
+     *
+     * @param taxon
+     * @param includeRelationships
+     *            the given list of TaxonRelationshipEdges will be taken into
+     *            account when retrieving media associated with the given taxon.
+     *            Can be NULL.
+     * @param limitToGalleries
+     *            whether to take only descriptions into account which are
+     *            marked as gallery, can be NULL
+     * @param includeTaxonDescriptions
+     *            whether to take TaxonDescriptions into account, can be NULL
+     * @param includeOccurrences
+     *          whether to take TaxonDescriptions into account, can be NULL
+     * @param includeTaxonNameDescriptions
+     *       whether to take TaxonNameDescriptions into account, can be NULL
+     * @param propertyPath
+     * @return
+     */
+    public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
+            Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
+            Boolean includeTaxonNameDescriptions, List<String> propertyPath);
 
     public List<TaxonBase> findTaxaByID(Set<Integer> listOfIDs);
 
@@ -521,13 +809,31 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     public int countAllRelationships();
 
     public List<TaxonNameBase> findIdenticalTaxonNames(List<String> propertyPath);
+
     public List<TaxonNameBase> findIdenticalTaxonNameIds(List<String> propertyPath);
+
     public String getPhylumName(TaxonNameBase name);
 
     public long deleteSynonymRelationships(Synonym syn);
 
-
     /**
+     * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
+     * {@link TaxonRelationshipType#INCLUDES() included} in the taxon represented by the given taxon uuid.
+     * The result also returns the path to these taxa represented by the uuids of
+     * the {@link TaxonRelationshipType taxon relationships types} and doubtful information.
+     * If classificationUuids is set only taxa of classifications are returned which are included
+     * in the given {@link Classification classifications}. ALso the path to these taxa may not include
+     * taxa from other classifications.
+     * @param taxonUuid uuid of the original taxon
+     * @param classificationUuids List of uuids of classifications used as a filter
+     * @param includeDoubtful set to <code>true</code> if also doubtfully included taxa should be included in the result
+     * @return a DTO which includes a list of taxa with the pathes from the original taxon to the given taxon as well
+     * as doubtful and date information. The original taxon is included in the result.
+     */
+    public IncludedTaxaDTO listIncludedTaxa(UUID taxonUuid, IncludedTaxonConfiguration configuration);
+
+
+   /**
      * Removes a synonym.<BR><BR>
      *
      * In detail it removes
@@ -545,9 +851,10 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param taxon
      * @param synonym
      * @param removeNameIfPossible
-     * @throws DataChangeNoRollbackException
+     * @return deleteResult
+     *
      */
-    public void deleteSynonym(Synonym synonym, Taxon taxon, boolean removeNameIfPossible, boolean newHomotypicGroupIfNeeded);
+    public DeleteResult deleteSynonym(Synonym synonym, SynonymDeletionConfigurator config);
 
 
     /**
@@ -559,7 +866,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageSize The maximum number of relationships returned (can be null for all relationships)
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * @param orderHints Properties to order by
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
+     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @param direction The direction of the relationship
      * @return a List of SynonymRelationship instances
      */
@@ -600,13 +907,42 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public List<Synonym>  createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
 
-    public Pager<SearchResult<TaxonBase>> findByFullText(Class<? extends TaxonBase> clazz, String queryString, Classification classification,
-            List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
-            List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException;
 
-    public Pager<SearchResult<TaxonBase>> findByEverythingFullText(String queryString,
-            Classification classification, List<Language> languages, boolean highlightFragments,
-            Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException;
+
+
+    /**
+     * Removes a synonym.<BR><BR>
+     *
+     * In detail it removes
+     *  <li>all synonym relationship to the given taxon or to all taxa if taxon is <code>null</code></li>
+     *  <li>the synonym concept if it is not referenced by any synonym relationship anymore</li>
+     *  <BR><BR>
+     *  If <code>config.removeNameIfPossible</code> is true
+     *  it also removes the synonym name if it is not used in any other context
+     *  (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
+     *  If <code>config.newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name is not deleted and
+     *  the name is homotypic to the taxon the name is moved to a new homotypical group.<BR><BR>
+     *
+     *  If synonym is <code>null</code> the method has no effect.
+     *
+     * @param taxon
+     * @param synonym
+     * @param config
+     * @return deleteResult
+     */
+    DeleteResult deleteSynonym(Synonym synonym, Taxon taxon,
+            SynonymDeletionConfigurator config);
+
+    public Pager<Taxon> pageAcceptedTaxaFor(UUID synonymUuid, UUID classificationUuid, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
+            List<String> propertyPaths);
+
+    public List<Taxon> listAcceptedTaxaFor(UUID synonymUuid, UUID classificationUuid, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
+            List<String> propertyPaths);
+    
+    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
+
+
+