From: <sc...@hy...> - 2010-05-26 00:53:52
|
Author: scottmf Date: 2010-05-25 17:20:32 -0700 (Tue, 25 May 2010) New Revision: 14623 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14623 Modified: trunk/plugins/vsphere/src/org/hyperic/hq/plugin/vsphere/VCenterPlatformDetector.java trunk/src/org/hyperic/hq/authz/server/session/ResourceDAO.java trunk/src/org/hyperic/hq/authz/server/session/ResourceEdgeDAO.java trunk/src/org/hyperic/hq/authz/server/session/ResourceManagerEJBImpl.java Log: [HPD-477] removed getPlatformCountByContainmentRelation() in favor of a more straight forward way to calculate what we need using resource prototypes via getPlatformCountMinusVsphereVmPlatforms(). Modified: trunk/plugins/vsphere/src/org/hyperic/hq/plugin/vsphere/VCenterPlatformDetector.java =================================================================== --- trunk/plugins/vsphere/src/org/hyperic/hq/plugin/vsphere/VCenterPlatformDetector.java 2010-05-25 23:32:59 UTC (rev 14622) +++ trunk/plugins/vsphere/src/org/hyperic/hq/plugin/vsphere/VCenterPlatformDetector.java 2010-05-26 00:20:32 UTC (rev 14623) @@ -35,6 +35,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hyperic.hq.authz.shared.AuthzConstants; import org.hyperic.hq.hqapi1.AgentApi; import org.hyperic.hq.hqapi1.HQApi; import org.hyperic.hq.hqapi1.ResourceApi; @@ -95,7 +96,7 @@ private static final String AGENT_PORT = "agent.setup.agentPort"; private static final String VC_TYPE = "VMware vCenter"; - private static final String VM_TYPE = "VMware vSphere VM"; + private static final String VM_TYPE = AuthzConstants.platformPrototypeVmwareVsphereVm; private static final String HOST_TYPE = "VMware vSphere Host"; private static final String POOL_TYPE = "VMware vSphere Resource Pool"; private static final String DEFAULT_POOL = "Resources"; Modified: trunk/src/org/hyperic/hq/authz/server/session/ResourceDAO.java =================================================================== --- trunk/src/org/hyperic/hq/authz/server/session/ResourceDAO.java 2010-05-25 23:32:59 UTC (rev 14622) +++ trunk/src/org/hyperic/hq/authz/server/session/ResourceDAO.java 2010-05-26 00:20:32 UTC (rev 14623) @@ -457,4 +457,15 @@ .setParameter("svcProto", AuthzConstants.authzService) .list(); } + + int getPlatformCountMinusVsphereVmPlatforms() { + String sql = "select count(*) from Resource r " + + "where r.resourceType.id = :platProto " + + "and r.prototype.name != :vspherevm"; + return ((Integer) getSession().createQuery(sql) + .setInteger("platProto", AuthzConstants.authzPlatform.intValue()) + .setString("vspherevm", AuthzConstants.platformPrototypeVmwareVsphereVm) + .uniqueResult()).intValue(); + } + } Modified: trunk/src/org/hyperic/hq/authz/server/session/ResourceEdgeDAO.java =================================================================== --- trunk/src/org/hyperic/hq/authz/server/session/ResourceEdgeDAO.java 2010-05-25 23:32:59 UTC (rev 14622) +++ trunk/src/org/hyperic/hq/authz/server/session/ResourceEdgeDAO.java 2010-05-26 00:20:32 UTC (rev 14623) @@ -295,17 +295,5 @@ return results.size() == 1; } - - public int getPlatformCountByContainmentRelation() { - String sql = "select count(distinct r.id) from Resource r " + - "JOIN r.resourceType t " + - "JOIN r.fromEdges e " + - "WHERE r.resourceType.id = :authzPlatform " + - "AND e.relation = :relationId"; - return ((Integer) getSession().createQuery(sql) - .setInteger("authzPlatform", AuthzConstants.authzPlatform.intValue()) - .setInteger("relationId", AuthzConstants.RELATION_CONTAINMENT_ID.intValue()) - .uniqueResult()).intValue(); - } } Modified: trunk/src/org/hyperic/hq/authz/server/session/ResourceManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/authz/server/session/ResourceManagerEJBImpl.java 2010-05-25 23:32:59 UTC (rev 14622) +++ trunk/src/org/hyperic/hq/authz/server/session/ResourceManagerEJBImpl.java 2010-05-26 00:20:32 UTC (rev 14623) @@ -1118,13 +1118,12 @@ } /** - * @return returns the platform count of all distinct authzPlatforms in the - * containment relation from the edge table. - * @see {@link AuthzConstants.RELATION_CONTAINMENT_ID} + * @return the resource count with prototype of {@link AuthzConstants.authzPlatform} + * minus resources with the prototype of {@link AuthConstants.platformPrototypeVmwareVsphereVm} * @ejb:interface-method */ - public int getPlatformCountByContainmentRelation() { - return getResourceEdgeDAO().getPlatformCountByContainmentRelation(); + public int getPlatformCountMinusVsphereVmPlatforms() { + return getResourceDAO().getPlatformCountMinusVsphereVmPlatforms(); } public static ResourceManagerLocal getOne() { |