Пример #1
0
  public EventNumberOfPassesRequest getEventPassesRequest(User user, Event event) {
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    try {
      Transaction transaction = session.beginTransaction();
      List result =
          session
              .createQuery(
                  "from EventNumberOfPassesRequest as eventNumberOfPassesRequest "
                      + "where eventNumberOfPassesRequest.idevent="
                      + event.getIdevent()
                      + " and eventNumberOfPassesRequest.iduser="
                      + user.getIduser())
              .list();
      transaction.commit();

      if (result != null && result.size() > 0) {
        return (EventNumberOfPassesRequest) result.get(0);
      }
    } finally {
      if (session.isOpen()) {
        session.disconnect();
        session.close();
      }
    }
    return null;
  }
Пример #2
0
 public void savePartnerRequest(ActivityPartnerRequest activityPartnerRequest) {
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   try {
     Transaction transaction = session.beginTransaction();
     List result =
         session
             .createQuery(
                 "from ActivityPartnerRequest as partnerrequest "
                     + "where partnerrequest.idactivity="
                     + activityPartnerRequest.getIdactivity()
                     + " and partnerrequest.iduser="
                     + activityPartnerRequest.getIduser())
             .list();
     transaction.commit();
     if (result != null && result.size() > 0) {
       Session session1 = SessionFactoryUtil.getInstance().getCurrentSession();
       Transaction transaction1 = session1.beginTransaction();
       for (Object o : result) {
         session1.delete(o);
       }
       transaction1.commit();
     }
   } finally {
     if (session.isOpen()) {
       session.disconnect();
       session.close();
     }
   }
   saveObject(activityPartnerRequest);
 }
Пример #3
0
 public void saveEventPassesRequest(EventNumberOfPassesRequest eventNumberOfPassesRequest) {
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   try {
     Transaction transaction = session.beginTransaction();
     List result =
         session
             .createQuery(
                 "from EventNumberOfPassesRequest as eventNumberOfPassesRequest "
                     + "where eventNumberOfPassesRequest.idevent="
                     + eventNumberOfPassesRequest.getIdevent()
                     + " and eventNumberOfPassesRequest.iduser="
                     + eventNumberOfPassesRequest.getIduser())
             .list();
     transaction.commit();
     if (result != null && result.size() > 0) {
       Session session1 = SessionFactoryUtil.getInstance().getCurrentSession();
       Transaction transaction1 = session1.beginTransaction();
       for (Object o : result) {
         session1.delete(o);
       }
       transaction1.commit();
     }
   } finally {
     if (session.isOpen()) {
       session.disconnect();
       session.close();
     }
   }
   saveObject(eventNumberOfPassesRequest);
 }
Пример #4
0
  public ActivityPartnerRequest getPartnerRequest(User user, Activity activity) {
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    try {
      Transaction transaction = session.beginTransaction();
      List result =
          session
              .createQuery(
                  "from ActivityPartnerRequest as partnerrequest "
                      + "where partnerrequest.idactivity="
                      + activity.getIdactivity()
                      + " and partnerrequest.iduser="
                      + user.getIduser())
              .list();
      transaction.commit();

      if (result != null && result.size() > 0) {
        return (ActivityPartnerRequest) result.get(0);
      }
    } finally {
      if (session.isOpen()) {
        session.disconnect();
        session.close();
      }
    }
    return null;
  }
Пример #5
0
  public User getUserByEmail(String email) {
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    List list = session.createQuery("from User as user where user.mail = '" + email + "'").list();

    transaction.commit();
    if (list != null && list.size() == 1) {
      return (User) list.get(0);
    }

    return null;
  }
Пример #6
0
  private User getUserByEmployeeId(String employeeId) {

    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    String queryString = "from User user where user.employeeId ='" + employeeId + "'";

    List list = session.createQuery(queryString).list();
    transaction.commit();
    if (list != null && list.size() == 1) {
      return (User) list.get(0);
    }
    return null;
  }
Пример #7
0
 public List<ActivityPartnerRequest> getAllActivityPartnerRequestForUser(User user) {
   List<ActivityPartnerRequest> result = new ArrayList<ActivityPartnerRequest>();
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   Transaction transaction = session.beginTransaction();
   List list =
       session
           .createQuery("from ActivityPartnerRequest apr where apr.iduser=" + user.getIduser())
           .list();
   transaction.commit();
   if (list != null && list.size() > 0) {
     for (Object o : list) {
       result.add((ActivityPartnerRequest) o);
     }
   }
   return result;
 }
Пример #8
0
 public User getUserByName(String firstName, String lastName) {
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   Transaction transaction = session.beginTransaction();
   String queryString =
       "from User user where user.firstname ='"
           + firstName
           + "' and user.lastname ='"
           + lastName
           + "'";
   //        System.out.println("queryString = " + queryString);
   List list = session.createQuery(queryString).list();
   transaction.commit();
   if (list != null && list.size() == 1) {
     return (User) list.get(0);
   }
   return null;
 }