Ejemplo n.º 1
0
  /** USE THIS INSTEAD OF THE BATGEN DELETE It also deletes associated events of the object.s */
  public int delete(Long key) throws BoException {
    SqlSession session = null;
    int result = 0;
    String where = "KEY='" + key + "' ";
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("where", where);

    // first delete all events associated with this object
    EventBo.getInstance().deleteEventsOf(ItemType.SOFTWARE, key);

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      result = mapper.delete(map);
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }

    return result;
  }
Ejemplo n.º 2
0
  /**
   * Deletes all data (rows) from SOFTWARE
   *
   * @throws BoException
   */
  public void deleteAll() throws BoException {
    SqlSession session = null;

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      mapper.deleteAll();
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }
  }
Ejemplo n.º 3
0
  /**
   * Get a list of software objects between (inclusive) the dates start and end.
   *
   * @param start
   * @param end
   * @return
   * @throws BoException
   */
  public List<Software> getListByPurchaseRange(Date start, Date end) throws BoException {
    SqlSession session = null;
    List<Software> list;

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      list = mapper.getListByPurchaseRange(start, end);
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);
    } finally {
      if (session != null) session.close();
    }

    return list;
  }
Ejemplo n.º 4
0
  public int update(Software value) throws BoException {
    SqlSession session = null;
    int result = 0;

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      result = mapper.update(value);
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }

    return result;
  }
Ejemplo n.º 5
0
  /**
   * Get a list of software objects within a cost range
   *
   * @param minCost
   * @param maxCost
   * @return
   * @throws BoException
   */
  public List<Software> getListByCostRange(String minCost, String maxCost) throws BoException {
    SqlSession session = null;
    List<Software> list;

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      list = mapper.getListByCostRange(minCost, maxCost);
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }

    return list;
  }
Ejemplo n.º 6
0
  /**
   * Retrieves max size software objects from database (Software table).
   *
   * @param size
   * @return List of software objects to populate results page for empty search bar.
   * @throws BoException
   */
  public List<Software> getDefaultResults(int size) throws BoException {
    SqlSession session = null;
    List<Software> list;

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      list = mapper.getDefaultResults(size);
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }

    return list;
  }
Ejemplo n.º 7
0
  /**
   * Retrieves all software objects from database (Software table) matching search term.
   *
   * @param searchText
   * @return List of all software objects matching search term.
   * @throws BoException
   */
  public List<Software> search(String searchText) throws BoException {
    SqlSession session = null;
    List<Software> list;

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      list = mapper.search(searchText);
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }

    return list;
  }
Ejemplo n.º 8
0
  public List<Software> getListByIsActive(Boolean key) throws BoException {
    SqlSession session = null;
    List<Software> list;

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      list = mapper.getListByIsActive(key);
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }

    return list;
  }
Ejemplo n.º 9
0
  public Software read(Long key) throws BoException {
    SqlSession session = null;
    Software result;
    String where = "KEY='" + key + "' ";
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("where", where);

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      result = mapper.read(map);
      session.commit();

    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }

    return result;
  }
Ejemplo n.º 10
0
  /**
   * Retrieves all software objects from the database (Software table) matching search terms.
   *
   * @param columns
   * @param searches
   * @return List of all software objects matching search terms.
   * @throws BoException
   */
  public List<Software> searchAdvanced(
      ArrayList<String> columns, ArrayList<ArrayList<String>> searches) throws BoException {
    SqlSession session = null;
    List<Software> list = new ArrayList<Software>();

    if (columns.size() == 0 && searches.size() == 0) {
      return SoftwareBo.getInstance().getAll();
    }

    try {
      session = SessionFactory.getSession();
      SoftwareDao mapper = session.getMapper(SoftwareDao.class);
      list = mapper.searchAdvanced(columns, searches);
      session.commit();
    } catch (Exception e) {
      session.rollback();
      throw new BoException(e);

    } finally {
      if (session != null) session.close();
    }

    return list;
  }