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 StringcreateClassified(Connection con, ClassifiedDetail classified)Create a classifiedstatic StringcreateSubscribe(Connection con, Subscribe subscribe)Create a subscription for user.static voiddeleteClassified(Connection con, String classifiedId)Delete the classified with the specified identifier.static voiddeleteSubscribe(Connection con, String subscribeId)Delete a subscription corresponding to the subscriber identifierstatic Collection<ClassifiedDetail>getAllClassifieds(Connection con, String instanceId)Get all classifieds of an instance corresponding to instanceIdstatic 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 instanceIdstatic ClassifiedDetailgetClassified(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 instanceIdstatic List<ClassifiedDetail>getClassifiedsWithStatus(Connection con, String instanceId, String status, int firstItemIndex, int elementsPerPage)Get all classifieds with given status for an instance corresponding to instanceIdstatic StringgetNbTotalClassifieds(Connection con, String instanceId)Get the number of classifieds to be validated for an instance corresponding to instanceIdstatic Collection<Subscribe>getSubscribesByUser(Connection con, String instanceId, String userId)Get all subscriptions for user and instance corresponding to userId and instanceIdstatic Collection<String>getUsersBySubscribe(Connection con, String instanceId, String field1, String field2)Get all subscribing users to a search corresponding to fields field1 and field2static voidupdateClassified(Connection con, ClassifiedDetail classified)Update a classified
-
-
-
Method Detail
-
createClassified
public static String createClassified(Connection con, ClassifiedDetail classified) throws SQLException
Create a classified- Parameters:
con- connection to the databaseclassified- 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 databaseclassifiedId- 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 databaseclassifiedId- the unique identifier of the classified- Returns:
- classified the
ClassifiedDetailinstance - 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 databaseinstanceId- the unique identifier of a classified component instance- Returns:
- a collection of
ClassifiedDetailinstances. - 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 databaseinstanceId- 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 databaseinstanceId- 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 databaseinstanceId- the classifieds component instancestatus- 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 databasenbDays- the number of daysinstanceId- 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 databasesubscribe- 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 databasesubscribeId- 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 databaseinstanceId- 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 databaseinstanceId- the unique identifier of a component instanceuserId- 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 databaseinstanceId- 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 donefield2- 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.
-
-