cleanup
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ITaxonService.java
index e103b3dda11ae73a72b8f7cc75db40c8ab0dc4dd..d37445947459a1813951ea6d0ac2d72e5bc28925 100644 (file)
@@ -23,6 +23,7 @@ import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 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;
@@ -30,16 +31,17 @@ 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.exception.UnpublishedException;
 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.Direction;
 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.TaxonName;
@@ -59,7 +61,16 @@ 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>{
+
+    /**
+     * {@inheritDoc}
+     * <BR><BR>
+     * NOTE: Also taxa with <code>publish=false</code> are returned.
+     */
+    @Override
+    public TaxonBase load(UUID uuid, List<String> propertyPaths);
 
     /**
      * Returns a list of taxa that matches the name string and the sec reference
@@ -67,7 +78,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.
@@ -253,13 +264,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);
 
 
     /**
@@ -268,13 +281,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)
@@ -282,13 +297,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);
 
 
     /**
@@ -297,13 +314,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
@@ -320,7 +339,7 @@ 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);
 
 
     /**
@@ -520,7 +539,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     @Deprecated
     public Pager<SearchResult<TaxonBase>> findByEverythingFullText(String queryString,
-            Classification classification, List<Language> languages, boolean highlightFragments,
+            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;
 
     /**
@@ -565,9 +584,12 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @throws IOException
      * @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 IOException, LuceneParseException;
+    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;
 
 
     /**
@@ -596,8 +618,9 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @throws IOException
      * @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, LuceneParseException;
 
@@ -616,7 +639,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
@@ -648,7 +673,8 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     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 IOException, LuceneParseException, LuceneMultiSearchException;
 
@@ -664,14 +690,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
@@ -695,23 +725,8 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * @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 IOException, LuceneParseException;
-
-
-    /**
-     *
-     * @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
@@ -774,7 +789,7 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      * an accepted taxon are counted
      * @return the number of synonyms
      */
-    public int countSynonyms(boolean onlyAttachedToTaxon);
+    public long countSynonyms(boolean onlyAttachedToTaxon);
 
     public List<TaxonName> findIdenticalTaxonNames(List<String> propertyPath);
 
@@ -842,9 +857,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<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
@@ -863,7 +878,8 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
      */
     public List<Synonym>  createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
 
-    public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, List<String> propertyPaths);
+    public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, boolean includeUnpublished,
+            List<String> propertyPaths) throws UnpublishedException;
 
     public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
 
@@ -949,6 +965,24 @@ public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
     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);
+
+
 
 
 }