summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java1
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java1
-rw-r--r--modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java15
3 files changed, 17 insertions, 0 deletions
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
index 6818fa2..954568d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/ResourceGroup.java
@@ -228,6 +228,7 @@ public class ResourceGroup extends Group {
public static final String QUERY_DELETE_EXPLICIT_BY_RESOURCE_IDS = "DELETE FROM RHQ_RESOURCE_GROUP_RES_EXP_MAP WHERE RESOURCE_ID IN ( :resourceIds )";
public static final String QUERY_DELETE_IMPLICIT_BY_RESOURCE_IDS = "DELETE FROM RHQ_RESOURCE_GROUP_RES_IMP_MAP WHERE RESOURCE_ID IN ( :resourceIds )";
+ public static final String QUERY_GET_GROUP_IDS_BY_RESOURCE_IDS = "SELECT DISTINCT RESOURCE_GROUP_ID FROM RHQ_RESOURCE_GROUP_RES_EXP_MAP WHERE RESOURCE_ID IN ( :resourceIds )";
public static final String QUERY_FIND_ALL_FILTERED_COUNT = "ResourceGroup.findAllFiltered_Count";
public static final String QUERY_FIND_ALL_FILTERED_COUNT_ADMIN = "ResourceGroup.findAllFiltered_Count_Admin";
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 0e59b6d..b5a185f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -380,6 +380,7 @@ public class ResourceSearchView extends Table {
protected void onUninventorySuccess() {
refresh(true);
+ CoreGUI.refresh();
}
protected List<ListGridField> createFields() {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 08ab0e2..a08e0d2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -124,6 +124,7 @@ import org.rhq.enterprise.server.discovery.DiscoveryServerServiceImpl;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.resource.disambiguation.DisambiguationUpdateStrategy;
import org.rhq.enterprise.server.resource.disambiguation.Disambiguator;
+import org.rhq.enterprise.server.resource.group.ResourceGroupDeleteException;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -466,6 +467,11 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
private boolean uninventoryResourcesBulkDelete(Subject overlord, List<Integer> resourceIds) {
+ // obtain group ids of affected groups
+ Query nativeQuery = entityManager.createNativeQuery(ResourceGroup.QUERY_GET_GROUP_IDS_BY_RESOURCE_IDS);
+ nativeQuery.setParameter("resourceIds", resourceIds);
+ List<Integer> groupIds = nativeQuery.getResultList();
+
String[] nativeQueriesToExecute = new String[] { //
ResourceGroup.QUERY_DELETE_EXPLICIT_BY_RESOURCE_IDS, // unmap from explicit groups
ResourceGroup.QUERY_DELETE_IMPLICIT_BY_RESOURCE_IDS // unmap from implicit groups
@@ -477,6 +483,15 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
hasErrors |= resourceManager.bulkNativeQueryDeleteInNewTransaction(overlord, nativeQueryToExecute,
resourceIds);
}
+
+ // update the resource type on affected groups
+ for (int groupId : groupIds) {
+ try {
+ resourceGroupManager.setResourceType(groupId);
+ } catch (ResourceGroupDeleteException rgde) {
+ log.warn("Unable to change resource type for group with id [" + groupId + "]", rgde);
+ }
+ }
return hasErrors;
}