smaller changes in ForSubtreeConfigurator
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ITaxonService.java
index a0a0c065e9aeffb817f95008f62b246b2ab21390..e103b3dda11ae73a72b8f7cc75db40c8ab0dc4dd 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy
@@ -16,29 +15,25 @@ import java.util.List;
 import java.util.Set;
 import java.util.UUID;
 
-import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.queryparser.classic.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.IdentifiedEntityDTO;
-import eu.etaxonomy.cdm.api.service.dto.MarkedEntityDTO;
 import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;
+import eu.etaxonomy.cdm.api.service.dto.MarkedEntityDTO;
 import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
 import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
 import eu.etaxonomy.cdm.api.service.search.LuceneMultiSearchException;
+import eu.etaxonomy.cdm.api.service.search.LuceneParseException;
 import eu.etaxonomy.cdm.api.service.search.SearchResult;
 import eu.etaxonomy.cdm.api.service.util.TaxonRelationshipEdge;
 import eu.etaxonomy.cdm.model.common.DefinedTerm;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.common.MarkerType;
-import eu.etaxonomy.cdm.model.common.RelationshipBase;
-import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
@@ -47,12 +42,11 @@ import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.media.MediaRepresentation;
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.Rank;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
+import eu.etaxonomy.cdm.model.taxon.SynonymType;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
@@ -62,19 +56,11 @@ import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
 import eu.etaxonomy.cdm.persistence.query.MatchMode;
 import eu.etaxonomy.cdm.persistence.query.OrderHint;
+import eu.etaxonomy.cdm.persistence.query.TaxonTitleType;
 
 
 public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
 
-    /**
-     * Computes all relationships.
-     * @param limit
-     * @param start
-     * @return
-     * FIXME candidate for harmonization - rename to listRelationships
-     */
-    public List<RelationshipBase> getAllRelationships(int limit, int start);
-
     /**
      * Returns a list of taxa that matches the name string and the sec reference
      * @param name the name string to search for
@@ -95,7 +81,6 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *
      * @param synonym
      * @param acceptedTaxon
-     * @param synonymRelationshipType the relationship type the newly created synonym will have. Defaults to SYNONYM_OF
      * @return
      */
     public UpdateResult swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon);
@@ -121,15 +106,6 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *                                 an accepted taxon, the synonym had a relationship to
      * @param deleteSynonym
      *                         if true the method tries to delete the old synonym from the database
-     * @param copyCitationInfo
-     *                         if true the citation and the microcitation of newly created synonyms
-     *                         is taken from the old synonym relationships.
-     * @param citation
-     *                         if given this citation is added to the newly created synonym
-     *                         relationships as citation. Only used if copyCitationInfo is <code> false</code>
-     * @param microCitation
-     *                         if given this microCitation is added to the newly created synonym
-     *                         relationships as microCitation.Only used if copyCitationInfo is <code> false</code>
      * @return
      *                         the newly created accepted taxon
      * @throws IllegalArgumentException
@@ -140,10 +116,21 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *          in the homotypic group. It is up to the implementing class to
      *          handle this situation via an exception or in another way.
      */
-    public Taxon changeSynonymToAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon, boolean deleteSynonym, boolean copyCitationInfo, Reference citation, String microCitation) throws HomotypicalGroupChangeException;
+    public UpdateResult changeSynonymToAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon, boolean deleteSynonym) throws HomotypicalGroupChangeException;
+
+    /**
+     * @param synonymUuid
+     * @param acceptedTaxonUuid
+     * @param newParentNodeUuid
+     * @param deleteSynonym
+     * @return
+     * @throws HomotypicalGroupChangeException
+     */
+    public UpdateResult changeSynonymToAcceptedTaxon(UUID synonymUuid, UUID acceptedTaxonUuid, UUID newParentNodeUuid,
+            boolean deleteSynonym)
+            throws HomotypicalGroupChangeException;
 
     /**
-     * TODO still needed and correct?
      * Change a synonym into a related concept
      *
      * @param synonym
@@ -155,29 +142,30 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param reference
      * @param microReference
      * @return
-     *                                 the newly created concept
+     *                                 update result with the newly created concept
      */
-    public Taxon changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
+    public UpdateResult changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
 
     /**
-     * TODO still needed and correct?
-     * Change a synonym into a related concept
+     *
+     * Change a related concept into synonym
      *
      * @param synonym
-     *                                 the synonym to change into the concept taxon
+     *                                 the concept taxon to change into a synonym
      * @param toTaxon
-     *                                 the taxon the newly created concept should be related to
-     * @param taxonRelationshipType
-     *                                 the type of relationship
-     * @param reference
-     * @param microReference
+     *                                 the taxon the newly created synonym should be related to
+     * @param oldRelationshipType
+     *              the type of old concept relationship
+     * @param synonymRelationshipType
+     *                                 the type of new synonym relationship
+     *
      * @return
-     *                                 the newly created concept
+     *                                 update result with the newly created synonym
      * @throws DataChangeNoRollbackException
      */
-  public       Synonym changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
+  public       UpdateResult changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
              TaxonRelationshipType oldRelationshipType,
-            SynonymRelationshipType synonymRelationshipType) throws DataChangeNoRollbackException;
+            SynonymType synonymType) throws DataChangeNoRollbackException;
 
     /**
      * Changes the homotypic group of a synonym into the new homotypic group.
@@ -187,8 +175,6 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * If the parameter <code>targetTaxon</code> is defined, the synonym is
      * added to this taxon irrespctive of if it has been related to this
      * taxon before.<BR>
-     * If <code>removeFromOtherTaxa</code> is true and <code>targetTaxon</code> is
-     * defined all relationships to other taxa are deleted.<BR>
      * If <code>setBasionymRelationIfApplicable</code> is true a basionym relationship
      * between the existing basionym(s) of the new homotypic group and the synonyms name
      * is added.<BR>
@@ -198,34 +184,68 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param taxon
      * @param setBasionymRelationIfApplicable
      */
-    public void changeHomotypicalGroupOfSynonym(Synonym synonym, HomotypicalGroup newHomotypicalGroup, Taxon targetTaxon,
-                        boolean removeFromOtherTaxa, boolean setBasionymRelationIfApplicable);
+    public void changeHomotypicalGroupOfSynonym(Synonym synonym, HomotypicalGroup newHomotypicalGroup,
+            Taxon targetTaxon, boolean setBasionymRelationIfApplicable);
+
+    /**
+     * See {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
+     * @param oldSynonym
+     * @param newTaxon
+     * @param moveHomotypicGroup
+     * @param newSynonymType
+     * @return
+     * @throws HomotypicalGroupChangeException
+     */
+    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
+            SynonymType newSynonymType) throws HomotypicalGroupChangeException;
 
 
     /**
      * Moves a synonym to another taxon and removes the old synonym relationship.
      *
-     * @param oldSynonymRelation the old synonym relationship defining the synonym to move and the old accepted taxon.
+     * @param oldSynonym the old synonym to move.
      * @param newTaxon the taxon the synonym will be moved to
-     * @param moveHomotypicGroup if the synonym belongs to a homotypical group with other synonyms and
+     * @param moveHomotypicGroup if the synonym belongs to a homotypic group with other synonyms and
      *                 <code>moveHomotypicGroup</code> is <code>true</code> all these synonyms are moved to the new taxon,
      *                 if <code>false</code> a {@link HomotypicalGroupChangeException} is thrown.
-     *                 <code>MoveHomotypicGroup</code> has no effect if the synonym is the only synonym in it's homotypic group.
-     * @param newSynonymRelationshipType the synonym relationship type of the new synonym relations. Default is
-     *                 {@link SynonymRelationshipType#HETEROTYPIC_SYNONYM_OF() heterotypic}.
-     * @param newReference The reference for the new synonym relation(s).
-     * @param newReferenceDetail The reference detail for the new synonym relation(s).
-     * @param keepReference if no <code>newReference</code> and/or no <code>newReferenceDetail</code>
-     *                 is defined they are taken from the old synonym relation(s) if <code>keepReference</code> is
-     *                 <code>true</code>. If <code>false</code> the reference and the reference detail will be taken
-     *                 only from the <code>newReference</code> and <code>newReferenceDetail</code>.
+     *                 <code>moveHomotypicGroup</code> has no effect if the synonym is the only synonym in it's homotypic group.
+     * @param newSynonymType the synonym type of the new synonyms. Default is
+     *                 {@link SynonymType#HETEROTYPIC_SYNONYM_OF() heterotypic}.
+     * @param newSecundum The secundum for the new synonyms).
+     * @param newSecundumDetail The secundum micro reference for the new synonym(s).
+     * @param keepSecundumIfUndefined if no <code>newSecundum</code> and/or no <code>newSecundumDetail</code>
+     *                 is defined they are taken from the old synonym(s) if <code>keepSecundumIfUndefined</code> is
+     *                 <code>true</code>. If <code>false</code> the secundum and the secundum detail will be taken
+     *                 only from the <code>newSecundum</code> and <code>newSecundumDetail</code> even if they are
+     *      undefined (<code>null</code>).
      * @return The new synonym relationship. If <code>moveHomotypicGroup</code> is <code>true</code> additionally
      *                 created new synonym relationships must be retrieved separately from the new taxon.
      * @throws HomotypicalGroupChangeException Exception is thrown if (1) synonym is homotypic to the old accepted taxon or
      *                 (2) synonym is in homotypic group with other synonyms and <code>moveHomotypicGroup</code> is false
      */
-    public UpdateResult moveSynonymToAnotherTaxon(SynonymRelationship oldSynonymRelation, Taxon newTaxon, boolean moveHomotypicGroup,
-            SynonymRelationshipType newSynonymRelationshipType, Reference newReference, String newReferenceDetail, boolean keepReference) throws HomotypicalGroupChangeException;
+    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
+            SynonymType newSynonymType, Reference newSecundum,
+            String newSecundumDetail, boolean keepSecundumIfUndefined) throws HomotypicalGroupChangeException;
+
+
+    /**
+     * @param oldSynonym
+     * @param newTaxonUUID
+     * @param moveHomotypicGroup
+     * @param newSynonymType
+     * @param reference
+     * @param referenceDetail
+     * @param keepReference
+     * @return
+     * @throws HomotypicalGroupChangeException
+     *
+     * @see {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
+     */
+    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym,
+            UUID newTaxonUUID, boolean moveHomotypicGroup,
+            SynonymType newSynonymType,
+            Reference newSecundum, String newSecundumDetail, boolean keepSecundumIfUndefined)
+            throws HomotypicalGroupChangeException;
 
     /**
      * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
@@ -242,7 +262,6 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
 
-
     /**
      * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
      * where the supplied taxon is relatedTo.
@@ -303,8 +322,23 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
             Integer limit, Integer start, List<String> propertyPaths);
 
+
+    /**
+     * Returns all or a page of all taxon concept relationships in the database.
+     * The result can be filtered by relationship types.
+     *
+     * @param types The taxon relationship type filter, if <code>null</code> no filter is set, if empty the result will also be empty
+     * @param pageSize the page size
+     * @param pageStart the number of the start page
+     * @param orderHints the order hints
+     * @param propertyPaths the property path to initialize the resulting objects
+     * @return list of taxon relationships matching the filter criteria
+     */
+    public List<TaxonRelationship> listTaxonRelationships(Set<TaxonRelationshipType> types,
+            Integer pageSize, Integer pageStart, List<OrderHint> orderHints, List<String> propertyPaths);
+
     /**
-     * lists all accepted taxa for the given {@link Synonym}
+     * Lists all classifications the given taxon/synonym is used in{@link Synonym}
      *
      * @param taxonBase
      * @param limit
@@ -315,32 +349,18 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     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.
+     * Returns the Synonyms (with the given synonym relationship type, if this argument is supplied)
+     * that do have the supplied taxon as accepted taxon.
      *
-     * @param taxon The synonym that is relatedFrom
-     * @param type The type of SynonymRelationship (can be null)
-     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
+     * @param taxon The accepted taxon
+     * @param type The type of Synonym (can be null)
+     * @param pageSize The maximum number of synonyms returned (can be null for returning synonyms)
      * @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 IBeanInitializer#initialize(Object, List)}
-     * @return a Pager of SynonymRelationship instances
+     * @return a Pager of {@link Synonym} instances
      */
-    public Pager<SynonymRelationship> getSynonyms(Synonym synonym, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
-
-    /**
-     * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
-     * where the supplied taxon is relatedTo.
-     *
-     * @param taxon The taxon that is relatedTo
-     * @param type The type of SynonymRelationship (can be null)
-     * @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 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);
+    public Pager<Synonym> getSynonyms(Taxon taxon, SynonymType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
      * This method returns in the first entry the list of synonyms of the
@@ -350,7 +370,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * {@link #getHeterotypicSynonymyGroups(Taxon, List)}
      *
      * @see                    #getSynonyms()
-     * @see                    SynonymRelationshipType#HETEROTYPIC_SYNONYM_OF()
+     * @see                    SynonymType#HETEROTYPIC_SYNONYM_OF()
      * @see                    eu.etaxonomy.cdm.model.name.HomotypicalGroup
 
      * @param taxon the accepted taxon
@@ -372,7 +392,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     /**
      * Returns the ordered list of all {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup homotypical groups}
      * that contain {@link Synonym synonyms} that are heterotypic to the given taxon.
-     * {@link eu.etaxonomy.cdm.model.name.TaxonNameBase Taxon names} of heterotypic synonyms
+     * {@link eu.etaxonomy.cdm.model.name.TaxonName Taxon names} of heterotypic synonyms
      * belong to a homotypical group which cannot be the homotypical group to which the
      * taxon name of the given taxon belongs. This method does not return the homotypic group the given
      * taxon belongs to.<BR>
@@ -385,7 +405,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *
      * @see                    #getHeterotypicSynonymyGroups()
      * @see                    #getSynonyms()
-     * @see                    SynonymRelationshipType#HETEROTYPIC_SYNONYM_OF()
+     * @see                    SynonymType#HETEROTYPIC_SYNONYM_OF()
      * @see                    eu.etaxonomy.cdm.model.name.HomotypicalGroup
 
      * @param taxon
@@ -447,7 +467,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     public List<TaxonBase> listTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, String authorship, Rank rank, Integer pageSize, Integer pageNumber);
 
     /**
-     * Returns a list of IdentifiableEntity instances (in particular, TaxonNameBase and TaxonBase instances)
+     * Returns a list of IdentifiableEntity instances (in particular, TaxonName and TaxonBase instances)
      * that match the properties specified in the configurator.
      * @param configurator
      * @return
@@ -490,9 +510,9 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @return a paged list of instances of type T matching the queryString and
      *         the additional filter criteria
      * @return
-     * @throws CorruptIndexException
+     * @throws LuceneCorruptIndexException
      * @throws IOException
-     * @throws ParseException
+     * @throws LuceneParseException
      * @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)}
@@ -501,7 +521,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     @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;
+            Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException, LuceneMultiSearchException;
 
     /**
      * Searches for TaxonBase instances using the TaxonBase free text index.
@@ -541,13 +561,13 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *            {@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 LuceneCorruptIndexException
      * @throws IOException
-     * @throws ParseException
+     * @throws LuceneParseException
      */
     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;
+            List<String> propertyPaths) throws IOException, LuceneParseException;
 
 
     /**
@@ -574,12 +594,12 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *            this method can return - see {@link IBeanInitializer#initialize(Object, List)}
      * @return a paged list of instances of {@link Taxon} instances
      * @throws IOException
-     * @throws ParseException
+     * @throws LuceneParseException
      */
     public Pager<SearchResult<TaxonBase>> findByDistribution(List<NamedArea> areaFilter, List<PresenceAbsenceTerm> statusFilter,
             Classification classification,
             Integer pageSize, Integer pageNumber,
-            List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, ParseException;
+            List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
 
     /**
      * Searches for TaxonBase instances using the TaxonBase free text index.
@@ -621,16 +641,16 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *            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 LuceneCorruptIndexException
      * @throws IOException
-     * @throws ParseException
+     * @throws LuceneParseException
      * @throws LuceneMultiSearchException
      */
     public Pager<SearchResult<TaxonBase>> findTaxaAndNamesByFullText(
             EnumSet<TaxaAndNamesSearchMode> searchModes,
             String queryString, Classification classification, Set<NamedArea> namedAreas, Set<PresenceAbsenceTerm> distributionStatus,
             List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
-            List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException, LuceneMultiSearchException;
+            List<String> propertyPaths) throws IOException, LuceneParseException, LuceneMultiSearchException;
 
     /**
      * Searches for TaxonBase instances by using the DescriptionElement free text index.
@@ -672,10 +692,10 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @return a paged list of instances of type T matching the queryString and
      *         the additional filter criteria
      * @throws IOException
-     * @throws CorruptIndexException
-     * @throws ParseException
+     * @throws LuceneCorruptIndexException
+     * @throws LuceneParseException
      */
-    public Pager<SearchResult<TaxonBase>> findByDescriptionElementFullText(Class<? extends DescriptionElementBase> clazz, String queryString, Classification classification, List<Feature> features, List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException;
+    public Pager<SearchResult<TaxonBase>> findByDescriptionElementFullText(Class<? extends DescriptionElementBase> clazz, String queryString, Classification classification, List<Feature> features, List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
 
 
     /**
@@ -748,15 +768,19 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public TaxonBase findTaxonByUuid(UUID uuid, List<String> propertyPaths);
 
-    public int countAllRelationships();
-
-    public List<TaxonNameBase> findIdenticalTaxonNames(List<String> propertyPath);
-
-    public List<TaxonNameBase> findIdenticalTaxonNameIds(List<String> propertyPath);
+    /**
+     * Counts the number of synonyms
+     * @param onlyAttachedToTaxon if <code>true</code> only those synonyms being attached to
+     * an accepted taxon are counted
+     * @return the number of synonyms
+     */
+    public int countSynonyms(boolean onlyAttachedToTaxon);
 
-    public String getPhylumName(TaxonNameBase name);
+    public List<TaxonName> findIdenticalTaxonNames(List<String> propertyPath);
 
-    public long deleteSynonymRelationships(Synonym syn);
+    public List<TaxonName> findIdenticalTaxonNameIds(List<String> propertyPath);
+//
+//    public String getPhylumName(TaxonName name);
 
     /**
      * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
@@ -779,14 +803,14 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * 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>
+     *  <li>the synonym concept</li>
      *  <BR><BR>
      *  If <code>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>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 <code>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 homotypic group.<BR><BR>
      *
      *  If synonym is <code>null</code> the method has no effect.
      *
@@ -810,23 +834,6 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public DeleteResult deleteSynonym(UUID synonymUuid, SynonymDeletionConfigurator config);
 
-    /**
-     * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
-     * depending on direction, where the supplied taxon is relatedTo or the supplied synonym is relatedFrom.
-     *
-     * @param taxonBase The taxon or synonym that is relatedTo or relatedFrom
-     * @param type The type of SynonymRelationship (can be null)
-     * @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 IBeanInitializer#initialize(Object, List)}
-     * @param direction The direction of the relationship
-     * @return a List of SynonymRelationship instances
-     */
-    public List<SynonymRelationship> listSynonymRelationships(
-            TaxonBase taxonBase, SynonymRelationshipType type, Integer pageSize, Integer pageNumber,
-            List<OrderHint> orderHints, List<String> propertyPaths, Direction direction);
-
     /**
      * @param tnb
      * @return
@@ -837,11 +844,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
 
     public Synonym findBestMatchingSynonym(String taxonName);
 
-    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern);
-
-    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern);
-
-    public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
+     public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
 
     /**
      * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
@@ -849,7 +852,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param tree
      * @return list of inferred synonyms
      */
-    public List<Synonym> createInferredSynonyms(Taxon taxon, Classification tree, SynonymRelationshipType type, boolean doWithMisappliedNames);
+    public List<Synonym> createInferredSynonyms(Taxon taxon, Classification tree, SynonymType type, boolean doWithMisappliedNames);
 
     /**
      * Creates all inferred synonyms for the taxon in the classification, but do not insert it to the database
@@ -860,38 +863,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public List<Synonym>  createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
 
-
-
-
-    /**
-     * 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
-     */
-    public 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 Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, List<String> propertyPaths);
 
     public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
 
@@ -923,6 +895,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param markerValue the optional
      * @param subtreeFilter filter on a classification subtree (TaxonNode)
      * @param includeEntity should the taxon as an object be included in the result
+     * @param titleType which label to give the returned entity, taxon.titleCache, name.titleCache or name.nameCache
      * @param pageSize page size
      * @param pageNumber page number
      * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
@@ -931,16 +904,8 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public <S extends TaxonBase> Pager<MarkedEntityDTO<S>> findByMarker(
             Class<S> clazz, MarkerType markerType, Boolean markerValue,
-            TaxonNode subtreeFilter, boolean includeEntity, Integer pageSize,
-            Integer pageNumber, List<String> propertyPaths);
-
-    /**
-     * @param synonymUuid
-     * @param taxonUuid
-     * @param config
-     * @return
-     */
-    public DeleteResult deleteSynonym(UUID synonymUuid, UUID taxonUuid, SynonymDeletionConfigurator config);
+            TaxonNode subtreeFilter, boolean includeEntity, TaxonTitleType titleType,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * @param synonymUUid
@@ -957,11 +922,6 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public DeleteResult deleteTaxon(UUID taxonUuid, TaxonDeletionConfigurator config, UUID classificationUuid);
 
-       public UpdateResult moveSynonymToAnotherTaxon(SynonymRelationship oldSynonymRelation,
-                       UUID newTaxonUUID, boolean moveHomotypicGroup,
-                       SynonymRelationshipType newSynonymRelationshipType,
-                       Reference reference, String referenceDetail, boolean keepReference)
-                       throws HomotypicalGroupChangeException;
 
        public UpdateResult moveFactualDateToAnotherTaxon(UUID fromTaxonUuid,
                        UUID toTaxonUuid);
@@ -982,31 +942,12 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param fromTaxonUuid
      * @param toTaxonUuid
      * @param oldRelationshipType
-     * @param synonymRelationshipType
+     * @param synonymType
      * @return
      * @throws DataChangeNoRollbackException
      */
     public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
-            TaxonRelationshipType oldRelationshipType, SynonymRelationshipType synonymRelationshipType) throws DataChangeNoRollbackException;
-
-    /**
-     * @param synonymUuid
-     * @param acceptedTaxonUuid
-     * @param newParentNodeUuid
-     * @param deleteSynonym
-     * @param copyCitationInfo
-     * @param citation
-     * @param microCitation
-     * @return
-     * @throws HomotypicalGroupChangeException
-     */
-    public UpdateResult changeSynonymToAcceptedTaxon(UUID synonymUuid, UUID acceptedTaxonUuid, UUID newParentNodeUuid,
-            boolean deleteSynonym, boolean copyCitationInfo, Reference citation, String microCitation)
-            throws HomotypicalGroupChangeException;
-
-
-
-
+            TaxonRelationshipType oldRelationshipType, SynonymType synonymType) throws DataChangeNoRollbackException;