Class ClassifiedsDAO


  • public class ClassifiedsDAO
    extends Object
    • 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 ClassifiedDetails 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.