Package org.silverpeas.components.gallery.dao

## Class MediaSQLQueryBuilder

- java.lang.Object
- - org.silverpeas.components.gallery.dao.MediaSQLQueryBuilder

- All Implemented Interfaces:
    `MediaCriteriaProcessor`

      public class MediaSQLQueryBuilder
      extends Object
      implements MediaCriteriaProcessor

  A dynamic builder of a SQL query.

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `endProcessing()` | Informs the processor the process is ended.
    `List<Media>` | `orderingResult​(List<Media> media)` | This method must be called after the media list is entirely loaded.
    `MediaCriteriaProcessor` | `processAlbums​(List<String> albumIds)` | Processes the criterion on the identifiers of albums (Actually, Album = Node).
    `MediaCriteriaProcessor` | `processComponentInstance​(String componentInstanceId)` | Processes the criterion on the component instance identifier.
    `MediaCriteriaProcessor` | `processCreator​(org.silverpeas.core.admin.user.model.UserDetail creator)` | Processes the criterion on the creator of the medias.
    `MediaCriteriaProcessor` | `processIdentifiers​(List<String> identifiers)` | Processes the criterion on the media identifiers.
    `MediaCriteriaProcessor` | `processMediaTypes​(List<MediaType> mediaTypes)` | Processes the criterion on type of media.
    `MediaCriteriaProcessor` | `processNbDaysBeforeThatMediaIsNotVisible​(Date referenceDate, int nbDaysBeforeThatMediaIsNotVisible)` | Processes the criterion on the nb of days before that a media is not visible.
    `MediaCriteriaProcessor` | `processOrdering​(List<MediaCriteria.QUERY_ORDER_BY> orderings)` | Processes the criterion on orderings of the medias matching the criteria.
    `MediaCriteriaProcessor` | `processResultLimit​(int resultLimit)` | Processes the criterion on the media result limit.
    `MediaCriteriaProcessor` | `processVisibility​(MediaCriteria.VISIBILITY visibility, Date dateReference, org.silverpeas.core.admin.user.model.UserDetail creator)` | Processes the criterion on the media visibility.
    `org.silverpeas.core.persistence.jdbc.sql.JdbcSqlQuery` | `result()` | Gets the result of the processing.
    `void` | `startProcessing()` | Informs the processor the start of the process.
    `MediaCriteriaProcessor` | `then()` | Informs the processor that there is a new criterion to process.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### startProcessing

          public void startProcessing()

      Description copied from interface: `MediaCriteriaProcessor`
      Informs the processor the start of the process. The processor use this method to allocate all the resources required by the processing here. It uses it to initialize the processor state machine.
      Specified by:
        `startProcessing` in interface `MediaCriteriaProcessor`

    - #### endProcessing

          public void endProcessing()

      Description copied from interface: `MediaCriteriaProcessor`
      Informs the processor the process is ended. The processor use this method to deallocate all the resources that were used during the processing. It uses it to tear down the processor state machine or to finalize some treatments.

      The processing has to stop once this method is called. Hence, the call of process methods should result to nothing or to an exception.
      Specified by:
        `endProcessing` in interface `MediaCriteriaProcessor`

    - #### result

          public org.silverpeas.core.persistence.jdbc.sql.JdbcSqlQuery result()

      Description copied from interface: `MediaCriteriaProcessor`
      Gets the result of the processing. Warning, the result can be incomplete if called before the processing ending (triggered with the call of `MediaCriteriaProcessor.endProcessing()` method).
      Specified by:
        `result` in interface `MediaCriteriaProcessor`
      Returns:
        the processing result.

    - #### then

          public MediaCriteriaProcessor then()

      Description copied from interface: `MediaCriteriaProcessor`
      Informs the processor that there is a new criterion to process. This method must be used by the caller to chain the different criterion processing.
      Specified by:
        `then` in interface `MediaCriteriaProcessor`
      Returns:
        the processor itself.

    - #### processResultLimit

          public MediaCriteriaProcessor processResultLimit​(int resultLimit)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on the media result limit.
      Specified by:
        `processResultLimit` in interface `MediaCriteriaProcessor`
      Parameters:
        `resultLimit` - the limit of the result (0 = no limit)
      Returns:
        the processor itself.

    - #### processVisibility

          public MediaCriteriaProcessor processVisibility​(MediaCriteria.VISIBILITY visibility,
                                                          Date dateReference,
                                                          org.silverpeas.core.admin.user.model.UserDetail creator)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on the media visibility.
      Specified by:
        `processVisibility` in interface `MediaCriteriaProcessor`
      Parameters:
        `visibility` - the requested visibility.
        `dateReference` - the date to use as reference
        `creator` - User Detail
      Returns:
        the processor itself.

    - #### processComponentInstance

          public MediaCriteriaProcessor processComponentInstance​(String componentInstanceId)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on the component instance identifier.
      Specified by:
        `processComponentInstance` in interface `MediaCriteriaProcessor`
      Parameters:
        `componentInstanceId` - the identifier of the component instance concerned by the criterion.
      Returns:
        the processor itself.

    - #### processAlbums

          public MediaCriteriaProcessor processAlbums​(List<String> albumIds)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on the identifiers of albums (Actually, Album = Node).
      Specified by:
        `processAlbums` in interface `MediaCriteriaProcessor`
      Parameters:
        `albumIds` - the identifiers of albums concerned by the criterion.
      Returns:
        the processor itself.

    - #### processCreator

          public MediaCriteriaProcessor processCreator​(org.silverpeas.core.admin.user.model.UserDetail creator)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on the creator of the medias.
      Specified by:
        `processCreator` in interface `MediaCriteriaProcessor`
      Parameters:
        `creator` - the user concerned by the criterion.
      Returns:
        the processor itself.

    - #### processMediaTypes

          public MediaCriteriaProcessor processMediaTypes​(List<MediaType> mediaTypes)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on type of media.
      Specified by:
        `processMediaTypes` in interface `MediaCriteriaProcessor`
      Parameters:
        `mediaTypes` - the media types concerned by the criterion.
      Returns:
        the processor itself.

    - #### processNbDaysBeforeThatMediaIsNotVisible

          public MediaCriteriaProcessor processNbDaysBeforeThatMediaIsNotVisible​(Date referenceDate,
                                                                                 int nbDaysBeforeThatMediaIsNotVisible)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on the nb of days before that a media is not visible.
      Specified by:
        `processNbDaysBeforeThatMediaIsNotVisible` in interface `MediaCriteriaProcessor`
      Parameters:
        `referenceDate` - the date to use as reference
        `nbDaysBeforeThatMediaIsNotVisible` - the nb of days before that a media is not visible.
      Returns:
        the processor itself.

    - #### processOrdering

          public MediaCriteriaProcessor processOrdering​(List<MediaCriteria.QUERY_ORDER_BY> orderings)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on orderings of the medias matching the criteria.
      Specified by:
        `processOrdering` in interface `MediaCriteriaProcessor`
      Parameters:
        `orderings` - the result orderings concerned by the criterion.
      Returns:
        the processor itself.

    - #### processIdentifiers

          public MediaCriteriaProcessor processIdentifiers​(List<String> identifiers)

      Description copied from interface: `MediaCriteriaProcessor`
      Processes the criterion on the media identifiers.
      Specified by:
        `processIdentifiers` in interface `MediaCriteriaProcessor`
      Parameters:
        `identifiers` - the media identifiers concerned by the criterion.
      Returns:
        the processor itself.

    - #### orderingResult

          public List<Media> orderingResult​(List<Media> media)

      Description copied from interface: `MediaCriteriaProcessor`
      This method must be called after the media list is entirely loaded. If an ordering was specified and if it was not possible to perform it by SQL clauses, then a logical sort is performed.
      Specified by:
        `orderingResult` in interface `MediaCriteriaProcessor`
      Parameters:
        `media` - the list of media to sort