Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
 public List<Activity> getActivities(Event parent) {
   List<Activity> result = new ArrayList<Activity>();
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   try {
     Transaction transaction = session.beginTransaction();
     Object event =
         session
             .createQuery("from Event as event where event.idevent= " + parent.getIdevent())
             .uniqueResult();
     transaction.commit();
     if (event != null) {
       Event eventEntity = (Event) event;
       Collection<Activity> activityList = eventEntity.getActivities();
       for (Activity activity : activityList) {
         result.add(activity);
       }
     }
   } finally {
     if (session.isOpen()) {
       session.flush();
       session.disconnect();
       session.close();
     }
   }
   return result;
 }
Ejemplo n.º 3
0
 public Event getEvent(Event event) {
   Event result = null;
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   try {
     Transaction transaction = session.beginTransaction();
     Object o =
         session
             .createQuery("from Event as event where event.idevent= " + event.getIdevent())
             .uniqueResult();
     transaction.commit();
     if (o != null) {
       result = (Event) o;
     }
   } finally {
     if (session.isOpen()) {
       session.disconnect();
       session.close();
     }
   }
   return result;
 }
Ejemplo n.º 4
0
  public List<User> getUserForEvent(Event selectedEvent) {
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    List<User> result = new ArrayList<User>();
    try {
      Transaction transaction = session.beginTransaction();

      String queryString =
          "select user from User as user where "
              + selectedEvent.getIdevent()
              + " in elements (user.events) order by user.firstname";
      List users = session.createQuery(queryString).list();
      transaction.commit();

      for (Object user : users) {
        result.add((User) user);
      }
    } finally {
      if (session.isOpen()) {
        session.disconnect();
        session.close();
      }
    }
    return result;
  }