*/
public static void processDaily(DSpace dspace,
StatSubscribeService service, Context context, int freq,
boolean test) throws SQLException, IOException
{
EPerson currentEPerson = null;
List<StatSubscription> rpSubscriptions = service
.getAllStatSubscriptionByFreq(freq);
for (StatSubscription rpSubscription : rpSubscriptions)
{
// Does this row relate to the same e-person as the last?
if ((currentEPerson == null)
|| (rpSubscription.getEpersonID() != currentEPerson.getID()))
{
// New e-person. Send mail for previous e-person
if (currentEPerson != null)
{
try
{
sendEmail(context, service, currentEPerson,
rpSubscriptions, freq, test);
}
catch (MessagingException me)
{
log.error("Failed to send stat subscription to eperson_id="
+ currentEPerson.getID());
log.error(me);
}
}
currentEPerson = EPerson.find(context,
rpSubscription.getEpersonID());
rpSubscriptions = new ArrayList<StatSubscription>();
}
rpSubscriptions.add(rpSubscription);
}
// Process the last person
if (currentEPerson != null)
{
try
{
sendEmail(context, service, currentEPerson, rpSubscriptions,
freq, test);
}
catch (MessagingException me)
{
log.error("Failed to send stat subscription to eperson_id="
+ currentEPerson.getID());
log.error(me);
}
}
}