Пример #1
0
 @Override
 public List<Contacts> getContactsforTask(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("tasks-with-contacts");
   Daily task = (Daily) sess.get(Daily.class, id);
   return task.getContactsConnectedWithTask();
 }
Пример #2
0
 @Override
 public List<Daily> getFromProxy(List<Daily> proxy) {
   Disjunction or = Restrictions.disjunction();
   for (Daily pr : proxy) {
     or.add(Restrictions.eq("id", pr.getId()));
   }
   return sessionFactory.getCurrentSession().createCriteria(Daily.class).add(or).list();
 }
Пример #3
0
  @Override
  public void removeTask(Daily task) {
    if (null != task) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      task = (Daily) sess.get(Daily.class, task.getId());
      List<Events> temp = task.getEventsConnectedWithTask();
      List<Calls> temp2 = task.getCallsConnectedWithTask();
      List<Contacts> temp3 = task.getContactsConnectedWithTask();

      if (temp != null && temp.size() != 0) {

        sess.enableFetchProfile("tasks-with-events");
        temp = eventsDAO.getFromProxy(temp);
        for (Events event : temp) {
          event.getConnectedTasks().remove(task);
          sess.update(event);
        }
      }

      if (temp2 != null && temp2.size() != 0) {
        sess.enableFetchProfile("tasks-with-calls");
        temp2 = callsDAO.getFromProxy(temp2);
        for (Calls call : temp2) {
          call.getTasks().remove(task);
          sess.update(call);
        }
      }

      if (temp3 != null && temp3.size() != 0) {
        sess.enableFetchProfile("tasks-with-contacts");
        temp3 = contactsDAO.getFromProxy(temp3);
        for (Contacts contact : temp3) {
          contact.getTasks().remove(task);
          sess.update(contact);
        }
      }
      sess.update(task);
      sessionFactory.getCurrentSession().delete(task);
    }
  }
Пример #4
0
  @Override
  public void addTask(Daily task) {
    sessionFactory.getCurrentSession().save(task);

    List<Events> temp = task.getEventsConnectedWithTask();
    List<Calls> temp2 = task.getCallsConnectedWithTask();
    List<Contacts> temp3 = task.getContactsConnectedWithTask();

    if (temp != null && temp.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("tasks-with-events");
      temp = eventsDAO.getFromProxy(temp);
      for (Events event : temp) {
        event.getConnectedTasks().add(task);
        eventsDAO.changeEvent(event);
      }
    }

    if (temp2 != null && temp2.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("tasks-with-calls");
      temp2 = callsDAO.getFromProxy(temp2);
      for (Calls call : temp2) {
        call.getTasks().add(task);
        callsDAO.changeCall(call);
      }
    }

    if (temp3 != null && temp3.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("tasks-with-contacts");
      temp3 = contactsDAO.getFromProxy(temp3);
      for (Contacts contact : temp3) {
        contact.getTasks().add(task);
        contactsDAO.changeContact(contact);
      }
    }
  }