ref #1445: fix helper methods for pesi merging
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ITaxonService.java
index 5c0e03b33c54753b2feb4b7d8b56f3d6c67eed6c..18719bf01caf7a8f3271207d1752fbf2b74eb043 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy
@@ -16,101 +15,63 @@ import java.util.List;
 import java.util.Set;
 import java.util.UUID;
 
-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.FindByIdentifierDTO;
+import eu.etaxonomy.cdm.api.service.dto.IdentifiedEntityDTO;
 import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;
+import eu.etaxonomy.cdm.api.service.dto.MarkedEntityDTO;
+import eu.etaxonomy.cdm.api.service.dto.TaxonRelationshipsDTO;
 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.exception.UnpublishedException;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.Language;
-import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
-import eu.etaxonomy.cdm.model.common.RelationshipBase;
+import eu.etaxonomy.cdm.model.common.MarkerType;
 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.PresenceAbsenceTerm;
 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;
 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;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.cdm.model.term.DefinedTerm;
+import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
 import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
-import eu.etaxonomy.cdm.persistence.fetch.CdmFetch;
+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>{
+public interface ITaxonService
+             extends IIdentifiableEntityService<TaxonBase>, IPublishableService<TaxonBase>{
 
     /**
-     * Computes all Taxon instances that do not have a taxonomic parent.
-     * @param sec The concept reference that the taxon belongs to
-     *
-     * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
-     * @return The List<Taxon> of root taxa.
-     * @deprecated obsolete when using classification
+     * {@inheritDoc}
+     * <BR><BR>
+     * NOTE: Also taxa with <code>publish=false</code> are returned.
      */
-    @Deprecated
-    public List<Taxon> getRootTaxa(Reference sec, CdmFetch cdmFetch, boolean onlyWithChildren);
-
-    /**
-     * Computes all Taxon instances which name is of a certain Rank.
-     * @param rank The rank of the taxon name
-     * @param sec The concept reference that the taxon belongs to
-     * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
-     * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
-     * the misapplied name are not returned.<Br>Default: true.
-     * @param propertyPaths
-     *            properties to be initialized, For detailed description and
-     *            examples <b>please refer to:</b>
-     *            {@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);
-
-    /**
-     * Computes all relationships.
-     * @param limit
-     * @param start
-     * @return
-     * FIXME candidate for harmonization - rename to listRelationships
-     */
-    public List<RelationshipBase> getAllRelationships(int limit, int start);
-
-    /**
-     * Returns TaxonRelationshipType vocabulary
-     * @return
-     * @deprecated use TermService#getVocabulary(VocabularyType) instead
-     */
-    @Deprecated
-    public OrderedTermVocabulary<TaxonRelationshipType> getTaxonRelationshipTypeVocabulary();
+    @Override
+    public TaxonBase load(UUID uuid, List<String> propertyPaths);
 
     /**
      * Returns a list of taxa that matches the name string and the sec reference
@@ -118,7 +79,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param sec the taxons sec reference
      * @return a list of taxa matching the name and the sec reference
      */
-    public List<TaxonBase> searchTaxaByName(String name, Reference sec);
+    public List<TaxonBase> searchByName(String name, boolean includeUnpublished, Reference sec);
 
     /**
      * Swaps given synonym and accepted taxon.
@@ -132,9 +93,10 @@ 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
+     * @param setNameInSource
+     * @return
      */
-    public void swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon);
+    public UpdateResult swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon, boolean setNameInSource);
 
     /**
      * Changes a synonym into an accepted taxon and removes
@@ -157,15 +119,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
@@ -176,27 +129,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;
 
     /**
-     * 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
+     * @param synonymUuid
+     * @param acceptedTaxonUuid
+     * @param newParentNodeUuid
+     * @param deleteSynonym
      * @return
-     *                                 the newly created concept
+     * @throws HomotypicalGroupChangeException
      */
-    public Taxon changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
+    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
@@ -208,38 +155,30 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param reference
      * @param microReference
      * @return
-     *                                 the newly created concept
-     * @throws DataChangeNoRollbackException
+     *                                 update result with the newly created concept
      */
-  public       Synonym changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
-             TaxonRelationshipType oldRelationshipType,
-            SynonymRelationshipType synonymRelationshipType) throws DataChangeNoRollbackException;
+    public UpdateResult 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
-     * @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)
+     * Change a related concept into synonym
      *
-     */
-    @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
+     * @param synonym
+     *                                 the concept taxon to change into a synonym
+     * @param toTaxon
+     *                                 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
+     *                                 update result with the newly created synonym
+     * @throws DataChangeNoRollbackException
      */
-    public DeleteResult deleteTaxon(Taxon taxon, TaxonDeletionConfigurator config, Classification classification) ;
+  public       UpdateResult changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
+             TaxonRelationshipType oldRelationshipType,
+            SynonymType synonymType) throws DataChangeNoRollbackException;
 
     /**
      * Changes the homotypic group of a synonym into the new homotypic group.
@@ -249,8 +188,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>
@@ -260,34 +197,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 SynonymRelationship 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)
@@ -295,14 +266,15 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *
      * @param taxon The taxon that is relatedTo
      * @param type The type of TaxonRelationship (can be null)
+     * @param includeUnpublished should unpublished related taxa also be returned?
      * @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 List of TaxonRelationship instances
      */
-    public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
-
+    public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
+            boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
 
     /**
@@ -311,13 +283,15 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *
      * @param taxon The taxon that is relatedTo
      * @param type The type of TaxonRelationship (can be null)
+     * @param includeUnpublished should unpublished related taxa also be returned?
      * @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 TaxonRelationship instances
      */
-    public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
+    public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
+            boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
      * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
@@ -325,13 +299,15 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *
      * @param taxon The taxon that is relatedFrom
      * @param type The type of TaxonRelationship (can be null)
+     * @param includeUnpublished should unpublished related taxa also be returned?
      * @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 List of TaxonRelationship instances
      */
-    public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
+    public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
+            boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
 
     /**
@@ -340,13 +316,15 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *
      * @param taxon The taxon that is relatedFrom
      * @param type The type of TaxonRelationship (can be null)
+     * @param includeUnpublished should unpublished related taxa also be returned?
      * @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 TaxonRelationship instances
      */
-    public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
+    public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
+            boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
      * lists all taxa which are related to the <code>taxon</code> given as
@@ -363,10 +341,25 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @return
      */
     public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
-            Integer limit, Integer start, List<String> propertyPaths);
+            boolean includeUnpublished, 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 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 pageNumber, 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
@@ -377,32 +370,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.
-     *
-     * @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 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(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.
+     * 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 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 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(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
@@ -412,7 +391,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
@@ -434,7 +413,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>
@@ -447,7 +426,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
@@ -489,7 +468,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * @return a list of TaxonBase instances
      */
-    public Pager<TaxonBase> findTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber);
+    public Pager<TaxonBase> findTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, String authorship, Rank rank, Integer pageSize, Integer pageNumber);
 
     /**
      * Returns a list of TaxonBase instances where the
@@ -506,10 +485,10 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
      * @return a List of TaxonBase instances
      */
-    public List<TaxonBase> listTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber);
+    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
@@ -552,9 +531,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)}
@@ -562,8 +541,8 @@ 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;
+            Classification classification, TaxonNode subtree, boolean includeUnpublished, List<Language> languages, boolean highlightFragments,
+            Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException, LuceneMultiSearchException;
 
     /**
      * Searches for TaxonBase instances using the TaxonBase free text index.
@@ -603,13 +582,16 @@ 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;
+    public Pager<SearchResult<TaxonBase>> findByFullText(Class<? extends TaxonBase> clazz, String queryString,
+            Classification classification, TaxonNode subtree,
+            boolean includeUnpublished, List<Language> languages,
+            boolean highlightFragments, Integer pageSize, Integer pageNumber,
+            List<OrderHint> orderHints, List<String> propertyPaths)
+                    throws IOException, LuceneParseException;
 
 
     /**
@@ -636,12 +618,13 @@ 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
      */
+    //TODO needed? currently only used in test
     public Pager<SearchResult<TaxonBase>> findByDistribution(List<NamedArea> areaFilter, List<PresenceAbsenceTerm> statusFilter,
-            Classification classification,
+            Classification classification, TaxonNode subtree,
             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.
@@ -658,7 +641,9 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *            Additional filter criterion: If a taxonomic classification
      *            three is specified here the result set will only contain taxa
      *            of the given classification
+     * @param subtree
      * @param namedAreas
+     * @param distributionStatus
      * @param languages
      *            Additional filter criterion: Search only in these languages.
      *            Not all text fields in the cdm model are multilingual, thus
@@ -683,16 +668,17 @@ 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,
+            String queryString, Classification classification, TaxonNode subtree,
+            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.
@@ -706,14 +692,18 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      *            the query string to filter by
      * @param classification
      *            Additional filter criterion: If a taxonomic classification
-     *            three is specified here the result set will only contain taxa
+     *            tree is specified here the result set will only contain taxa
      *            of the given classification
+     * @param subtree
+     *            Additional filter criterion: If a taxonomic classification
+     *            subtree is specified here the result set will only contain taxa
+     *            of the given subtree
      * @param features
      *            TODO
      * @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.
+     *            Not all text fields in the CDM model are multi-lingual, thus
+     *            this setting will only apply to the multi-lingual fields.
      *            Other fields are searched nevertheless if this parameter is
      *            set or not.
      * @param highlightFragments
@@ -734,26 +724,11 @@ 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;
-
-
-    /**
-     *
-     * @param taxon
-     * @param size
-     * @param height
-     * @param widthOrDuration
-     * @param mimeTypes
-     * @return
-     *
-     * @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);
-
+    public Pager<SearchResult<TaxonBase>> findByDescriptionElementFullText(Class<? extends DescriptionElementBase> clazz,
+            String queryString, Classification classification, TaxonNode subtree, List<Feature> features, List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
 
     /**
      * Lists all Media found in an any TaxonDescription associated with this
@@ -810,15 +785,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 long countSynonyms(boolean onlyAttachedToTaxon);
 
-    public String getPhylumName(TaxonNameBase name);
+    public List<TaxonName> findIdenticalTaxonNames(List<String> propertyPath);
 
-    public long deleteSynonymRelationships(Synonym syn);
+    public List<UUID> findIdenticalTaxonNameIds(List<String> propertyPath);
+//
+//    public String getPhylumName(TaxonName name);
 
     /**
      * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
@@ -841,14 +820,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.
      *
@@ -860,23 +839,17 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public DeleteResult deleteSynonym(Synonym synonym, 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.
+     * Removes a synonym.
      *
-     * @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
+     * The method essentially loads the synonym and calls the
+     * {@link #deleteSynonym(Synonym, SynonymDeletionConfigurator) deleteSynonym} method
+     *
+     * @param synonymUuid
+     * @param config
+     * @return
      */
-    public List<SynonymRelationship> listSynonymRelationships(
-            TaxonBase taxonBase, SynonymRelationshipType type, Integer pageSize, Integer pageNumber,
-            List<OrderHint> orderHints, List<String> propertyPaths, Direction direction);
+    public DeleteResult deleteSynonym(UUID synonymUuid, SynonymDeletionConfigurator config);
 
     /**
      * @param tnb
@@ -886,13 +859,9 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
 
     public Taxon findBestMatchingTaxon(MatchingTaxonConfigurator config);
 
-    public Synonym findBestMatchingSynonym(String taxonName);
+    public Synonym findBestMatchingSynonym(String taxonName, boolean includeUnpublished);
 
-    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon();
-
-    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym();
-
-    public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
+     public List<UuidAndTitleCache<? extends IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
 
     /**
      * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
@@ -900,7 +869,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
@@ -911,61 +880,58 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public List<Synonym>  createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
 
+    public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, boolean includeUnpublished,
+            List<String> propertyPaths) throws UnpublishedException;
 
+    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
 
 
     /**
-     * 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
+     * @param clazz the optional {@link TaxonBase} subclass
+     * @param identifier the identifier string
+     * @param identifierType the identifier type
+     * @param subtreeFilter filter on a classification subtree (TaxonNode)
+     * @param matchmode the match mode for the identifier string
+     * @param includeEntity should the taxon as an object be included in the result
+     * @param pageSize page size
+     * @param pageNumber page number
+     * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
+     * @return the resulting {@link IdentifiedEntityDTO} pager
+     * @see IIdentifiableEntityService#findByIdentifier(Class, String, DefinedTerm, MatchMode, boolean, Integer, Integer, List)
      */
-    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);
-
-
-    public <S extends TaxonBase> Pager<FindByIdentifierDTO<S>> findByIdentifier(
+    public <S extends TaxonBase> Pager<IdentifiedEntityDTO<S>> findByIdentifier(
                        Class<S> clazz, String identifier, DefinedTerm identifierType, TaxonNode subtreeFilter,
                        MatchMode matchmode, boolean includeEntity, Integer pageSize,
                        Integer pageNumber,     List<String> propertyPaths);
 
-
     /**
-     * @param synonymUuid
-     * @param taxonUuid
-     * @param config
-     * @return
+     * Returns a pager for {@link MarkedEntityDTO DTOs} that hold the marker including type, title and uuid
+     * and the according {@link TaxonBase} information (uuid, title and the taxon object itself (optional)).
+     *
+     * @param clazz The optional {@link TaxonBase} subclass
+     * @param markerType the obligatory marker type, if not given, the results will always be empty
+     * @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)
+     * @return the resulting {@link MarkedEntityDTO} pager
+     * @see IIdentifiableEntityService#findByMarker(Class, MarkerType, Boolean, boolean, Integer, Integer, List)
      */
-    public DeleteResult deleteSynonym(UUID synonymUuid, UUID taxonUuid, SynonymDeletionConfigurator config);
+    public <S extends TaxonBase> Pager<MarkedEntityDTO<S>> findByMarker(
+            Class<S> clazz, MarkerType markerType, Boolean markerValue,
+            TaxonNode subtreeFilter, boolean includeEntity, TaxonTitleType titleType,
+            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * @param synonymUUid
      * @param acceptedTaxonUuid
+     * @param setNameInSource
      * @return
      */
-    public UpdateResult swapSynonymAndAcceptedTaxon(UUID synonymUUid, UUID acceptedTaxonUuid);
+    public UpdateResult swapSynonymAndAcceptedTaxon(UUID synonymUUid, UUID acceptedTaxonUuid, boolean setNameInSource);
 
     /**
      * @param taxonUuid
@@ -975,12 +941,62 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public DeleteResult deleteTaxon(UUID taxonUuid, TaxonDeletionConfigurator config, UUID classificationUuid);
 
-       public SynonymRelationship moveSynonymToAnotherTaxon(SynonymRelationship oldSynonymRelation,
-                       UUID newTaxonUUID, boolean moveHomotypicGroup,
-                       SynonymRelationshipType newSynonymRelationshipType,
-                       Reference reference, String referenceDetail, boolean keepReference)
-                       throws HomotypicalGroupChangeException;
 
+       public UpdateResult moveFactualDateToAnotherTaxon(UUID fromTaxonUuid,
+                       UUID toTaxonUuid);
+
+
+    /**
+     * @param synonymUuid
+     * @param toTaxonUuid
+     * @param taxonRelationshipType
+     * @param citation
+     * @param microcitation
+     * @return
+     */
+    public UpdateResult changeSynonymToRelatedTaxon(UUID synonymUuid, UUID toTaxonUuid, TaxonRelationshipType taxonRelationshipType,
+            Reference citation, String microcitation);
+
+    /**
+     * @param fromTaxonUuid
+     * @param toTaxonUuid
+     * @param oldRelationshipType
+     * @param synonymType
+     * @return
+     * @throws DataChangeNoRollbackException
+     */
+    public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
+            TaxonRelationshipType oldRelationshipType, SynonymType synonymType) throws DataChangeNoRollbackException;
+
+    /**
+     * Returns a list of taxon relationships for a given taxon as DTO.
+     * @param taxonUuid
+     * @param directTypes
+     * @param inversTypes
+     * @param direction
+     * @param groupMisapplications
+     * @param includeUnpublished
+     * @param pageSize
+     * @param pageNumber
+     * @return
+     */
+    public TaxonRelationshipsDTO listTaxonRelationships(UUID taxonUuid,
+            Set<TaxonRelationshipType> directTypes,
+            Set<TaxonRelationshipType> inversTypes, Direction direction, boolean groupMisapplications,
+            boolean includeUnpublished, Integer pageSize, Integer pageNumber);
+
+    /**
+     * @param clazz
+     * @param restrictions
+     * @param pageSize
+     * @param pageIndex
+     * @param orderHints
+     * @param propertyPaths
+     * @param includeUnpublished
+     * @return
+     */
+    public <S extends TaxonBase> Pager<S> page(Class<S> clazz, List<Restriction<?>> restrictions, Integer pageSize, Integer pageIndex,
+            List<OrderHint> orderHints, List<String> propertyPaths, boolean includeUnpublished);