Class SubscribersDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.datasource.AbstractMyBatisDAO
-
- org.ametys.plugins.newsletter.daos.SubscribersDAO
-
- All Implemented Interfaces:
LogEnabled,PluginAware,Component,Configurable,Contextualizable,Serviceable,ThreadSafe
public class SubscribersDAO extends AbstractMyBatisDAO implements ThreadSafe
DAO for accessing newsletters subscribers.
-
-
Field Summary
Fields Modifier and Type Field Description static StringROLEThe Avalon role name.-
Fields inherited from class org.ametys.core.datasource.AbstractMyBatisDAO
_manager
-
-
Constructor Summary
Constructors Constructor Description SubscribersDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidempty(String categoryId, String siteName)Empty a category's subscribers.SubscribergetSubscriber(String email, String siteName, String categoryId)Get a subscriber to a newsletter categorySubscribergetSubscriberByToken(String token)Get a subscriber by his tokenList<Subscriber>getSubscribers()Get the whole list for subscribersList<Subscriber>getSubscribers(String siteName, String categoryId)Get the subscribers to a newsletter categoryList<Subscriber>getSubscribers(String siteName, String categoryId, int offset, int limit)Get the subscribers to a newsletter categoryintgetSubscribersCount(String siteName, String categoryId)Get the subscribers count for a newsletter categoryList<Subscriber>getSubscriptions(String email, String siteName)Get the list of subscriptions for a given email and site name.voidmodifySubscriptions(Collection<Subscriber> newSubscribers, Collection<String> removeSubscriptions)Insert several subscriptions to newsletters.voidsubscribe(Collection<Subscriber> subscribers)Insert several subscriptions to newsletters.voidsubscribe(Subscriber subscriber)Subscribes to the newslettervoidunsubscribe(String token)Unsubscribes to the newslettervoidunsubscribe(String email, String siteName)Remove all subscriptions for a subscriber in a given site.-
Methods inherited from class org.ametys.core.datasource.AbstractMyBatisDAO
_configureDatasource, _getDataSourceId, _getMyBatisConfiguration, configure, contextualize, getSession, getSession, reload, service, setPluginInfo
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
SubscribersDAO
public SubscribersDAO()
-
-
Method Detail
-
getSubscribers
public List<Subscriber> getSubscribers()
Get the whole list for subscribers- Returns:
- The list for subscribers
-
getSubscribers
public List<Subscriber> getSubscribers(String siteName, String categoryId)
Get the subscribers to a newsletter category- Parameters:
siteName- The site namecategoryId- The newsletter category's id- Returns:
- the subscribers
-
getSubscribers
public List<Subscriber> getSubscribers(String siteName, String categoryId, int offset, int limit)
Get the subscribers to a newsletter category- Parameters:
siteName- The site namecategoryId- The newsletter category's idoffset- The number of results to ignore.limit- The maximum number of results to return.- Returns:
- the subscribers
-
getSubscribersCount
public int getSubscribersCount(String siteName, String categoryId)
Get the subscribers count for a newsletter category- Parameters:
siteName- The site namecategoryId- The newsletter category's id- Returns:
- the subscribers count
-
getSubscriber
public Subscriber getSubscriber(String email, String siteName, String categoryId)
Get a subscriber to a newsletter category- Parameters:
email- The subscriber emailsiteName- The site namecategoryId- The newsletter category's id- Returns:
- the subscribers
-
getSubscriberByToken
public Subscriber getSubscriberByToken(String token)
Get a subscriber by his token- Parameters:
token- The user token- Returns:
- the subscribers
-
getSubscriptions
public List<Subscriber> getSubscriptions(String email, String siteName)
Get the list of subscriptions for a given email and site name.- Parameters:
email- the email.siteName- the site name.- Returns:
- the list of subscriptions.
-
subscribe
public void subscribe(Subscriber subscriber)
Subscribes to the newsletter- Parameters:
subscriber- The subscriber
-
subscribe
public void subscribe(Collection<Subscriber> subscribers)
Insert several subscriptions to newsletters.- Parameters:
subscribers- a list of subscribers.
-
modifySubscriptions
public void modifySubscriptions(Collection<Subscriber> newSubscribers, Collection<String> removeSubscriptions)
Insert several subscriptions to newsletters.- Parameters:
newSubscribers- the collection of subscribers to insert.removeSubscriptions- the collection of subscription tokens to remove.
-
unsubscribe
public void unsubscribe(String token)
Unsubscribes to the newsletter- Parameters:
token- The unique token
-
empty
public void empty(String categoryId, String siteName)
Empty a category's subscribers.- Parameters:
categoryId- the category to empty.siteName- the site name.
-
unsubscribe
public void unsubscribe(String email, String siteName)
Remove all subscriptions for a subscriber in a given site.- Parameters:
email- the category to empty.siteName- the site name.
-
-