|
From: <jt...@hy...> - 2007-03-12 20:28:28
|
Author: jtravis Date: 2007-03-12 12:28:18 -0800 (Mon, 12 Mar 2007) New Revision: 3705 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3705 Modified: trunk/src/org/hyperic/hq/appdef/server/session/PlatformManagerEJBImpl.java trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java trunk/src/org/hyperic/hq/appdef/server/session/ServiceManagerEJBImpl.java trunk/src/org/hyperic/hq/dao/PlatformDAO.java trunk/src/org/hyperic/hq/dao/ServerDAO.java trunk/src/org/hyperic/hq/dao/ServiceDAO.java Log: Add methods to get resource type counts Modified: trunk/src/org/hyperic/hq/appdef/server/session/PlatformManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/PlatformManagerEJBImpl.java 2007-03-12 20:27:21 UTC (rev 3704) +++ trunk/src/org/hyperic/hq/appdef/server/session/PlatformManagerEJBImpl.java 2007-03-12 20:28:18 UTC (rev 3705) @@ -1374,6 +1374,17 @@ getPlatformDAO().remove(ip); } + /** + * Returns a list of 2 element arrays. The first element is the name of + * the platform type, the second element is the # of platforms of that + * type in the inventory. + * + * @ejb:interface-method + */ + public List getPlatformTypeCounts() { + return getPlatformDAO().getPlatformTypeCounts(); + } + public static PlatformManagerLocal getOne() { try { return PlatformManagerUtil.getLocalHome().create(); Modified: trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java 2007-03-12 20:27:21 UTC (rev 3704) +++ trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java 2007-03-12 20:28:18 UTC (rev 3705) @@ -1348,6 +1348,17 @@ server.setName(server.getName().trim()); } + /** + * Returns a list of 2 element arrays. The first element is the name of + * the server type, the second element is the # of servers of that + * type in the inventory. + * + * @ejb:interface-method + */ + public List getServerTypeCounts() { + return getServerDAO().getServerTypeCounts(); + } + public static ServerManagerLocal getOne() { try { return ServerManagerUtil.getLocalHome().create(); Modified: trunk/src/org/hyperic/hq/appdef/server/session/ServiceManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/ServiceManagerEJBImpl.java 2007-03-12 20:27:21 UTC (rev 3704) +++ trunk/src/org/hyperic/hq/appdef/server/session/ServiceManagerEJBImpl.java 2007-03-12 20:28:18 UTC (rev 3705) @@ -1698,6 +1698,17 @@ } } + /** + * Returns a list of 2 element arrays. The first element is the name of + * the service type, the second element is the # of services of that + * type in the inventory. + * + * @ejb:interface-method + */ + public List getServiceTypeCounts() { + return getServiceDAO().getServiceTypeCounts(); + } + public static ServiceManagerLocal getOne() { try { return ServiceManagerUtil.getLocalHome().create(); Modified: trunk/src/org/hyperic/hq/dao/PlatformDAO.java =================================================================== --- trunk/src/org/hyperic/hq/dao/PlatformDAO.java 2007-03-12 20:27:21 UTC (rev 3704) +++ trunk/src/org/hyperic/hq/dao/PlatformDAO.java 2007-03-12 20:28:18 UTC (rev 3705) @@ -337,4 +337,12 @@ } return platforms; } + + public List getPlatformTypeCounts() { + String sql = "select t.name, count(*) from PlatformType t, " + + "Platform p where p.platformType = t " + + "group by t.name order by t.name"; + + return getSession().createQuery(sql).list(); + } } Modified: trunk/src/org/hyperic/hq/dao/ServerDAO.java =================================================================== --- trunk/src/org/hyperic/hq/dao/ServerDAO.java 2007-03-12 20:27:21 UTC (rev 3704) +++ trunk/src/org/hyperic/hq/dao/ServerDAO.java 2007-03-12 20:28:18 UTC (rev 3705) @@ -219,4 +219,13 @@ } return servers; } + + public List getServerTypeCounts() { + String sql = "select t.name, count(*) from ServerType t, " + + "Server s where s.serverType = t " + + "group by t.name order by t.name"; + + return getSession().createQuery(sql).list(); + } + } Modified: trunk/src/org/hyperic/hq/dao/ServiceDAO.java =================================================================== --- trunk/src/org/hyperic/hq/dao/ServiceDAO.java 2007-03-12 20:27:21 UTC (rev 3704) +++ trunk/src/org/hyperic/hq/dao/ServiceDAO.java 2007-03-12 20:28:18 UTC (rev 3705) @@ -436,4 +436,12 @@ } return services; } + + public List getServiceTypeCounts() { + String sql = "select t.name, count(*) from ServiceType t, " + + "Service s where s.serviceType = t " + + "group by t.name order by t.name"; + + return getSession().createQuery(sql).list(); + } } |