예제 #1
0
 /*
  * (non-Javadoc)
  *
  * @see cn.tinder.fuego.dao.AssetsQuotaDao#create(cn.tinder.fuego.domain.po. AssetsQuota)
  */
 @Override
 public void create(AssetsQuota quota) {
   // TODO Auto-generated method stub
   log.debug("[DAO] Create a AssetsQuota:" + quota.toString());
   try {
     HibernateUtil.add(quota);
   } catch (RuntimeException re) {
     throw re;
   } finally {
     HibernateUtil.closeSession();
   }
   log.debug("[DAO] Success! -Create a AssetsQuota:" + quota.toString());
 }
예제 #2
0
 /*
  * (non-Javadoc)
  *
  * @see cn.tinder.fuego.dao.CheckPlanDao#create(cn.tinder.fuego.domain.po.CheckPlan )
  */
 @Override
 public void create(CheckPlan plan) {
   // TODO Auto-generated method stub
   log.debug("[DAO] Create a CheckPlan:" + plan.toString());
   try {
     HibernateUtil.add(plan);
   } catch (RuntimeException re) {
     throw re;
   } finally {
     HibernateUtil.closeSession();
   }
   log.debug("[DAO] Success! -Create a CheckPlan:" + plan.toString());
 }
예제 #3
0
  /*
   * (non-Javadoc)
   *
   * @see cn.tinder.fuego.dao.CheckPlanDao#delete(cn.tinder.fuego.domain.po.CheckPlan )
   */
  @Override
  public void delete(CheckPlan plan) {
    // TODO Auto-generated method stub
    log.debug("[DAO] Delete the CheckPlan:" + plan.toString());

    Session session = null;
    Transaction tx = null;
    String hql = null;
    // SystemUser user = null;
    try {
      session = HibernateUtil.getSession();

      tx = session.beginTransaction();

      hql = "delete from CheckPlan where trans_id=? and dept_id=? ";
      Query query = session.createQuery(hql);
      query.setString(0, plan.getTransID());
      query.setString(1, plan.getDeptID());

      query.executeUpdate();

      tx.commit();
    } catch (RuntimeException re) {
      throw re;
    } finally {
      if (null != session) {
        session.close();
      }
    }

    log.debug("[DAO] Success!Delete the CheckPlan:" + plan.toString());
  }
예제 #4
0
  /*
   * (non-Javadoc)
   *
   * @see cn.tinder.fuego.dao.CheckPlanDao#getByTransID(java.lang.String)
   */
  @Override
  public List<CheckPlan> getByTransID(String transid) {
    // TODO Auto-generated method stub
    log.debug("[DAO] get the TransID by ID:" + transid);
    List<CheckPlan> checkList;
    Session s = null;
    try {
      s = HibernateUtil.getSession();

      Criteria c = s.createCriteria(CheckPlan.class);
      c.add(Restrictions.eq("transID", transid));

      checkList = c.list();

    } catch (RuntimeException e) {
      log.error("get checkplan id by transid failed." + transid, e);
      throw e;
    } finally {
      if (s != null) {
        s.close();
      }
    }

    return checkList;
  }
예제 #5
0
  @Override
  public void deleteByTransID(String transID) {

    Session session = null;
    Transaction tx = null;
    String hql = null;
    // SystemUser user = null;
    try {
      session = HibernateUtil.getSession();

      tx = session.beginTransaction();

      hql = "delete from CheckPlan where trans_id=?";
      Query query = session.createQuery(hql);
      query.setString(0, transID);

      query.executeUpdate();

      tx.commit();
    } catch (RuntimeException re) {
      throw re;
    } finally {
      if (null != session) {
        session.close();
      }
    }
  }
예제 #6
0
  /*
   * (non-Javadoc)
   *
   * @see cn.tinder.fuego.dao.AssetsQuotaDao#delete(cn.tinder.fuego.domain.po. AssetsQuota)
   */
  @Override
  public void delete(AssetsQuota quota) {
    // TODO Auto-generated method stub
    log.debug("[DAO] Delete the DiscardPlan:" + quota.toString());

    Session session = null;
    Transaction tx = null;
    String hql = null;
    // SystemUser user = null;
    try {
      session = HibernateUtil.getSession();

      tx = session.beginTransaction();

      hql = "delete from AssetsQuota where ASSETS_NAME =? and  DUTY = ?";
      Query query = session.createQuery(hql);
      query.setString(0, quota.getAssetsName());
      query.setString(1, quota.getDuty());

      query.executeUpdate();

      tx.commit();
    } catch (RuntimeException re) {
      throw re;
    } finally {
      if (null != session) {
        session.close();
      }
    }

    log.debug("[DAO] Success!Delete the DiscardPlan:" + quota.toString());
  }
예제 #7
0
 /* (non-Javadoc)
  * @see cn.tinder.fuego.dao.AssetsQuotaDao#getByDuty(java.lang.String)
  */
 @Override
 public List<AssetsQuota> getByDuty(String duty) {
   // TODO Auto-generated method stub
   log.debug("[DAO] get the AssetsQuota by Name:" + duty);
   Session s = null;
   // Transaction tx = null;
   // String hql = null;
   List<AssetsQuota> quotaList = null;
   try {
     s = HibernateUtil.getSession();
     Criteria c = s.createCriteria(AssetsQuota.class);
     c.add(Restrictions.eq("duty", duty)); //
     quotaList = c.list();
   } catch (RuntimeException re) {
     throw re;
   } finally {
     // HibernateUtil.closeSession();
     if (s != null) {
       s.close();
     }
   }
   if (quotaList != null) {
     log.debug("[DAO] Success!  get the AssetsName by Name:" + quotaList.toString());
   }
   return quotaList;
 }
예제 #8
0
 /*
  * (non-Javadoc)
  *
  * @see cn.tinder.fuego.dao.CheckPlanDao#saveOrUpdate(cn.tinder.fuego.domain. po.CheckPlan)
  */
 @Override
 public void saveOrUpdate(CheckPlan plan) {
   // TODO Auto-generated method stub
   try {
     delete(plan);
     create(plan);
   } catch (RuntimeException re) {
     throw re;
   } finally {
     HibernateUtil.closeSession();
   }
 }
예제 #9
0
 /*
  * (non-Javadoc)
  *
  * @see cn.tinder.fuego.dao.AssetsQuotaDao#saveOrUpdate(cn.tinder.fuego.domain .po.AssetsQuota)
  */
 @Override
 public void saveOrUpdate(AssetsQuota quota) {
   // TODO Auto-generated method stub
   try {
     this.delete(quota);
     this.create(quota);
   } catch (RuntimeException re) {
     throw re;
   } finally {
     HibernateUtil.closeSession();
   }
 }
예제 #10
0
  /*
   * (non-Javadoc)
   *
   * @see cn.tinder.fuego.dao.AssetsQuotaDao#getByAssetsName(java.lang.String)
   */
  @Override
  public List<AssetsQuota> getByFilter(AssetsQuota filter) {
    // TODO Auto-generated method stub
    log.debug("[DAO] get the AssetsQuota by filter " + filter);
    Session s = null;
    // Transaction tx = null;
    // String hql = null;
    List<AssetsQuota> quota = null;
    try {
      s = HibernateUtil.getSession();
      Criteria c = s.createCriteria(AssetsQuota.class);

      if (null != filter) {
        if (null != filter.getAssetsName()) {
          c.add(Restrictions.like("assetsName", "%" + filter.getAssetsName() + "%")); //
        }
        if (null != filter.getDuty()) {
          c.add(Restrictions.eq("duty", filter.getDuty())); //
        }
        if (null != filter.getManufacture()) {
          c.add(Restrictions.eq("manufacture", filter.getManufacture())); //
        }
        if (null != filter.getSpec()) {
          c.add(Restrictions.eq("spec", filter.getSpec())); //
        }
      }

      quota = c.list();
    } catch (RuntimeException re) {
      throw re;
    } finally {
      // HibernateUtil.closeSession();
      if (s != null) {
        s.close();
      }
    }
    if (quota != null) {
      log.debug("[DAO] Success!  get the AssetsName by Name:" + quota.toString());
    }
    return quota;
  }
예제 #11
0
  /* (non-Javadoc)
   * @see cn.tinder.fuego.dao.ReceivePlanDao#create(java.util.List)
   */
  @Override
  public void create(List<CheckPlan> planlist) {
    Session session = null;
    Transaction tx = null;
    try {
      session = HibernateUtil.getSession();
      tx = session.beginTransaction();
      for (CheckPlan rplan : planlist) {
        session.save(rplan);
      }
      tx.commit();

    } catch (RuntimeException re) {
      throw re;
    } finally {
      //  HibernateUtil.closeSession();
      if (session != null) {
        session.close();
      }
    }
  }
예제 #12
0
  @Override
  public void create(List<AssetsQuota> quotaList) {
    Session session = null;
    Transaction tx = null;
    try {
      session = HibernateUtil.getSession();
      tx = session.beginTransaction();
      for (AssetsQuota quota : quotaList) {
        session.save(quota);
      }
      tx.commit();

    } catch (RuntimeException re) {
      throw re;
    } finally {
      //  HibernateUtil.closeSession();
      if (session != null) {
        session.close();
      }
    }
  }
예제 #13
0
  /* (non-Javadoc)
   * @see cn.tinder.fuego.dao.AssetsQuotaDao#getAllAssetsQuota()
   */
  @Override
  public List<AssetsQuota> getAllAssetsQuota() {

    Session s = null;
    // Transaction tx = null;
    // String hql = null;
    List<AssetsQuota> quotaList = null;
    try {
      s = HibernateUtil.getSession();
      Criteria c = s.createCriteria(AssetsQuota.class);
      quotaList = c.list();
    } catch (RuntimeException re) {
      throw re;
    } finally {
      // HibernateUtil.closeSession();
      if (s != null) {
        s.close();
      }
    }
    if (quotaList != null) {
      log.debug("[DAO] Success!  get the AssetsName by Name:" + quotaList.toString());
    }
    return quotaList;
  }