Пример #1
0
  /**
   * Remove from DB the PhyisicalMachines from initPhysical implementation (actually remove
   * DataCenter @see dataCenter, for cascading delete physical machines disapear) Clean from DB the
   * scheduler test virtual datacenter, virtual application, icon and virtual images.
   *
   * @throws PersistenceException
   */
  public void clearCreatedDomainObjects() throws PersistenceException {
    if (dc == null) {
      return;
    }

    factorytest = HibernateDAOFactory.instance();
    DataCenterDAO daoDc = factorytest.getDataCenterDAO();
    VirtualDataCenterDAO daoVdc = factorytest.getVirtualDataCenterDAO();
    IconDAO daoIco = factorytest.getIconDAO();
    VirtualImageDAO daoVi = factorytest.getVirtualImageDAO();

    factorytest.beginConnection();

    log.debug("Cleaning all the created objects ");

    daoDc.makeTransient(dc);
    daoVdc.makeTransient(vdc);

    daoIco.makeTransient(icon);

    // TODO: create the speciphic method by description??
    // Criterion descriptionTest = Restrictions.eq("description", "test");
    // for (VirtualimageHB vi : daoVi.findByCriteria(descriptionTest))
    // {
    // HibernateUtil.getSession().delete(vi); // XXX use DAO
    // }

    factorytest.endConnection();
  }
Пример #2
0
  /**
   * VirtualDataCenter Factory construction
   *
   * @throws PersistenceException
   */
  private VirtualDataCenterHB createVirtualDataCenter(
      DatacenterHB dc, EnterpriseHB enterprise, HypervisorType htype) throws PersistenceException {
    factorytest = HibernateDAOFactory.instance();
    VirtualDataCenterDAO daoVdc = factorytest.getVirtualDataCenterDAO();

    factorytest.beginConnection();

    VirtualDataCenterHB vdc = new VirtualDataCenterHB();
    vdc.setEnterpriseHB(enterprise);
    vdc.setIdDataCenter(dc.getIdDataCenter());
    vdc.setName("test");
    vdc.setHypervisorType(htype);
    vdc.setNetwork(createNetwork());
    daoVdc.makePersistent(vdc);

    factorytest.endConnection();

    return vdc;
  }