/** * 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(); }
private DatacenterHB createDataCenter() throws PersistenceException { factorytest = HibernateDAOFactory.instance(); DataCenterDAO daoDC = factorytest.getDataCenterDAO(); factorytest.beginConnection(); DatacenterHB data = new DatacenterHB(); data.setName(DATACENTER_TEST); // XXX data.setSituation("test"); // XXX data.setRacks(racks); daoDC.makePersistent(data); factorytest.endConnection(); return data; }