Example #1
0
 public void saveTask(Object[] tasks, String mominId) throws TaskException {
   if (mominId == null) {
     for (Object o : tasks) {
       saveTask((Task) o);
     }
     return;
   }
   Task t;
   for (Object o : tasks) {
     t = (Task) o;
     if (!mominId.equals(t.getMominId())) throw new TaskException("droit");
     t.setMominId(mominId);
     saveTask(t);
   }
 }
Example #2
0
  @SuppressWarnings("unchecked")
  public List<Task> getWeekTasksStat(String name, String momin, Date startWeek) {
    Query query;
    List<Task> list;
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

    query =
        em.createQuery(
            "select from "
                + Task.class.getName()
                + " t where t.mominId = :momin AND  name =:name AND  t.date >= :start  AND  t.date  < :end order by date asc");
    query.setParameter("name", name);

    Task.moveToDay(startWeek, -1);
    startWeek.setHours(0);
    startWeek.setMinutes(0);
    startWeek.setSeconds(0);
    Date end = CalendarUtil.copyDate(startWeek);
    CalendarUtil.addDaysToDate(end, 7);
    query.setParameter("momin", momin);
    query.setParameter("start", startWeek);
    //	    end.setTime(end.getTime()-2000);
    query.setParameter("end", end);
    list = query.getResultList();

    //	    if(group == null)
    //	    	getCache().put(keyWeek, list);

    return list;
  }
Example #3
0
  @SuppressWarnings("deprecation")
  public void saveTask(Task task) {
    //		Date startWeek = Task.moveToDay(CalendarUtil.copyDate(task.getDate()), -1);
    //		String keyWeek = task.getMominId() + startWeek.toGMTString().substring(0, 11);
    boolean update = true;
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
    em.getTransaction().begin();
    if (task.getId() != null) {
      em.merge(task);
    } else {
      em.persist(task);
      update = false;
    }
    em.flush();
    em.getTransaction().commit();
    if (!update) return;

    //		Queue que= QueueFactory.getQueue("userfeedupdates");
    //		que.add(url("/task/tskseed?s=&m="+task.getMominId()+"&w="+task.getDate().getTime()+"&t="+new
    // Date().getTime()+"&n="+ task.getName().replaceAll(" ","+")).method(Method.GET));
    //
    //	que.add(TaskOptions.Builder.url("/task/tskseed?s=&m="+task.getMominId()+"&w="+task.getDate().getTime()+"&t="+new Date().getTime()).param("n", task.getName()).method(Method.GET));
    /*que.add(url("/tskseed")
    .param("s","2")
    .param("n",task.getName())
    .param("m",task.getMominId()).
    param("w",task.getDate().getTime()+"")
    .param("t",new Date().getTime()+"")
    );*/
    //		getCache().put(keyWeek, null);
    // TaskSeedServlet.stat(task.getName(), task.getMominId(), task.getDate(), new
    // Date().getTime());
    //		Key k = KeyFactory.createKey(Task.class.getSimpleName(), task.getId());
    //		List<Key> keys = new ArrayList<Key>();keys.add(k);
    //		DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    //		Map<Key, Entity> map = ds.get(keys);
  }