Deprecate getCharacterData method in service layer
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / IDescriptionService.java
index 7702725247cc428163be241140ebdef1b7bf8543..00390d74b7277668363dce9e2165b4a0e0dd24f0 100644 (file)
@@ -17,16 +17,19 @@ import java.util.Set;
 import java.util.UUID;
 
 import eu.etaxonomy.cdm.api.service.pager.Pager;
+import eu.etaxonomy.cdm.api.utility.DescriptionUtility;
 import eu.etaxonomy.cdm.model.common.Annotation;
+import eu.etaxonomy.cdm.model.common.DefinedTerm;
 import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.Marker;
 import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.common.TermVocabulary;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Distribution;
 import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;
-import eu.etaxonomy.cdm.model.description.Scope;
+import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
 import eu.etaxonomy.cdm.model.location.NamedArea;
@@ -34,7 +37,8 @@ import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
 import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.persistence.dao.IBeanInitializer;
+import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
 import eu.etaxonomy.cdm.persistence.query.OrderHint;
 
 public interface IDescriptionService extends IIdentifiableEntityService<DescriptionBase> {
@@ -44,11 +48,13 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @return
      * @deprecated use TermService#getVocabulary(VocabularyType) instead
      */
+    @Deprecated
     public TermVocabulary<Feature> getDefaultFeatureVocabulary();
 
     /**
      * @deprecated use TermService#getVocabulary(VocabularyType) instead
      */
+    @Deprecated
     public TermVocabulary<Feature> getFeatureVocabulary(UUID uuid);
 
     /**
@@ -94,6 +100,8 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      */
     public UUID deleteDescriptionElement(DescriptionElementBase descriptionElement);
 
+    public UUID deleteDescriptionElement(UUID descriptionElementUuid);
+
     /**
      * List the descriptions of type <T>, filtered using the following parameters
      *
@@ -121,35 +129,124 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
     public int count(Class<? extends DescriptionBase> type, Boolean hasImages, Boolean hasText, Set<Feature> feature);
 
     /**
-     * Returns description elements of type <TYPE>, belonging to a given description, optionally filtered by one or more features
+     * Returns description elements of type <TYPE>, belonging to a given
+     * description, optionally filtered by one or more features
      *
-     * @param description The description which these description elements belong to (can be null to count all description elements)
-     * @param features Restrict the results to those description elements which are scoped by one of the Features passed (can be null or empty)
-     * @param type The type of description
-     * @param class
-     * @param pageSize The maximum number of description elements returned (can be null for all description elements)
-     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
+     * @param description
+     *            The description which these description elements belong to
+     *            (can be null to count all description elements)
+     * @param descriptionType
+     *            A filter DescriptionElements which belong to of a specific
+     *            class of Descriptions
+     * @param features
+     *            Restrict the results to those description elements which are
+     *            scoped by one of the Features passed (can be null or empty)
+     * @param type
+     *            A filter for DescriptionElements of a specific class
+     * @param pageSize
+     *            The maximum number of description elements returned (can be
+     *            null for all description elements)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param propertyPaths
+     *            Properties to initialize in the returned entities, following
+     *            the syntax described in
+     *            {@link IBeanInitializer#initialize(Object, List)}
      * @return a Pager containing DescriptionElementBase instances
-     *
-     * FIXME candidate for harmonization - rename to pageDescriptionElements
+
+     * @deprecated use
+     *             {@link #pageDescriptionElements(DescriptionBase, Set, Class, Integer, Integer, List)}
+     *             instead
      */
+    @Deprecated
     public Pager<DescriptionElementBase> getDescriptionElements(DescriptionBase description,Set<Feature> features, Class<? extends DescriptionElementBase> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
+
     /**
-     * Returns description elements of type <TYPE>, belonging to a given description, optionally filtered by one or more features
+     * Returns description elements of type <TYPE>, belonging to a given
+     * description, optionally filtered by one or more features
      *
-     * @param description The description which these description elements belong to (can be null to count all description elements)
-     * @param features Restrict the results to those description elements which are scoped by one of the Features passed (can be null or empty)
-     * @param type The type of description
-     * @param class
-     * @param pageSize The maximum number of description elements returned (can be null for all description elements)
-     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
-     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
-     * @return a List containing DescriptionElementBase instances
+     * @param description
+     *            The description which these description elements belong to
+     *            (can be null to count all description elements)
+     * @param descriptionType
+     *            A filter DescriptionElements which belong to of a specific
+     *            class of Descriptions
+     * @param features
+     *            Restrict the results to those description elements which are
+     *            scoped by one of the Features passed (can be null or empty)
+     * @param type
+     *            A filter for DescriptionElements of a specific class
+     * @param pageSize
+     *            The maximum number of description elements returned (can be
+     *            null for all description elements)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param propertyPaths
+     *            Properties to initialize in the returned entities, following
+     *            the syntax described in
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     *
+     * @return a Pager containing DescriptionElementBase instances
      */
+    public Pager<DescriptionElementBase> pageDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType, Set<Feature> features, Class<? extends DescriptionElementBase> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+
+    /**
+     * Returns description elements of type <TYPE>, belonging to a given
+     * description, optionally filtered by one or more features
+     *
+     * @param description
+     *            The description which these description elements belong to
+     *            (can be null to count all description elements)
+     * @param features
+     *            Restrict the results to those description elements which are
+     *            scoped by one of the Features passed (can be null or empty)
+     * @param type
+     *            A filter for DescriptionElements of a specific class
+     * @param pageSize
+     *            The maximum number of description elements returned (can be
+     *            null for all description elements)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param propertyPaths
+     *            Properties to initialize in the returned entities, following
+     *            the syntax described in
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a List of DescriptionElementBase instances
+     * @deprecated use {@link #listDescriptionElements(DescriptionBase, Class, Set, Class, Integer, Integer, List)} instead
+     */
+    @Deprecated
     public List<DescriptionElementBase> listDescriptionElements(DescriptionBase description,Set<Feature> features, Class<? extends DescriptionElementBase> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
+    /**
+     * Returns description elements of type <TYPE>, belonging to a given
+     * description, optionally filtered by one or more features
+     *
+     * @param description
+     *            The description which these description elements belong to
+     *            (can be null to count all description elements)
+     * @param features
+     *            Restrict the results to those description elements which are
+     *            scoped by one of the Features passed (can be null or empty)
+     * @param type
+     *            A filter DescriptionElements of a for specific class
+     * @param pageSize
+     *            The maximum number of description elements returned (can be
+     *            null for all description elements)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param propertyPaths
+     *            Properties to initialize in the returned entities, following
+     *            the syntax described in
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a List of DescriptionElementBase instances
+     */
+    public List<DescriptionElementBase> listDescriptionElements(DescriptionBase description, Class<? extends DescriptionBase> descriptionType, Set<Feature> features, Class<? extends DescriptionElementBase> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+
     /**
      * Return a Pager containing Annotation entities belonging to the DescriptionElementBase instance supplied, optionally filtered by MarkerType
      * @param annotatedObj The object that "owns" the annotations returned
@@ -176,7 +273,7 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      *
      * @see #pageMarkedTaxonDescriptions(Taxon, Set, Set, Set, Integer, Integer, List)
      */
-    public Pager<TaxonDescription> pageTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public Pager<TaxonDescription> pageTaxonDescriptions(Taxon taxon, Set<DefinedTerm> scopes, Set<NamedArea> geographicalScope, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * Returns a List of TaxonDescription instances, optionally filtered by parameters passed to this method
@@ -190,7 +287,7 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @return a Pager containing TaxonDescription instances
      */
-    public Pager<TaxonDescription> pageTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Set<MarkerType> markerTypes, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public Pager<TaxonDescription> pageTaxonDescriptions(Taxon taxon, Set<DefinedTerm> scopes, Set<NamedArea> geographicalScope, Set<MarkerType> markerTypes, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * @see {@link #pageTaxonDescriptions(Taxon, Set, Set, Integer, Integer, List)}
@@ -203,7 +300,7 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @param propertyPaths
      * @return
      */
-    public List<TaxonDescription> listTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public List<TaxonDescription> listTaxonDescriptions(Taxon taxon, Set<DefinedTerm> scopes, Set<NamedArea> geographicalScope, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
 
 
@@ -218,7 +315,7 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @param propertyPaths
      * @return
      */
-    public List<TaxonDescription> listTaxonDescriptions(Taxon taxon, Set<Scope> scopes, Set<NamedArea> geographicalScope, Set<MarkerType> markerTypes, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    public List<TaxonDescription> listTaxonDescriptions(Taxon taxon, Set<DefinedTerm> scopes, Set<NamedArea> geographicalScope, Set<MarkerType> markerTypes, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
     /**
      * Returns all {@link Media} attached to a taxon via TaxonDescription.elements.media.
@@ -269,7 +366,7 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
      * @return a Pager containing TaxonDescription instances
      */
-    public Pager<TaxonDescription> searchDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTermBase presence, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
+    public Pager<TaxonDescription> searchDescriptionByDistribution(Set<NamedArea> namedAreas, PresenceAbsenceTerm presence, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
 
     /**
      * Returns a Paged List of DescriptionElementBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
@@ -301,9 +398,117 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      */
     public Pager<Media> getMedia(DescriptionElementBase descriptionElement, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
-    public <T extends DescriptionElementBase> List<T>  getDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<? extends T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+    /**
+     * Provides access to all DescriptionElements associated with the given Taxon
+     * via a TaxonDescrition.
+     *
+     * @param taxon
+     *            The Taxon to return Description elements for
+     * @param features
+     *            Restrict the results to those description elements which are
+     *            scoped by one of the Features passed (can be null or empty)
+     * @param type
+     *            A filter for DescriptionElements of a specific class
+     * @param pageSize
+     *            The maximum number of description elements returned (can be
+     *            null for all description elements)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param propertyPaths
+     *            Properties to initialize in the returned entities, following
+     *            the syntax described in
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a List containing all matching DescriptionElementBase instances
+     *
+     * @deprecated use {@link #listDescriptionElementsForTaxon(Taxon, Set, Class, Integer, Integer, List)} instead
+     */
+    @Deprecated
+    public <T extends DescriptionElementBase> List<T>  getDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
 
-    public DistributionTree getOrderedDistributions(Set<TaxonDescription> taxonDescriptions, Set<NamedAreaLevel> levels, List<String> propertyPaths);
+    /**
+     * Provides access to all DescriptionElements associated with the given Taxon
+     * via a TaxonDescrition.
+     *
+     * @param taxon
+     *            The Taxon to return Description elements for
+     * @param features
+     *            Restrict the results to those description elements which are
+     *            scoped by one of the Features passed (can be null or empty)
+     * @param type
+     *            A filter for DescriptionElements of a specific class
+     * @param pageSize
+     *            The maximum number of description elements returned (can be
+     *            null for all description elements)
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param propertyPaths
+     *            Properties to initialize in the returned entities, following
+     *            the syntax described in
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a List containing all matching DescriptionElementBase instances
+     *
+     */
+    public <T extends DescriptionElementBase> List<T>  listDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+
+    /**
+     * Provides access to all DescriptionElements associated with the given Taxon
+     * via a TaxonDescrition.
+     *
+     * @param taxon
+     *            The Taxon to return Description elements for
+     * @param features
+     *            Restrict the results to those description elements which are
+     *            scoped by one of the Features passed (can be null or empty)
+     * @param type
+     *            A filter for DescriptionElements of a specific class
+     * @param pageSize
+     *            The maximum number of description elements returned
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param propertyPaths
+     *            Properties to initialize in the returned entities, following
+     *            the syntax described in
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a Pager for all matching DescriptionElementBase instances
+     *
+     */
+    public <T extends DescriptionElementBase> Pager<T>  pageDescriptionElementsForTaxon(Taxon taxon, Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
+
+
+    /**
+     * @param taxonDescriptions
+     * @param subAreaPreference
+     *            enables the <b>Sub area preference rule</b> if set to true,
+     *            see {@link DescriptionUtility#filterDistributions(Collection,
+     *            boolean, boolean}
+
+     * @param statusOrderPreference
+     *            enables the <b>Status order preference rule</b> if set to
+     *            true, see {@link
+     *            DescriptionUtility#filterDistributions(Collection, boolean,
+     *            boolean}
+     * @param hideMarkedAreas
+     *            distributions where the area has a {@link Marker} with one of
+     *            the specified {@link MarkerType}s will be skipped, see
+     *            {@link DescriptionUtility#filterDistributions(Collection, boolean, boolean, Set)}
+     * @param omitLevels
+     *            A Set NamedArea levels to omit - optional
+     * @param propertyPaths
+     *            the initialization strategy
+     *
+     * @return
+     * @deprecated use {@link IEditGeoService#composeDistributionInfoFor()} instead
+     */
+    @Deprecated
+    public DistributionTree getOrderedDistributions(
+            Set<TaxonDescription> taxonDescriptions,
+            boolean subAreaPreference,
+            boolean statusOrderPreference,
+            Set<MarkerType> hideMarkedAreas,
+            Set<NamedAreaLevel> omitLevels, List<String> propertyPaths);
 
     /**
       * Generate a string representation of the structured <code>description</code> supplied in natural language
@@ -335,7 +540,66 @@ public interface IDescriptionService extends IIdentifiableEntityService<Descript
      * @param targetDescription
      * @param isPaste if true, the elements are only copied (cloned) and not removed from the
      *         old description
+     * @return
+     */
+    public UpdateResult moveDescriptionElementsToDescription(Collection<DescriptionElementBase> descriptionElements, DescriptionBase targetDescription, boolean isPaste);
+
+    /**
+     * Pager method to get all {@link NamedAreas} instances which are currently used
+     * by {@link Distribution} elements.
+     *
+     * @param pageSize
+     *            The maximum number of description elements returned
+     * @param pageNumber
+     *            The offset (in pageSize chunks) from the start of the result
+     *            set (0 - based)
+     * @param propertyPaths
+     *            Properties to initialize in the returned entities, following
+     *            the syntax described in
+     *            {@link IBeanInitializer#initialize(Object, List)}
+     * @return a Pager for all NamedAreas instances which are currently in use.
+     *
      */
-    public void moveDescriptionElementsToDescription(Collection<DescriptionElementBase> descriptionElements, DescriptionBase targetDescription, boolean isPaste);
+    public Pager<TermDto> pageNamedAreasInUse(boolean includeAllParents, Integer pageSize,
+            Integer pageNumber);
+
+       public DeleteResult deleteDescription(DescriptionBase description);
+
+       public DeleteResult deleteDescription(UUID descriptionUuid);
+
+    /**
+     * @param sourceTaxon
+     * @param targetTaxon
+     * @return
+     */
+    public UpdateResult moveTaxonDescriptions(Taxon sourceTaxon, Taxon targetTaxon);
+
+    /**
+     * @param sourceTaxonUuid
+     * @param targetTaxonUuid
+     * @return
+     */
+    public UpdateResult moveTaxonDescriptions(UUID sourceTaxonUuid, UUID targetTaxonUuid);
+
+
+    /**
+     * @param descriptionElementUUIDs
+     * @param targetDescriptionUuid
+     * @param isCopy
+     * @return
+     */
+    public UpdateResult moveDescriptionElementsToDescription(Set<UUID> descriptionElementUUIDs, UUID targetDescriptionUuid,
+            boolean isCopy);
+
+    /**
+     * @param descriptionElementUUIDs
+     * @param targetTaxonUuid
+     * @param moveMessage
+     * @param isCopy
+     * @return
+     */
+    public UpdateResult moveDescriptionElementsToDescription(Set<UUID> descriptionElementUUIDs, UUID targetTaxonUuid,
+            String moveMessage, boolean isCopy);
+
 
 }
\ No newline at end of file