modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 112 +++++- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 78 ++-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java | 26 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java | 55 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java | 55 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java | 186 ++++++++-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java | 28 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 34 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 16 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java | 44 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java | 5 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 46 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 46 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 44 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 2 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 6 22 files changed, 550 insertions(+), 272 deletions(-)
New commits: commit 7998b60510c104396ceac2d5492bcc6324dcea16 Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Mar 14 14:41:19 2011 -0400
Try and improve portlet layout by better lining up recent/sched columns.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java index 4e1aac7..f7e3ee4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java @@ -81,8 +81,12 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting //TODO: change this to use the Smart GWT default value. public static String RANGE_DISABLED_MESSAGE_DEFAULT = MSG.common_msg_noItemsToShow();
- private static String recentOperations = MSG.common_title_recent_operations(); - private static String scheduledOperations = MSG.common_title_scheduled_operations(); + private static final String RECENT_OPERATIONS = MSG.common_title_recent_operations(); + private static final String SCHEDULED_OPERATIONS = MSG.common_title_scheduled_operations(); + + private static final int WIDTH_RECENT_TIME = 150; + private static final int WIDTH_RECENT_STATUS = 50; + private static final int WIDTH_SCHEDULED_TIME = WIDTH_RECENT_TIME + WIDTH_RECENT_STATUS;
// set on initial configuration, the window for this portlet view. private PortletWindow portletWindow; @@ -114,10 +118,10 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting protected void onInit() { super.onInit();
- this.recentOperationsGrid = new LocatableListGrid(recentOperations); + this.recentOperationsGrid = new LocatableListGrid(RECENT_OPERATIONS); recentOperationsGrid.setDataSource(getDataSourceCompleted()); recentOperationsGrid.setAutoFetchData(true); - recentOperationsGrid.setTitle(recentOperations); + recentOperationsGrid.setTitle(RECENT_OPERATIONS); recentOperationsGrid.setWidth100(); //defining header span String[] completedRows = new String[] { // @@ -126,7 +130,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting RecentOperationsDataSource.Field.OPERATION.propertyName(), // RecentOperationsDataSource.Field.TIME.propertyName(), // RecentOperationsDataSource.Field.STATUS.propertyName() }; - recentOperationsGrid.setHeaderSpans(new HeaderSpan(recentOperations, completedRows)); + recentOperationsGrid.setHeaderSpans(new HeaderSpan(RECENT_OPERATIONS, completedRows)); recentOperationsGrid.setHeaderSpanHeight(20); recentOperationsGrid.setHeaderHeight(40); recentOperationsGrid.setResizeFieldsInRealTime(true); @@ -135,21 +139,21 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting addMember(recentOperationsGrid);
// Add the list table as the top half of the view. - this.scheduledOperationsGrid = new LocatableListGrid(scheduledOperations); + this.scheduledOperationsGrid = new LocatableListGrid(SCHEDULED_OPERATIONS); scheduledOperationsGrid.setDataSource(getDataSourceScheduled()); scheduledOperationsGrid.setAutoFetchData(true); - scheduledOperationsGrid.setTitle(scheduledOperations); + scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS); scheduledOperationsGrid.setWidth100(); String[] scheduledRows = new String[] { // ScheduledOperationsDataSource.Field.RESOURCE.propertyName(), // AncestryUtil.RESOURCE_ANCESTRY, // ScheduledOperationsDataSource.Field.OPERATION.propertyName(), // ScheduledOperationsDataSource.Field.TIME.propertyName() }; - scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, scheduledRows)); + scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(SCHEDULED_OPERATIONS, scheduledRows)); scheduledOperationsGrid.setHeaderSpanHeight(20); scheduledOperationsGrid.setHeaderHeight(40);
- scheduledOperationsGrid.setTitle(scheduledOperations); + scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS); scheduledOperationsGrid.setResizeFieldsInRealTime(true); scheduledOperationsGrid.setCellHeight(50); scheduledOperationsGrid.setWrapCells(true); @@ -193,10 +197,10 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting RecentOperationsDataSource.Field.OPERATION.title());
ListGridField timeRecent = new ListGridField(RecentOperationsDataSource.Field.TIME.propertyName(), - RecentOperationsDataSource.Field.TIME.title(), 150); + RecentOperationsDataSource.Field.TIME.title(), WIDTH_RECENT_TIME);
ListGridField statusRecent = new ListGridField(RecentOperationsDataSource.Field.STATUS.propertyName(), - RecentOperationsDataSource.Field.STATUS.title(), 50); + RecentOperationsDataSource.Field.STATUS.title(), WIDTH_RECENT_STATUS); statusRecent.setAlign(Alignment.CENTER);
recentOperationsGrid.setFields(resourceRecent, ancestryRecent, operationRecent, timeRecent, statusRecent); @@ -233,7 +237,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting ScheduledOperationsDataSource.Field.OPERATION.title());
ListGridField timeNext = new ListGridField(ScheduledOperationsDataSource.Field.TIME.propertyName(), - ScheduledOperationsDataSource.Field.TIME.title(), 150); + ScheduledOperationsDataSource.Field.TIME.title(), WIDTH_SCHEDULED_TIME);
scheduledOperationsGrid.setFields(resourceNext, ancestryNext, operationNext, timeNext); }
commit 3b64aac3b9f1e0809c9934272cfb13b224ada082 Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Mar 14 14:40:34 2011 -0400
Reduce verbosity on some Alert Condition text display. The 'Exceeds' is unnecessary, takes up valuable column space, and is, I think, confusing when not using a greater-than operator.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index ac808be..8293144 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -1048,15 +1048,15 @@ view_alert_common_tab_conditions_value = Value view_alert_common_tab_conditions_type_availability = Availability Change view_alert_common_tab_conditions_type_availability_down = Went down view_alert_common_tab_conditions_type_availability_up = Came up -view_alert_common_tab_conditions_type_metric_threshold = Metric Value Exceeds Threshold -view_alert_common_tab_conditions_type_metric_calltime_threshold = Call Time Value Exceeds Threshold +view_alert_common_tab_conditions_type_metric_threshold = Metric Value Threshold +view_alert_common_tab_conditions_type_metric_calltime_threshold = Call Time Value Threshold view_alert_common_tab_conditions_type_metric_calltime_destination = with call destination matching view_alert_common_tab_conditions_type_metric_calltime_change = Call Time Value Changes view_alert_common_tab_conditions_type_metric_calltime_change_verb = by at least view_alert_common_tab_conditions_type_metric_calltime_delta_grows = Grows view_alert_common_tab_conditions_type_metric_calltime_delta_shrinks = Shrinks view_alert_common_tab_conditions_type_metric_calltime_delta_other = Changes -view_alert_common_tab_conditions_type_metric_baseline = Metric Value Exceeds Baseline +view_alert_common_tab_conditions_type_metric_baseline = Metric Value Baseline view_alert_common_tab_conditions_type_metric_baseline_verb = of view_alert_common_tab_conditions_type_metric_change = Metric Value Change view_alert_common_tab_conditions_type_metric_trait_change = Trait Change
commit 032810bc2ba918cdd1691593f7abd3259a667a57 Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Mar 14 13:59:37 2011 -0400
Resource Ancestry (Disambiguation) Work Incorporate feedback into design and perform some refactoring to clean up impl. - Keep Name and Ancestry fields simple with only linked resource names displayed - Enhance hover values for both Name (with type info) and Ancestry (with hierarchy and type info) - Move more logic to AncestryUtil for simplified Impl. Use standard Record attributes, defined here, across Ancestry using datasources and views. - Remove Ancestry and in some places, Type as DS fields. These should be DS fields, only, if necessary, ListGrid fields. - Add Ancestry to AlertDataSource and its users - Fix issue with the Ancestry hover for Assigned resources in Resource Selector. - Added Resource filtering prior to gwt serialization for Alerts.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java index 02c76a2..db11bdd 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java @@ -20,7 +20,9 @@ package org.rhq.enterprise.gui.coregui.client.alert;
import java.util.ArrayList; import java.util.Date; +import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set;
import com.allen_sauer.gwt.log.client.Log; @@ -47,6 +49,8 @@ import org.rhq.core.domain.alert.AlertPriority; import org.rhq.core.domain.alert.notification.AlertNotificationLog; import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.AlertCriteria; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ImageManager; @@ -54,6 +58,9 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback; import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility; @@ -109,7 +116,7 @@ public class AlertDataSource extends RPCDataSource<Alert> { ListGridField nameField = new ListGridField("name", MSG.view_alerts_field_name()); nameField.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { - Integer resourceId = listGridRecord.getAttributeAsInt("resourceId"); + Integer resourceId = listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID); Integer defId = listGridRecord.getAttributeAsInt("definitionId"); String url = LinkManager.getSubsystemAlertDefinitionLink(resourceId, defId); return SeleniumUtility.getLocatableHref(url, o.toString(), null); @@ -157,25 +164,48 @@ public class AlertDataSource extends RPCDataSource<Alert> { fields.add(statusField);
if (this.entityContext.type != EntityContext.Type.Resource) { - // TODO need to disambiguate this - ListGridField resourceNameField = new ListGridField("resourceName", MSG.view_alerts_field_resource()); + ListGridField resourceNameField = new ListGridField(AncestryUtil.RESOURCE_NAME, MSG + .view_alerts_field_resource()); resourceNameField.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { - Integer resourceId = listGridRecord.getAttributeAsInt("resourceId"); - String url = LinkManager.getResourceLink(resourceId); + String url = LinkManager + .getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID)); return SeleniumUtility.getLocatableHref(url, o.toString(), null); } }); + resourceNameField.setShowHover(true); + resourceNameField.setHoverCustomizer(new HoverCustomizer() { + + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getResourceHoverHTML(listGridRecord, 0); + } + }); fields.add(resourceNameField);
- ctimeField.setWidth(100); - nameField.setWidth("25%"); - conditionField.setWidth("40%"); + ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); + ancestryField.setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { + return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); + } + }); + ancestryField.setShowHover(true); + ancestryField.setHoverCustomizer(new HoverCustomizer() { + + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); + } + }); + fields.add(ancestryField); + + ctimeField.setWidth(125); + nameField.setWidth("20%"); + conditionField.setWidth("30%"); priorityField.setWidth(50); - statusField.setWidth("15%"); - resourceNameField.setWidth("20%"); + statusField.setWidth("80"); + resourceNameField.setWidth("25%"); + ancestryField.setWidth("25%"); } else { - ctimeField.setWidth(100); + ctimeField.setWidth(125); nameField.setWidth("35%"); conditionField.setWidth("40%"); priorityField.setWidth(50); @@ -201,9 +231,54 @@ public class AlertDataSource extends RPCDataSource<Alert> { public void onSuccess(PageList<Alert> result) { long fetchTime = System.currentTimeMillis() - start; Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms"); - response.setData(buildRecords(result)); - // For paging to work, we have to specify size of full result set. - response.setTotalRows(result.getTotalSize()); + + if (entityContext.type != EntityContext.Type.Resource) { + dataRetrieved(result, response, request); + } else { + response.setData(buildRecords(result)); + response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set + processResponse(request.getRequestId(), response); + } + } + }); + } + + /** + * Additional processing to support a cross-resource view) + * @param result + * @param response + * @param request + */ + protected void dataRetrieved(final PageList<Alert> result, final DSResponse response, final DSRequest request) { + HashSet<Integer> typesSet = new HashSet<Integer>(); + HashSet<String> ancestries = new HashSet<String>(); + for (Alert alert : result) { + Resource resource = alert.getAlertDefinition().getResource(); + typesSet.add(resource.getResourceType().getId()); + ancestries.add(resource.getAncestry()); + } + + // In addition to the types of the result resources, get the types of their ancestry + typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries)); + + ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance(); + typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { + @Override + public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types); + + Record[] records = buildRecords(result); + for (Record record : records) { + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + + // Build the decoded ancestry Strings now for display + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); + } + response.setData(records); + response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set processResponse(request.getRequestId(), response); } }); @@ -240,11 +315,16 @@ public class AlertDataSource extends RPCDataSource<Alert> { record.setAttribute("acknowledgingSubject", from.getAcknowledgingSubject());
record.setAttribute("definitionId", from.getAlertDefinition().getId()); - record.setAttribute("resourceId", from.getAlertDefinition().getResource().getId()); - record.setAttribute("resourceName", from.getAlertDefinition().getResource().getName()); + Resource resource = from.getAlertDefinition().getResource(); record.setAttribute("name", from.getAlertDefinition().getName()); record.setAttribute("priority", ImageManager.getAlertIcon(from.getAlertDefinition().getPriority()));
+ // for ancestry handling + record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId()); + record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName()); + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry()); + record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId()); + Set<AlertConditionLog> conditionLogs = from.getConditionLogs(); String conditionText; String conditionValue; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java index 721b559..f80a435 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java @@ -1,6 +1,5 @@ package org.rhq.enterprise.gui.coregui.client.alert;
-import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; @@ -96,11 +95,7 @@ public class AlertPortletDataSource extends AlertDataSource { }
public void onSuccess(PageList<Alert> result) { - long fetchTime = System.currentTimeMillis() - start; - Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms"); - response.setData(buildRecords(result)); - response.setTotalRows(result.size()); - processResponse(request.getRequestId(), response); + dataRetrieved(result, response, request); } }); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java index 54f6d41..4e1aac7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java @@ -42,13 +42,14 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.configuration.definition.PropertySimpleType; import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource; import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource; import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; @@ -57,6 +58,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * A view that displays a live table of completed Operations and scheduled operations. @@ -120,7 +122,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting //defining header span String[] completedRows = new String[] { // RecentOperationsDataSource.Field.RESOURCE.propertyName(), // - RecentOperationsDataSource.Field.ANCESTRY.propertyName(), // + AncestryUtil.RESOURCE_ANCESTRY, // RecentOperationsDataSource.Field.OPERATION.propertyName(), // RecentOperationsDataSource.Field.TIME.propertyName(), // RecentOperationsDataSource.Field.STATUS.propertyName() }; @@ -140,7 +142,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting scheduledOperationsGrid.setWidth100(); String[] scheduledRows = new String[] { // ScheduledOperationsDataSource.Field.RESOURCE.propertyName(), // - ScheduledOperationsDataSource.Field.ANCESTRY.propertyName(), // + AncestryUtil.RESOURCE_ANCESTRY, // ScheduledOperationsDataSource.Field.OPERATION.propertyName(), // ScheduledOperationsDataSource.Field.TIME.propertyName() }; scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(scheduledOperations, scheduledRows)); @@ -161,20 +163,29 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
ListGridField resourceRecent = new ListGridField(RecentOperationsDataSource.Field.RESOURCE.propertyName(), RecentOperationsDataSource.Field.RESOURCE.title()); + resourceRecent.setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { + String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID)); + return SeleniumUtility.getLocatableHref(url, o.toString(), null); + } + }); + resourceRecent.setShowHover(true); + resourceRecent.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getResourceHoverHTML(listGridRecord, 0); + } + });
- ListGridField ancestryRecent = new ListGridField(RecentOperationsDataSource.Field.ANCESTRY.propertyName(), - RecentOperationsDataSource.Field.ANCESTRY.title()); + ListGridField ancestryRecent = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); ancestryRecent.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES); + return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); } }); ancestryRecent.setShowHover(true); ancestryRecent.setHoverCustomizer(new HoverCustomizer() { public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return "<p style='width:400px'>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>"; + return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); } });
@@ -192,20 +203,29 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
ListGridField resourceNext = new ListGridField(ScheduledOperationsDataSource.Field.RESOURCE.propertyName(), ScheduledOperationsDataSource.Field.RESOURCE.title()); + resourceNext.setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { + String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID)); + return SeleniumUtility.getLocatableHref(url, o.toString(), null); + } + }); + resourceNext.setShowHover(true); + resourceNext.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getResourceHoverHTML(listGridRecord, 0); + } + });
- ListGridField ancestryNext = new ListGridField(ScheduledOperationsDataSource.Field.ANCESTRY.propertyName(), - ScheduledOperationsDataSource.Field.ANCESTRY.title()); + ListGridField ancestryNext = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); ancestryNext.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES); + return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); } }); ancestryNext.setShowHover(true); ancestryNext.setHoverCustomizer(new HoverCustomizer() { public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return "<p style='width:400px'>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>"; + return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); } });
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java index 7e6cf94..24820ec 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/problems/ProblemResourcesPortlet.java @@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems
//import java.text.SimpleDateFormat; import static org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource.Field.ALERTS; -import static org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource.Field.ANCESTRY; import static org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource.Field.AVAILABILITY; import static org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource.Field.RESOURCE;
@@ -49,6 +48,7 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.configuration.definition.PropertySimpleType; import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.UserSessionManager; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableWidget; @@ -57,12 +57,13 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.resource.ProblemResourcesDataSource; import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel; +import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * A view that displays a paginated table of Resources with alerts, @@ -121,19 +122,30 @@ public class ProblemResourcesPortlet extends Table<ProblemResourcesDataSource> i }
ListGridField resourceField = new ListGridField(RESOURCE.propertyName(), RESOURCE.title()); + resourceField.setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { + String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")); + return SeleniumUtility.getLocatableHref(url, o.toString(), null); + } + }); + resourceField.setShowHover(true); + resourceField.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getResourceHoverHTML(listGridRecord, 0); + } + });
- ListGridField ancestryField = new ListGridField(ANCESTRY.propertyName(), ANCESTRY.title()); + ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); ancestryField.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES); + return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); } }); ancestryField.setShowHover(true); ancestryField.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return "<p style='width:400px'>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>"; + return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); } });
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java index c2e47fa..edb9ff7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java @@ -43,6 +43,7 @@ import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow; @@ -247,8 +248,7 @@ public abstract class AbstractOperationHistoryListView<T extends AbstractOperati }
protected ListGridField createAncestryField() { - ListGridField ancestryField = new ListGridField(ResourceOperationHistoryDataSource.Field.ANCESTRY, MSG - .common_title_ancestry()); + ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); ancestryField.setAlign(Alignment.LEFT); ancestryField.setCellAlign(Alignment.LEFT); return ancestryField; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java index 587a8ca..e678426 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/ResourceGroupResourceSelector.java @@ -23,30 +23,77 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory;
import java.util.Collection; +import java.util.HashSet; +import java.util.Map;
+import com.smartgwt.client.data.Record; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
/** * @author Jay Shaughnessy */ public class ResourceGroupResourceSelector extends ResourceSelector {
+ Collection<Resource> resources; + public ResourceGroupResourceSelector(String locatorId, Collection<Resource> resources, ResourceType resourceTypeFilter, boolean forceResourceTypeFilter) {
super(locatorId, resourceTypeFilter, forceResourceTypeFilter);
- if (null != resources) { - ListGridRecord[] data = (new ResourceDatasource()).buildRecords(resources); - setAssigned(data); - } + this.resources = resources;
this.setOverflow(Overflow.AUTO); } + + @Override + protected void onInit() { + + if (null != this.resources) { + // to properly handle ancestry we need to provide the LGRecords with necessary ResourceType info for + // the initially assigned resources + + HashSet<Integer> typesSet = new HashSet<Integer>(); + HashSet<String> ancestries = new HashSet<String>(); + for (Resource resource : this.resources) { + typesSet.add(resource.getResourceType().getId()); + ancestries.add(resource.getAncestry()); + } + + // In addition to the types of the result resources, get the types of their ancestry + typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries)); + + ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance(); + typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { + @Override + public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types); + + ListGridRecord[] records = (new ResourceDatasource()).buildRecords(resources); + + for (Record record : records) { + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + } + + setAssigned(records); + ResourceGroupResourceSelector.super.onInit(); + } + }); + } else { + super.onInit(); + } + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java index 8132abd..da178c4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/history/GroupMemberResourceOperationHistoryListView.java @@ -1,30 +1,37 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history;
+import java.util.ArrayList; +import java.util.List; + import com.smartgwt.client.data.Criteria; import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.HoverCustomizer; import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; + import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; +import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView; - -import java.util.ArrayList; -import java.util.List; +import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * @author Ian Springer */ -public class GroupMemberResourceOperationHistoryListView - extends AbstractOperationHistoryListView<ResourceOperationHistoryDataSource> { +public class GroupMemberResourceOperationHistoryListView extends + AbstractOperationHistoryListView<ResourceOperationHistoryDataSource> {
private ResourceGroupComposite groupComposite;
public GroupMemberResourceOperationHistoryListView(String locatorId, ResourceGroupComposite groupComposite, - int groupOperationHistoryId) { - super(locatorId, new ResourceOperationHistoryDataSource(), null, - new Criteria(ResourceOperationHistoryDataSource.CriteriaField.GROUP_OPERATION_HISTORY_ID, - String.valueOf(groupOperationHistoryId))); + int groupOperationHistoryId) { + super(locatorId, new ResourceOperationHistoryDataSource(), null, new Criteria( + ResourceOperationHistoryDataSource.CriteriaField.GROUP_OPERATION_HISTORY_ID, String + .valueOf(groupOperationHistoryId))); this.groupComposite = groupComposite; }
@@ -37,9 +44,37 @@ public class GroupMemberResourceOperationHistoryListView fields.add(idField);
ListGridField resourceField = createResourceField(); - resourceField.setWidth("70%"); + resourceField.setWidth("25%"); + resourceField.setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { + String url = LinkManager.getResourceLink(listGridRecord.getAttributeAsInt("id")); + return SeleniumUtility.getLocatableHref(url, o.toString(), null); + } + }); + resourceField.setShowHover(true); + resourceField.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getResourceHoverHTML(listGridRecord, 0); + } + }); fields.add(resourceField);
+ ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); + ancestryField.setWidth("35%"); + ancestryField.setCellFormatter(new CellFormatter() { + public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { + return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); + } + }); + ancestryField.setShowHover(true); + ancestryField.setHoverCustomizer(new HoverCustomizer() { + + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); + } + }); + fields.add(ancestryField); + ListGridField statusField = createStatusField(); fields.add(statusField);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java index 6dd55ac..33a5246 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java @@ -22,6 +22,9 @@ import java.util.Collection; import java.util.HashSet; import java.util.Map;
+import com.smartgwt.client.data.Record; +import com.smartgwt.client.widgets.grid.ListGridRecord; + import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.LinkManager; @@ -34,6 +37,16 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility; */ public abstract class AncestryUtil {
+ // ListGrid Record attribute names expected to be set on records processed by the utility + public static final String RESOURCE_ANCESTRY = "resourceAncestry"; + public static final String RESOURCE_ANCESTRY_VALUE = "resourceAncestryDecoded"; + public static final String RESOURCE_ANCESTRY_HOVER = "resourceAncestryHover"; + public static final String RESOURCE_ANCESTRY_TYPES = "resourceAncestryTypes"; + public static final String RESOURCE_HOVER = "resourceHover"; + public static final String RESOURCE_ID = "resourceId"; + public static final String RESOURCE_NAME = "resourceName"; + public static final String RESOURCE_TYPE_ID = "resourceTypeId"; + /** * Get the complete set of resource types in the ancestries provided. This is useful for * being able to load all the types in advance of generating decoded values. @@ -75,7 +88,7 @@ public abstract class AncestryUtil { }
StringBuilder sbResources = new StringBuilder(); - StringBuilder sbTypes = (null != types) ? new StringBuilder() : null; + StringBuilder sbTypes = (null != types) ? new StringBuilder("Parent Ancestry<hr/>") : null; String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM); for (int i = 0; i < ancestryEntries.length; ++i) { String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM); @@ -83,15 +96,25 @@ public abstract class AncestryUtil { int ancestorResourceId = Integer.valueOf(entryTokens[1]); String ancestorName = entryTokens[2];
- sbResources.append((i > 0) ? " > " : ""); + sbResources.append((i > 0) ? " < " : ""); + //sbResources.append(" < "); String url = LinkManager.getResourceLink(ancestorResourceId); String suffix = resourceId + "_" + entryTokens[1]; - sbResources.append(SeleniumUtility.getLocatableHref(url, ancestorName, suffix)); + String href = SeleniumUtility.getLocatableHref(url, ancestorName, suffix); + sbResources.append(href);
if (null != sbTypes) { - sbTypes.append((i > 0) ? " > " : ""); + if (i > 0) { + sbTypes.append("<br/>"); + for (int j = 0; j < i; ++j) { + sbTypes.append(" "); + } + } ResourceType rt = types.get(ancestorTypeId); - sbTypes.append(rt.getName() + "[" + rt.getPlugin() + "]"); + sbTypes.append(href); + sbTypes.append(" [" + rt.getPlugin() + " / "); + sbTypes.append(rt.getName()); + sbTypes.append("]"); } }
@@ -103,6 +126,109 @@ public abstract class AncestryUtil { return result; }
+ public static String getAncestryValue(Record record) { + String ancestry = record.getAttributeAsString(RESOURCE_ANCESTRY); + if (null == ancestry) { + return ""; + } + + Integer resourceId = record.getAttributeAsInt(RESOURCE_ID); + // if not set assume the standard "id" attr is a resourceId + resourceId = (null != resourceId) ? resourceId : record.getAttributeAsInt("id"); + StringBuilder sbResources = new StringBuilder(); + String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM); + for (int i = 0; i < ancestryEntries.length; ++i) { + String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM); + int ancestorResourceId = Integer.valueOf(entryTokens[1]); + String ancestorName = entryTokens[2]; + + sbResources.append((i > 0) ? " < " : ""); + String url = LinkManager.getResourceLink(ancestorResourceId); + String suffix = resourceId + "_" + entryTokens[1]; + String href = SeleniumUtility.getLocatableHref(url, ancestorName, suffix); + sbResources.append(href); + } + + return sbResources.toString(); + } + + public static String getAncestryHoverHTML(ListGridRecord listGridRecord, int width) { + String ancestryHover = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY_HOVER); + if (null != ancestryHover) { + return ancestryHover; + } + + String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY); + if (null == ancestry) { + return ""; + } + + Integer resourceId = listGridRecord.getAttributeAsInt(RESOURCE_ID); + // if not set assume the standard "id" attr is a resourceId + resourceId = (null != resourceId) ? resourceId : listGridRecord.getAttributeAsInt("id"); + String resourceName = listGridRecord.getAttribute(RESOURCE_NAME); + // if not set assume the standard "name" attr is a resourceName + resourceName = (null != resourceName) ? resourceName : listGridRecord.getAttribute("name"); + Map<Integer, ResourceType> types = ((MapWrapper) listGridRecord.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES)) + .getMap(); + Integer resourceTypeId = listGridRecord.getAttributeAsInt(RESOURCE_TYPE_ID); + ResourceType type = types.get(resourceTypeId); + String resourceLongName = getResourceLongName(resourceName, type); + + width = (width <= 0) ? 500 : width; + + // decode ancestry + StringBuilder sb = new StringBuilder("<p style='width:"); + sb.append(width); + sb.append("px'>Parent Ancestry for: "); + sb.append(resourceLongName); + sb.append("<hr/>"); + String[] ancestryEntries = ancestry.split(Resource.ANCESTRY_DELIM); + for (int i = ancestryEntries.length - 1, j = 0; i >= 0; --i, ++j) { + String[] entryTokens = ancestryEntries[i].split(Resource.ANCESTRY_ENTRY_DELIM); + int ancestorTypeId = Integer.valueOf(entryTokens[0]); + String ancestorName = entryTokens[2]; + + // indent with spaces + if (j > 0) { + sb.append("<br/>"); + for (int k = 0; k < j; ++k) { + sb.append(" "); + } + } + type = types.get(ancestorTypeId); + sb.append(getResourceLongName(ancestorName, type)); + } + + // add target resource, indent with spaces + sb.append("<br/>"); + for (int k = 0; k <= ancestryEntries.length; ++k) { + sb.append(" "); + } + sb.append(resourceLongName); + + sb.append("</p>"); + + String result = sb.toString(); + listGridRecord.setAttribute(RESOURCE_ANCESTRY_HOVER, result); + return result; + } + + private static String getResourceLongName(String resourceName, ResourceType type) { + StringBuffer sb = new StringBuffer("<b>"); + + sb.append(resourceName); + sb.append("</b>"); + + if (type != null) { + sb.append(" [" + type.getPlugin() + " / "); + sb.append(type.getName()); + sb.append("]"); + } + + return sb.toString(); + } + /** * Get a resource name that combines type and resource information. This is useful for when we want to * use a single column for dispay of the resource "name". The name is wrapped in a navigable link. @@ -111,23 +237,45 @@ public abstract class AncestryUtil { * * @return the long name for the resource */ - public static String getResourceLongName(int resourceId, String resourceName, ResourceType type) { - StringBuilder sb = new StringBuilder(); - if (type != null) { - if (type.getPlugin() != null) { - sb.append(type.getPlugin()); - sb.append(" "); - } - - sb.append(type.getName()); - sb.append(" "); + public static String getResourceHoverHTML(Record record, int width) { + String resourceHover = record.getAttributeAsString(RESOURCE_HOVER); + if (null != resourceHover) { + return resourceHover; }
- String url = LinkManager.getResourceLink(resourceId); - String suffix = String.valueOf(resourceId); - sb.append(SeleniumUtility.getLocatableHref(url, resourceName, suffix)); + String resourceName = record.getAttribute(RESOURCE_NAME); + // if not set assume the standard "name" attr is a resourceName + resourceName = (null != resourceName) ? resourceName : record.getAttribute("name"); + Map<Integer, ResourceType> types = ((MapWrapper) record.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES)).getMap(); + Integer resourceTypeId = record.getAttributeAsInt(RESOURCE_TYPE_ID); + ResourceType type = types.get(resourceTypeId); + width = (width <= 0) ? 500 : width;
- return sb.toString(); + StringBuilder sb = new StringBuilder("<p style='width:"); + sb.append(width); + sb.append("px'>"); + + sb.append(getResourceLongName(resourceName, type)); + + sb.append("</p>"); + + String result = sb.toString(); + record.setAttribute(RESOURCE_HOVER, result); + return result; + } + + // We do not want smargwt to see we are storing our map into an attribute because it barfs on our key/value pairs + // so instead we have to wrap it in a non-Map POJO Object so smartgwt just handles it as a java.lang.Object. + public static class MapWrapper { + private Map<Integer, ResourceType> map; + + public MapWrapper(Map<Integer, ResourceType> map) { + this.map = map; + } + + public Map<Integer, ResourceType> getMap() { + return this.map; + } }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java index 8a7d883..27f49f2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java @@ -1,6 +1,5 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.ANCESTRY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION; @@ -110,6 +109,8 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { @Override public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
Record[] records = buildRecords(result); for (Record record : records) { @@ -120,17 +121,12 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite record.setAttribute(TYPE.propertyName(), type.getName()); }
- // decode ancestry - String ancestry = record.getAttributeAsString(ANCESTRY.propertyName()); - if (null == ancestry) { - continue; - } - int resourceId = record.getAttributeAsInt("id"); - String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types); - // Preserve the encoded ancestry for special-case formatting at higher levels. Set the - // decoded strings as different attributes. - record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]); - record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]); + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + + // Build the decoded ancestry Strings now for display + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); } response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set @@ -173,7 +169,6 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite record.setAttribute("resource", res); record.setAttribute("id", res.getId()); record.setAttribute(NAME.propertyName(), res.getName()); - record.setAttribute(ANCESTRY.propertyName(), res.getAncestry()); record.setAttribute(DESCRIPTION.propertyName(), res.getDescription()); record.setAttribute(TYPE.propertyName(), res.getResourceType().getId()); record.setAttribute(PLUGIN.propertyName(), res.getResourceType().getPlugin()); @@ -183,7 +178,12 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite record.setAttribute(AVAILABILITY.propertyName(), ImageManager.getAvailabilityIconFromAvailType(res .getCurrentAvailability().getAvailabilityType()));
- record.setAttribute("resourcePersmission", from.getResourcePermission()); + record.setAttribute("resourcePermission", from.getResourcePermission()); + + // for ancestry handling + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, res.getAncestry()); + record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, res.getResourceType().getId()); + return record; }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java index cf11666..b689133 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDataSourceField.java @@ -39,9 +39,7 @@ public enum ResourceDataSourceField {
CATEGORY("resourceType.category", CoreGUI.getMessages().common_title_category()),
- AVAILABILITY("currentAvailability", CoreGUI.getMessages().common_title_availability()), - - ANCESTRY("ancestry", CoreGUI.getMessages().common_title_ancestry()); + AVAILABILITY("currentAvailability", CoreGUI.getMessages().common_title_availability());
/** * Corresponds to a property name of Resource (e.g. resourceType.name). diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java index 7f7cb7e..9a10084 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java @@ -18,7 +18,6 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.ANCESTRY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION; @@ -62,10 +61,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
public static final String FILTER_GROUP_ID = "groupId";
- // a decoded resource ancestry for display, with - public static final String ATTR_ANCESTRY_RESOURCES = ANCESTRY.name() + "Resources"; - public static final String ATTR_ANCESTRY_TYPES = ANCESTRY.name() + "Types"; - private static ResourceDatasource INSTANCE;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); @@ -104,10 +99,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> { nameDataField.setCanEdit(false); fields.add(nameDataField);
- DataSourceTextField ancestryDataField = new DataSourceTextField(ANCESTRY.propertyName(), ANCESTRY.title(), 200); - ancestryDataField.setCanEdit(false); - fields.add(ancestryDataField); - DataSourceTextField descriptionDataField = new DataSourceTextField(DESCRIPTION.propertyName(), DESCRIPTION .title()); descriptionDataField.setCanEdit(false); @@ -159,14 +150,14 @@ public class ResourceDatasource extends RPCDataSource<Resource> { }
// In addition to the types of the result resources, get the types of their ancestry - // NOTE: this may be too labor intensive in general, but since this is a singleton I couldn't - // make it easily optional. typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance(); typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { @Override public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
Record[] records = buildRecords(result); for (Record record : records) { @@ -177,17 +168,12 @@ public class ResourceDatasource extends RPCDataSource<Resource> { record.setAttribute(TYPE.propertyName(), type.getName()); }
- // decode ancestry - String ancestry = record.getAttributeAsString(ANCESTRY.propertyName()); - if (null == ancestry) { - continue; - } - int resourceId = record.getAttributeAsInt("id"); - String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types); - // Preserve the encoded ancestry for special-case formatting at higher levels. Set the - // decoded strings as different attributes. - record.setAttribute(ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]); - record.setAttribute(ATTR_ANCESTRY_TYPES, decodedAncestry[1]); + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + + // Build the decoded ancestry Strings now for display + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); } response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set @@ -236,7 +222,6 @@ public class ResourceDatasource extends RPCDataSource<Resource> { record.setAttribute("id", from.getId()); record.setAttribute("uuid", from.getUuid()); record.setAttribute(NAME.propertyName(), from.getName()); - record.setAttribute(ANCESTRY.propertyName(), from.getAncestry()); record.setAttribute(DESCRIPTION.propertyName(), from.getDescription()); record.setAttribute(TYPE.propertyName(), from.getResourceType().getId()); record.setAttribute(PLUGIN.propertyName(), from.getResourceType().getPlugin()); @@ -246,6 +231,9 @@ public class ResourceDatasource extends RPCDataSource<Resource> { record.setAttribute(AVAILABILITY.propertyName(), ImageManager.getAvailabilityIconFromAvailType(from .getCurrentAvailability().getAvailabilityType()));
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry()); + record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceType().getId()); + return record; }
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 a4d2835..dc6b945 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 @@ -18,7 +18,6 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.resource;
-import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.ANCESTRY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.AVAILABILITY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY; import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.DESCRIPTION; @@ -153,19 +152,24 @@ public class ResourceSearchView extends Table { return SeleniumUtility.getLocatableHref(url, o.toString(), null); } }); + nameField.setShowHover(true); + nameField.setHoverCustomizer(new HoverCustomizer() {
- ListGridField ancestryField = new ListGridField(ANCESTRY.propertyName(), ANCESTRY.title()); + public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { + return AncestryUtil.getResourceHoverHTML(listGridRecord, 0); + } + }); + + ListGridField ancestryField = new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry()); ancestryField.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) { - return listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES); + return listGridRecord.getAttributeAsString(AncestryUtil.RESOURCE_ANCESTRY_VALUE); } }); ancestryField.setShowHover(true); ancestryField.setHoverCustomizer(new HoverCustomizer() { public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return "<p style='width:400px'>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>"; + return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); } });
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java index 9ba7787..796c490 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java @@ -49,9 +49,6 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory
public static abstract class Field extends AbstractOperationHistoryDataSource.Field { public static final String RESOURCE = "resource"; - public static final String RESOURCE_ID = "resource.id"; - public static final String ANCESTRY = "resource.ancestry"; - public static final String TYPE = "resource.resourceType.id"; public static final String GROUP_OPERATION_HISTORY = "groupOperationHistory"; }
@@ -67,9 +64,6 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE); fields.add(resourceField);
- DataSourceTextField ancestryField = new DataSourceTextField(Field.ANCESTRY); - fields.add(ancestryField); - return fields; }
@@ -123,30 +117,17 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { @Override public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
Record[] records = buildRecords(result); for (Record record : records) { - // enhance resource name - int resourceId = record.getAttributeAsInt(Field.RESOURCE_ID); - int resourceTypeId = record.getAttributeAsInt(Field.TYPE); - String resourceName = record.getAttributeAsString(Field.RESOURCE); - ResourceType type = types.get(resourceTypeId); - record.setAttribute(Field.RESOURCE, AncestryUtil - .getResourceLongName(resourceId, resourceName, type)); - - // decode ancestry - String ancestry = record.getAttributeAsString(Field.ANCESTRY); - if (null == ancestry) { - continue; - } - String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types); - // Preserve the encoded ancestry for special-case formatting at higher levels. Set the - // decoded strings as different attributes. - //record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]); - //record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]); - // TODO: If we elect to use a hover handler then we'll need ListGridFields set up - // Until then we'll just set the Ancestry field. - record.setAttribute(Field.ANCESTRY, decodedAncestry[0]); + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + + // Build the decoded ancestry Strings now for display + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); } response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set @@ -160,10 +141,13 @@ public class ResourceOperationHistoryDataSource extends AbstractOperationHistory ListGridRecord record = super.copyValues(from);
record.setAttribute(Field.ID, from.getId()); - record.setAttribute(Field.RESOURCE_ID, from.getResource().getId()); record.setAttribute(Field.RESOURCE, from.getResource().getName()); - record.setAttribute(Field.ANCESTRY, from.getResource().getAncestry()); - record.setAttribute(Field.TYPE, from.getResource().getResourceType().getId()); + + // for ancestry handling + record.setAttribute(AncestryUtil.RESOURCE_ID, from.getResource().getId()); + record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResource().getName()); + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getResource().getAncestry()); + record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResource().getResourceType().getId());
return record; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java index 6d76cb1..5632322 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDetailsView.java @@ -40,8 +40,8 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDetailsView; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * @author Ian Springer @@ -108,8 +108,9 @@ public class ResourceOperationHistoryDetailsView extends AbstractOperationHistor
if (showResourceField) { Resource resource = resourceOperationHistory.getResource(); - disambiguatedResourceName = AncestryUtil.getResourceLongName(resource.getId(), resource - .getName(), resource.getResourceType()); + String url = LinkManager.getResourceLink(resource.getId()); + disambiguatedResourceName = SeleniumUtility.getLocatableHref(url, resource.getName(), String + .valueOf(resource.getId())); }
displayDetails(resourceOperationHistory); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java index 94749e2..f310997 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceSelector.java @@ -39,6 +39,7 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypePluginTreeDataSource; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; @@ -177,9 +178,7 @@ public class ResourceSelector extends AbstractSelector<Resource> { protected HoverCustomizer getNameHoverCustomizer() { return new HoverCustomizer() { public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum, int colNum) { - return "<p style='width:400px'>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_RESOURCES) + "</br>" - + listGridRecord.getAttributeAsString(ResourceDatasource.ATTR_ANCESTRY_TYPES) + "</p>"; + return AncestryUtil.getAncestryHoverHTML(listGridRecord, 0); } }; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java index db60b8c..42808cf 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java @@ -44,7 +44,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; @@ -60,17 +59,13 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL
public enum Field {
- ANCESTRY("ancestry", MSG.common_title_ancestry()), - OPERATION("operationName", MSG.dataSource_operationSchedule_field_operationName()),
RESOURCE("resource", MSG.common_title_resource()),
STATUS("operationStatus", MSG.common_title_status()),
- TIME("operationStartTime", MSG.common_title_timestamp()), - - TYPE("typeId", MSG.common_title_type()); + TIME("operationStartTime", MSG.common_title_timestamp());
/** * Corresponds to a property name of Resource (e.g. resourceType.name). @@ -127,10 +122,6 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE.propertyName, Field.RESOURCE.title); fields.add(resourceField);
- DataSourceTextField ancestryField = new DataSourceTextField(Field.ANCESTRY.propertyName(), Field.ANCESTRY - .title()); - fields.add(ancestryField); - DataSourceTextField operationField = new DataSourceTextField(Field.OPERATION.propertyName(), Field.OPERATION .title()); fields.add(operationField); @@ -207,27 +198,17 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { @Override public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
Record[] records = buildRecords(result); for (Record record : records) { - // enhance resource name - int resourceId = record.getAttributeAsInt("id"); - int resourceTypeId = record.getAttributeAsInt(Field.TYPE.propertyName); - String resourceName = record.getAttributeAsString(Field.RESOURCE.propertyName); - ResourceType type = types.get(resourceTypeId); - record.setAttribute(Field.RESOURCE.propertyName, AncestryUtil.getResourceLongName(resourceId, - resourceName, type)); - - // decode ancestry - String ancestry = record.getAttributeAsString(Field.ANCESTRY.propertyName()); - if (null == ancestry) { - continue; - } - String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types); - // Preserve the encoded ancestry for special-case formatting at higher levels. Set the - // decoded strings as different attributes. - record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]); - record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]); + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + + // Build the decoded ancestry Strings now for display + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); } response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set @@ -239,13 +220,16 @@ public class RecentOperationsDataSource extends RPCDataSource<ResourceOperationL @Override public ListGridRecord copyValues(ResourceOperationLastCompletedComposite from) { ListGridRecord record = new ListGridRecord(); - record.setAttribute("id", from.getResourceId()); - record.setAttribute(Field.ANCESTRY.propertyName, from.getAncestry()); record.setAttribute(Field.OPERATION.propertyName, from.getOperationName()); record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName()); record.setAttribute(Field.STATUS.propertyName, getStatusIconLink(from)); record.setAttribute(Field.TIME.propertyName, new Date(from.getOperationStartTime())); - record.setAttribute(Field.TYPE.propertyName, from.getResourceTypeId()); + + // for ancestry handling + record.setAttribute(AncestryUtil.RESOURCE_ID, from.getResourceId()); + record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResourceName()); + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry()); + record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceTypeId());
record.setAttribute("entity", from); return record; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java index 0f509df..a835711 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java @@ -40,7 +40,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; @@ -56,15 +55,11 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati
public enum Field {
- ANCESTRY("ancestry", MSG.common_title_ancestry()), - OPERATION("operationName", MSG.dataSource_operationSchedule_field_operationName()),
RESOURCE("resource", MSG.common_title_resource()),
- TIME("operationNextFireTime", MSG.dataSource_operationSchedule_field_nextFireTime()), - - TYPE("typeId", MSG.common_title_type()); + TIME("operationNextFireTime", MSG.dataSource_operationSchedule_field_nextFireTime());
/** * Corresponds to a property name of Resource (e.g. resourceType.name). @@ -120,10 +115,6 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE.propertyName, Field.RESOURCE.title); fields.add(resourceField);
- DataSourceTextField ancestryField = new DataSourceTextField(Field.ANCESTRY.propertyName(), Field.ANCESTRY - .title()); - fields.add(ancestryField); - DataSourceTextField operationField = new DataSourceTextField(Field.OPERATION.propertyName(), Field.OPERATION .title()); fields.add(operationField); @@ -196,27 +187,17 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { @Override public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
Record[] records = buildRecords(result); for (Record record : records) { - // enhance resource name - int resourceId = record.getAttributeAsInt("id"); - int resourceTypeId = record.getAttributeAsInt(Field.TYPE.propertyName); - String resourceName = record.getAttributeAsString(Field.RESOURCE.propertyName); - ResourceType type = types.get(resourceTypeId); - record.setAttribute(Field.RESOURCE.propertyName, AncestryUtil.getResourceLongName(resourceId, - resourceName, type)); - - // decode ancestry - String ancestry = record.getAttributeAsString(Field.ANCESTRY.propertyName()); - if (null == ancestry) { - continue; - } - String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types); - // Preserve the encoded ancestry for special-case formatting at higher levels. Set the - // decoded strings as different attributes. - record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]); - record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]); + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + + // Build the decoded ancestry Strings now for display + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); } response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set @@ -233,12 +214,15 @@ public class ScheduledOperationsDataSource extends RPCDataSource<ResourceOperati @Override public ListGridRecord copyValues(ResourceOperationScheduleComposite from) { ListGridRecord record = new ListGridRecord(); - record.setAttribute("id", from.getResourceId()); - record.setAttribute(Field.ANCESTRY.propertyName, from.getAncestry()); record.setAttribute(Field.OPERATION.propertyName, from.getOperationName()); record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName()); record.setAttribute(Field.TIME.propertyName, new Date(from.getOperationNextFireTime())); - record.setAttribute(Field.TYPE.propertyName, from.getResourceTypeId()); + + // for ancestry handling + record.setAttribute(AncestryUtil.RESOURCE_ID, from.getResourceId()); + record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResourceName()); + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry()); + record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceTypeId());
record.setAttribute("entity", from); return record; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java index d354bbd..756bc4a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java @@ -42,7 +42,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; @@ -60,13 +59,9 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom
ALERTS("numAlerts", MSG.dataSource_problemResources_field_alerts()),
- ANCESTRY("ancestry", MSG.common_title_ancestry()), - AVAILABILITY("availabilityType", MSG.common_title_availability()),
- RESOURCE("resource", MSG.common_title_resource()), - - TYPE("typeId", MSG.common_title_type()); + RESOURCE("resource", MSG.common_title_resource());
/** * Corresponds to a property name of Resource (e.g. resourceType.name). @@ -122,10 +117,6 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom protected List<DataSourceField> addDataSourceFields() { List<DataSourceField> fields = super.addDataSourceFields();
- DataSourceTextField ancestryField = new DataSourceTextField(Field.ANCESTRY.propertyName(), Field.ANCESTRY - .title()); - fields.add(ancestryField); - DataSourceTextField alertsField = new DataSourceTextField(Field.ALERTS.propertyName, Field.ALERTS.title()); fields.add(alertsField);
@@ -196,27 +187,17 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { @Override public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
Record[] records = buildRecords(result); for (Record record : records) { - // enhance resource name - int resourceId = record.getAttributeAsInt("id"); - int resourceTypeId = record.getAttributeAsInt(Field.TYPE.propertyName); - String resourceName = record.getAttributeAsString(Field.RESOURCE.propertyName); - ResourceType type = types.get(resourceTypeId); - record.setAttribute(Field.RESOURCE.propertyName, AncestryUtil.getResourceLongName(resourceId, - resourceName, type)); - - // decode ancestry - String ancestry = record.getAttributeAsString(Field.ANCESTRY.propertyName()); - if (null == ancestry) { - continue; - } - String[] decodedAncestry = AncestryUtil.decodeAncestry(resourceId, ancestry, types); - // Preserve the encoded ancestry for special-case formatting at higher levels. Set the - // decoded strings as different attributes. - record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_RESOURCES, decodedAncestry[0]); - record.setAttribute(ResourceDatasource.ATTR_ANCESTRY_TYPES, decodedAncestry[1]); + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + + // Build the decoded ancestry Strings now for display + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); } response.setData(records); response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set @@ -229,12 +210,15 @@ public class ProblemResourcesDataSource extends RPCDataSource<ProblemResourceCom public ListGridRecord copyValues(ProblemResourceComposite from) { ListGridRecord record = new ListGridRecord(); record.setAttribute("id", from.getResourceId()); - record.setAttribute(Field.ANCESTRY.propertyName, from.getAncestry()); record.setAttribute(Field.ALERTS.propertyName, from.getNumAlerts()); record.setAttribute(Field.AVAILABILITY.propertyName, ImageManager.getAvailabilityIconFromAvailType(from .getAvailabilityType())); record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName()); - record.setAttribute(Field.TYPE.propertyName, from.getResourceTypeId()); + + // for ancestry handling + record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResourceName()); + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry()); + record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceTypeId());
record.setAttribute("entity", from); return record; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java index 3072708..3ae0259 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertGWTServiceImpl.java @@ -18,9 +18,13 @@ */ package org.rhq.enterprise.gui.coregui.server.gwt;
+import java.util.ArrayList; +import java.util.List; + import org.rhq.core.domain.alert.Alert; import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.AlertCriteria; +import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.exception.ThrowableUtil; import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTService; @@ -39,8 +43,15 @@ public class AlertGWTServiceImpl extends AbstractGWTServiceImpl implements Alert
public PageList<Alert> findAlertsByCriteria(AlertCriteria criteria) throws RuntimeException { try { - return SerialUtility.prepare(this.alertManager.findAlertsByCriteria(getSessionSubject(), criteria), - "AlertService.findAlertsByCriteria"); + PageList<Alert> result = this.alertManager.findAlertsByCriteria(getSessionSubject(), criteria); + if (!result.isEmpty()) { + List<Resource> resources = new ArrayList<Resource>(result.size()); + for (Alert alert : result) { + resources.add(alert.getAlertDefinition().getResource()); + } + ObjectFilter.filterFieldsInCollection(resources, ResourceGWTServiceImpl.importantFieldsSet); + } + return SerialUtility.prepare(result, "AlertService.findAlertsByCriteria"); } catch (Throwable t) { throw new RuntimeException(ThrowableUtil.getAllMessages(t)); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java index c903f13..0290135 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java @@ -67,7 +67,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O try { PageList<ResourceOperationHistory> result = operationManager.findResourceOperationHistoriesByCriteria( getSessionSubject(), criteria); - if (result.size() > 0) { + if (!result.isEmpty()) { List<Resource> resources = new ArrayList<Resource>(result.size()); for (ResourceOperationHistory history : result) { resources.add(history.getResource()); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java index 44bcb42..4c474c1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java @@ -107,7 +107,7 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re // "productVersion "} "tags" };
- private static Set<String> importantFieldsSet = new HashSet<String>(Arrays.asList(importantFields)); + public static Set<String> importantFieldsSet = new HashSet<String>(Arrays.asList(importantFields));
@Override public void init(ServletConfig config) throws ServletException {
rhq-commits@lists.fedorahosted.org