Esempio n. 1
0
  public List<Team> getTeams() {
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    List result = null;
    try {
      Transaction transaction = session.beginTransaction();
      result = session.createQuery("from Team").list();
      session.flush();
      transaction.commit();
    } catch (HibernateException e) {
      e.printStackTrace();
    } finally {
      if (session.isOpen()) {
        session.close();
      }
    }

    List<Team> teams = new ArrayList<Team>();
    for (Object o : result) {
      if (o instanceof Team) {
        teams.add((Team) o);
      }
    }

    return teams;
  }
Esempio 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;
 }
Esempio n. 3
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;
 }
Esempio n. 4
0
 public List<Event> getEvent(String name) {
   List<Event> result = new ArrayList<Event>();
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   try {
     Transaction transaction = session.beginTransaction();
     List list = session.createQuery("from Event as event where event.name='" + name + "'").list();
     transaction.commit();
     for (Object o : list) {
       result.add((Event) o);
     }
   } finally {
     if (session.isOpen()) {
       session.disconnect();
       session.close();
     }
   }
   return result;
 }
Esempio n. 5
0
 public List<User> getUsers() {
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   List<User> result = new ArrayList<User>();
   try {
     Transaction transaction = session.beginTransaction();
     List list = session.createQuery("from User").list();
     transaction.commit();
     for (Object o : list) {
       User user = (User) o;
       result.add(user);
     }
   } finally {
     if (session.isOpen()) {
       session.disconnect();
       session.close();
     }
   }
   return result;
 }
Esempio n. 6
0
  public List<Logo> getLogos() {
    List<Logo> result = new ArrayList<Logo>();
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    try {
      Transaction transaction = session.beginTransaction();

      List list = session.createQuery("from Logo").list();
      transaction.commit();
      for (Object o : list) {
        Logo logo = (Logo) o;
        result.add(logo);
      }
    } finally {
      if (session.isOpen()) {
        session.disconnect();
        session.close();
      }
    }
    return result;
  }
Esempio n. 7
0
 public List<User> getUsersForTeam(Team team) {
   Session session = SessionFactoryUtil.getInstance().getCurrentSession();
   Transaction transaction = session.beginTransaction();
   List list =
       session
           .createQuery(
               "from TeamUserSelection as teamUserSelection where teamUserSelection.idteam= "
                   + team.getId())
           .list();
   transaction.commit();
   if (list != null) {
     List<User> result = new ArrayList<User>();
     for (Object o : list) {
       User user = getUser(((TeamUserSelection) o).getIduser());
       result.add(user);
     }
     return result;
   }
   return null;
 }
Esempio n. 8
0
  public List<Activity> getActivities() {
    List<Activity> result = new ArrayList<Activity>();
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    try {
      Transaction transaction = session.beginTransaction();
      List list = session.createQuery("from Activity").list();
      transaction.commit();

      for (Object o : list) {
        Activity activity = (Activity) o;
        result.add(activity);
      }
    } finally {
      if (session.isOpen()) {
        session.flush();
        session.disconnect();
        session.close();
      }
    }
    return result;
  }
Esempio n. 9
0
  public List<Location> getLocations() {
    List<Location> result = new ArrayList<Location>();
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    try {
      Transaction transaction = session.beginTransaction();
      List list = session.createQuery("from Location").list();
      transaction.commit();

      if (list != null) {
        for (Object o : list) {
          Location location = (Location) o;
          result.add(location);
        }
      }
    } finally {
      if (session.isOpen()) {
        session.flush();
        session.disconnect();
        session.close();
      }
    }
    return result;
  }
Esempio n. 10
0
  public List<ClassificationType> getClassificationTypes() {
    List<ClassificationType> result = new ArrayList<ClassificationType>();
    Session session = SessionFactoryUtil.getInstance().getCurrentSession();
    try {
      Transaction transaction = session.beginTransaction();
      List list = session.createQuery("from ClassificationType").list();
      transaction.commit();

      if (list != null) {
        for (Object o : list) {
          ClassificationType classificationType = (ClassificationType) o;
          result.add(classificationType);
        }
      }
    } finally {
      if (session.isOpen()) {
        session.flush();
        session.disconnect();
        session.close();
      }
    }
    return result;
  }
Esempio n. 11
0
  public List<User> getUserForActivity(Activity activity) {
    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 "
              + activity.getIdactivity()
              + " in elements (user.activities)";
      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;
  }
Esempio n. 12
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;
  }