Esempio n. 1
0
  @Override
  public void removeRequest(Requests request) {
    if (null != request) {

      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      request = (Requests) sess.get(Requests.class, request.getId());
      List<Contacts> contTemp = request.getContacts();
      List<Products> prodTemp = request.getProducts();

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

        sess.enableFetchProfile("requests-with-products");
        contTemp = contactsDAO.getFromProxy(contTemp);
        for (Contacts contact : contTemp) {
          contact.getConnectedRequests().remove(request);
          sess.update(contact);
        }
      }
      if (prodTemp != null && prodTemp.size() != 0) {
        sess.enableFetchProfile("requests-with-products");
        prodTemp = productsDAO.getFromProxy(prodTemp);
        for (Products product : prodTemp) {
          product.getRequestsForProduct().remove(request);
          sess.update(product);
        }
      }
      sess.update(request);
      sessionFactory.getCurrentSession().delete(request);
    }
  }
Esempio n. 2
0
  @Override
  public void addRequest(Requests request) {

    sessionFactory.getCurrentSession().save(request);
    List<Contacts> contTemp = request.getContacts();
    List<Products> prodTemp = request.getProducts();

    if (contTemp != null && contTemp.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("requests-with-products");
      contTemp = contactsDAO.getFromProxy(contTemp);
      for (Contacts contact : contTemp) {
        contact.getConnectedRequests().add(request);
        contactsDAO.changeContact(contact);
      }
    }
    if (prodTemp != null && prodTemp.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("requests-with-products");
      prodTemp = productsDAO.getFromProxy(prodTemp);
      for (Products product : prodTemp) {
        product.getRequestsForProduct().add(request);
        productsDAO.changeProduct(product);
      }
    }
  }
Esempio n. 3
0
 @Override
 public List<Products> getAllProducts(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("requests-with-products");
   Requests request = (Requests) sess.get(Requests.class, id);
   return request.getProducts();
 }
Esempio n. 4
0
 @Override
 public List<ContragentsInShipment> getParticipationInShipments(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("clients-with-rolesShip");
   Clients client = (Clients) sess.get(Clients.class, id);
   return client.getParticipantInShipments();
 }
Esempio n. 5
0
 @Override
 public List<Requests> getRequestsFromClient(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("clients-with-requests");
   Clients client = (Clients) sess.get(Clients.class, id);
   return client.getRequests();
 }
Esempio n. 6
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();
 }
Esempio n. 7
0
 @Override
 public Shipments getShipmentForPosition(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("clients-with-shipments");
   ContragentsInShipment client =
       (ContragentsInShipment) sess.get(ContragentsInShipment.class, id);
   return client.getShipment();
 }
Esempio n. 8
0
 public List<Shipments> getShipmentsForClient(Long id) {
   org.hibernate.Session sess = sessionFactory.getCurrentSession();
   sess.enableFetchProfile("clients-with-rolesShip");
   sess.enableFetchProfile("clients-with-shipments");
   Clients client = (Clients) sess.get(Clients.class, id);
   List<Shipments> returnList = new ArrayList<Shipments>();
   List<ContragentsInShipment> shipList = client.getParticipantInShipments();
   for (ContragentsInShipment con : shipList) {
     returnList.add(con.getShipment());
   }
   return returnList;
 }
Esempio n. 9
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);
    }
  }
Esempio n. 10
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);
      }
    }
  }
Esempio n. 11
0
  @Override
  public void addClient(Clients client) {
    List<Documents> temp = client.getDocuments();
    List<Payments> temp2 = client.getPaymentsFromClient();
    sessionFactory.getCurrentSession().save(client);

    // add links to documents
    if (temp != null && temp.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("clients-with-documents");
      temp = documentsDAO.getFromProxy(temp);
      for (Documents doc : temp) {
        doc.getClients().add(client);
        documentsDAO.changeDocument(doc);
      }
    }

    if (temp2 != null && temp2.size() != 0) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("clients-with-payments");
      temp2 = paymentsDAO.getFromProxy(temp2);
      for (Payments payment : temp2) {
        payment.setPayerOfPayment(client);
        paymentsDAO.changePayment(payment);
      }
    }

    if (client.getPaymentsToClient() != null) {
      org.hibernate.Session sess = sessionFactory.getCurrentSession();
      sess.enableFetchProfile("clients-with-payments");
      temp2 = paymentsDAO.getFromProxy(client.getPaymentsToClient());
      for (Payments payment : temp2) {
        payment.setReceiverOfPayment(client);
        paymentsDAO.changePayment(payment);
      }
    }
  }
Esempio n. 12
0
 public void enableFetchProfile(String name) throws UnknownProfileException {
   session.enableFetchProfile(name);
 }