Package org.silverpeas.components.classifieds.dao

## Class ClassifiedsDAO

- java.lang.Object
- - org.silverpeas.components.classifieds.dao.ClassifiedsDAO

-     public class ClassifiedsDAO
      extends Object

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static String` | `createClassified​(Connection con, ClassifiedDetail classified)` | Create a classified
    `static String` | `createSubscribe​(Connection con, Subscribe subscribe)` | Create a subscription for user.
    `static void` | `deleteClassified​(Connection con, String classifiedId)` | Delete the classified with the specified identifier.
    `static void` | `deleteSubscribe​(Connection con, String subscribeId)` | Delete a subscription corresponding to the subscriber identifier
    `static Collection<ClassifiedDetail>` | `getAllClassifieds​(Connection con, String instanceId)` | Get all classifieds of an instance corresponding to instanceId
    `static List<ClassifiedDetail>` | `getAllClassifiedsToUnpublish​(Connection con, int nbDays, String instanceId)` | Get all expiring classifieds (corresponding of a number of days)
    `static Collection<Subscribe>` | `getAllSubscribes​(Connection con, String instanceId)` | Get all subscriptions for an instance corresponding to instanceId
    `static ClassifiedDetail` | `getClassified​(Connection con, String classifiedId)` | Get the classified with the specified identifier.
    `static List<ClassifiedDetail>` | `getClassifiedsByUser​(Connection con, String instanceId, String userId)` | Get all the classifieds for user and instance, corresponding to userId and instanceId
    `static List<ClassifiedDetail>` | `getClassifiedsWithStatus​(Connection con, String instanceId, String status, int firstItemIndex, int elementsPerPage)` | Get all classifieds with given status for an instance corresponding to instanceId
    `static String` | `getNbTotalClassifieds​(Connection con, String instanceId)` | Get the number of classifieds to be validated for an instance corresponding to instanceId
    `static Collection<Subscribe>` | `getSubscribesByUser​(Connection con, String instanceId, String userId)` | Get all subscriptions for user and instance corresponding to userId and instanceId
    `static Collection<String>` | `getUsersBySubscribe​(Connection con, String instanceId, String field1, String field2)` | Get all subscribing users to a search corresponding to fields field1 and field2
    `static void` | `updateClassified​(Connection con, ClassifiedDetail classified)` | Update a classified

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

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

- - ### Method Detail

    - #### createClassified

          public static String createClassified​(Connection con,
                                                ClassifiedDetail classified)
                                         throws SQLException

      Create a classified
      Parameters:
        `con` - connection to the database
        `classified` - the new classified
      Returns:
        classifiedId the unique identifier of the created classified
      Throws:
        `SQLException` - if the classified cannot be created.

    - #### updateClassified

          public static void updateClassified​(Connection con,
                                              ClassifiedDetail classified)
                                       throws SQLException

      Update a classified
      Parameters:
        `con` - connection to the database.
        `classified` - the ClassifiedDetail with the data to update.
      Throws:
        `SQLException` - if the classified cannot be updated

    - #### deleteClassified

          public static void deleteClassified​(Connection con,
                                              String classifiedId)
                                       throws SQLException

      Delete the classified with the specified identifier.
      Parameters:
        `con` - connection to the database
        `classifiedId` - the unique identifier of a classified
      Throws:
        `SQLException` - if the classified fail to be deleted.

    - #### getClassified

          public static ClassifiedDetail getClassified​(Connection con,
                                                       String classifiedId)
                                                throws SQLException

      Get the classified with the specified identifier.
      Parameters:
        `con` - connection to the database
        `classifiedId` - the unique identifier of the classified
      Returns:
        classified the `ClassifiedDetail` instance
      Throws:
        `SQLException` - if the classified cannot be fetched

    - #### getAllClassifieds

          public static Collection<ClassifiedDetail> getAllClassifieds​(Connection con,
                                                                       String instanceId)
                                                                throws SQLException

      Get all classifieds of an instance corresponding to instanceId
      Parameters:
        `con` - connection to the database
        `instanceId` - the unique identifier of a classified component instance
      Returns:
        a collection of `ClassifiedDetail` instances.
      Throws:
        `SQLException` - if the fetching of the classifieds fails

    - #### getNbTotalClassifieds

          public static String getNbTotalClassifieds​(Connection con,
                                                     String instanceId)
                                              throws SQLException

      Get the number of classifieds to be validated for an instance corresponding to instanceId
      Parameters:
        `con` - the connection to the database
        `instanceId` - the unique identifier of a classified component instance.
      Returns:
        the count of classifieds in the component instance.
      Throws:
        `SQLException` - if an error occurs while getting the classifieds count.

    - #### getClassifiedsByUser

          public static List<ClassifiedDetail> getClassifiedsByUser​(Connection con,
                                                                    String instanceId,
                                                                    String userId)
                                                             throws SQLException

      Get all the classifieds for user and instance, corresponding to userId and instanceId
      Parameters:
        `con` - connection to the database
        `instanceId` - the unique identifier of a classifieds component instance.
        `userId` - the unique identifier of the user
      Returns:
        a collection of `ClassifiedDetail`s of the user.
      Throws:
        `SQLException` - if the classifieds getting fails.

    - #### getClassifiedsWithStatus

          public static List<ClassifiedDetail> getClassifiedsWithStatus​(Connection con,
                                                                        String instanceId,
                                                                        String status,
                                                                        int firstItemIndex,
                                                                        int elementsPerPage)
                                                                 throws SQLException

      Get all classifieds with given status for an instance corresponding to instanceId
      Parameters:
        `con` - connection to the database
        `instanceId` - the classifieds component instance
        `status` - status of the classifieds
      Returns:
        a list of `ClassifiedDetail`
      Throws:
        `SQLException` - if the classifieds cannot be fetched.

    - #### getAllClassifiedsToUnpublish

          public static List<ClassifiedDetail> getAllClassifiedsToUnpublish​(Connection con,
                                                                            int nbDays,
                                                                            String instanceId)
                                                                     throws SQLException

      Get all expiring classifieds (corresponding of a number of days)
      Parameters:
        `con` - connection to the database
        `nbDays` - the number of days
        `instanceId` - component instance identifier
      Returns:
        a list of `ClassifiedDetail`
      Throws:
        `SQLException` - if the classifieds cannot be fetched

    - #### createSubscribe

          public static String createSubscribe​(Connection con,
                                               Subscribe subscribe)
                                        throws SQLException

      Create a subscription for user.
      Parameters:
        `con` - connection to the database
        `subscribe` - the subscription to create.
      Returns:
        subscribeId the unique identifier of a subscription.
      Throws:
        `SQLException` - if the creation fails.

    - #### deleteSubscribe

          public static void deleteSubscribe​(Connection con,
                                             String subscribeId)
                                      throws SQLException

      Delete a subscription corresponding to the subscriber identifier
      Parameters:
        `con` - connection to the database
        `subscribeId` - the unique identifier of a subscription
      Throws:
        `SQLException` - if the deletion fails.

    - #### getAllSubscribes

          public static Collection<Subscribe> getAllSubscribes​(Connection con,
                                                               String instanceId)
                                                        throws SQLException

      Get all subscriptions for an instance corresponding to instanceId
      Parameters:
        `con` - connection to the database
        `instanceId` - the unique identifier of a component instance.
      Returns:
        a collection of `Subscribe`
      Throws:
        `SQLException` - if the fetching fails

    - #### getSubscribesByUser

          public static Collection<Subscribe> getSubscribesByUser​(Connection con,
                                                                  String instanceId,
                                                                  String userId)
                                                           throws SQLException

      Get all subscriptions for user and instance corresponding to userId and instanceId
      Parameters:
        `con` - connection to the database
        `instanceId` - the unique identifier of a component instance
        `userId` - the unique identifier of a user
      Returns:
        a collection of `Subscribe`
      Throws:
        `SQLException` - if the fetching fails.

    - #### getUsersBySubscribe

          public static Collection<String> getUsersBySubscribe​(Connection con,
                                                               String instanceId,
                                                               String field1,
                                                               String field2)
                                                        throws SQLException

      Get all subscribing users to a search corresponding to fields field1 and field2
      Parameters:
        `con` - connection to the database
        `instanceId` - the unique identifier of the component instance on which the subscriptions have to be found.
        `field1` - value of the first field of a classified on which subscription can be done
        `field2` - value of the second field of a classified on which subscription can be done
      Returns:
        a collection of user identifiers.
      Throws:
        `SQLException` - if the getting of the subscribers fail.