test_class.declarator: datacenterGenerator
test_class.modifier: private
test_class.original_string: private DatacenterGenerator datacenterGenerator;
test_class.type: DatacenterGenerator
test_class.var_name: datacenterGenerator
test_class.declarator: vmgenerator
test_class.modifier: private
test_class.original_string: private VirtualMachineGenerator vmgenerator;
test_class.type: VirtualMachineGenerator
test_class.var_name: vmgenerator
test_class.file: model/src/test/java/com/abiquo/server/core/infrastructure/RackDAOTest.java
test_class.identifier: RackDAOTest
test_class.superclass: extends DefaultDAOTestBase<RackDAO, Rack>
test_case.body: @Test
      public void test_findRacks() throws IllegalAccessException, InvocationTargetException,
          NoSuchMethodException
      {
          Datacenter datacenter1 = datacenterGenerator.createUniqueInstance();
          Datacenter datacenter2 = datacenterGenerator.createUniqueInstance();
          Rack rack2_1 = datacenter2.createRack("bRack_1", 2, 4094, 2, 10);
          Rack rack2_2 = datacenter2.createRack("aRack_2", 2, 4094, 2, 10);
          ds().persistAll(datacenter1, datacenter2, rack2_1, rack2_2);
  
          RackDAO dao = createDaoForRollbackTransaction();
          Assert.assertEquals(dao.findRacks(reload(dao, datacenter1)).size(), 0);
          List<Rack> result = dao.findRacks(reload(dao, datacenter2));
          assertEqualsPropertyForList(Rack.NAME_PROPERTY, result, "aRack_2", "bRack_1");
      }
test_case.class_method_signature: RackDAOTest.test_findRacks()
test_case.full_signature: @Test public void test_findRacks()
test_case.identifier: test_findRacks
test_case.invocations: createUniqueInstance createUniqueInstance createRack createRack persistAll ds createDaoForRollbackTransaction assertEquals size findRacks reload findRacks reload assertEqualsPropertyForList
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test_findRacks()
focal_class.declarator: QUERY_GET_FILTERED_RACKS = //
          "SELECT  r.idRack, r.idDataCenter, r.name, r.shortDescription, r.largeDescription, r.vlan_id_min, r.vlan_id_max, "
              + "r.vlans_id_avoided, r.vlan_per_vdc_expected, r.nrsq, r.haEnabled, r.version_c FROM " //
              + "rack r LEFT OUTER JOIN datacenter dc ON r.idDatacenter = dc.idDatacenter "
              + "WHERE dc.idDatacenter = :idDatacenter " //
              + "AND (r.name like :filter "
              + "OR r.idRack in (SELECT pms.idRack FROM physicalmachine pms LEFT OUTER JOIN enterprise ent ON pms.idEnterprise = ent.idEnterprise "
              + "WHERE ent.name like :filter OR pms.name like :filter ) " + ")"
focal_class.modifier: private final static
focal_class.original_string: private final static String QUERY_GET_FILTERED_RACKS = //
          "SELECT  r.idRack, r.idDataCenter, r.name, r.shortDescription, r.largeDescription, r.vlan_id_min, r.vlan_id_max, "
              + "r.vlans_id_avoided, r.vlan_per_vdc_expected, r.nrsq, r.haEnabled, r.version_c FROM " //
              + "rack r LEFT OUTER JOIN datacenter dc ON r.idDatacenter = dc.idDatacenter "
              + "WHERE dc.idDatacenter = :idDatacenter " //
              + "AND (r.name like :filter "
              + "OR r.idRack in (SELECT pms.idRack FROM physicalmachine pms LEFT OUTER JOIN enterprise ent ON pms.idEnterprise = ent.idEnterprise "
              + "WHERE ent.name like :filter OR pms.name like :filter ) " + ")";
focal_class.type: String
focal_class.var_name: QUERY_GET_FILTERED_RACKS
focal_class.declarator: SQL_RACK_IDS_BY_MIN_VLAN_COUNT = //
          //
          "SELECT rack_filtered_dc.idRack FROM "
              + //
              "(SELECT r.idRack, r.idDatacenter, r.vlan_id_min, r.vlan_id_max, r.vlan_per_vdc_expected, r.nrsq, count(vn.id) as vlans_used "
              + //
              "FROM rack r LEFT JOIN vlan_network_assignment vn ON r.idRack = vn.idRack GROUP BY r.idRack ) as rack_filtered_dc "
              + //
              "WHERE rack_filtered_dc.idDataCenter = :idDatacenter AND rack_filtered_dc.vlans_used + rack_filtered_dc.vlan_per_vdc_expected + (((rack_filtered_dc.vlan_id_max - rack_filtered_dc.vlan_id_min +1 ) * (rack_filtered_dc.nrsq)) / 100) <= ((rack_filtered_dc.vlan_id_max - rack_filtered_dc.vlan_id_min) + 1) "
              + //
              "ORDER BY rack_filtered_dc.vlans_used + rack_filtered_dc.vlan_per_vdc_expected ASC"
focal_class.modifier: private final static
focal_class.original_string: private final static String SQL_RACK_IDS_BY_MIN_VLAN_COUNT = //
          //
          "SELECT rack_filtered_dc.idRack FROM "
              + //
              "(SELECT r.idRack, r.idDatacenter, r.vlan_id_min, r.vlan_id_max, r.vlan_per_vdc_expected, r.nrsq, count(vn.id) as vlans_used "
              + //
              "FROM rack r LEFT JOIN vlan_network_assignment vn ON r.idRack = vn.idRack GROUP BY r.idRack ) as rack_filtered_dc "
              + //
              "WHERE rack_filtered_dc.idDataCenter = :idDatacenter AND rack_filtered_dc.vlans_used + rack_filtered_dc.vlan_per_vdc_expected + (((rack_filtered_dc.vlan_id_max - rack_filtered_dc.vlan_id_min +1 ) * (rack_filtered_dc.nrsq)) / 100) <= ((rack_filtered_dc.vlan_id_max - rack_filtered_dc.vlan_id_min) + 1) "
              + //
              "ORDER BY rack_filtered_dc.vlans_used + rack_filtered_dc.vlan_per_vdc_expected ASC";
focal_class.type: String
focal_class.var_name: SQL_RACK_IDS_BY_MIN_VLAN_COUNT
focal_class.declarator: SQL_RACK_IDS_BY_MIN_VLAN_COUNT_LITE = //
          //
          "SELECT r.idRack " + //
              "FROM rack r, virtualapp va, virtualdatacenter vdc, datacenter dc " + //
              "WHERE va.idVirtualApp = :idVApp " + //
              "AND vdc.idVirtualDataCenter = va.idVirtualDataCenter " + //
              "AND vdc.idDataCenter = r.idDatacenter"
focal_class.modifier: private final static
focal_class.original_string: private final static String SQL_RACK_IDS_BY_MIN_VLAN_COUNT_LITE = //
          //
          "SELECT r.idRack " + //
              "FROM rack r, virtualapp va, virtualdatacenter vdc, datacenter dc " + //
              "WHERE va.idVirtualApp = :idVApp " + //
              "AND vdc.idVirtualDataCenter = va.idVirtualDataCenter " + //
              "AND vdc.idDataCenter = r.idDatacenter";
focal_class.type: String
focal_class.var_name: SQL_RACK_IDS_BY_MIN_VLAN_COUNT_LITE
focal_class.declarator: COUNT_DEPLOYED_VLA = //
          "SELECT COUNT(vn.id) " + //
              "FROM NetworkAssignment vn WHERE " + //
              "vn.rack.id = :idRack"
focal_class.modifier: private final static
focal_class.original_string: private final static String COUNT_DEPLOYED_VLA = //
          "SELECT COUNT(vn.id) " + //
              "FROM NetworkAssignment vn WHERE " + //
              "vn.rack.id = :idRack";
focal_class.type: String
focal_class.var_name: COUNT_DEPLOYED_VLA
focal_class.declarator: HQL_NOT_MANAGED_RACKS_BY_DATACENTER = //
          "SELECT nmr " + //
              "FROM Rack nmr WHERE " + //
              "nmr.datacenter.id = :idDatacenter and nmr.class = " + Rack.class.getName()
focal_class.modifier: private final static
focal_class.original_string: private final static String HQL_NOT_MANAGED_RACKS_BY_DATACENTER = //
          "SELECT nmr " + //
              "FROM Rack nmr WHERE " + //
              "nmr.datacenter.id = :idDatacenter and nmr.class = " + Rack.class.getName();
focal_class.type: String
focal_class.var_name: HQL_NOT_MANAGED_RACKS_BY_DATACENTER
focal_class.declarator: QUERY_USED_VDRP = "SELECT vm.vdrpPort " + //
          "FROM com.abiquo.server.core.cloud.VirtualMachine vm " + //
          "WHERE vm.hypervisor.machine.rack = :rack "
focal_class.modifier: private final
focal_class.original_string: private final String QUERY_USED_VDRP = "SELECT vm.vdrpPort " + //
          "FROM com.abiquo.server.core.cloud.VirtualMachine vm " + //
          "WHERE vm.hypervisor.machine.rack = :rack ";
focal_class.type: String
focal_class.var_name: QUERY_USED_VDRP
focal_class.declarator: HQL_EMPTY_OFF_MACHINES_IN_RACK =
          "select m from Machine m where m.rack.id = :rackId and m.state = "
              + MachineState.HALTED_FOR_SAVE.ordinal()
              + " order by (case when exists (select n from Hypervisor n where n.machine = m) then 0 else 1 end)"
focal_class.modifier: private final static
focal_class.original_string: private final static String HQL_EMPTY_OFF_MACHINES_IN_RACK =
          "select m from Machine m where m.rack.id = :rackId and m.state = "
              + MachineState.HALTED_FOR_SAVE.ordinal()
              + " order by (case when exists (select n from Hypervisor n where n.machine = m) then 0 else 1 end)";
focal_class.type: String
focal_class.var_name: HQL_EMPTY_OFF_MACHINES_IN_RACK
focal_class.declarator: HQL_EMPTY_ON_MACHINES_IN_RACK =
          "select m from Machine m where m.rack.id = :rackId and m.state = "
              + MachineState.MANAGED.ordinal()
              + " and not exists (select vm from VirtualMachine vm where vm.hypervisor.machine = m)"
focal_class.modifier: private final static
focal_class.original_string: private final static String HQL_EMPTY_ON_MACHINES_IN_RACK =
          "select m from Machine m where m.rack.id = :rackId and m.state = "
              + MachineState.MANAGED.ordinal()
              + " and not exists (select vm from VirtualMachine vm where vm.hypervisor.machine = m)";
focal_class.type: String
focal_class.var_name: HQL_EMPTY_ON_MACHINES_IN_RACK
focal_class.file: model/src/main/java/com/abiquo/server/core/infrastructure/RackDAO.java
focal_class.identifier: RackDAO
focal_class.class_method_signature: RackDAO.RackDAO()
focal_class.full_signature: public  RackDAO()
focal_class.identifier: RackDAO
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  RackDAO()
focal_class.class_method_signature: RackDAO.RackDAO(final EntityManager entityManager)
focal_class.full_signature: public  RackDAO(final EntityManager entityManager)
focal_class.identifier: RackDAO
focal_class.modifiers: public
focal_class.parameters: (final EntityManager entityManager)
focal_class.signature:  RackDAO(final EntityManager entityManager)
focal_class.class_method_signature: RackDAO.sameDatacenter(final Datacenter datacenter)
focal_class.full_signature: private static Criterion sameDatacenter(final Datacenter datacenter)
focal_class.identifier: sameDatacenter
focal_class.modifiers: private static
focal_class.parameters: (final Datacenter datacenter)
focal_class.return: Criterion
focal_class.signature: Criterion sameDatacenter(final Datacenter datacenter)
focal_class.class_method_signature: RackDAO.equalName(final String name)
focal_class.full_signature: private static Criterion equalName(final String name)
focal_class.identifier: equalName
focal_class.modifiers: private static
focal_class.parameters: (final String name)
focal_class.return: Criterion
focal_class.signature: Criterion equalName(final String name)
focal_class.class_method_signature: RackDAO.findRacks(final Datacenter datacenter)
focal_class.full_signature: public List<Rack> findRacks(final Datacenter datacenter)
focal_class.identifier: findRacks
focal_class.modifiers: public
focal_class.parameters: (final Datacenter datacenter)
focal_class.return: List<Rack>
focal_class.signature: List<Rack> findRacks(final Datacenter datacenter)
focal_class.class_method_signature: RackDAO.findRacks(final Datacenter datacenter, final String filter)
focal_class.full_signature: public List<Rack> findRacks(final Datacenter datacenter, final String filter)
focal_class.identifier: findRacks
focal_class.modifiers: public
focal_class.parameters: (final Datacenter datacenter, final String filter)
focal_class.return: List<Rack>
focal_class.signature: List<Rack> findRacks(final Datacenter datacenter, final String filter)
focal_class.class_method_signature: RackDAO.getSQLQueryResults(final Session session, final Query query,
          final Class<T> objectClass, final int idFieldPosition)
focal_class.full_signature: @SuppressWarnings("unchecked") private List<T> getSQLQueryResults(final Session session, final Query query,
          final Class<T> objectClass, final int idFieldPosition)
focal_class.identifier: getSQLQueryResults
focal_class.modifiers: @SuppressWarnings("unchecked") private
focal_class.parameters: (final Session session, final Query query,
          final Class<T> objectClass, final int idFieldPosition)
focal_class.return: List<T>
focal_class.signature: List<T> getSQLQueryResults(final Session session, final Query query,
          final Class<T> objectClass, final int idFieldPosition)
focal_class.class_method_signature: RackDAO.findRacksWithHAEnabled(final Datacenter datacenter)
focal_class.full_signature: public List<Rack> findRacksWithHAEnabled(final Datacenter datacenter)
focal_class.identifier: findRacksWithHAEnabled
focal_class.modifiers: public
focal_class.parameters: (final Datacenter datacenter)
focal_class.return: List<Rack>
focal_class.signature: List<Rack> findRacksWithHAEnabled(final Datacenter datacenter)
focal_class.class_method_signature: RackDAO.existsAnyWithDatacenterAndName(final Datacenter datacenter, final String name)
focal_class.full_signature: public boolean existsAnyWithDatacenterAndName(final Datacenter datacenter, final String name)
focal_class.identifier: existsAnyWithDatacenterAndName
focal_class.modifiers: public
focal_class.parameters: (final Datacenter datacenter, final String name)
focal_class.return: boolean
focal_class.signature: boolean existsAnyWithDatacenterAndName(final Datacenter datacenter, final String name)
focal_class.class_method_signature: RackDAO.existsAnyOtherWithDatacenterAndName(final Rack rack, final String name)
focal_class.full_signature: public boolean existsAnyOtherWithDatacenterAndName(final Rack rack, final String name)
focal_class.identifier: existsAnyOtherWithDatacenterAndName
focal_class.modifiers: public
focal_class.parameters: (final Rack rack, final String name)
focal_class.return: boolean
focal_class.signature: boolean existsAnyOtherWithDatacenterAndName(final Rack rack, final String name)
focal_class.class_method_signature: RackDAO.getRackIdByMinVLANCount(final int idDatacenter)
focal_class.full_signature: public List<Integer> getRackIdByMinVLANCount(final int idDatacenter)
focal_class.identifier: getRackIdByMinVLANCount
focal_class.modifiers: public
focal_class.parameters: (final int idDatacenter)
focal_class.return: List<Integer>
focal_class.signature: List<Integer> getRackIdByMinVLANCount(final int idDatacenter)
focal_class.class_method_signature: RackDAO.getNumberOfDeployedVlanNetworks(final Integer rackId)
focal_class.full_signature: public Long getNumberOfDeployedVlanNetworks(final Integer rackId)
focal_class.identifier: getNumberOfDeployedVlanNetworks
focal_class.modifiers: public
focal_class.parameters: (final Integer rackId)
focal_class.return: Long
focal_class.signature: Long getNumberOfDeployedVlanNetworks(final Integer rackId)
focal_class.class_method_signature: RackDAO.findByIds(final Integer datacenterId, final Integer rackId)
focal_class.full_signature: public Rack findByIds(final Integer datacenterId, final Integer rackId)
focal_class.identifier: findByIds
focal_class.modifiers: public
focal_class.parameters: (final Integer datacenterId, final Integer rackId)
focal_class.return: Rack
focal_class.signature: Rack findByIds(final Integer datacenterId, final Integer rackId)
focal_class.class_method_signature: RackDAO.findAllNotManagedRacksByDatacenter(final Integer datacenterId)
focal_class.full_signature: public List<Rack> findAllNotManagedRacksByDatacenter(final Integer datacenterId)
focal_class.identifier: findAllNotManagedRacksByDatacenter
focal_class.modifiers: public
focal_class.parameters: (final Integer datacenterId)
focal_class.return: List<Rack>
focal_class.signature: List<Rack> findAllNotManagedRacksByDatacenter(final Integer datacenterId)
focal_class.class_method_signature: RackDAO.findAllNotManagedRacksByDatacenter(final Integer datacenterId,
          final String filter)
focal_class.full_signature: public List<Rack> findAllNotManagedRacksByDatacenter(final Integer datacenterId,
          final String filter)
focal_class.identifier: findAllNotManagedRacksByDatacenter
focal_class.modifiers: public
focal_class.parameters: (final Integer datacenterId,
          final String filter)
focal_class.return: List<Rack>
focal_class.signature: List<Rack> findAllNotManagedRacksByDatacenter(final Integer datacenterId,
          final String filter)
focal_class.class_method_signature: RackDAO.findUsedVrdpPorts(final Rack rack)
focal_class.full_signature: @SuppressWarnings("unchecked") public List<Integer> findUsedVrdpPorts(final Rack rack)
focal_class.identifier: findUsedVrdpPorts
focal_class.modifiers: @SuppressWarnings("unchecked") public
focal_class.parameters: (final Rack rack)
focal_class.return: List<Integer>
focal_class.signature: List<Integer> findUsedVrdpPorts(final Rack rack)
focal_class.class_method_signature: RackDAO.getEmptyOffMachines(final Integer rackId)
focal_class.full_signature: public Integer getEmptyOffMachines(final Integer rackId)
focal_class.identifier: getEmptyOffMachines
focal_class.modifiers: public
focal_class.parameters: (final Integer rackId)
focal_class.return: Integer
focal_class.signature: Integer getEmptyOffMachines(final Integer rackId)
focal_class.class_method_signature: RackDAO.getEmptyOnMachines(final Integer rackId)
focal_class.full_signature: public Integer getEmptyOnMachines(final Integer rackId)
focal_class.identifier: getEmptyOnMachines
focal_class.modifiers: public
focal_class.parameters: (final Integer rackId)
focal_class.return: Integer
focal_class.signature: Integer getEmptyOnMachines(final Integer rackId)
focal_class.class_method_signature: RackDAO.getRandomMachinesToStartFromRack(final Integer rackId,
          final Integer howMany)
focal_class.full_signature: public List<Machine> getRandomMachinesToStartFromRack(final Integer rackId,
          final Integer howMany)
focal_class.identifier: getRandomMachinesToStartFromRack
focal_class.modifiers: public
focal_class.parameters: (final Integer rackId,
          final Integer howMany)
focal_class.return: List<Machine>
focal_class.signature: List<Machine> getRandomMachinesToStartFromRack(final Integer rackId,
          final Integer howMany)
focal_class.class_method_signature: RackDAO.getRandomMachinesToShutDownFromRack(final Integer rackId,
          final Integer howMany)
focal_class.full_signature: public List<Machine> getRandomMachinesToShutDownFromRack(final Integer rackId,
          final Integer howMany)
focal_class.identifier: getRandomMachinesToShutDownFromRack
focal_class.modifiers: public
focal_class.parameters: (final Integer rackId,
          final Integer howMany)
focal_class.return: List<Machine>
focal_class.signature: List<Machine> getRandomMachinesToShutDownFromRack(final Integer rackId,
          final Integer howMany)
focal_class.class_method_signature: RackDAO.getAllMachinesToShutDownFromRack(final Integer rackId)
focal_class.full_signature: public List<Machine> getAllMachinesToShutDownFromRack(final Integer rackId)
focal_class.identifier: getAllMachinesToShutDownFromRack
focal_class.modifiers: public
focal_class.parameters: (final Integer rackId)
focal_class.return: List<Machine>
focal_class.signature: List<Machine> getAllMachinesToShutDownFromRack(final Integer rackId)
focal_class.superclass: extends DefaultDAOBase<Integer, Rack>
focal_method.body: public List<Rack> findRacks(final Datacenter datacenter)
      {
          return findRacks(datacenter, null);
      }
focal_method.class_method_signature: RackDAO.findRacks(final Datacenter datacenter)
focal_method.full_signature: public List<Rack> findRacks(final Datacenter datacenter)
focal_method.identifier: findRacks
focal_method.invocations: findRacks
focal_method.modifiers: public
focal_method.parameters: (final Datacenter datacenter)
focal_method.return: List<Rack>
focal_method.signature: List<Rack> findRacks(final Datacenter datacenter)