BrightSide Workbench Full Report + Source Code
DossierNotifier.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.dossier.dossier;
19 
20 import java.util.Date;
21 import java.util.List;
22 import org.amic.util.date.CheckDate;
23 import org.turro.dossier.db.DossierPU;
24 import org.turro.dossier.entity.Dossier;
25 import org.turro.dossier.entity.DossierStatus;
26 import org.turro.elephant.db.WhereClause;
27 import org.turro.i18n.I_;
28 import org.turro.scheduler.motor.DefaultTask;
29 
34 public class DossierNotifier extends DefaultTask {
35 
36  @Override
37  public String getName() {
38  return I_.get("Dossier notifier");
39  }
40 
41  @Override
42  public void run() {
43  Date now = new Date();
44  int days = Integer.parseInt(getData()) * -1;
45  Date from = new CheckDate(now).addDays(days).getDate();
46  for(Dossier dossier : getDossiers(now)) {
47  DossierActivitySet das = new DossierActivitySet(dossier, from);
48  if(!das.isEmpty()) {
49  new DossierNotification(dossier, das, from).sendMail(constructor);
50  }
51  }
52  }
53 
54  private List<Dossier> getDossiers(Date now) {
55  WhereClause wc = new WhereClause();
56  wc.addClause("select distinct dossier from Dossier as dossier");
57  wc.addClause("where dossier.status <> :status");
59  return new DossierPU().getResultList(wc);
60  }
61 
62  @Override
63  public String getDataLabel() {
64  return I_.get("Days");
65  }
66 }
void addNamedValue(String name, Object value)
static String get(String msg)
Definition: I_.java:41