Exemplo n.º 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();
  }
Exemplo n.º 2
0
  /**
   * VirtualImage Factory construction XXX is not stored on DB. (not an HB because it's not useful
   * the ''category''/''repository''...)
   *
   * @throws PersistenceException
   * @param name
   * @param cpu
   * @param ram
   * @param hd
   * @return a reference to the newly created VirtualimageHB persistent object
   * @throws PersistenceException
   */
  public VirtualimageHB createVirtualImage(String name, int cpu, int ram, long hd)
      throws PersistenceException {
    factorytest = HibernateDAOFactory.instance();
    VirtualImageDAO daoVI = factorytest.getVirtualImageDAO();

    factorytest.beginConnection();

    VirtualimageHB vImage = new VirtualimageHB();

    vImage.setName(name);
    vImage.setDescription("test");

    vImage.setCpuRequired(cpu);
    vImage.setHdRequired(hd);
    vImage.setRamRequired(ram);

    vImage.setPathName("test");

    vImage.setIcon(icon);
    vImage.setCategory(category);
    vImage.setType(imageType);
    vImage.setRepository(repository);

    daoVI.makePersistent(vImage);

    vImagesCreated.add(vImage);

    factorytest.endConnection();

    return vImage;
  }