示例#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 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);
    }
  }
示例#3
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);
      }
    }
  }