dev/null |binary modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 89 --- modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java | 109 +++ modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/RecentlyAddedResourceComposite.java | 14 modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java | 36 - modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceParentFlyweight.java | 59 -- modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java | 28 - modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/MembersAvailabilityHint.java | 68 ++ modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/MembersCategoryHint.java | 52 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java | 4 modules/enterprise/gui/coregui/src/main/webapp/css/search.css | 2 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java | 39 - modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageComponent.java | 118 ++++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java | 128 ++++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java | 120 ++++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameRenderer.java | 62 ++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageComponent.java | 118 ---- modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java | 88 --- modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java | 35 - modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java | 23 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java | 40 + modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java | 18 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java | 19 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java | 22 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java | 38 + modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java | 18 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageDecorator.java | 77 ++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageTag.java | 100 +++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameDecorator.java | 110 +++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java | 175 ++++++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java | 49 + modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java | 58 -- modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java | 43 + modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties | 4 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/inventory-components.xml | 32 - modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml | 14 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld | 108 +++ modules/enterprise/gui/portal-war/src/main/webapp/css/win.css | 14 modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_down_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_down_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_unknown_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_unknown_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_up_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_up_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_down_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_down_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_unknown_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_unknown_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_up_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_up_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_unknown_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_unknown_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_unknown_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_unknown_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_unknown_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_unknown_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_down_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_down_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_unknown_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_unknown_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_up_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_up_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_down_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_down_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_unknown_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_up_16.png |binary modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_up_24.png |binary modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp | 43 - modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp | 61 +- modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp | 9 modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp | 24 modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp | 31 - modules/enterprise/gui/portal-war/src/main/webapp/portlet/recentlyApproved/View.jsp | 5 modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp | 22 modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp | 21 modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml | 10 modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menuitem.xhtml | 5 modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml | 4 modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repoSubscriptions.xhtml | 16 modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/inventory/view.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml | 48 - modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/resourcePicker.xhtml | 6 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/configurationUpdate.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/oobHistory.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/operationHistory.xhtml | 8 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 147 ----- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java | 27 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DefaultDisambiguationUpdateStrategies.java | 187 ++++++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java | 168 ++++++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java | 65 ++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java | 279 ++++++++++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java | 87 +++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java | 145 +++++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ResourceResolution.java | 46 + 110 files changed, 2752 insertions(+), 899 deletions(-)
New commits: commit 62411f35ab0bed414e6dcb1a5bed13b59bc87cfe Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 31 17:14:03 2010 +0200
BZ 592970 - new icon set enables unknown availability state to be shown in the tree.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java index f6c442b..dccbbaa 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/AutoGroupCompositeFlyweight.java @@ -27,9 +27,17 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List;
+import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
/** + * This class is mostly a copy of {@link AutoGroupComposite} but is linked together + * with {@link ResourceFlyweight}, {@link ResourceTypeFlyweight} and {@link ResourceSubCategoryFlyweight} instances as opposed to + * their fully featured counterparts which is what makes this class flyweight. + * <p> + * In addition to the {@link AutoGroupComposite}, this class contains some more properties used + * in the UI layer. + * * @see AutoGroupComposite * * @author Lukas Krejci @@ -46,7 +54,9 @@ public class AutoGroupCompositeFlyweight implements Serializable { private boolean mainResource; private ResourceFlyweight parentResource; private String name; - + private MembersAvailabilityHint membersAvailabilityHint; + private MembersCategoryHint membersCategoryHint; + private List<ResourceFlyweight> resources;
public AutoGroupCompositeFlyweight(AutoGroupCompositeFlyweight other) { @@ -154,6 +164,22 @@ public class AutoGroupCompositeFlyweight implements Serializable { return name; }
+ public MembersAvailabilityHint getMembersAvailabilityHint() { + return membersAvailabilityHint; + } + + public void setMembersAvailabilityHint(MembersAvailabilityHint membersAvailabilityHint) { + this.membersAvailabilityHint = membersAvailabilityHint; + } + + public MembersCategoryHint getMembersCategoryHint() { + return membersCategoryHint; + } + + public void setMembersCategoryHint(MembersCategoryHint membersCategoryHint) { + this.membersCategoryHint = membersCategoryHint; + } + @Override public String toString() { return "AutoGroupCompositeFlyweight[" + ((this.resourceType != null) ? "Resource: " : "Subcategory: ") diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/MembersAvailabilityHint.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/MembersAvailabilityHint.java new file mode 100644 index 0000000..325461c --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/MembersAvailabilityHint.java @@ -0,0 +1,68 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.core.domain.resource.flyweight; + +import org.rhq.core.domain.measurement.AvailabilityType; + +/** + * Hints about the availability of resources in an {@link AutoGroupCompositeFlyweight}. + * + * @author Lukas Krejci + */ +public enum MembersAvailabilityHint { + + /** + * All member resources are up. + */ + UP, + + /** + * Some member resources are down. + */ + DOWN, + + /** + * Some member resources don't have a known availability state. + */ + UNKNOWN; + + public static MembersAvailabilityHint fromAvailabilityType(AvailabilityType availType) { + if (availType == null) { + return UNKNOWN; + } + + switch (availType) { + case UP: + return UP; + case DOWN: + return DOWN; + default: + return UNKNOWN; + } + } + + public String toString() { + return name().toLowerCase(); + } +} diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/MembersCategoryHint.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/MembersCategoryHint.java new file mode 100644 index 0000000..05b922b --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/flyweight/MembersCategoryHint.java @@ -0,0 +1,52 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.core.domain.resource.flyweight; + +import org.rhq.core.domain.resource.ResourceCategory; + +/** + * Hints about the category of resources contained in a {@link AutoGroupCompositeFlyweight}. + * + * @author Lukas Krejci + */ +public enum MembersCategoryHint { + PLATFORM, SERVER, SERVICE, MIXED, NONE; + + public static MembersCategoryHint fromResourceCategory(ResourceCategory category) { + switch (category) { + case PLATFORM: + return PLATFORM; + case SERVER: + return SERVER; + case SERVICE: + return SERVICE; + default: + return null; + } + } + + public String toString() { + return name().toLowerCase(); + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java index 2f1bd6f..269360c 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java @@ -33,6 +33,8 @@ import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.resource.Agent; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.flyweight.AutoGroupCompositeFlyweight; +import org.rhq.core.domain.resource.flyweight.MembersAvailabilityHint; +import org.rhq.core.domain.resource.flyweight.MembersCategoryHint; import org.rhq.core.domain.resource.flyweight.ResourceFlyweight; import org.rhq.core.domain.resource.flyweight.ResourceSubCategoryFlyweight; import org.rhq.core.domain.resource.flyweight.ResourceTypeFlyweight; @@ -172,7 +174,12 @@ public class ResourceTreeModelUIBean { Map<Object, List<ResourceFlyweight>> children = new HashMap<Object, List<ResourceFlyweight>>(); log.debug("composite parent" + compositeParent); if (compositeParent != null) { + + MembersCategoryHint membersCategory = MembersCategoryHint.NONE; + MembersAvailabilityHint membersAvailabilityHint = MembersAvailabilityHint.UP; + for (ResourceFlyweight res : compositeParent.getParentResource().getChildResources()) { + boolean process = false; if (compositeParent.getSubcategory() != null) { // parent is a sub category if (res.getResourceType().getSubCategory() != null @@ -182,19 +189,55 @@ public class ResourceTreeModelUIBean {
// A subSubCategory in a subcategory addToList(children, res.getResourceType().getSubCategory(), res); + process = true; } else if (compositeParent.getSubcategory().equals(res.getResourceType().getSubCategory()) && compositeParent.getParentResource().equals(res.getParentResource())) { // Direct entries in a subcategory... now group them by autogroup (type) addToList(children, res.getResourceType(), res); + process = true; } } else if (compositeParent.getResourceType() != null) { if (compositeParent.getResourceType().equals(res.getResourceType()) && compositeParent.getParentResource().getId() == res.getParentResource().getId()) {
addToList(children, res.getResourceType(), res); + process = true; + } + } + + if (process) { + //amend the overall category of all the members of the auto group. + switch (membersCategory) { + case NONE: //this is the first child, so let's use its category as a starting point + membersCategory = MembersCategoryHint.fromResourceCategory(res.getResourceType().getCategory()); + break; + case MIXED: //this is the "final" state. The children type is not going to change from this. + break; + default: //check if this child has the same category as its previous siblings. + if (MembersCategoryHint.fromResourceCategory(res.getResourceType().getCategory()) != membersCategory) { + membersCategory = MembersCategoryHint.MIXED; + } + } + + //amend the availability hint of the autogroup. If all resources are up, the hint is UP, if some of the resources + //are down, the hint is DOWN, if some of the resources' avail state is unknown, the hint is UNKNOWN. + //The down state has the highest priority. + switch (membersAvailabilityHint) { + case UP: + membersAvailabilityHint = MembersAvailabilityHint.fromAvailabilityType(res.getCurrentAvailability().getAvailabilityType()); + break; + case UNKNOWN: + if (res.getCurrentAvailability().getAvailabilityType() == AvailabilityType.DOWN) { + membersAvailabilityHint = MembersAvailabilityHint.DOWN; + } + break; + case DOWN:; //a "terminal" state... if some resource is down, the overall state is going to be down as that is the most important information. } } } + + compositeParent.setMembersCategoryHint(membersCategory); + compositeParent.setMembersAvailabilityHint(membersAvailabilityHint); }
AutoGroupCompositeFlyweight compositeParentNode = (AutoGroupCompositeFlyweight) parentNode.getData(); diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_16.png deleted file mode 100644 index 4254cdf..0000000 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_16.png and /dev/null differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_24.png deleted file mode 100644 index 9bf7418..0000000 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_24.png and /dev/null differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_down_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_down_16.png new file mode 100644 index 0000000..35a748c Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_down_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_down_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_down_24.png new file mode 100644 index 0000000..3237333 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_down_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_unknown_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_unknown_16.png new file mode 100644 index 0000000..aaefc27 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_unknown_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_unknown_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_unknown_24.png new file mode 100644 index 0000000..51e0a5e Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_unknown_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_up_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_up_16.png new file mode 100644 index 0000000..734d98b Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_up_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_up_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_up_24.png new file mode 100644 index 0000000..d6b06e0 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_server_up_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_down_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_down_16.png new file mode 100644 index 0000000..2cfd4db Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_down_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_down_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_down_24.png new file mode 100644 index 0000000..25144f1 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_down_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_unknown_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_unknown_16.png new file mode 100644 index 0000000..f376733 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_unknown_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_unknown_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_unknown_24.png new file mode 100644 index 0000000..8e81dc5 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_unknown_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_up_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_up_16.png new file mode 100644 index 0000000..3bd2c67 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_up_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_up_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_up_24.png new file mode 100644 index 0000000..b310d15 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Auto_group_service_up_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_16.png index af73da1..7fd96d4 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_16.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_24.png index 66627f8..ec5fbca 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_24.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_down_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_unknown_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_unknown_16.png new file mode 100644 index 0000000..8318b3d Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_unknown_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_unknown_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_unknown_24.png new file mode 100644 index 0000000..9bf9597 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_unknown_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_16.png index 223b0b3..ac410ca 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_16.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_24.png index fb50a9d..deb9e94 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_24.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Platform_up_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_16.png index 69a4d9f..57adb89 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_16.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_24.png index 660e4b8..06d0e26 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_24.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_down_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_unknown_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_unknown_16.png new file mode 100644 index 0000000..e911512 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_unknown_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_unknown_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_unknown_24.png new file mode 100644 index 0000000..1d94a83 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_unknown_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_16.png index 132e4ce..c76e3eb 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_16.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_24.png index 83da6ad..88ca45b 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_24.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Server_up_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_16.png index d09143b..9240927 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_16.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_24.png index 24b1d98..bdc8532 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_24.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_down_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_unknown_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_unknown_16.png new file mode 100644 index 0000000..771ccff Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_unknown_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_unknown_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_unknown_24.png new file mode 100644 index 0000000..5356ae7 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_unknown_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_16.png index bbebc5c..0ef05e9 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_16.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_24.png index 7df5599..6babc43 100644 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_24.png and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Service_up_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_16.png deleted file mode 100644 index de32196..0000000 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_16.png and /dev/null differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_24.png deleted file mode 100644 index 5566923..0000000 Binary files a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_24.png and /dev/null differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_down_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_down_16.png new file mode 100644 index 0000000..c75e7a8 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_down_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_down_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_down_24.png new file mode 100644 index 0000000..321ea56 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_down_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_unknown_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_unknown_16.png new file mode 100644 index 0000000..63b2050 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_unknown_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_unknown_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_unknown_24.png new file mode 100644 index 0000000..b9d3d88 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_unknown_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_up_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_up_16.png new file mode 100644 index 0000000..4678909 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_up_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_up_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_up_24.png new file mode 100644 index 0000000..b9b400d Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_server_up_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_down_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_down_16.png new file mode 100644 index 0000000..c75e7a8 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_down_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_down_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_down_24.png new file mode 100644 index 0000000..321ea56 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_down_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_unknown_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_unknown_16.png new file mode 100644 index 0000000..63b2050 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_unknown_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_up_16.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_up_16.png new file mode 100644 index 0000000..4678909 Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_up_16.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_up_24.png b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_up_24.png new file mode 100644 index 0000000..b9b400d Binary files /dev/null and b/modules/enterprise/gui/portal-war/src/main/webapp/images/icons/Subcategory_service_up_24.png differ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml index 5275d13..2b1af7d 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml @@ -65,8 +65,8 @@ <rich:treeNode type="AutoGroupComposite" iconCollapsed="/images/icons/dir_closed.png" iconExpanded="/images/icons/dir_open.png" - iconLeaf="/images/icons/#{resourceTreeItem.data.resourceType == null? 'Subcategory' : 'Auto_group'}_16.png" - icon="/images/icons/#{resourceTreeItem.data.resourceType == null? 'Subcategory' : 'Auto_group'}_16.png"> + iconLeaf="/images/icons/#{resourceTreeItem.data.resourceType == null? 'Subcategory' : 'Auto_group'}_#{resourceTreeItem.data.membersCategoryHint}_#{resourceTreeItem.data.membersAvailabilityHint}_16.png" + icon="/images/icons/#{resourceTreeItem.data.resourceType == null? 'Subcategory' : 'Auto_group'}_#{resourceTreeItem.data.membersCategoryHint}_#{resourceTreeItem.data.membersAvailabilityHint}_16.png">
<a4j:support event="oncontextmenu" reRender="autoGroupMenu" timeout="5000" disableDefault="true" status="commonStatus" limitToList="true" @@ -91,10 +91,10 @@ </rich:treeNode> <!-- Tree Node supporting context menu --> <rich:treeNode type="Resource" - icon="/images/icons/#{resourceTreeItem.data.resourceType.category}_#{resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up'}_16.png" + icon="/images/icons/#{resourceTreeItem.data.resourceType.category}_#{resourceTreeItem.data.currentAvailability.availabilityType == null ? 'unknown' : (resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up')}_16.png" iconCollapsed="/images/icons/dir_closed.png" iconExpanded="/images/icons/dir_open.png" - iconLeaf="/images/icons/#{resourceTreeItem.data.resourceType.category}_#{resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up'}_16.png"> + iconLeaf="/images/icons/#{resourceTreeItem.data.resourceType.category}_#{resourceTreeItem.data.currentAvailability.availabilityType == null ? 'unknown' : (resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up')}_16.png"> <a4j:support event="oncontextmenu" reRender="resourceMenu" timeout="5000" disableDefault="true" status="commonStatus" limitToList="true" ajaxSingle="true" oncomplete="#{rich:component('resourceMenu')}.show(event, {})">
commit 0360ca3af85e2c55a2cdefd2347ec0c325444903 Author: Lukas Krejci lkrejci@redhat.com Date: Wed May 19 19:52:53 2010 +0200
introduce the disambiguation update strategy as a paramter to disambiguate method in ResourceManagerBean so that UI code can influence the disambiguation.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java index 36c7f88..8999775 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java @@ -29,6 +29,8 @@ import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.server.resource.ResourceManagerLocal; +import org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies; +import org.rhq.enterprise.server.resource.disambiguation.DisambiguationUpdateStrategy; import org.rhq.enterprise.server.util.LookupUtil;
/** @@ -37,7 +39,7 @@ import org.rhq.enterprise.server.util.LookupUtil; * <p> * This class implements the {@link PagedListDataModel#fetchPage(PageControl)} method and defers * the actual loading of the data to a new {@link #fetchDataForPage(PageControl)} method. The result - * of that call is supplied to the {@link ResourceManagerLocal#disambiguate(java.util.List, boolean, IntExtractor)} + * of that call is supplied to the {@link ResourceManagerLocal#disambiguate(java.util.List, IntExtractor, DisambiguationUpdateStrategy)} * method and the disambiguated results are then returned from the {@link #fetchPage(PageControl)} method. * * @author Lukas Krejci @@ -64,8 +66,8 @@ public abstract class ResourceNameDisambiguatingPagedListDataModel<T> extends public PageList<DisambiguationReport<T>> fetchPage(PageControl pc) { PageList<T> data = fetchDataForPage(pc);
- ResourceNamesDisambiguationResult<T> disambiguation = resourceManager.disambiguate(data, alwaysIncludeParents, - getResourceIdExtractor()); + ResourceNamesDisambiguationResult<T> disambiguation = resourceManager.disambiguate(data, getResourceIdExtractor(), + DefaultDisambiguationUpdateStrategies.getDefault());
return new PageList<DisambiguationReport<T>>(disambiguation.getResolution(), data.getTotalSize(), data .getPageControl()); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java index 0837143..41e710f 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java @@ -28,6 +28,7 @@ import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.server.resource.ResourceManagerLocal; +import org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies;
/** * A utility class to provide page lists of disambiguated resource lists for the @@ -42,7 +43,7 @@ public class DisambiguatedResourceListUtil { }
public static <T> PageList<DisambiguationReport<T>> disambiguate(ResourceManagerLocal resourceManager, PageList<T> results, IntExtractor<T> resourceIdExtractor) { - ResourceNamesDisambiguationResult<T> result = resourceManager.disambiguate(results, true, resourceIdExtractor); + ResourceNamesDisambiguationResult<T> result = resourceManager.disambiguate(results, resourceIdExtractor, DefaultDisambiguationUpdateStrategies.getDefault()); return new PageList<DisambiguationReport<T>>(result.getResolution(), results.getTotalSize(), results.getPageControl()); } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java index 1ce8845..afe2e3b 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java @@ -31,6 +31,7 @@ import org.rhq.core.domain.util.PageControl; import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.server.resource.ResourceManagerLocal; +import org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies; import org.rhq.enterprise.server.util.LookupUtil;
/** @@ -78,6 +79,6 @@ public class ResourceSelectUIBean { result = resourceManager.findResourceComposites(EnterpriseFacesContextUtility.getSubject(), null, null, null, null, pref, true, pc);
- return resourceManager.disambiguate(result, false, RESOURCE_ID_EXTRACTOR).getResolution(); + return resourceManager.disambiguate(result, RESOURCE_ID_EXTRACTOR, DefaultDisambiguationUpdateStrategies.getDefault()).getResolution(); } } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java index dbc0ffd..730755e 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java @@ -122,6 +122,7 @@ import org.rhq.enterprise.server.jaxb.adapter.ResourceListAdapter; import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal; import org.rhq.enterprise.server.operation.OperationManagerLocal; import org.rhq.enterprise.server.resource.disambiguation.DisambiguationPolicy; +import org.rhq.enterprise.server.resource.disambiguation.DisambiguationUpdateStrategy; import org.rhq.enterprise.server.resource.disambiguation.Disambiguator; import org.rhq.enterprise.server.resource.disambiguation.MutableDisambiguationReport; import org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies; @@ -2103,11 +2104,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage return (findChildResources(subject, parentResource, pageControl)); }
- public <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, boolean alwaysIncludeParent, - IntExtractor<? super T> extractor) { - //TODO the alwaysIncludeParents is obsolete and ignored - //DefaultDisambiguationUpdateStrategies strategy = DefaultDisambiguationUpdateStrategies.KEEP_PARENTS_TO_TOPMOST_SERVERS; - DefaultDisambiguationUpdateStrategies strategy = DefaultDisambiguationUpdateStrategies.KEEP_ALL_PARENTS; - return Disambiguator.disambiguate(results, strategy, extractor, entityManager); + public <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, IntExtractor<? super T> extractor, + DisambiguationUpdateStrategy updateStrategy) { + return Disambiguator.disambiguate(results, updateStrategy, extractor, entityManager); } } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java index 9ce98c3..448bb78 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java @@ -36,7 +36,6 @@ import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceError; import org.rhq.core.domain.resource.ResourceErrorType; import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite; import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary; import org.rhq.core.domain.resource.composite.ResourceComposite; @@ -51,6 +50,7 @@ import org.rhq.core.domain.resource.group.composite.AutoGroupComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.IntExtractor; +import org.rhq.enterprise.server.resource.disambiguation.DisambiguationUpdateStrategy; import org.rhq.enterprise.server.resource.disambiguation.Disambiguator; import org.rhq.enterprise.server.resource.group.ResourceGroupNotFoundException;
@@ -458,6 +458,6 @@ public interface ResourceManagerLocal { * @see Disambiguator#disambiguate(List, boolean, IntExtractor, javax.persistence.EntityManager) * @return the disambiguation result or null on error */ - <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, boolean alwayIncludeParent, - IntExtractor<? super T> resourceIdExtractor); + <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, IntExtractor<? super T> resourceIdExtractor, + DisambiguationUpdateStrategy updateStrategy); } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DefaultDisambiguationUpdateStrategies.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DefaultDisambiguationUpdateStrategies.java index c5553e3..c11c3dd 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DefaultDisambiguationUpdateStrategies.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DefaultDisambiguationUpdateStrategies.java @@ -180,4 +180,8 @@ public enum DefaultDisambiguationUpdateStrategies implements DisambiguationUpdat resource.resourceType.plugin = null; } } + + public static DefaultDisambiguationUpdateStrategies getDefault() { + return DefaultDisambiguationUpdateStrategies.KEEP_ALL_PARENTS; + } } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java index c2a11a6..4674c1e 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java @@ -27,6 +27,10 @@ import java.util.EnumSet;
/** * Defines a strategy for updating a results list with the disambiguation information. + * <p> + * See {@link DefaultDisambiguationUpdateStrategies} for a couple of implemented strategies. + * + * @see DefaultDisambiguationUpdateStrategies * * @author Lukas Krejci */
commit 80b360465252621770543e6ee4d7b790ab856f03 Author: Lukas Krejci lkrejci@redhat.com Date: Wed May 19 15:19:35 2010 +0200
removing the deprecated methods from ResourceNamesDisambiguationResult + adapted quick search in menu to use the new style disambig.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java index 6d9b93a..197378d 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java @@ -136,16 +136,6 @@ public class DisambiguationReport<T> implements Serializable { return parents; }
- @Deprecated - public String getResourceTypeName() { - return resourceType.getName(); - } - - @Deprecated - public String getResourceTypePluginName() { - return resourceType.getPlugin(); - } - /** * @return the ResourceType of the resource represented by the {@link #getOriginal()} * or null if type disambiguation isn't needed. diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java index a12053f..4578aee 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java @@ -38,19 +38,9 @@ public class ResourceNamesDisambiguationResult<T> implements Serializable { private static final long serialVersionUID = 1L;
private List<DisambiguationReport<T>> resolution; - @Deprecated - private boolean typeResolutionNeeded; - @Deprecated - private boolean pluginResolutionNeeded; - @Deprecated - private boolean parentResolutionNeeded;
- public ResourceNamesDisambiguationResult(List<DisambiguationReport<T>> resolution, boolean needsTypeResolution, - boolean needsParentResolution, boolean needsPluginResolution) { + public ResourceNamesDisambiguationResult(List<DisambiguationReport<T>> resolution) { this.resolution = resolution; - this.parentResolutionNeeded = needsParentResolution; - this.typeResolutionNeeded = needsTypeResolution; - this.pluginResolutionNeeded = needsPluginResolution; }
/** @@ -62,35 +52,7 @@ public class ResourceNamesDisambiguationResult<T> implements Serializable { return resolution; }
- /** - * This tells the caller whether the result set contained resources with different types. - */ - @Deprecated - public boolean isTypeResolutionNeeded() { - return typeResolutionNeeded; - } - - /** - * This is true when the resources come from different parents. - */ - @Deprecated - public boolean isParentResolutionNeeded() { - return parentResolutionNeeded; - } - - /** - * This is true if the results contained resources of different types with the same name. - * In that case, the types need to be augmented with the plugin they come from. - */ - @Deprecated - public boolean isPluginResolutionNeeded() { - return pluginResolutionNeeded; - } - public String toString() { - return "ResourceNamesDisambiguationResult(typeResolutionNeeded=" + typeResolutionNeeded + - ", parentResolutionNeeded=" + parentResolutionNeeded + - ", pluginResolutionNeeded=" + pluginResolutionNeeded + - ", resolution=" + resolution + ")"; + return "ResourceNamesDisambiguationResult(resolution=" + resolution + ")"; } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java index d799ec2..36c7f88 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/ResourceNameDisambiguatingPagedListDataModel.java @@ -45,9 +45,6 @@ import org.rhq.enterprise.server.util.LookupUtil; public abstract class ResourceNameDisambiguatingPagedListDataModel<T> extends PagedListDataModel<DisambiguationReport<T>> {
- private boolean currentPageNeedsTypeResolution; - private boolean currentPageNeedsPluginResolution; - private boolean currentPageNeedsParentResolution; private boolean alwaysIncludeParents;
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager(); @@ -70,39 +67,11 @@ public abstract class ResourceNameDisambiguatingPagedListDataModel<T> extends ResourceNamesDisambiguationResult<T> disambiguation = resourceManager.disambiguate(data, alwaysIncludeParents, getResourceIdExtractor());
- currentPageNeedsParentResolution = disambiguation.isParentResolutionNeeded(); - currentPageNeedsPluginResolution = disambiguation.isPluginResolutionNeeded(); - currentPageNeedsTypeResolution = disambiguation.isTypeResolutionNeeded(); - return new PageList<DisambiguationReport<T>>(disambiguation.getResolution(), data.getTotalSize(), data .getPageControl()); }
/** - * @return true if the current page contains resources that need parent resolution - * in order to become uniquely named. - */ - public boolean isCurrentPageNeedsParentResolution() { - return currentPageNeedsParentResolution; - } - - /** - * @return true if the current page contains resources of types that have the same name - * and thus need to resolve those types using their plugin names. - */ - public boolean isCurrentPageNeedsPluginResolution() { - return currentPageNeedsPluginResolution; - } - - /** - * @return true if the current page contains resources that need type resolution - * in order to become uniquely named. - */ - public boolean isCurrentPageNeedsTypeResolution() { - return currentPageNeedsTypeResolution; - } - - /** * This method is to be implemented by inheritors and is called to fetch the actual data * that contain the resources to disambiguate. * diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java index eefb034..6b80cd4 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java @@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.inventory.resource;
import javax.faces.component.UIComponentBase; +import javax.faces.context.FacesContext;
import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.gui.util.FacesComponentUtility; @@ -77,16 +78,17 @@ public class DisambiguatedResourceNameComponent extends UIComponentBase { this.resourceName = resourceName; }
- public boolean isNameAsLink() { + public Boolean getNameAsLink() { if (nameAsLink == null) { - Boolean ret = FacesComponentUtility.getExpressionAttribute(this, NAME_AS_LINK_ATTRIBUTE, Boolean.class); - return ret == null ? true : ret; - } else { - return nameAsLink; + nameAsLink = FacesComponentUtility.getExpressionAttribute(this, NAME_AS_LINK_ATTRIBUTE, Boolean.class); + if (nameAsLink == null) { + nameAsLink = true; + } } + return nameAsLink; }
- public void setNameAsLink(boolean nameAsLink) { + public void setNameAsLink(Boolean nameAsLink) { this.nameAsLink = nameAsLink; }
@@ -102,4 +104,17 @@ public class DisambiguatedResourceNameComponent extends UIComponentBase { public void setResourceId(int resourceId) { this.resourceId = resourceId; } + + public Object saveState(FacesContext facesContext) { + Object[] state = new Object[2]; + state[0] = super.saveState(facesContext); + state[1] = this.nameAsLink; + return state; + } + + public void restoreState(FacesContext facesContext, Object stateValues) { + Object[] state = (Object[]) stateValues; + super.restoreState(facesContext, state[0]); + this.nameAsLink = (Boolean) state[1]; + } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameRenderer.java index 07c7ecd..286d063 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameRenderer.java @@ -53,7 +53,7 @@ public class DisambiguatedResourceNameRenderer extends Renderer {
DisambiguationReport.Resource resource = new DisambiguationReport.Resource(resourceId, resourceName, resourceType);
- if (nameComponent.isNameAsLink()) { + if (nameComponent.getNameAsLink()) { DisambiguatedResourceLineageRenderer.encodeUrl(writer, resource); } else { DisambiguatedResourceLineageRenderer.encodeSimple(writer, resource); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java index 74ae826..1ce8845 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java @@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFactory; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; import org.rhq.core.domain.util.PageControl; import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; @@ -53,39 +52,6 @@ public class ResourceSelectUIBean { } };
- public static class DisambiguationReportWrapper extends DisambiguationReport<ResourceComposite> { - private static final long serialVersionUID = 1L; - - private boolean typeResolutionNeeded; - private boolean parentResolutionNeeded; - private boolean pluginResolutionNeeded; - - /** - * @param original - * @param parents - * @param resourceTypeName - * @param resourceTypePluginName - */ - public DisambiguationReportWrapper(DisambiguationReport<ResourceComposite> report, boolean typeResolutionNeeded, boolean parentResolutionNeeded, boolean pluginResolutionNeeded) { - super(report.getOriginal(), report.getParents(), report.getResourceType()); - this.typeResolutionNeeded = typeResolutionNeeded; - this.parentResolutionNeeded = parentResolutionNeeded; - this.pluginResolutionNeeded = pluginResolutionNeeded; - } - - public boolean isTypeResolutionNeeded() { - return typeResolutionNeeded; - } - - public boolean isParentResolutionNeeded() { - return parentResolutionNeeded; - } - - public boolean isPluginResolutionNeeded() { - return pluginResolutionNeeded; - } - } - public Resource getResource() { return resource; } @@ -102,7 +68,7 @@ public class ResourceSelectUIBean { this.searchString = searchString; }
- public List<DisambiguationReportWrapper> autocomplete(Object suggest) { + public List<DisambiguationReport<ResourceComposite>> autocomplete(Object suggest) { String pref = (String) suggest; ArrayList<ResourceComposite> result;
@@ -112,24 +78,6 @@ public class ResourceSelectUIBean { result = resourceManager.findResourceComposites(EnterpriseFacesContextUtility.getSubject(), null, null, null, null, pref, true, pc);
- return wrap(resourceManager.disambiguate(result, false, RESOURCE_ID_EXTRACTOR)); - } - - private List<DisambiguationReportWrapper> wrap(ResourceNamesDisambiguationResult<ResourceComposite> result) { - List<DisambiguationReportWrapper> ret = new ArrayList<DisambiguationReportWrapper>(); - if (result == null) { - return ret; - } - - boolean typeRes = result.isTypeResolutionNeeded(); - boolean parentRes = result.isParentResolutionNeeded(); - boolean pluginRes = result.isPluginResolutionNeeded(); - - - for (DisambiguationReport<ResourceComposite> r : result.getResolution()) { - ret.add(new DisambiguationReportWrapper(r, typeRes, parentRes, pluginRes)); - } - - return ret; + return resourceManager.disambiguate(result, false, RESOURCE_ID_EXTRACTOR).getResolution(); } } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml index ab5ece0..f7bbaa9 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml @@ -6,7 +6,8 @@ xmlns:onf="http://jboss.org/on/function" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.ajax4jsf.org/rich" - xmlns:a4j="http://richfaces.org/a4j%22%3E + xmlns:a4j="http://richfaces.org/a4j" + xmlns:onc="http://jboss.org/on/component%22%3E
<h:form>
@@ -163,11 +164,12 @@ </h:column> <h:column> <f:facet name="header">Resource</f:facet> - <h:outputText value="#{result.original.resource.name}"/> + <onc:disambiguatedResourceName resourceName="#{result.original.resource.name}" + resourceId="#{result.original.resource.id}" nameAsLink="false" disambiguationReport="#{result}"/> </h:column> <h:column> - <f:facet name="header">Parent</f:facet> - <h:outputText value="#{result.original.parent.name}"/> + <f:facet name="header">Location</f:facet> + <onc:disambiguatedResourceLineage parents="#{result.parents}" renderLinks="false"/> </h:column> </rich:suggestionbox> </h:panelGroup> diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java index 42d62f2..7adc22e 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java @@ -46,6 +46,31 @@ public class Disambiguator {
public static final int MAXIMUM_DISAMBIGUATED_TREE_DEPTH = 7;
+ private static final String PARENT_INFO_QUERY; + + static { + StringBuilder selectBuilder = new StringBuilder( + "SELECT r0.id, r0.name, r0.resourceType.id, r0.resourceType.name, r0.resourceType.plugin, r0.resourceType.singleton"); + StringBuilder fromBuilder = new StringBuilder("FROM Resource r0"); + + for (int i = 1; i <= MAXIMUM_DISAMBIGUATED_TREE_DEPTH; ++i) { + int pi = i - 1; + selectBuilder.append(", r").append(i).append(".id"); + selectBuilder.append(", r").append(i).append(".name"); + selectBuilder.append(", rt").append(i).append(".id"); + selectBuilder.append(", rt").append(i).append(".name"); + selectBuilder.append(", rt").append(i).append(".plugin"); + selectBuilder.append(", rt").append(i).append(".singleton"); + + fromBuilder.append(" left join r").append(pi).append(".parentResource r").append(i); + fromBuilder.append(" left join r").append(i).append(".resourceType rt").append(i); + } + + fromBuilder.append(" WHERE r0.id IN (:resourceIds)"); + + PARENT_INFO_QUERY = selectBuilder.append(" ").append(fromBuilder).toString(); + } + private Disambiguator() {
} @@ -77,15 +102,9 @@ public class Disambiguator { EntityManager entityManager) {
if (results.isEmpty()) { - return new ResourceNamesDisambiguationResult<T>(new ArrayList<DisambiguationReport<T>>(), false, false, - false); + return new ResourceNamesDisambiguationResult<T>(new ArrayList<DisambiguationReport<T>>()); }
- //this is obsolete - boolean typeResolutionNeeded = true; - boolean pluginResolutionNeeded = true; - boolean parentResolutionNeeded = true; - //we can't assume the ordering of the provided results and the disambiguation query results //will be the same.
@@ -113,26 +132,7 @@ public class Disambiguator { //check that we still have something to disambiguate if (reportsByResourceId.size() > 0) { //k, now let's construct the JPQL query to get the parents and type infos... - StringBuilder selectBuilder = new StringBuilder( - "SELECT r0.id, r0.name, r0.resourceType.id, r0.resourceType.name, r0.resourceType.plugin, r0.resourceType.singleton"); - StringBuilder fromBuilder = new StringBuilder("FROM Resource r0"); - - for (int i = 1; i <= MAXIMUM_DISAMBIGUATED_TREE_DEPTH; ++i) { - int pi = i - 1; - selectBuilder.append(", r").append(i).append(".id"); - selectBuilder.append(", r").append(i).append(".name"); - selectBuilder.append(", rt").append(i).append(".id"); - selectBuilder.append(", rt").append(i).append(".name"); - selectBuilder.append(", rt").append(i).append(".plugin"); - selectBuilder.append(", rt").append(i).append(".singleton"); - - fromBuilder.append(" left join r").append(pi).append(".parentResource r").append(i); - fromBuilder.append(" left join r").append(i).append(".resourceType rt").append(i); - } - - fromBuilder.append(" WHERE r0.id IN (:resourceIds)"); - - Query parentsQuery = entityManager.createQuery(selectBuilder.append(" ").append(fromBuilder).toString()); + Query parentsQuery = entityManager.createQuery(PARENT_INFO_QUERY);
parentsQuery.setParameter("resourceIds", reportsByResourceId.keySet());
@@ -246,8 +246,7 @@ public class Disambiguator { resolution.add(report.getReport()); }
- return new ResourceNamesDisambiguationResult<T>(resolution, typeResolutionNeeded, parentResolutionNeeded, - pluginResolutionNeeded); + return new ResourceNamesDisambiguationResult<T>(resolution); }
private static <T> void repartitionUnique(ReportPartitions<T> partitions, DisambiguationUpdateStrategy updateStrategy, List<ReportPartitions<T>> ambigousPartitions) {
commit 84ffd30343640f9b66d238b8e85a7ccab756e08b Author: Lukas Krejci lkrejci@redhat.com Date: Wed May 19 13:24:31 2010 +0200
portlets as well as the JSF based pages should work now with the new style disambiguation.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java index bb61ae6..60f5031 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java @@ -75,14 +75,14 @@ public class DisambiguatedResourceLineageRenderer extends Renderer { encodePreName(writer, parent); writer.startElement("a", null); writer.writeAttribute("href", getUrl(parent), null); - writer.writeText(parent.getName(), null); + writeName(writer, parent); writer.endElement("a"); encodePostName(writer, parent); }
public static void encodeSimple(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { encodePreName(writer, parent); - writer.writeText(parent.getName(), null); + writeName(writer, parent); encodePostName(writer, parent); }
@@ -92,21 +92,37 @@ public class DisambiguatedResourceLineageRenderer extends Renderer {
private static void encodePreName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { if (!parent.getType().isSingleton()) { + writer.startElement("span", null); + writer.writeAttribute("class", "disambiguated-resource-type", null); writer.writeText(parent.getType().getName(), null); writer.writeText(" ", null); if (parent.getType().getPlugin() != null) { + writer.startElement("span", null); + writer.writeAttribute("class", "disambiguated-resource-plugin", null); writer.writeText("(", null); writer.writeText(parent.getType().getPlugin(), null); writer.writeText(" plugin) ", null); + writer.endElement("span"); } + writer.endElement("span"); } }
private static void encodePostName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { if (parent.getType().isSingleton() && parent.getType().getPlugin() != null) { + writer.startElement("span", null); + writer.writeAttribute("class", "disambiguated-resource-plugin", null); writer.writeText(" (", null); writer.writeText(parent.getType().getPlugin(), null); writer.writeText(" plugin) ", null); + writer.endElement("span"); } } + + private static void writeName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + writer.startElement("span", null); + writer.writeAttribute("class", "disambiguated-resource-name", null); + writer.writeText(parent.getName(), null); + writer.endElement("span"); + } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java index c52d2b9..9b05558 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java @@ -120,11 +120,8 @@ public class AddGroupResourcesFormPrepareAction extends Action { PageList<Resource> pendingResources = resourceManager.findResourceByIds(user, pendingResourceIds, true, pcPending);
- ResourceNamesDisambiguationResult<Resource> pendingResourcesDisambiguation = - resourceManager.disambiguate(pendingResources, true, RESOURCE_ID_EXTRACTOR); - - PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedpeningResources = - DisambiguatedResourceListUtil.buildResourceList(pendingResourcesDisambiguation, pendingResources.getTotalSize(), pendingResources.getPageControl(), false); + PageList<DisambiguationReport<Resource>> disambiguatedpeningResources = + DisambiguatedResourceListUtil.disambiguate(resourceManager, pendingResources, RESOURCE_ID_EXTRACTOR);
request.setAttribute(Constants.PENDING_RESOURCES_ATTR, disambiguatedpeningResources); request.setAttribute(Constants.NUM_PENDING_RESOURCES_ATTR, disambiguatedpeningResources.size()); @@ -152,11 +149,8 @@ public class AddGroupResourcesFormPrepareAction extends Action { + resourceGroup.getClass().getSimpleName() + " group type"); }
- ResourceNamesDisambiguationResult<Resource> availableResourcesDisambiguation = - resourceManager.disambiguate(availableResources, true, RESOURCE_ID_EXTRACTOR); - - PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedAvailResources = - DisambiguatedResourceListUtil.buildResourceList(availableResourcesDisambiguation, availableResources.getTotalSize(), availableResources.getPageControl(), false); + PageList<DisambiguationReport<Resource>> disambiguatedAvailResources = + DisambiguatedResourceListUtil.disambiguate(resourceManager, availableResources, RESOURCE_ID_EXTRACTOR);
request.setAttribute(Constants.AVAIL_RESOURCES_ATTR, disambiguatedAvailResources); request.setAttribute(Constants.NUM_AVAIL_RESOURCES_ATTR, disambiguatedAvailResources.size()); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java index fe1baf0..72d36e3 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java @@ -37,6 +37,7 @@ import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.gui.util.StringUtility; @@ -109,9 +110,8 @@ public class AddResourcesPrepareAction extends Action { PageList<Resource> pendingResources = resourceManager.findResourceByIds(subject, pendingResourceArray, false, pcPending);
- PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedPendingResources = - DisambiguatedResourceListUtil.buildResourceList(resourceManager.disambiguate(pendingResources, true, RESOURCE_ID_EXTRACTOR), - pendingResources.getTotalSize(), pendingResources.getPageControl(), false); + PageList<DisambiguationReport<Resource>> disambiguatedPendingResources = + DisambiguatedResourceListUtil.disambiguate(resourceManager, pendingResources, RESOURCE_ID_EXTRACTOR);
// give 'em to the jsp page log.debug("put selected page of pending resources in request"); @@ -131,11 +131,9 @@ public class AddResourcesPrepareAction extends Action { availableResources = resourceManager.findAvailableResourcesForDashboardPortlet(subject, typeIdFilter, categoryFilter, excludeIds, pcAvail);
- PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedAvailableResources = - DisambiguatedResourceListUtil.buildResourceList(resourceManager.disambiguate(availableResources, true, RESOURCE_ID_EXTRACTOR), - availableResources.getTotalSize(), availableResources.getPageControl(), false); - - + PageList<DisambiguationReport<Resource>> disambiguatedAvailableResources = + DisambiguatedResourceListUtil.disambiguate(resourceManager, availableResources, RESOURCE_ID_EXTRACTOR); + log.debug("put selected page of available resources in request"); request.setAttribute(Constants.AVAIL_RESOURCES_ATTR, disambiguatedAvailableResources); request.setAttribute(Constants.NUM_AVAIL_RESOURCES_ATTR, disambiguatedAvailableResources.getTotalSize()); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java index a59c02f..f258108 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java @@ -33,6 +33,7 @@ import org.rhq.core.domain.operation.composite.GroupOperationLastCompletedCompos import org.rhq.core.domain.operation.composite.GroupOperationScheduleComposite; import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite; import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposite; +import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.domain.util.PageOrdering; @@ -69,9 +70,9 @@ public class ViewAction extends TilesAction { boolean displayLastCompleted = false; boolean displayNextScheduled = false;
- PageList<DisambiguatedResourceListUtil.Record<ResourceOperationLastCompletedComposite>> disambiguatedLastCompletedResourceOps = new PageList<DisambiguatedResourceListUtil.Record<ResourceOperationLastCompletedComposite>>(); + PageList<DisambiguationReport<ResourceOperationLastCompletedComposite>> disambiguatedLastCompletedResourceOps = new PageList<DisambiguationReport<ResourceOperationLastCompletedComposite>>(); PageList<GroupOperationLastCompletedComposite> lastCompletedGroupOps = new PageList<GroupOperationLastCompletedComposite>(); - PageList<DisambiguatedResourceListUtil.Record<ResourceOperationScheduleComposite>> disambiguatedNextScheduledResourceOps = new PageList<DisambiguatedResourceListUtil.Record<ResourceOperationScheduleComposite>>(); + PageList<DisambiguationReport<ResourceOperationScheduleComposite>> disambiguatedNextScheduledResourceOps = new PageList<DisambiguationReport<ResourceOperationScheduleComposite>>(); PageList<GroupOperationScheduleComposite> nextScheduledGroupOps = new PageList<GroupOperationScheduleComposite>();
try { @@ -97,9 +98,8 @@ public class ViewAction extends TilesAction { PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = manager.findRecentlyCompletedResourceOperations(user.getSubject(), null, pageControl);
- disambiguatedLastCompletedResourceOps = DisambiguatedResourceListUtil.buildResourceList( - resourceManager.disambiguate(lastCompletedResourceOps, true, RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR), - lastCompletedResourceOps.getTotalSize(), lastCompletedResourceOps.getPageControl(), true); + disambiguatedLastCompletedResourceOps = DisambiguatedResourceListUtil.disambiguate( + resourceManager, lastCompletedResourceOps, RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR);
pageControl = new PageControl(0, operationPreferences.lastCompleted); pageControl.initDefaultOrderingField("go.createdTime", PageOrdering.DESC); @@ -112,9 +112,8 @@ public class ViewAction extends TilesAction { manager.findCurrentlyScheduledResourceOperations(user.getSubject(), pageControl);
- disambiguatedNextScheduledResourceOps = DisambiguatedResourceListUtil.buildResourceList( - resourceManager.disambiguate(nextScheduledResourceOps, true, RESOURCE_OPERATION_SCHEDULE_RESOURCE_ID_EXTRACTOR), - nextScheduledResourceOps.getTotalSize(), nextScheduledResourceOps.getPageControl(), true); + disambiguatedNextScheduledResourceOps = DisambiguatedResourceListUtil.disambiguate( + resourceManager, nextScheduledResourceOps, RESOURCE_OPERATION_SCHEDULE_RESOURCE_ID_EXTRACTOR);
pageControl = new PageControl(0, operationPreferences.nextScheduled); nextScheduledGroupOps = manager.findCurrentlyScheduledGroupOperations(user.getSubject(), pageControl); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java index b500a72..a0f94aa 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java @@ -30,6 +30,7 @@ import org.apache.struts.tiles.ComponentContext; import org.apache.struts.tiles.actions.TilesAction;
import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.IntExtractor; @@ -75,9 +76,8 @@ public class PrepareAction extends TilesAction { PageList<Resource> resources = resourceManager.findResourceByIds(user.getSubject(), alertPrefs.asArray(), false, pageControl);
- PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedResources = - DisambiguatedResourceListUtil.buildResourceList(resourceManager.disambiguate(resources, true, RESOURCE_ID_EXTRACTOR), - resources.getTotalSize(), resources.getPageControl(), false); + PageList<DisambiguationReport<Resource>> disambiguatedResources = + DisambiguatedResourceListUtil.disambiguate(resourceManager, resources, RESOURCE_ID_EXTRACTOR);
request.setAttribute("criticalAlertsList", disambiguatedResources); request.setAttribute("criticalAlertsTotalSize", disambiguatedResources.getTotalSize()); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java index 77da660..1d9b37b 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java @@ -31,6 +31,7 @@ import org.apache.struts.tiles.actions.TilesAction;
import org.rhq.core.domain.alert.Alert; import org.rhq.core.domain.alert.AlertPriority; +import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.IntExtractor; @@ -58,7 +59,7 @@ public class ViewAction extends TilesAction { public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- PageList<DisambiguatedResourceListUtil.Record<Alert>> disambiguatedAlerts = new PageList<DisambiguatedResourceListUtil.Record<Alert>>(); + PageList<DisambiguationReport<Alert>> disambiguatedAlerts = new PageList<DisambiguationReport<Alert>>(); try { WebUser user = SessionUtils.getWebUser(request.getSession()); if (user == null) { @@ -78,8 +79,7 @@ public class ViewAction extends TilesAction { : ArrayUtils.wrapInArray(alertPrefs.asArray())), AlertPriority.getByLegacyIndex(alertPrefs.priority), alertPrefs.timeRange, pageControl);
- disambiguatedAlerts = DisambiguatedResourceListUtil.buildResourceList(resourceManager.disambiguate(alerts, true, RESOURCE_ID_EXTRACTOR) - , alerts.getTotalSize(), alerts.getPageControl(), true); + disambiguatedAlerts = DisambiguatedResourceListUtil.disambiguate(resourceManager, alerts, RESOURCE_ID_EXTRACTOR); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Dashboard Portlet [CriticalAlerts] experienced an error: " + e.getMessage(), e); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java index 6fc3516..d4b38fb 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java @@ -36,6 +36,7 @@ import org.apache.struts.tiles.ComponentContext; import org.apache.struts.tiles.actions.TilesAction;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ProblemResourceComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; @@ -64,7 +65,7 @@ public class ViewAction extends TilesAction { public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- List<DisambiguatedResourceListUtil.Record<ProblemResourceComposite>> disambiguatedList = new ArrayList<DisambiguatedResourceListUtil.Record<ProblemResourceComposite>>(); + List<DisambiguationReport<ProblemResourceComposite>> disambiguatedList = new ArrayList<DisambiguationReport<ProblemResourceComposite>>();
String timeRange = getResources(request).getMessage("dash.home.ProblemResources.timeRangeUnlimited"); try { @@ -103,9 +104,8 @@ public class ViewAction extends TilesAction { PageList<ProblemResourceComposite> list = problemManager.findProblemResources(subject, begin, new PageControl(0, problemResourcePreferences.range));
- disambiguatedList = DisambiguatedResourceListUtil.buildResourceList( - resourceManager.disambiguate(list, true, RESOURCE_ID_EXTRACTOR), - list.getTotalSize(), list.getPageControl(), true); + disambiguatedList = DisambiguatedResourceListUtil.disambiguate( + resourceManager, list, RESOURCE_ID_EXTRACTOR);
long end = System.currentTimeMillis(); log.debug("Performance: Took [" + (end - start) + "]ms to find " + problemResourcePreferences.range diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java index aa6a17b..fb9be73 100755 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java @@ -18,6 +18,10 @@ */ package org.rhq.enterprise.gui.legacy.portlet.resourcehealth;
+import java.io.IOException; +import java.io.StringWriter; +import java.util.Iterator; + import javax.security.auth.login.LoginException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -41,6 +45,7 @@ import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.WebUserPreferences.FavoriteResourcePortletPreferences; import org.rhq.enterprise.gui.legacy.portlet.BaseRSSAction; import org.rhq.enterprise.gui.legacy.portlet.RSSFeed; +import org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceLineageTag; import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.util.LookupUtil; @@ -69,11 +74,9 @@ public class RSSAction extends BaseRSSAction { favoriteResourcePreferences.asArray(), PageControl.getUnlimitedInstance());
if ((results != null) && (results.size() > 0)) { - ResourceNamesDisambiguationResult<ResourceHealthComposite> disambiguatedLResults = manager.disambiguate(results, true, ViewAction.RESOURCE_ID_EXTRACTOR); - - PageList<DisambiguatedResourceListUtil.Record<ResourceHealthComposite>> list = DisambiguatedResourceListUtil.buildResourceList(disambiguatedLResults, results.getTotalSize(), results.getPageControl(), false); + PageList<DisambiguationReport<ResourceHealthComposite>> list = DisambiguatedResourceListUtil.disambiguate(manager, results, ViewAction.RESOURCE_ID_EXTRACTOR);
- for (DisambiguatedResourceListUtil.Record<ResourceHealthComposite> summary : list) { + for (DisambiguationReport<ResourceHealthComposite> summary : list) { String link = feed.getBaseUrl() + FunctionTagLibrary.getDefaultResourceTabURL() + "?id=" + summary.getOriginal().getId();
@@ -83,7 +86,7 @@ public class RSSAction extends BaseRSSAction { .getOriginal().getAlerts())); String typeText = res.getMessage("dash.home.ResourceHealth.rss.item.resourceType", summary .getOriginal().getTypeName()); - String parentsText = res.getMessage("dash.home.ResourceHealth.rss.item.resourceParents", summary.getLineage()); + String parentsText = res.getMessage("dash.home.ResourceHealth.rss.item.resourceParents", getLineage(summary));
long now = System.currentTimeMillis();
@@ -112,6 +115,15 @@ public class RSSAction extends BaseRSSAction { } else { throw new LoginException("RSS access requires authentication"); } - + } + + private static String getLineage(DisambiguationReport<?> report) { + StringWriter writer = new StringWriter(); + try { + DisambiguatedResourceLineageTag.writeParents(writer, report.getParents(), false, false); + return writer.toString(); + } catch (IOException e) { + return ""; + } } } \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java index 7db8562..7a1a824 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java @@ -59,7 +59,7 @@ public class ViewAction extends TilesAction { public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- PageList<DisambiguatedResourceListUtil.Record<ResourceHealthComposite>> list = new PageList<DisambiguatedResourceListUtil.Record<ResourceHealthComposite>>(); + PageList<DisambiguationReport<ResourceHealthComposite>> list = new PageList<DisambiguationReport<ResourceHealthComposite>>(); boolean showAvailability = true; boolean showAlerts = true; try { @@ -78,9 +78,7 @@ public class ViewAction extends TilesAction { ResourceManagerLocal manager = LookupUtil.getResourceManager(); PageList<ResourceHealthComposite> lst = manager.findResourceHealth(user.getSubject(), favoriteResourcePreferences.asArray(), pc);
- ResourceNamesDisambiguationResult<ResourceHealthComposite> disambiguatedList = manager.disambiguate(lst, true, RESOURCE_ID_EXTRACTOR); - - list = DisambiguatedResourceListUtil.buildResourceList(disambiguatedList, lst.getTotalSize(), lst.getPageControl(), true); + list = DisambiguatedResourceListUtil.disambiguate(manager, lst, RESOURCE_ID_EXTRACTOR);
showAvailability = favoriteResourcePreferences.showAvailability; showAlerts = favoriteResourcePreferences.showAlerts; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageDecorator.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageDecorator.java new file mode 100644 index 0000000..1c860b3 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageDecorator.java @@ -0,0 +1,77 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.legacy.taglib.display; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.List; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; + +/** + * The same as {@link DisambiguatedResourceLineageTag} but for use inside + * display:column. + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceLineageDecorator extends BaseDecorator { + + private List<DisambiguationReport.Resource> parents; + private Boolean renderLinks; + + public List<DisambiguationReport.Resource> getParents() { + return parents; + } + + public void setParents(List<DisambiguationReport.Resource> parents) { + this.parents = parents; + } + + public Boolean getRenderLinks() { + return renderLinks; + } + + public void setRenderLinks(Boolean renderLinks) { + this.renderLinks = renderLinks; + } + + @SuppressWarnings("unchecked") + public String decorate(Object obj) { + List<DisambiguationReport.Resource> parents = getParents(); + if (parents == null) { + parents = (List<DisambiguationReport.Resource>) obj; + } + + try { + StringWriter writer = new StringWriter(); + boolean renderLinks = this.renderLinks == null || this.renderLinks; + + DisambiguatedResourceLineageTag.writeParents(writer, parents, renderLinks, true); + return writer.toString(); + } catch (IOException e) { + return null; + } + } + +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageTag.java index 77e49d8..3088a62 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageTag.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageTag.java @@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.legacy.taglib.display;
import java.io.IOException; +import java.io.Writer; import java.util.Iterator; import java.util.List;
@@ -67,20 +68,8 @@ public class DisambiguatedResourceLineageTag extends TagSupport { JspWriter writer = pageContext.getOut();
try { - if (parents != null && parents.size() > 0) { - - Iterator<DisambiguationReport.Resource> it = parents.iterator(); - DisambiguationReport.Resource parent = it.next(); - DisambiguatedResourceNameTag.writeResource(writer, renderLinks, parent.getId(), parent.getName(), - parent.getType()); - - while (it.hasNext()) { - writer.append(DisambiguatedResourceLineageComponent.DEFAULT_SEPARATOR); - parent = it.next(); - DisambiguatedResourceNameTag.writeResource(writer, renderLinks, parent.getId(), parent.getName(), - parent.getType()); - } - } + boolean renderLinks = this.renderLinks == null || this.renderLinks; + writeParents(writer, parents, renderLinks, true);
return super.doEndTag(); } catch (IOException e) { @@ -88,4 +77,24 @@ public class DisambiguatedResourceLineageTag extends TagSupport { } }
+ private static String getUrl(DisambiguationReport.Resource resource) { + return DisambiguatedResourceNameTag.getDefaultResourceUrl(resource.getId()); + } + + public static void writeParents(Writer writer, List<DisambiguationReport.Resource> parents, boolean renderLinks, boolean htmlOuptut) throws IOException { + if (parents != null && parents.size() > 0) { + + Iterator<DisambiguationReport.Resource> it = parents.iterator(); + DisambiguationReport.Resource parent = it.next(); + DisambiguatedResourceNameTag.writeResource(writer, renderLinks ? getUrl(parent) : null, parent.getName(), + parent.getType(), htmlOuptut); + + while (it.hasNext()) { + writer.append(DisambiguatedResourceLineageComponent.DEFAULT_SEPARATOR); + parent = it.next(); + DisambiguatedResourceNameTag.writeResource(writer, renderLinks ? getUrl(parent) : null, parent.getName(), + parent.getType(), htmlOuptut); + } + } + } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameDecorator.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameDecorator.java new file mode 100644 index 0000000..1bd3fbc --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameDecorator.java @@ -0,0 +1,110 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.legacy.taglib.display; + +import java.io.IOException; +import java.io.StringWriter; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; + +/** + * For use in display:column elements + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceNameDecorator extends BaseDecorator { + + private int resourceId; + private String resourceName; + private String url; + private Boolean nameAsLink; + private DisambiguationReport<?> disambiguationReport; + + public int getResourceId() { + return resourceId; + } + + public void setResourceId(int resourceId) { + this.resourceId = resourceId; + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Boolean getNameAsLink() { + return nameAsLink; + } + + public void setNameAsLink(Boolean nameAsLink) { + this.nameAsLink = nameAsLink; + } + + public DisambiguationReport<?> getDisambiguationReport() { + return disambiguationReport; + } + + public void setDisambiguationReport(DisambiguationReport<?> disambiguationReport) { + this.disambiguationReport = disambiguationReport; + } + + public String decorate(Object obj) { + DisambiguationReport<?> report = getDisambiguationReport(); + if (report == null) { + report = (DisambiguationReport<?>) obj; + } + + try { + //default to true + boolean renderLink = nameAsLink == null || nameAsLink.booleanValue(); + + String renderedUrl = null; + if (renderLink) { + renderedUrl = this.url; + if (renderedUrl == null) { + renderedUrl = DisambiguatedResourceNameTag.getDefaultResourceUrl(resourceId); + } + } + + StringWriter writer = new StringWriter(); + DisambiguatedResourceNameTag.writeResource(writer, renderedUrl, resourceName, report.getResourceType(), true); + + return writer.toString(); + } catch (IOException e) { + return null; + } + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java index 240f4f8..1077aab 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java @@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.legacy.taglib.display;
import java.io.IOException; +import java.io.Writer;
import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspTagException; @@ -40,18 +41,19 @@ import org.rhq.core.domain.resource.composite.DisambiguationReport; public class DisambiguatedResourceNameTag extends TagSupport {
private static final long serialVersionUID = 1L; - - private DisambiguationReport<?> disambiguatedReport; + + private DisambiguationReport<?> disambiguationReport; private String resourceName; private Integer resourceId; private Boolean nameAsLink; + private String url;
- public DisambiguationReport<?> getDisambiguatedReport() { - return disambiguatedReport; + public DisambiguationReport<?> getDisambiguationReport() { + return disambiguationReport; }
- public void setDisambiguatedReport(DisambiguationReport<?> disambiguatedReport) { - this.disambiguatedReport = disambiguatedReport; + public void setDisambiguationReport(DisambiguationReport<?> disambiguationReport) { + this.disambiguationReport = disambiguationReport; }
public String getResourceName() { @@ -70,6 +72,14 @@ public class DisambiguatedResourceNameTag extends TagSupport { this.resourceId = resourceId; }
+ public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + public Boolean getNameAsLink() { return nameAsLink; } @@ -83,47 +93,83 @@ public class DisambiguatedResourceNameTag extends TagSupport { JspWriter writer = pageContext.getOut();
try { - if (disambiguatedReport != null) { + if (disambiguationReport != null) {
- DisambiguationReport.ResourceType resourceType = disambiguatedReport.getResourceType(); + DisambiguationReport.ResourceType resourceType = disambiguationReport.getResourceType();
//default to true boolean renderLink = nameAsLink == null || nameAsLink.booleanValue();
- writeResource(writer, renderLink, resourceId, resourceName, resourceType); + String renderedUrl = null; + if (renderLink) { + renderedUrl = this.url; + if (renderedUrl == null) { + renderedUrl = getDefaultResourceUrl(resourceId); + } + } + writeResource(writer, renderedUrl, resourceName, resourceType, true); } - + return super.doEndTag(); } catch (IOException e) { throw new JspTagException(e); } } - - public static void writeResource(JspWriter writer, boolean renderLink, int resourceId, String resourceName, DisambiguationReport.ResourceType resourceType) throws IOException { + + public static void writeResource(Writer writer, String url, String resourceName, + DisambiguationReport.ResourceType resourceType, boolean htmlOutput) throws IOException { if (!resourceType.isSingleton()) { - writer.append(resourceType.getName()).append(" "); + if (htmlOutput) { + writer.append("<span class="disambiguated-resource-type">"); + }
+ writer.append(resourceType.getName()).append(" "); + if (resourceType.getPlugin() != null) { - writer.append("(").append(resourceType.getPlugin()) - .append(" plugin) "); + if (htmlOutput) { + writer.append("<span class="disambiguated-resource-plugin">"); + } + writer.append("(").append(resourceType.getPlugin()).append(" plugin) "); + if (htmlOutput) { + writer.append("</span>"); + } + } + + if (htmlOutput) { + writer.append("</span>"); } } - - if (renderLink) { - writer.append("<a href="/rhq/resource/summary/overview.xhtml?id="); - writer.print(resourceId); - writer.append("">"); + + if (url != null) { + writer.append("<a href="").append(url).append("">"); + } + + if (htmlOutput) { + writer.append("<span class="disambiguated-resource-name">"); } - writer.append(resourceName); - - if (renderLink) { - writer.append("</a>"); + if (htmlOutput) { + writer.append("</span>"); }
+ if (url != null) { + writer.append("</a>"); + } + if (resourceType.isSingleton() && resourceType.getPlugin() != null) { - writer.append(" ").append(resourceType.getPlugin()) - .append(" plugin)"); + if (htmlOutput) { + writer.append("<span class="disambiguated-resource-plugin">"); + } + + writer.append(" (").append(resourceType.getPlugin()).append(" plugin)"); + + if (htmlOutput) { + writer.append("</span>"); + } } } + + public static String getDefaultResourceUrl(int resourceId) { + return "/rhq/resource/summary/overview.xhtml?id=" + resourceId; + } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java index 24a373a..0837143 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java @@ -23,16 +23,11 @@
package org.rhq.enterprise.gui.legacy.util;
-import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; -import org.rhq.core.domain.resource.composite.ResourceParentFlyweight; -import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageComponent; +import org.rhq.core.util.IntExtractor; +import org.rhq.enterprise.server.resource.ResourceManagerLocal;
/** * A utility class to provide page lists of disambiguated resource lists for the @@ -42,79 +37,12 @@ import org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageComponent */ public class DisambiguatedResourceListUtil {
- private static final String RESOURCE_URL = "/rhq/resource/summary/overview.xhtml"; - private DisambiguatedResourceListUtil() {
}
- public static class Record<T> { - - private T original; - private String lineage; - private String originalResourceTypeName; - - public Record(T original, String resourceTypeName, String lineage) { - this.original = original; - this.lineage = lineage; - this.originalResourceTypeName = resourceTypeName; - } - - public T getOriginal() { - return original; - } - - public String getLineage() { - return lineage; - } - - public String getOriginalResourceTypeName() { - return originalResourceTypeName; - } - } - - public static <T> PageList<Record<T>> buildResourceList(ResourceNamesDisambiguationResult<T> results, int totalSize, PageControl pageControl, boolean renderLinks) { - ArrayList<Record<T>> convertedResults = new ArrayList<Record<T>>(results.getResolution().size()); - - for(DisambiguationReport<T> dr : results.getResolution()) { - String typeName = dr.getResourceTypeName(); - if (results.isPluginResolutionNeeded()) { - typeName += " (" + dr.getResourceTypePluginName() + " plugin)"; - } - convertedResults.add(new Record<T>(dr.getOriginal(), typeName, buildLineage(dr.getParents(), renderLinks))); - } - return new PageList<Record<T>>(convertedResults, totalSize, pageControl); - } - - private static String buildLineage(List<ResourceParentFlyweight> parents, boolean renderLinks) { - if (parents == null || parents.size() == 0) { - return ""; - } - - Iterator<ResourceParentFlyweight> it = parents.iterator(); - - StringBuilder bld = new StringBuilder(); - - appendParentName(bld, it.next(), renderLinks); - - while (it.hasNext()) { - bld.append(ResourcePartialLineageComponent.DEFAULT_SEPARATOR); - appendParentName(bld, it.next(), renderLinks); - } - - return bld.toString(); - } - - private static void appendParentName(StringBuilder bld, ResourceParentFlyweight parent, boolean renderLinks) { - if (renderLinks) { - bld.append("<a href="").append(RESOURCE_URL).append("?id=").append(parent.getParentId()) - .append("">"); - } - - bld.append(parent.getParentName()); - - if (renderLinks) { - bld.append("</a>"); - } + public static <T> PageList<DisambiguationReport<T>> disambiguate(ResourceManagerLocal resourceManager, PageList<T> results, IntExtractor<T> resourceIdExtractor) { + ResourceNamesDisambiguationResult<T> result = resourceManager.disambiguate(results, true, resourceIdExtractor); + return new PageList<DisambiguationReport<T>>(result.getResolution(), results.getTotalSize(), results.getPageControl()); } } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld index eefd1e1..2d7fe8e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld @@ -893,7 +893,7 @@ <tag> <name>disambiguatedResourceName</name> <tag-class>org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceNameTag</tag-class> - <body-content>JSP</body-content> + <body-content>empty</body-content> <attribute> <name>disambiguationReport</name> <required>true</required> @@ -908,11 +908,17 @@ </attribute> <attribute> <name>resourceId</name> - <required>true</required> + <required>false</required> <rtexprvalue>true</rtexprvalue> <type>Integer</type> </attribute> <attribute> + <name>url</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>String</type> + </attribute> + <attribute> <name>nameAsLink</name> <required>false</required> <rtexprvalue>false</rtexprvalue> @@ -923,7 +929,61 @@ <tag> <name>disambiguatedResourceLineage</name> <tag-class>org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceLineageTag</tag-class> - <body-content>JSP</body-content> + <body-content>empty</body-content> + <attribute> + <name>parents</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>java.util.List</type> + </attribute> + <attribute> + <name>renderLinks</name> + <required>false</required> + <rtexprvalue>false</rtexprvalue> + <type>Boolean</type> + </attribute> + </tag> + + <tag> + <name>disambiguatedResourceNameDecorator</name> + <tag-class>org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceNameDecorator</tag-class> + <body-content>empty</body-content> + <attribute> + <name>disambiguationReport</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>org.rhq.core.domain.resource.composite.DisambiguationReport</type> + </attribute> + <attribute> + <name>resourceName</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>String</type> + </attribute> + <attribute> + <name>resourceId</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>Integer</type> + </attribute> + <attribute> + <name>url</name> + <required>false</required> + <rtexprvalue>true</rtexprvalue> + <type>String</type> + </attribute> + <attribute> + <name>nameAsLink</name> + <required>false</required> + <rtexprvalue>false</rtexprvalue> + <type>Boolean</type> + </attribute> + </tag> + + <tag> + <name>disambiguatedResourceLineageDecorator</name> + <tag-class>org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceLineageDecorator</tag-class> + <body-content>empty</body-content> <attribute> <name>parents</name> <required>true</required> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css b/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css index 76d051e..6859fe2 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css +++ b/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css @@ -2371,3 +2371,17 @@ ul.radio-group .unspecified { .rich-tree-h-ic-img, .rich-tree-node-handleicon-collapsed, .rich-tree-node-handleicon-expanded { cursor:pointer; } + +/* Disambiguated resources formatting */ +.disambiguated-resource-type { + font-style: italic; +} + +.disambiguated-resource-plugin { + font-style: italic; +} + +.disambiguated-resource-name { +} + + diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp index 35e9965..661008f 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp @@ -338,7 +338,6 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') </html:select>
</td> - <td><html:img page="/images/spacer.gif" width="5" height="30" border="0"/></td> </tr> </table> </td> @@ -366,21 +365,22 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') items="${AvailableResources}" var="item" padRows="true" - rightSidebar="true" + rightSidebar="true" styleId="fromTable" postfix="a" > <display:column width="1%" property="original.id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="fromToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> <display:checkboxdecorator name="availableResources" onclick="ToggleSelection(this, widgetProperties)" styleClass="availableListMember"/> </display:column> - <display:column property="original.name" title="common.header.ResourceName" - width="30%" - sortAttr="res.name" /> - <display:column property="original.resourceType.name" title="resource.group.inventory.TypeTH" - width="39%" - sortAttr="res.resourceType.name" > + <display:column title="common.header.ResourceName" + width="49%" + sortAttr="res.name"> + + <display:disambiguatedResourceNameDecorator resourceName="${item.original.name}" disambiguationReport="${item}" nameAsLink="false"/> </display:column> - <display:column property="lineage" title="resource.group.inventory.ParentTH" - width="30%" /> + <display:column title="resource.group.inventory.ParentTH" + width="50%"> + <display:disambiguatedResourceLineageDecorator parents="${item.parents}" renderLinks="false" /> + </display:column>
</display:table> </div> @@ -415,7 +415,7 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') <display:table cellpadding="0" cellspacing="0" border="0" width="100%" action="${selfPpAction}" items="${PendingResources}" - var="resource" + var="item" padRows="true" leftSidebar="true" styleId="toTable" @@ -423,15 +423,15 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') <display:column width="1%" property="original.id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="toToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> <display:checkboxdecorator name="pendingResources" onclick="ToggleSelection(this, widgetProperties)" styleClass="pendingListMember"/> </display:column> - <display:column property="original.name" title="common.header.ResourceName" - width="30%" - sortAttr="res.name" /> - <display:column property="original.resourceType.name" title="resource.group.inventory.TypeTH" - width="39%" - sortAttr="res.resourceType.name" > - </display:column> - <display:column property="lineage" title="resource.group.inventory.ParentTH" - width="30%" /> + <display:column title="common.header.ResourceName" + width="49%" + sortAttr="res.name"> + <display:disambiguatedResourceNameDecorator resourceName="${item.original.name}" disambiguationReport="${item}" nameAsLink="false"/> + </display:column> + <display:column title="resource.group.inventory.ParentTH" + width="50%"> + <display:disambiguatedResourceLineageDecorator parents="${item.parents}" renderLinks="false" /> + </display:column> </display:table> </div> <!-- / --> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp index 810963c..ba76919 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp @@ -5,6 +5,7 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="/WEB-INF/tld/hq.tld" prefix="hq" %> +<%@ taglib uri="/WEB-INF/tld/display.tld" prefix="display" %>
<tiles:importAttribute name="displayLastCompleted"/> <tiles:importAttribute name="lastCompletedResource" ignore="true"/> @@ -46,7 +47,6 @@ <c:if test="${!empty lastCompletedResource}"> <tr> <td width="25%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ResourceName"/></td> - <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Type"/></td> <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Location"/></td> <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> <td width="20%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> @@ -54,9 +54,8 @@ </tr> <c:forEach items="${lastCompletedResource}" var="obj"> <tr class="ListRow"> - <td class="ListCell"><html:link page="/rhq/resource/summary/overview.xhtml?id=${obj.original.resourceId}"><c:out value="${obj.original.resourceName}"/></html:link></td> - <td class="ListCell"><c:out value="${obj.original.resourceTypeName}"/></td> - <td class="ListCell"><c:out value="${obj.lineage}" escapeXml="false"/></td> + <td class="ListCell"><display:disambiguatedResourceName resourceName="${obj.original.resourceName}" disambiguationReport="${obj}" resourceId="${obj.original.resourceId}" /></td> + <td class="ListCell"><display:disambiguatedResourceLineage parents="${obj.parents}" /></td> <td class="ListCell"><c:out value="${obj.original.operationName}"/></td> <td class="ListCell"><hq:dateFormatter value="${obj.original.operationStartTime}"/></td> <td class="ListCell" align="center"> @@ -83,7 +82,7 @@ <c:if test="${!empty lastCompletedGroup}"> <tr> <td width="40%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.GroupName"/></td> - <td width="35%" class="ListHeaderInactive" colspan="2"><fmt:message key="dash.home.TableHeader.GroupResourceType"/></td> + <td width="35%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.GroupResourceType"/></td> <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> <td width="25%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> <td width="5%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Status"/></td> @@ -91,7 +90,7 @@ <c:forEach items="${lastCompletedGroup}" var="obj"> <tr class="ListRow"> <td class="ListCell"><html:link page="/rhq/groups/monitor/graphs.xhtml?category=COMPATIBLE&groupId=${obj.groupId}"><c:out value="${obj.groupName}"/></html:link></td> - <td class="ListCell" colspan="2"><c:out value="${obj.groupResourceTypeName}"/></td> + <td class="ListCell"><c:out value="${obj.groupResourceTypeName}"/></td> <td class="ListCell"><c:out value="${obj.operationName}"/></td> <td class="ListCell"><hq:dateFormatter value="${obj.operationStartTime}"/></td> <td class="ListCell" align="center"> @@ -141,16 +140,14 @@ <c:if test="${!empty nextScheduledResource}"> <tr> <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ResourceName"/></td> - <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Type"/></td> - <td width="35%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Location"/></td> + <td width="35%" class="ListHeaderInactive" colspan="2"><fmt:message key="dash.home.TableHeader.Location"/></td> <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> <td width="15%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> </tr> <c:forEach items="${nextScheduledResource}" var="obj"> <tr class="ListRow"> - <td class="ListCell"><html:link page="/rhq/resource/operation/resourceOperationScheduleDetails.xhtml?id=${obj.original.resourceId}&jobId=${obj.original.operationJobId}"><c:out value="${obj.original.resourceName}"/></html:link></td> - <td class="ListCell"><c:out value="${obj.original.resourceTypeName}"/></td> - <td class="ListCell"><c:out value="${obj.lineage}" escapeXml="false" /></td> + <td class="ListCell"><display:disambiguatedResourceName resourceName="${obj.original.resourceName}" disambiguationReport="${obj}" url="/rhq/resource/operation/resourceOperationScheduleDetails.xhtml?id=${obj.original.resourceId}&jobId=${obj.original.operationJobId}"/></td> + <td class="ListCell" colspan="2"><display:disambiguatedResourceLineage parents="${obj.parents}" /></td> <td class="ListCell"><c:out value="${obj.original.operationName}"/></td> <td class="ListCell"><hq:dateFormatter value="${obj.original.operationNextFireTime}"/></td> </tr> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp index 4221584..eebbc19 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp @@ -99,9 +99,12 @@ var help = 'hq:help/'; <display:checkboxdecorator name="ids" onclick="ToggleSelection(this, widgetProperties, true)" styleClass="listMember"/> </display:column>
- <display:column width="25%" property="original.name" sortAttr="res.name" title="dash.settings.ListHeader.Resource" /> - <display:column width="25%" property="original.resourceType.name" title="dash.settings.ListHeader.Type" /> - <display:column width="25%" property="lineage" title="dash.settings.ListHeader.Location" /> + <display:column width="25%" sortAttr="res.name" title="dash.settings.ListHeader.Resource"> + <display:disambiguatedResourceNameDecorator resourceName="${resource.original.name}" resourceId="${resource.original.id}" disambiguationReport="${resource}"/> + </display:column> + <display:column width="25%" title="dash.settings.ListHeader.Location"> + <display:disambiguatedResourceLineageDecorator parents="${resource.parents}"/> + </display:column> <display:column width="25%" property="original.description" sortAttr="res.description" title="common.header.Description" />
</display:table> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp index 7e0205e..0d3e602 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp @@ -5,6 +5,8 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="/WEB-INF/tld/hq.tld" prefix="hq" %> +<%@ taglib uri="/WEB-INF/tld/display.tld" prefix="display" %> + <tiles:importAttribute name="criticalAlerts"/>
<c:url var="rssUrl" value="/rss/ViewCriticalAlerts.rss"> @@ -33,7 +35,6 @@ <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="20%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.ResourceName"/><html:img page="/images/tb_sortup_inactive.gif" width="9" height="9" border="0"/></td> - <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Type"/></td> <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Location"/></td> <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.AlertName"/></td> <td width="20%" class="ListHeaderInactiveCenter"><fmt:message key="dash.home.TableHeader.DateTime"/></td> @@ -42,16 +43,15 @@ <tr class="ListRow"> <c:choose> <c:when test="{item.original.alertDefinition.resource eq null}"> - <td class="ListCell" colspan="3"> + <td class="ListCell" colspan="2"> <fmt:message key="dash.home.removed.resource"/> </td> </c:when> <c:otherwise> <td class="ListCell"> - <html:link page="/rhq/resource/summary/overview.xhtml?id=${item.original.alertDefinition.resource.id}"><c:out value="${item.original.alertDefinition.resource.name}"/> </html:link> + <display:disambiguatedResourceName resourceName="${item.original.alertDefinition.resource.name}" disambiguationReport="${item}" resourceId="${item.original.alertDefinition.resource.id}"/> </td> - <td class="ListCell"><c:out value="${item.original.alertDefinition.resource.resourceType.name}" /></td> - <td class="ListCell"><c:out value="${item.lineage}" /> </td> + <td class="ListCell"><display:disambiguatedResourceLineage parents="${item.parents}" /> </td> </c:otherwise> </c:choose> <td class="ListCell"><html:link page="/alerts/Alerts.do?mode=viewAlert&id=${item.original.alertDefinition.resource.id}&a=${item.original.id}"><c:out value="${item.original.alertDefinition.name}"/> </html:link></td> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp index 93695da..481cb5c 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp @@ -33,9 +33,12 @@ <c:when test="${not empty problemResources}"> <display:table cellspacing="0" cellpadding="0" width="100%" action="/Dashboard.do" var="obj" items="${problemResources}" > - <display:column width="20%" href="/rhq/resource/summary/overview.xhtml?id=${obj.original.resourceId}" property="original.resourceName" title="dash.home.TableHeader.ResourceName"/> - <display:column width="20%" property="originalResourceTypeName" title="dash.home.TableHeader.Type"/> - <display:column width="20%" property="lineage" title="dash.home.TableHeader.Location"/> + <display:column width="20%" title="dash.home.TableHeader.ResourceName"> + <display:disambiguatedResourceNameDecorator resourceName="${obj.original.resourceName}" resourceId="${obj.original.resourceId}" disambiguationReport="${obj}"/> + </display:column> + <display:column width="20%" title="dash.home.TableHeader.Location"> + <display:disambiguatedResourceLineageDecorator parents="${obj.parents}"/> + </display:column> <display:column width="10%" property="original.numAlerts" title="dash.home.TableHeader.Alerts" align="center"/> <display:column width="10%" property="original.availabilityType" title="resource.common.monitor.visibility.CAvailabilityTH" align="center" > display:availabilitydecorator/ diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp index a347bb3..58e74b7 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp @@ -24,14 +24,15 @@ <tiles:importAttribute name="alerts"/>
<c:choose > - <c:when test="${not empty resourceHealth}"> - - <display:table cellspacing="0" cellpadding="0" width="100%" action="/Dashboard.do" + <c:when test="${not empty resourceHealth}"> + <display:table cellspacing="0" cellpadding="0" width="100%" action="/Dashboard.do" var="item" items="${resourceHealth}" > - - <display:column width="25%" href="/rhq/resource/summary/overview.xhtml?id=${item.original.id}" property="original.name" sortAttr="res.name" title="dash.home.TableHeader.ResourceName"/> - <display:column width="25%" property="original.typeName" title="dash.home.TableHeader.Type"/> - <display:column width="25%" property="lineage" title="dash.home.TableHeader.Location"/> + <display:column width="25%" sortAttr="res.name" title="dash.home.TableHeader.ResourceName"> + <display:disambiguatedResourceNameDecorator resourceName="${item.original.name}" disambiguationReport="${item}" resourceId="${item.original.id}"/> + </display:column> + <display:column width="25%" title="dash.home.TableHeader.Location"> + <display:disambiguatedResourceLineageDecorator parents="${item.parents}"/> + </display:column> <c:if test="${alerts}"> <display:column width="10%" property="original.alerts" title="dash.home.TableHeader.Alerts" align="center"/> </c:if> @@ -42,9 +43,7 @@ </display:column> </c:if> </display:table> - <tiles:insert definition=".dashContent.seeAll"/> - </c:when> <c:otherwise> <table width="100%" cellpadding="0" cellspacing="0" border="0">
commit dcfd561e28af59dddaa52cad801733c14eebee1c Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 17 20:06:53 2010 +0200
Implementing the JSP tags for disambiguated resources...
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageTag.java new file mode 100644 index 0000000..77e49d8 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceLineageTag.java @@ -0,0 +1,91 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.legacy.taglib.display; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.JspTagException; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.tagext.TagSupport; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; +import org.rhq.enterprise.gui.inventory.resource.DisambiguatedResourceLineageComponent; + +/** + * Renders the location of a disambiguated resource. + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceLineageTag extends TagSupport { + private static final long serialVersionUID = 1L; + + private List<DisambiguationReport.Resource> parents; + private Boolean renderLinks; + + public List<DisambiguationReport.Resource> getParents() { + return parents; + } + + public void setParents(List<DisambiguationReport.Resource> parents) { + this.parents = parents; + } + + public Boolean getRenderLinks() { + return renderLinks; + } + + public void setRenderLinks(Boolean renderLinks) { + this.renderLinks = renderLinks; + } + + @Override + public int doEndTag() throws JspException { + JspWriter writer = pageContext.getOut(); + + try { + if (parents != null && parents.size() > 0) { + + Iterator<DisambiguationReport.Resource> it = parents.iterator(); + DisambiguationReport.Resource parent = it.next(); + DisambiguatedResourceNameTag.writeResource(writer, renderLinks, parent.getId(), parent.getName(), + parent.getType()); + + while (it.hasNext()) { + writer.append(DisambiguatedResourceLineageComponent.DEFAULT_SEPARATOR); + parent = it.next(); + DisambiguatedResourceNameTag.writeResource(writer, renderLinks, parent.getId(), parent.getName(), + parent.getType()); + } + } + + return super.doEndTag(); + } catch (IOException e) { + throw new JspTagException(e); + } + } + +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java new file mode 100644 index 0000000..240f4f8 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/taglib/display/DisambiguatedResourceNameTag.java @@ -0,0 +1,129 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.legacy.taglib.display; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.JspTagException; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.tagext.TagSupport; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; + +/** + * + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceNameTag extends TagSupport { + + private static final long serialVersionUID = 1L; + + private DisambiguationReport<?> disambiguatedReport; + private String resourceName; + private Integer resourceId; + private Boolean nameAsLink; + + public DisambiguationReport<?> getDisambiguatedReport() { + return disambiguatedReport; + } + + public void setDisambiguatedReport(DisambiguationReport<?> disambiguatedReport) { + this.disambiguatedReport = disambiguatedReport; + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public Integer getResourceId() { + return resourceId; + } + + public void setResourceId(Integer resourceId) { + this.resourceId = resourceId; + } + + public Boolean getNameAsLink() { + return nameAsLink; + } + + public void setNameAsLink(Boolean nameAsLink) { + this.nameAsLink = nameAsLink; + } + + @Override + public int doEndTag() throws JspException { + JspWriter writer = pageContext.getOut(); + + try { + if (disambiguatedReport != null) { + + DisambiguationReport.ResourceType resourceType = disambiguatedReport.getResourceType(); + + //default to true + boolean renderLink = nameAsLink == null || nameAsLink.booleanValue(); + + writeResource(writer, renderLink, resourceId, resourceName, resourceType); + } + + return super.doEndTag(); + } catch (IOException e) { + throw new JspTagException(e); + } + } + + public static void writeResource(JspWriter writer, boolean renderLink, int resourceId, String resourceName, DisambiguationReport.ResourceType resourceType) throws IOException { + if (!resourceType.isSingleton()) { + writer.append(resourceType.getName()).append(" "); + + if (resourceType.getPlugin() != null) { + writer.append("(").append(resourceType.getPlugin()) + .append(" plugin) "); + } + } + + if (renderLink) { + writer.append("<a href="/rhq/resource/summary/overview.xhtml?id="); + writer.print(resourceId); + writer.append("">"); + } + + writer.append(resourceName); + + if (renderLink) { + writer.append("</a>"); + } + + if (resourceType.isSingleton() && resourceType.getPlugin() != null) { + writer.append(" ").append(resourceType.getPlugin()) + .append(" plugin)"); + } + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld index 15c0f95..eefd1e1 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tld/display.tld @@ -889,4 +889,52 @@ </display:table> ]]> </example> </tag> + + <tag> + <name>disambiguatedResourceName</name> + <tag-class>org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceNameTag</tag-class> + <body-content>JSP</body-content> + <attribute> + <name>disambiguationReport</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>org.rhq.core.domain.resource.composite.DisambiguationReport</type> + </attribute> + <attribute> + <name>resourceName</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>String</type> + </attribute> + <attribute> + <name>resourceId</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>Integer</type> + </attribute> + <attribute> + <name>nameAsLink</name> + <required>false</required> + <rtexprvalue>false</rtexprvalue> + <type>Boolean</type> + </attribute> + </tag> + + <tag> + <name>disambiguatedResourceLineage</name> + <tag-class>org.rhq.enterprise.gui.legacy.taglib.display.DisambiguatedResourceLineageTag</tag-class> + <body-content>JSP</body-content> + <attribute> + <name>parents</name> + <required>true</required> + <rtexprvalue>true</rtexprvalue> + <type>java.util.List</type> + </attribute> + <attribute> + <name>renderLinks</name> + <required>false</required> + <rtexprvalue>false</rtexprvalue> + <type>Boolean</type> + </attribute> + </tag> </taglib>
commit 1cd199930a8af38a2384d143e2251a8af1a82192 Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 17 20:06:25 2010 +0200
Fixes to the DisambiguatedResourceNameComponent
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java index b189de9..eefb034 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java @@ -26,28 +26,39 @@ package org.rhq.enterprise.gui.inventory.resource; import javax.faces.component.UIComponentBase;
import org.rhq.core.domain.resource.composite.DisambiguationReport; +import org.rhq.core.gui.util.FacesComponentUtility;
/** - * + * Component for displaying a resource name together with disambiguation + * information. * * @author Lukas Krejci */ public class DisambiguatedResourceNameComponent extends UIComponentBase { public static final String COMPONENT_TYPE = "org.jboss.on.DisambiguatedResourceName"; public static final String COMPONENT_FAMILY = "org.jboss.on.DisambiguatedResourceName"; - + private static final String DISAMBIGUATION_REPORT_ATTRIBUTE = "disambiguationReport"; + private static final String RESOURCE_NAME_ATTRIBUTE = "resourceName"; + private static final String RESOURCE_ID_ATTRIBUTE = "resourceId"; + private static final String NAME_AS_LINK_ATTRIBUTE = "nameAsLink"; + private DisambiguationReport<?> disambiguationReport; private String resourceName; - private int resourceId; - private boolean nameAsLink = true; - + private Integer resourceId; + private Boolean nameAsLink; + @Override public String getFamily() { return COMPONENT_FAMILY; }
public DisambiguationReport<?> getDisambiguationReport() { - return disambiguationReport; + if (disambiguationReport == null) { + return FacesComponentUtility.getExpressionAttribute(this, DISAMBIGUATION_REPORT_ATTRIBUTE, + DisambiguationReport.class); + } else { + return disambiguationReport; + } }
public void setDisambiguationReport(DisambiguationReport<?> disambiguationReport) { @@ -55,7 +66,11 @@ public class DisambiguatedResourceNameComponent extends UIComponentBase { }
public String getResourceName() { - return resourceName; + if (resourceName == null) { + return FacesComponentUtility.getExpressionAttribute(this, RESOURCE_NAME_ATTRIBUTE); + } else { + return resourceName; + } }
public void setResourceName(String resourceName) { @@ -63,7 +78,12 @@ public class DisambiguatedResourceNameComponent extends UIComponentBase { }
public boolean isNameAsLink() { - return nameAsLink; + if (nameAsLink == null) { + Boolean ret = FacesComponentUtility.getExpressionAttribute(this, NAME_AS_LINK_ATTRIBUTE, Boolean.class); + return ret == null ? true : ret; + } else { + return nameAsLink; + } }
public void setNameAsLink(boolean nameAsLink) { @@ -71,7 +91,12 @@ public class DisambiguatedResourceNameComponent extends UIComponentBase { }
public int getResourceId() { - return resourceId; + if (resourceId == null) { + Integer ret = FacesComponentUtility.getExpressionAttribute(this, RESOURCE_ID_ATTRIBUTE, Integer.class); + return ret == null ? 0 : ret; + } else { + return resourceId; + } }
public void setResourceId(int resourceId) {
commit 2e8907e9e8f025de47f5b036f5703ad284f5d250 Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 17 14:58:17 2010 +0200
Renaming ResourcePartialLineage* to DisambiguatedResourceLineage* and adding a new DisambiguatedResourceName(Component|Renderer) to easily change the way we render a disambiguated resource name uniformly across the (JSF based) UI.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageComponent.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageComponent.java new file mode 100644 index 0000000..d02d26e --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageComponent.java @@ -0,0 +1,118 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.inventory.resource; + +import java.util.List; + +import javax.faces.component.UIComponentBase; +import javax.faces.context.FacesContext; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; +import org.rhq.core.gui.util.FacesComponentUtility; + +/** + * A component for displaying partial resource lineage that comes out of the resource name + * disambiguation procedure. + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceLineageComponent extends UIComponentBase { + public static final String COMPONENT_TYPE = "org.jboss.on.DisambiguatedResourceLineage"; + public static final String COMPONENT_FAMILY = "org.jboss.on.DisambiguatedResourceLineage"; + + public static final String DEFAULT_SEPARATOR = " > "; + + private static final String PARENTS_ATTRIBUTE = "parents"; + private static final String RENDER_LINKS_ATTRIBUTE = "renderLinks"; + private static final String SEPARATOR_ATTRIBUTE = "separator"; + + private Boolean renderLinks; + private String separator; + private List<DisambiguationReport.Resource> parents; + + public String getFamily() { + return COMPONENT_FAMILY; + } + + public Boolean getRenderLinks() { + if (renderLinks == null) { + renderLinks = FacesComponentUtility.getExpressionAttribute(this, RENDER_LINKS_ATTRIBUTE, Boolean.class); + if (renderLinks == null) { + renderLinks = true; + } + } + return renderLinks; + } + + + public void setRenderLinks(Boolean renderLinks) { + this.renderLinks = renderLinks; + } + + + public String getSeparator() { + if (separator == null) { + separator = FacesComponentUtility.getExpressionAttribute(this, SEPARATOR_ATTRIBUTE, String.class); + if (separator == null) { + separator = DEFAULT_SEPARATOR; + } + } + return separator; + } + + public void setSeparator(String separator) { + this.separator = separator; + } + + @SuppressWarnings("unchecked") + public List<DisambiguationReport.Resource> getParents() { + if (parents == null) { + //do *NOT* store this value into the parents explicitly + //unless dynamic updates (if the expression is in loop for example) + //won't work. + return FacesComponentUtility.getExpressionAttribute(this, PARENTS_ATTRIBUTE, List.class); + } else { + return parents; + } + } + + public void setParents(List<DisambiguationReport.Resource> parents) { + this.parents = parents; + } + + public Object saveState(FacesContext facesContext) { + Object[] state = new Object[3]; + state[0] = super.saveState(facesContext); + state[1] = this.renderLinks; + state[2] = this.separator; + return state; + } + + public void restoreState(FacesContext facesContext, Object stateValues) { + Object[] state = (Object[]) stateValues; + super.restoreState(facesContext, state[0]); + this.renderLinks = (Boolean) state[1]; + this.separator = (String) state[2]; + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java new file mode 100644 index 0000000..bb61ae6 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceLineageRenderer.java @@ -0,0 +1,112 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.inventory.resource; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; +import javax.faces.render.Renderer; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; + +/** + * Renderer for {@link DisambiguatedResourceLineageComponent} + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceLineageRenderer extends Renderer { + private static final String RESOURCE_URL = "/rhq/resource/summary/overview.xhtml"; + + @Override + public void encodeBegin(FacesContext context, UIComponent component) throws IOException { + DisambiguatedResourceLineageComponent lineageComponent = (DisambiguatedResourceLineageComponent) component; + + String separator = lineageComponent.getSeparator(); + List<DisambiguationReport.Resource> parents = lineageComponent.getParents(); + boolean renderLinks = lineageComponent.getRenderLinks(); + + if (parents != null && parents.size() > 0) { + ResponseWriter writer = context.getResponseWriter(); + + Iterator<DisambiguationReport.Resource> parentsIt = parents.iterator(); + + if (renderLinks) { + encodeUrl(writer, parentsIt.next()); + while(parentsIt.hasNext()) { + writer.writeText(separator, null); + encodeUrl(writer, parentsIt.next()); + } + } else { + encodeSimple(writer, parentsIt.next()); + while(parentsIt.hasNext()) { + writer.writeText(separator, null); + encodeSimple(writer, parentsIt.next()); + } + } + } + } + + public static void encodeUrl(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + encodePreName(writer, parent); + writer.startElement("a", null); + writer.writeAttribute("href", getUrl(parent), null); + writer.writeText(parent.getName(), null); + writer.endElement("a"); + encodePostName(writer, parent); + } + + public static void encodeSimple(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + encodePreName(writer, parent); + writer.writeText(parent.getName(), null); + encodePostName(writer, parent); + } + + private static String getUrl(DisambiguationReport.Resource parent) { + return RESOURCE_URL + "?id=" + parent.getId(); + } + + private static void encodePreName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + if (!parent.getType().isSingleton()) { + writer.writeText(parent.getType().getName(), null); + writer.writeText(" ", null); + if (parent.getType().getPlugin() != null) { + writer.writeText("(", null); + writer.writeText(parent.getType().getPlugin(), null); + writer.writeText(" plugin) ", null); + } + } + } + + private static void encodePostName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + if (parent.getType().isSingleton() && parent.getType().getPlugin() != null) { + writer.writeText(" (", null); + writer.writeText(parent.getType().getPlugin(), null); + writer.writeText(" plugin) ", null); + } + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java new file mode 100644 index 0000000..b189de9 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameComponent.java @@ -0,0 +1,80 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.inventory.resource; + +import javax.faces.component.UIComponentBase; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; + +/** + * + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceNameComponent extends UIComponentBase { + public static final String COMPONENT_TYPE = "org.jboss.on.DisambiguatedResourceName"; + public static final String COMPONENT_FAMILY = "org.jboss.on.DisambiguatedResourceName"; + + private DisambiguationReport<?> disambiguationReport; + private String resourceName; + private int resourceId; + private boolean nameAsLink = true; + + @Override + public String getFamily() { + return COMPONENT_FAMILY; + } + + public DisambiguationReport<?> getDisambiguationReport() { + return disambiguationReport; + } + + public void setDisambiguationReport(DisambiguationReport<?> disambiguationReport) { + this.disambiguationReport = disambiguationReport; + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public boolean isNameAsLink() { + return nameAsLink; + } + + public void setNameAsLink(boolean nameAsLink) { + this.nameAsLink = nameAsLink; + } + + public int getResourceId() { + return resourceId; + } + + public void setResourceId(int resourceId) { + this.resourceId = resourceId; + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameRenderer.java new file mode 100644 index 0000000..07c7ecd --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/DisambiguatedResourceNameRenderer.java @@ -0,0 +1,62 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.inventory.resource; + +import java.io.IOException; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; +import javax.faces.render.Renderer; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; + +/** + * + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceNameRenderer extends Renderer { + + @Override + public void encodeBegin(FacesContext context, UIComponent component) throws IOException { + DisambiguatedResourceNameComponent nameComponent = (DisambiguatedResourceNameComponent) component; + + ResponseWriter writer = context.getResponseWriter(); + + DisambiguationReport<?> report = nameComponent.getDisambiguationReport(); + String resourceName = nameComponent.getResourceName(); + int resourceId = nameComponent.getResourceId(); + + DisambiguationReport.ResourceType resourceType = report.getResourceType(); + + DisambiguationReport.Resource resource = new DisambiguationReport.Resource(resourceId, resourceName, resourceType); + + if (nameComponent.isNameAsLink()) { + DisambiguatedResourceLineageRenderer.encodeUrl(writer, resource); + } else { + DisambiguatedResourceLineageRenderer.encodeSimple(writer, resource); + } + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageComponent.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageComponent.java deleted file mode 100644 index 98502bc..0000000 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageComponent.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.rhq.enterprise.gui.inventory.resource; - -import java.util.List; - -import javax.faces.component.UIComponentBase; -import javax.faces.context.FacesContext; - -import org.rhq.core.domain.resource.composite.DisambiguationReport; -import org.rhq.core.gui.util.FacesComponentUtility; - -/** - * A component for displaying partial resource lineage that comes out of the resource name - * disambiguation procedure. - * - * @author Lukas Krejci - */ -public class ResourcePartialLineageComponent extends UIComponentBase { - public static final String COMPONENT_TYPE = "org.jboss.on.ResourcePartialLineage"; - public static final String COMPONENT_FAMILY = "org.jboss.on.ResourcePartialLineage"; - - public static final String DEFAULT_SEPARATOR = " > "; - - private static final String PARENTS_ATTRIBUTE = "parents"; - private static final String RENDER_LINKS_ATTRIBUTE = "renderLinks"; - private static final String SEPARATOR_ATTRIBUTE = "separator"; - - private Boolean renderLinks; - private String separator; - private List<DisambiguationReport.Resource> parents; - - public String getFamily() { - return COMPONENT_FAMILY; - } - - public Boolean getRenderLinks() { - if (renderLinks == null) { - renderLinks = FacesComponentUtility.getExpressionAttribute(this, RENDER_LINKS_ATTRIBUTE, Boolean.class); - if (renderLinks == null) { - renderLinks = true; - } - } - return renderLinks; - } - - - public void setRenderLinks(Boolean renderLinks) { - this.renderLinks = renderLinks; - } - - - public String getSeparator() { - if (separator == null) { - separator = FacesComponentUtility.getExpressionAttribute(this, SEPARATOR_ATTRIBUTE, String.class); - if (separator == null) { - separator = DEFAULT_SEPARATOR; - } - } - return separator; - } - - public void setSeparator(String separator) { - this.separator = separator; - } - - @SuppressWarnings("unchecked") - public List<DisambiguationReport.Resource> getParents() { - if (parents == null) { - //do *NOT* store this value into the parents explicitly - //unless dynamic updates (if the expression is in loop for example) - //won't work. - return FacesComponentUtility.getExpressionAttribute(this, PARENTS_ATTRIBUTE, List.class); - } else { - return parents; - } - } - - public void setParents(List<DisambiguationReport.Resource> parents) { - this.parents = parents; - } - - public Object saveState(FacesContext facesContext) { - Object[] state = new Object[3]; - state[0] = super.saveState(facesContext); - state[1] = this.renderLinks; - state[2] = this.separator; - return state; - } - - public void restoreState(FacesContext facesContext, Object stateValues) { - Object[] state = (Object[]) stateValues; - super.restoreState(facesContext, state[0]); - this.renderLinks = (Boolean) state[1]; - this.separator = (String) state[2]; - } -} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java deleted file mode 100644 index 9cd471e..0000000 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.rhq.enterprise.gui.inventory.resource; - -import java.io.IOException; -import java.util.Iterator; -import java.util.List; - -import javax.faces.component.UIComponent; -import javax.faces.context.FacesContext; -import javax.faces.context.ResponseWriter; -import javax.faces.render.Renderer; - -import org.rhq.core.domain.resource.composite.DisambiguationReport; - -/** - * Renderer for {@link ResourcePartialLineageComponent} - * - * @author Lukas Krejci - */ -public class ResourcePartialLineageRenderer extends Renderer { - private static final String RESOURCE_URL = "/rhq/resource/summary/overview.xhtml"; - - @Override - public void encodeBegin(FacesContext context, UIComponent component) throws IOException { - ResourcePartialLineageComponent lineageComponent = (ResourcePartialLineageComponent) component; - - String separator = lineageComponent.getSeparator(); - List<DisambiguationReport.Resource> parents = lineageComponent.getParents(); - boolean renderLinks = lineageComponent.getRenderLinks(); - - if (parents != null && parents.size() > 0) { - ResponseWriter writer = context.getResponseWriter(); - - Iterator<DisambiguationReport.Resource> parentsIt = parents.iterator(); - - if (renderLinks) { - encodeUrl(writer, parentsIt.next()); - while(parentsIt.hasNext()) { - writer.writeText(separator, null); - encodeUrl(writer, parentsIt.next()); - } - } else { - encodeSimple(writer, parentsIt.next()); - while(parentsIt.hasNext()) { - writer.writeText(separator, null); - encodeSimple(writer, parentsIt.next()); - } - } - } - } - - private void encodeUrl(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { - encodePreName(writer, parent); - writer.startElement("a", null); - writer.writeAttribute("href", getUrl(parent), null); - writer.writeText(parent.getName(), null); - writer.endElement("a"); - encodePostName(writer, parent); - } - - private void encodeSimple(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { - encodePreName(writer, parent); - writer.writeText(parent.getName(), null); - encodePostName(writer, parent); - } - - private static String getUrl(DisambiguationReport.Resource parent) { - return RESOURCE_URL + "?id=" + parent.getId(); - } - - private void encodePreName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { - if (!parent.getType().isSingleton()) { - writer.writeText(parent.getType().getName(), null); - writer.writeText(" ", null); - if (parent.getType().getPlugin() != null) { - writer.writeText(" (", null); - writer.writeText(parent.getType().getPlugin(), null); - writer.writeText(" plugin) ", null); - } - } - } - - private void encodePostName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { - if (parent.getType().isSingleton() && parent.getType().getPlugin() != null) { - writer.writeText(" (", null); - writer.writeText(parent.getType().getPlugin(), null); - writer.writeText(" plugin) ", null); - } - } -} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java index 082425d..c52d2b9 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java @@ -44,8 +44,7 @@ import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.IntExtractor; -import org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageComponent; -import org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageRenderer; +import org.rhq.enterprise.gui.inventory.resource.DisambiguatedResourceLineageComponent; import org.rhq.enterprise.gui.legacy.Constants; import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.gui.legacy.util.RequestUtils; @@ -223,7 +222,7 @@ public class AddGroupResourcesFormPrepareAction extends Action { StringBuilder bld = new StringBuilder(it.next().getName());
while (it.hasNext()) { - bld.append(ResourcePartialLineageComponent.DEFAULT_SEPARATOR).append(it.next().getName()); + bld.append(DisambiguatedResourceLineageComponent.DEFAULT_SEPARATOR).append(it.next().getName()); }
return bld.toString(); diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/inventory-components.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/inventory-components.xml index 2d20275..d8865f1 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/inventory-components.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/inventory-components.xml @@ -15,15 +15,25 @@ </component>
<component> - <component-type>org.jboss.on.ResourcePartialLineage</component-type> - <component-class>org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageComponent</component-class> + <component-type>org.jboss.on.DisambiguatedResourceLineage</component-type> + <component-class>org.rhq.enterprise.gui.inventory.resource.DisambiguatedResourceLineageComponent</component-class>
<component-extension> - <component-family>org.jboss.on.ResourcePartialLineage</component-family> - <renderer-type>org.jboss.on.ResourcePartialLineage</renderer-type> + <component-family>org.jboss.on.DisambiguatedResourceLineage</component-family> + <renderer-type>org.jboss.on.DisambiguatedResourceLineage</renderer-type> </component-extension> </component>
+ <component> + <component-type>org.jboss.on.DisambiguatedResourceName</component-type> + <component-class>org.rhq.enterprise.gui.inventory.resource.DisambiguatedResourceNameComponent</component-class> + + <component-extension> + <component-family>org.jboss.on.DisambiguatedResourceName</component-family> + <renderer-type>org.jboss.on.DisambiguatedResourceName</renderer-type> + </component-extension> + </component> + <render-kit> <renderer> <description>renderer for a ResourceLineage component</description> @@ -32,10 +42,16 @@ <renderer-class>org.rhq.enterprise.gui.inventory.resource.ResourceLineageRenderer</renderer-class> </renderer> <renderer> - <description>renderer for a ResourcePartialLineage component</description> - <component-family>org.jboss.on.ResourcePartialLineage</component-family> - <renderer-type>org.jboss.on.ResourcePartialLineage</renderer-type> - <renderer-class>org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageRenderer</renderer-class> + <description>renderer for a DisambiguatedResourceLineage component</description> + <component-family>org.jboss.on.DisambiguatedResourceLineage</component-family> + <renderer-type>org.jboss.on.DisambiguatedResourceLineage</renderer-type> + <renderer-class>org.rhq.enterprise.gui.inventory.resource.DisambiguatedResourceLineageRenderer</renderer-class> + </renderer> + <renderer> + <description>renderer for a DisambiguatedResourceName component</description> + <component-family>org.jboss.on.DisambiguatedResourceName</component-family> + <renderer-type>org.jboss.on.DisambiguatedResourceName</renderer-type> + <renderer-class>org.rhq.enterprise.gui.inventory.resource.DisambiguatedResourceNameRenderer</renderer-class> </renderer> </render-kit>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml index 665299a..1f06adf 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml @@ -97,10 +97,18 @@ </tag>
<tag> - <tag-name>resourcePartialLineage</tag-name> + <tag-name>disambiguatedResourceLineage</tag-name> <component> - <component-type>org.jboss.on.ResourcePartialLineage</component-type> - <renderer-type>org.jboss.on.ResourcePartialLineage</renderer-type> + <component-type>org.jboss.on.DisambiguatedResourceLineage</component-type> + <renderer-type>org.jboss.on.DisambiguatedResourceLineage</renderer-type> + </component> + </tag> + + <tag> + <tag-name>disambiguatedResourceName</tag-name> + <component> + <component-type>org.jboss.on.DisambiguatedResourceName</component-type> + <renderer-type>org.jboss.on.DisambiguatedResourceName</renderer-type> </component> </tag>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menuitem.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menuitem.xhtml index 3bbce89..eeedfee 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menuitem.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menuitem.xhtml @@ -234,6 +234,9 @@ currentMenuItem - the org.rhq.enterprise.server.perspective.menuItem to render <h:column> <f:facet name="header">Resource</f:facet> <h:outputText value="#{result.original.resource.name}" /> + <onc:disambiguatedResourceName resourceName="#{result.original.resource.name}" + resourceId="#{result.original.resource.id}" disambiguationReport="#{result}" + nameAsLink="false" /> </h:column> <h:column rendered="#{result.typeResolutionNeeded}"> <f:facet name="header">Type</f:facet> @@ -241,7 +244,7 @@ currentMenuItem - the org.rhq.enterprise.server.perspective.menuItem to render </h:column> <h:column rendered="#{result.parentResolutionNeeded}"> <f:facet name="header">Parent</f:facet> - <onc:resourcePartialLineage parents="#{result.parents}" renderLinks="false" /> + <onc:disambiguatedResourceLineage parents="#{result.parents}" renderLinks="false" /> </h:column> </rich:suggestionbox> </h:panelGroup> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml index 28edad0..347697e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml @@ -416,6 +416,8 @@ </onc:sortableColumnHeader> </f:facet>
+ <onc:disambiguatedResourceName resourceName="#{resourceitem.original.name}" + resourceId="#{resourceitem.original.id}" disambiguationReport="#{resourceitem}" /> <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> <f:param name="id" value="#{resourceitem.original.id}" /> <h:outputText value="#{resourceitem.original.name}" /> @@ -426,7 +428,7 @@ <f:facet name="header"> <h:outputText value="Parent" /> </f:facet> - <onc:resourcePartialLineage parents="#{resourceitem.parents}"/> + <onc:disambiguatedResourceLineage parents="#{resourceitem.parents}"/> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repoSubscriptions.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repoSubscriptions.xhtml index 2977cda..01d1a57 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repoSubscriptions.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repoSubscriptions.xhtml @@ -103,17 +103,15 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{resourceitem.original.id}"/> - <h:outputText value="#{resourceitem.original.name}" /> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{resourceitem.original.name}" + resourceId="#{resourceitem.original.id}" disambiguationReport="#{resourceitem}" /> </rich:column>
rich:column <f:facet name="header"> <h:outputText value="Parent" /> </f:facet> - <onc:resourcePartialLineage parents="#{resourceitem.parents}" /> + <onc:disambiguatedResourceLineage parents="#{resourceitem.parents}" /> </rich:column>
rich:column @@ -246,10 +244,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{availableitem.original.id}"/> - <h:outputText value="#{availableitem.original.name}" /> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{resourceitem.original.name}" + resourceId="#{resourceitem.original.id}" disambiguationReport="#{resourceitem}" /> </rich:column>
rich:column @@ -257,7 +253,7 @@ <h:outputText value="Parent"/> </f:facet>
- <onc:resourcePartialLineage parents="#{availableitem.parents}"/> + <onc:disambiguatedResourceLineage parents="#{availableitem.parents}"/> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/inventory/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/inventory/view.xhtml index a7076f4..c189e92 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/inventory/view.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/inventory/view.xhtml @@ -229,10 +229,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{resourceWithAvailability.original.resource.id}"/> - <h:outputText value="#{resourceWithAvailability.original.resource.name}"/> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{resourceWithAvailability.original.resource.name}" + resourceId="#{resourceWithAvailability.original.resource.id}" disambiguationReport="#{resourceWithAvailability}" /> </rich:column>
<rich:column > @@ -240,7 +238,7 @@ <h:outputText styleClass="headerText" value="Parent"/> </f:facet>
- <onc:resourcePartialLineage parents="#{resourceWithAvailability.parents}" /> + <onc:disambiguatedResourceLineage parents="#{resourceWithAvailability.parents}" /> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml index 9f132c8..c4969a8 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml @@ -179,10 +179,8 @@ groupId - the group id of the Group being accessed </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{resourceWithAvailability.original.resource.id}"/> - <h:outputText value="#{resourceWithAvailability.original.resource.name}"/> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{resourceWithAvailability.original.resource.name}" + resourceId="#{resourceWithAvailability.original.resource.id}" disambiguationReport="#{resourceWithAvailability}" /> </rich:column>
rich:column @@ -190,7 +188,7 @@ groupId - the group id of the Group being accessed <h:outputText styleClass="headerText" value="Parent"/> </f:facet>
- <onc:resourcePartialLineage parents="#{resourceWithAvailability.parents}"/> + <onc:disambiguatedResourceLineage parents="#{resourceWithAvailability.parents}"/> </rich:column>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml index b1c3495..a112891 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml @@ -130,26 +130,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputText value="#{item.resourceType.singleton ? '' : item.resourceType.name}" /> - <h:outputText value="#{item.resourceType.singleton ? '' : ' '}" /> - <h:outputText value="#{not item.resourceType.singleton and item.resourceType.plugin != null ? '(' : ''}" /> - <h:outputText value="#{not item.resourceType.singleton and item.resourceType.plugin != null ? item.resourceType.plugin : ''}" /> - <h:outputText value="#{not item.resourceType.singleton and item.resourceType.plugin != null ? ' plugin) ' : ''}" /> - <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{item.original.resource.id}" /> - <!-- - <h:outputText value="#{item.original.resource.name}" /> - <h:outputText value="#{item.resourceType.singleton ? '' : ' ('}" /> - <h:outputText value="#{item.resourceType.singleton ? '' : item.original.resource.resourceType.name}" /> - <h:outputText value="#{not item.resourceType.singleton and browseResourcesDataModel.currentPageNeedsPluginResolution ? ', plugin ' : ''}" /> - <h:outputText value="#{not item.resourceType.singleton and browseResourcesDataModel.currentPageNeedsPluginResolution ? item.resourceType.plugin : ''}" /> - <h:outputText value="#{item.resourceType.singleton ? '' : ')'}" /> - --> - <h:outputText value="#{item.original.resource.name}" /> - </h:outputLink> - <h:outputText value="#{item.resourceType.singleton and item.resourceType.plugin != null ? ' (' : ''}" /> - <h:outputText value="#{item.resourceType.singleton and item.resourceType.plugin != null ? item.resourceType.plugin : ''}" /> - <h:outputText value="#{item.resourceType.singleton and item.resourceType.plugin != null ? ' plugin)' : ''}" /> + <onc:disambiguatedResourceName resourceName="#{item.original.resource.name}" + resourceId="#{item.original.resource.id}" disambiguationReport="#{item}"/> </rich:column> <!-- rich:column @@ -167,7 +149,7 @@ <h:outputText styleClass="headerText" value="Location" /> </f:facet>
- <onc:resourcePartialLineage parents="#{item.parents}" renderLinks="true"/> + <onc:disambiguatedResourceLineage parents="#{item.parents}" renderLinks="true"/> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/resourcePicker.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/resourcePicker.xhtml index 6e46aff..287e571 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/resourcePicker.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/resourcePicker.xhtml @@ -98,7 +98,9 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputText value="#{item.original.resource.name}" /> + <onc:disambiguatedResourceName resourceName="#{item.original.resource.name}" + resourceId="#{item.original.resource.id}" disambiguationReport="#{item}" + nameAsLink="false" /> </rich:column>
rich:column @@ -106,7 +108,7 @@ <h:outputText styleClass="headerText" value="Parent" /> </f:facet>
- <onc:resourcePartialLineage parents="#{item.parents}" renderLinks="false"/> + <onc:disambiguatedResourceLineage parents="#{item.parents}" renderLinks="false"/> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml index 863357b..bf85748 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertDefinitions.xhtml @@ -100,10 +100,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{item.original.alertDefinition.resource.id}" /> - <h:outputText value="#{item.original.alertDefinition.resource.name}" /> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{item.original.alertDefinition.resource.name}" + resourceId="#{item.original.alertDefinition.resource.id}" disambiguationReport="#{item}"/> </rich:column>
rich:column @@ -111,7 +109,7 @@ <h:outputText styleClass="headerText" value="Parent" /> </f:facet>
- <onc:resourcePartialLineage parents="#{item.parents}"/> + <onc:disambiguatedResourceLineage parents="#{item.parents}"/> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml index f2ca8fd..e97f9fc 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml @@ -100,10 +100,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{item.original.alert.alertDefinition.resource.id}" /> - <h:outputText value="#{item.original.alert.alertDefinition.resource.name}" /> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{item.original.alert.alertDefinition.resource.name}" + resourceId="#{item.original.alert.alertDefinition.resource.id}" disambiguationReport="#{item}"/> </rich:column>
rich:column @@ -111,7 +109,7 @@ <h:outputText styleClass="headerText" value="Parent" /> </f:facet>
- <onc:resourcePartialLineage parents="#{item.parents}"/> + <onc:disambiguatedResourceLineage parents="#{item.parents}"/> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/configurationUpdate.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/configurationUpdate.xhtml index a07d657..1de7009 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/configurationUpdate.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/configurationUpdate.xhtml @@ -91,10 +91,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{item.original.resourceId}" /> - <h:outputText value="#{item.original.resourceName}" /> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{item.original.resourceName}" + resourceId="#{item.original.resourceId}" disambiguationReport="#{item}"/> </rich:column>
rich:column @@ -102,7 +100,7 @@ <h:outputText styleClass="headerText" value="Parent" /> </f:facet>
- <onc:resourcePartialLineage parents="#{item.parents}" /> + <onc:disambiguatedResourceLineage parents="#{item.parents}" /> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/oobHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/oobHistory.xhtml index a7cebd5..8559c91 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/oobHistory.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/oobHistory.xhtml @@ -96,10 +96,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{item.original.resourceId}" /> - <h:outputText value="#{item.original.resourceName}" /> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{item.original.resourceName}" + resourceId="#{item.original.resourceId}" disambiguationReport="#{item}"/> </rich:column>
rich:column @@ -107,7 +105,7 @@ <h:outputText styleClass="headerText" value="Parent" /> </f:facet>
- <onc:resourcePartialLineage parents="#{item.parents}"/> + <onc:disambiguatedResourceLineage parents="#{item.parents}"/> </rich:column>
rich:column diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/operationHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/operationHistory.xhtml index 302037d..0259872 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/operationHistory.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/operationHistory.xhtml @@ -91,10 +91,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> - <f:param name="id" value="#{item.original.history.resource.id}" /> - <h:outputText value="#{item.original.history.resource.name}" /> - </h:outputLink> + <onc:disambiguatedResourceName resourceName="#{item.original.history.resource.name}" + resourceId="#{item.original.history.resource.id}" disambiguationReport="#{item}"/> </rich:column>
rich:column @@ -102,7 +100,7 @@ <h:outputText styleClass="headerText" value="Parent" /> </f:facet>
- <onc:resourcePartialLineage parents="#{item.parents}" /> + <onc:disambiguatedResourceLineage parents="#{item.parents}" /> </rich:column>
commit 8de71a4dcd50f65586ebc2d3bc400b0055265496 Author: Lukas Krejci lkrejci@redhat.com Date: Tue May 11 21:39:51 2010 +0200
Moving stuff around to make more sense + making the DisambiguationUpdatePolicy an interface to allow for new impls.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java index f7b2381..ed96aa5 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java @@ -862,89 +862,8 @@ public class Resource implements Comparable<Resource>, Serializable { public static final String QUERY_RESOURCE_REPORT = "Resource.findResourceReport"; public static final String QUERY_RESOURCE_VERSION_REPORT = "Resource.findResourceVersionReport";
- public static final int MAX_SUPPORTED_RESOURCE_HIERARCHY_DEPTH = 7; - - private static final String NAME_CONCAT_SEPARATOR = "~!@#)))"; - private static final int UUID_LENGTH = 36;
- /** - * Helper for {@link #NATIVE_QUERY_FIND_DISAMBIGUATION_LEVEL}. - * We need to guard against concatenation with a NULL value which - * would yield a NULL result. We don't want that in that query, otherwise - * we'd get skewed results for combination of resources on different - * levels in the resource hierarchy. - * - * @param column - * @return - */ - private static String guardNullCase(String column) { - return "(CASE WHEN " + column + " IS NULL THEN 'null' ELSE " + column + " END)"; - } - - /** - * We're trying to find the minimum ancestry level that provides the disambiguate paths - * (in terms of unique resource names) for given resources. Obviously this query only works - * for hierarchies at most 7 levels deep (as the rest of the named queries above). - * - * <ul> - * <li>target_cnt gives us the number of resources we're trying to disambiguate. - * <li>l1_cnt gives us the number of resources with unique names, - * <li>l2_cnt gives us the number of resources with unique names with the names of the parent taken into account, - * <li>l3_cnt is the number of resource with unique names when parent and grandparent are included, etc. - * </ul> - * - * So when the caller gets the result row of this query, s/he can reason as follows: - * <ul> - * <li>l1_cnt = target_cnt: the names of the resources are unique in the given set - * <li>l2_cnt = target_cnt: the names + parent names are unique - * <li>... - * </ul> - * - * we need to do the concatenation of names instead of doing a DISTINCT over - * more columns because (at least in Postgres) a set of columns doesn't define - * equality operator to be used in the COUNT aggregate. - * Thus we need to add the "unlikely separator" hack. - * - * This query has to be native because Hibernate doesn't understand the - * COUNT(DISTINCT ...)) where ... is anything else than a path to a property in Hibernate terminology. - */ - public static final String NATIVE_QUERY_FIND_DISAMBIGUATION_LEVEL = "" // - + "SELECT COUNT(r.ID) AS target_cnt, " // - + "COUNT(DISTINCT(t.name)) AS bare_type_cnt," // - + "COUNT(DISTINCT(t.name || '" + NAME_CONCAT_SEPARATOR + "' || t.plugin)) AS full_type_cnt," // - + "COUNT(DISTINCT(r.name)) AS l1_cnt," // - + "COUNT(DISTINCT(r.name || '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p1.name") + ")) AS l2_cnt," // - + "COUNT(DISTINCT(r.name || '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p1.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p2.name") + ")) AS l3_cnt," // - + "COUNT(DISTINCT(r.name || '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p1.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p2.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p3.name") + ")) AS l4_cnt," // - + "COUNT(DISTINCT(r.name || '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p1.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p2.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p3.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p4.name") + ")) AS l5_cnt," // - + "COUNT(DISTINCT(r.name || '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p1.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p2.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p3.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p4.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p5.name") + ")) AS l6_cnt," // - + "COUNT(DISTINCT(r.name || '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p1.name") // - + "|| " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p2.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p3.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p4.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p5.name") // - + " || " + " '" + NAME_CONCAT_SEPARATOR + "' || " + guardNullCase("p6.name") + ")) AS l7_cnt " // - + "FROM " + TABLE_NAME + " r " // - + "JOIN " + ResourceType.TABLE_NAME + " t ON r.RESOURCE_TYPE_ID = t.ID " // - + "LEFT OUTER JOIN " + TABLE_NAME + " p1 ON r.PARENT_RESOURCE_ID = p1.ID " // - + "LEFT OUTER JOIN " + TABLE_NAME + " p2 ON p1.PARENT_RESOURCE_ID = p2.ID " // - + "LEFT OUTER JOIN " + TABLE_NAME + " p3 ON p2.PARENT_RESOURCE_ID = p3.ID " // - + "LEFT OUTER JOIN " + TABLE_NAME + " p4 ON p3.PARENT_RESOURCE_ID = p4.ID " // - + "LEFT OUTER JOIN " + TABLE_NAME + " p5 ON p4.PARENT_RESOURCE_ID = p5.ID " // - + "LEFT OUTER JOIN " + TABLE_NAME + " p6 ON p5.PARENT_RESOURCE_ID = p6.ID " // - + "WHERE r.ID IN (@@RESOURCE_IDS@@)"; - private static final long serialVersionUID = 1L;
public static final Resource ROOT = null; diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java index d04e6cd..dbc0ffd 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java @@ -124,7 +124,7 @@ import org.rhq.enterprise.server.operation.OperationManagerLocal; import org.rhq.enterprise.server.resource.disambiguation.DisambiguationPolicy; import org.rhq.enterprise.server.resource.disambiguation.Disambiguator; import org.rhq.enterprise.server.resource.disambiguation.MutableDisambiguationReport; -import org.rhq.enterprise.server.resource.disambiguation.DisambiguationUpdateStrategy; +import org.rhq.enterprise.server.resource.disambiguation.DefaultDisambiguationUpdateStrategies; import org.rhq.enterprise.server.resource.disambiguation.ReportPartitions; import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; import org.rhq.enterprise.server.util.CriteriaQueryGenerator; @@ -2106,8 +2106,8 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage public <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, boolean alwaysIncludeParent, IntExtractor<? super T> extractor) { //TODO the alwaysIncludeParents is obsolete and ignored - //DisambiguationUpdateStrategy strategy = DisambiguationUpdateStrategy.KEEP_PARENTS_TO_TOPMOST_SERVERS; - DisambiguationUpdateStrategy strategy = DisambiguationUpdateStrategy.KEEP_ALL_PARENTS; + //DefaultDisambiguationUpdateStrategies strategy = DefaultDisambiguationUpdateStrategies.KEEP_PARENTS_TO_TOPMOST_SERVERS; + DefaultDisambiguationUpdateStrategies strategy = DefaultDisambiguationUpdateStrategies.KEEP_ALL_PARENTS; return Disambiguator.disambiguate(results, strategy, extractor, entityManager); } } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DefaultDisambiguationUpdateStrategies.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DefaultDisambiguationUpdateStrategies.java new file mode 100644 index 0000000..c5553e3 --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DefaultDisambiguationUpdateStrategies.java @@ -0,0 +1,183 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.server.resource.disambiguation; + +import java.util.EnumSet; + +import org.rhq.enterprise.server.resource.disambiguation.MutableDisambiguationReport.Resource; + +/** + * This enumerates different strategies that can be used to update the results to produce disambiguated list. + * + * @author Lukas Krejci + */ +public enum DefaultDisambiguationUpdateStrategies implements DisambiguationUpdateStrategy { + + /** + * The disambiguation policy is followed precisely. + */ + EXACT { + public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + updateResources(policy, report); + int nofParents = policy.size() - 1; + if (nofParents < 0) + nofParents = 0; + + if (nofParents == 0) { + report.parents.clear(); + } else { + while (report.parents.size() > nofParents) { + report.parents.remove(report.parents.size() - 1); + } + } + } + }, + + /** + * Even if the disambiguation policy determined that parents are not needed to disambiguate the + * results, at least one of them is kept in the report. + */ + KEEP_AT_LEAST_ONE_PARENT { + public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + updateResources(policy, report); + int nofParents = policy.size() - 1; + if (nofParents < 1) + nofParents = 1; + + while (report.parents.size() > nofParents) { + report.parents.remove(report.parents.size() - 1); + } + } + + @Override + public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { + return EnumSet.allOf(ResourceResolution.class); + } + }, + + /** + * The parentage of the report is retained at least up to the server/service directly under platform. + * If the policy needs the platform to stay, it is of course preserved. + */ + KEEP_PARENTS_TO_TOPMOST_SERVERS { + public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + updateResources(policy, report); + //only remove the platform, if the policy doesn't dictate its presence... + if (policy.size() > 1 && report.parents.size() > policy.size() - 1) { + report.parents.remove(report.parents.size() - 1); + } + } + + @Override + public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { + return EnumSet.allOf(ResourceResolution.class); + } + }, + + /** + * All parents are preserved no matter what the policy says. + */ + KEEP_ALL_PARENTS { + public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + updateResources(policy, report); + //do nothing to the parents, keep them as they are... + } + + @Override + public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { + return EnumSet.allOf(ResourceResolution.class); + } + }; + + /** + * This updates the resources in the report according to the resolutions contained in the policy. + * This method is called as part of the {@link DisambiguationUpdateStrategy#update(DisambiguationPolicy, MutableDisambiguationReport)} + * implementations in this enum before the individual enums modify the parent list as they see fit. + * This method is left public because it is generic enough to be reused by other potential implementations of the + * {@link DisambiguationUpdateStrategy} interface. + * + * @param <T> + * @param policy + * @param report + */ + public static <T> void updateResources(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + updateResource(policy.get(0), report.resource); + + int disambiguationPolicyIndex = 1; + while (disambiguationPolicyIndex < policy.size() && disambiguationPolicyIndex - 1 < report.parents.size()) { + ResourceResolution parentResolution = policy.get(disambiguationPolicyIndex); + MutableDisambiguationReport.Resource parent = report.parents.get(disambiguationPolicyIndex - 1); + updateResource(parentResolution, parent); + + disambiguationPolicyIndex++; + } + + disambiguationPolicyIndex--; + + //because the parents update strategy might leave more parents than this policy requires for disambiguation + //we need to treat those parents as well. Because they are not needed for disambiguation, treat them as + //if only the name and type was needed for them. + for (; disambiguationPolicyIndex < report.parents.size(); ++disambiguationPolicyIndex) { + updateResource(ResourceResolution.TYPE, report.parents.get(disambiguationPolicyIndex)); + } + + //don't replicate the plugin information on the parents if it was reported + //on the resource already. + //this has to be done on all the parents, not just the ones that are immediately needed + //for disambiguation. The parents update strategies might leave more parents than those needed. + if (policy.get(0) == ResourceResolution.PLUGIN) { + for (MutableDisambiguationReport.Resource parent : report.parents) { + if (report.resource.resourceType.plugin.equals(parent.resourceType.plugin)) { + + parent.resourceType.plugin = null; + } + } + } + } + + /** + * @return a set of resolutions for which the unique reports need to be repartitioned at the resource level. + * In another words this forces the disambiguation to continue on up the disambiguation chain even if the + * it disambiguates the resuts successfully at the resource level. + */ + public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { + return EnumSet.noneOf(ResourceResolution.class); + } + + /** + * @return a set of resolutions for which uniquely disambiguated reports are to be repartitioned further. + * The resolutions from this set apply on the parents (on any level), unlike the resolutions from {@link #resourceLevelRepartitionableResolutions()}. + */ + public EnumSet<ResourceResolution> alwaysRepartitionableResolutions() { + return EnumSet.noneOf(ResourceResolution.class); + } + + + private static void updateResource(ResourceResolution resolution, Resource resource) { + switch (resolution) { + case NAME: case TYPE: + resource.resourceType.plugin = null; + } + } +} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java index 39c7f92..d4ce232 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java @@ -150,44 +150,6 @@ public class DisambiguationPolicy extends ArrayList<ResourceResolution> { return null; }
- public <T> void update(MutableDisambiguationReport<T> report) { - ResourceResolution resourceResolution = this.get(0); - resourceResolution.update(report.resource); - - int disambiguationPolicyIndex = 1; - while (disambiguationPolicyIndex < this.size() && disambiguationPolicyIndex - 1 < report.parents.size()) { - ResourceResolution parentResolution = this.get(disambiguationPolicyIndex); - MutableDisambiguationReport.Resource parent = report.parents.get(disambiguationPolicyIndex - 1); - parentResolution.update(parent); - - disambiguationPolicyIndex++; - } - - disambiguationPolicyIndex--; - - //because the parents update strategy might leave more parents than this policy requires for disambiguation - //we need to treat those parents as well. Because they are not needed for disambiguation, treat them as - //if only the name and type was needed for them. - for (; disambiguationPolicyIndex < report.parents.size(); ++disambiguationPolicyIndex) { - ResourceResolution.TYPE.update(report.parents.get(disambiguationPolicyIndex)); - } - - //don't replicate the plugin information on the parents if it was reported - //on the resource already. - //this has to be done on all the parents, not just the ones that are immediately needed - //for disambiguation. The parents update strategies might leave more parents than those needed. - if (resourceResolution == ResourceResolution.PLUGIN) { - for (MutableDisambiguationReport.Resource parent : report.parents) { - if (report.resource.resourceType.plugin.equals(parent.resourceType.plugin)) { - - parent.resourceType.plugin = null; - } - } - } - - parentsUpdateStrategy.update(this, report); - } - private <T> MutableDisambiguationReport.Resource getComparingResource(MutableDisambiguationReport<T> report) { int size = size(); if (size == 0) diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java index 03b046a..c2a11a6 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java @@ -26,107 +26,36 @@ package org.rhq.enterprise.server.resource.disambiguation; import java.util.EnumSet;
/** - * This enumerates different strategies that can be used to update the results to produce disambiguated list. + * Defines a strategy for updating a results list with the disambiguation information. * * @author Lukas Krejci */ -public enum DisambiguationUpdateStrategy { +public interface DisambiguationUpdateStrategy {
/** - * The disambiguation policy is followed precisely. - */ - EXACT { - public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { - int nofParents = policy.size() - 1; - if (nofParents < 0) - nofParents = 0; - - if (nofParents == 0) { - report.parents.clear(); - } else { - while (report.parents.size() > nofParents) { - report.parents.remove(report.parents.size() - 1); - } - } - } - }, - - /** - * Even if the disambiguation policy determined that parents are not needed to disambiguate the - * results, at least one of them is kept in the report. - */ - KEEP_AT_LEAST_ONE_PARENT { - public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { - int nofParents = policy.size() - 1; - if (nofParents < 1) - nofParents = 1; - - while (report.parents.size() > nofParents) { - report.parents.remove(report.parents.size() - 1); - } - } - - @Override - public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { - return EnumSet.allOf(ResourceResolution.class); - } - }, - - /** - * The parentage of the report is retained at least up to the server/service directly under platform. - * If the policy needs the platform to stay, it is of course preserved. - */ - KEEP_PARENTS_TO_TOPMOST_SERVERS { - public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { - //only remove the platform, if the policy doesn't dictate its presence... - if (policy.size() > 1 && report.parents.size() > policy.size() - 1) { - report.parents.remove(report.parents.size() - 1); - } - } - - @Override - public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { - return EnumSet.allOf(ResourceResolution.class); - } - }, - - /** - * All parents are preserved no matter what the policy says. - */ - KEEP_ALL_PARENTS { - public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { - //do nothing to the parents, keep them as they are... - } - - @Override - public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { - return EnumSet.allOf(ResourceResolution.class); - } - }; - - /** - * Updates the report using the policy. + * Updates the report using the policy. It is guaranteed that the resource and its parents + * in the report are already processed using the + * {@link ResourceResolution#update(MutableDisambiguationReport.Resource)} + * method. This method is then called to ensure that the report as a whole conforms to the policy *and* this + * strategy. This might entail removing some elements from the parent list for example. * * @param <T> * @param policy * @param report */ - public abstract <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report); + <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report);
/** * @return a set of resolutions for which the unique reports need to be repartitioned at the resource level. * In another words this forces the disambiguation to continue on up the disambiguation chain even if the * it disambiguates the resuts successfully at the resource level. */ - public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { - return EnumSet.noneOf(ResourceResolution.class); - } + EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions();
/** * @return a set of resolutions for which uniquely disambiguated reports are to be repartitioned further. * The resolutions from this set apply on the parents (on any level), unlike the resolutions from {@link #resourceLevelRepartitionableResolutions()}. */ - public EnumSet<ResourceResolution> alwaysRepartitionableResolutions() { - return EnumSet.noneOf(ResourceResolution.class); - } -} \ No newline at end of file + EnumSet<ResourceResolution> alwaysRepartitionableResolutions(); + +} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java index 2390a69..42d62f2 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java @@ -45,11 +45,11 @@ import org.rhq.core.util.IntExtractor; public class Disambiguator {
public static final int MAXIMUM_DISAMBIGUATED_TREE_DEPTH = 7; - + private Disambiguator() { - + } - + /** * Given a list of results, this method produces an object decorates the provided original results * with data needed to disambiguate the results with respect to resource names, their types and ancestory. @@ -67,13 +67,14 @@ public class Disambiguator { * * @param <T> the type of the result elements * @param results the results to disambiguate - * @param parentsDisambiguationStrategy how are the parents going to be disambiguated + * @param disambiguationUpdateStrategy how is the disambiguation info going to be applied to the results. * @param resourceIdExtractor an object able to extract resource id from an instance of type parameter. * @param entityManager an entityManager to be used to access the database * @return the disambiguation result or null on error */ - public static <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, DisambiguationUpdateStrategy parentsDisambiguationStrategy, - IntExtractor<? super T> extractor, EntityManager entityManager) { + public static <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, + DisambiguationUpdateStrategy disambiguationUpdateStrategy, IntExtractor<? super T> extractor, + EntityManager entityManager) {
if (results.isEmpty()) { return new ResourceNamesDisambiguationResult<T>(new ArrayList<DisambiguationReport<T>>(), false, false, @@ -124,7 +125,7 @@ public class Disambiguator { selectBuilder.append(", rt").append(i).append(".name"); selectBuilder.append(", rt").append(i).append(".plugin"); selectBuilder.append(", rt").append(i).append(".singleton"); - + fromBuilder.append(" left join r").append(pi).append(".parentResource r").append(i); fromBuilder.append(" left join r").append(i).append(".resourceType rt").append(i); } @@ -140,31 +141,33 @@ public class Disambiguator { //I will partition the resulting reports by resource name.to create groups of //resources that are "mutually ambiguous". Because each such group potenitally //requires different level of disambiguation, I will then process them individually. - - ReportPartitions<T> partitionedReports = new ReportPartitions<T>(DisambiguationPolicy.getUniqueNamePolicy(parentsDisambiguationStrategy)); - + + ReportPartitions<T> partitionedReports = new ReportPartitions<T>(DisambiguationPolicy + .getUniqueNamePolicy(disambiguationUpdateStrategy)); + @SuppressWarnings("unchecked") List<Object[]> parentsResults = (List<Object[]>) parentsQuery.getResultList(); for (Object[] parentsResult : parentsResults) { - List<MutableDisambiguationReport.Resource> parents = new ArrayList<MutableDisambiguationReport.Resource>(MAXIMUM_DISAMBIGUATED_TREE_DEPTH); + List<MutableDisambiguationReport.Resource> parents = new ArrayList<MutableDisambiguationReport.Resource>( + MAXIMUM_DISAMBIGUATED_TREE_DEPTH); Integer resourceId = (Integer) parentsResult[0]; String resourceName = (String) parentsResult[1]; Integer typeId = (Integer) parentsResult[2]; String typeName = (String) parentsResult[3]; String pluginName = (String) parentsResult[4]; Boolean singleton = (Boolean) parentsResult[5]; - + MutableDisambiguationReport.ResourceType resourceType = new MutableDisambiguationReport.ResourceType(); resourceType.id = typeId; resourceType.name = typeName; resourceType.plugin = pluginName; resourceType.singleton = singleton; - + MutableDisambiguationReport.Resource resource = new MutableDisambiguationReport.Resource(); resource.id = resourceId; resource.name = resourceName; resource.resourceType = resourceType; - + for (int i = 0; i < MAXIMUM_DISAMBIGUATED_TREE_DEPTH; ++i) { Integer parentId = (Integer) parentsResult[6 + 6 * i]; if (parentId == null) @@ -174,18 +177,18 @@ public class Disambiguator { String parentType = (String) parentsResult[6 + 6 * i + 3]; String parentPlugin = (String) parentsResult[6 + 6 * i + 4]; Boolean parentSingleton = (Boolean) parentsResult[6 + 6 * i + 5]; - + MutableDisambiguationReport.ResourceType type = new MutableDisambiguationReport.ResourceType(); type.id = parentTypeId; type.name = parentType; type.plugin = parentPlugin; type.singleton = parentSingleton; - + MutableDisambiguationReport.Resource parent = new MutableDisambiguationReport.Resource(); parent.id = parentId; parent.name = parentName; parent.resourceType = type; - + parents.add(parent); }
@@ -193,68 +196,45 @@ public class Disambiguator { for (MutableDisambiguationReport<T> report : reportsByResourceId.get(resourceId)) { report.resource = resource; report.parents = parents; - + partitionedReports.put(report); } } - + //ok, now I have the reports partitioned by resource name. let's go through each partition //and figure out the disambiguation needed for it. - + List<ReportPartitions<T>> ambiguousSubPartitions = new ArrayList<ReportPartitions<T>>(); - + if (!partitionedReports.isPartitionsUnique()) { ambiguousSubPartitions.add(partitionedReports); } else { - ReportPartitions<T> repartition = partitionedReports.updateUniqueReports(); - while (repartition != null) { - if(!repartition.isPartitionsUnique()) { - ambiguousSubPartitions.add(repartition); - repartition = null; - } else { - repartition = repartition.updateUniqueReports(); - } - } + repartitionUnique(partitionedReports, disambiguationUpdateStrategy, ambiguousSubPartitions); } - + while (ambiguousSubPartitions.size() > 0) { Iterator<ReportPartitions<T>> subPartitionIterator = ambiguousSubPartitions.iterator(); List<ReportPartitions<T>> newAmbiguousPartitions = new ArrayList<ReportPartitions<T>>(); - - while(subPartitionIterator.hasNext()) { + + while (subPartitionIterator.hasNext()) { ReportPartitions<T> subPartition = subPartitionIterator.next();
- ReportPartitions<T> repartition = subPartition.updateUniqueReports(); - while (repartition != null) { - if(!repartition.isPartitionsUnique()) { - newAmbiguousPartitions.add(repartition); - repartition = null; - } else { - repartition = repartition.updateUniqueReports(); - } - } - - for(List<MutableDisambiguationReport<T>> partitionReports : subPartition.getAmbiguousPartitions()) { - ReportPartitions<T> replacementSubpartition = new ReportPartitions<T>(subPartition.getDisambiguationPolicy().getNext()); + repartitionUnique(subPartition, disambiguationUpdateStrategy, newAmbiguousPartitions); + + for (List<MutableDisambiguationReport<T>> partitionReports : subPartition.getAmbiguousPartitions()) { + ReportPartitions<T> replacementSubpartition = new ReportPartitions<T>(subPartition + .getDisambiguationPolicy().getNext()); replacementSubpartition.putAll(partitionReports); if (!replacementSubpartition.isPartitionsUnique()) { newAmbiguousPartitions.add(replacementSubpartition); } else { - repartition = replacementSubpartition.updateUniqueReports(); - while (repartition != null) { - if(!repartition.isPartitionsUnique()) { - newAmbiguousPartitions.add(repartition); - repartition = null; - } else { - repartition = repartition.updateUniqueReports(); - } - } + repartitionUnique(replacementSubpartition, disambiguationUpdateStrategy, newAmbiguousPartitions); } } subPartitionIterator.remove(); } - - for(ReportPartitions<T> newPartition : newAmbiguousPartitions) { + + for (ReportPartitions<T> newPartition : newAmbiguousPartitions) { ambiguousSubPartitions.add(newPartition); } } @@ -267,6 +247,34 @@ public class Disambiguator { }
return new ResourceNamesDisambiguationResult<T>(resolution, typeResolutionNeeded, parentResolutionNeeded, - pluginResolutionNeeded); + pluginResolutionNeeded); + } + + private static <T> void repartitionUnique(ReportPartitions<T> partitions, DisambiguationUpdateStrategy updateStrategy, List<ReportPartitions<T>> ambigousPartitions) { + + while (true) { + //try to repartition + DisambiguationPolicy repartitionPolicy = partitions.getDisambiguationPolicy().getNextRepartitioningPolicy(); + if (repartitionPolicy != null) { + //ok, we have a new policy to try... let's see if it makes any difference. + partitions = new ReportPartitions<T>(repartitionPolicy, partitions.getUniquePartitions()); + + //bail out if we have partitions that are not unique + if (!partitions.isPartitionsUnique()) { + ambigousPartitions.add(partitions); + return; + } + } else { + //ok, there is no other repartitioning policy that we can try. + //Let's update the reports in the unique partitions... + for (List<MutableDisambiguationReport<T>> partition : partitions.getUniquePartitions()) { + for (MutableDisambiguationReport<T> report : partition) { + updateStrategy.update(partitions.getDisambiguationPolicy(), report); + } + } + + return; + } + } } } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java index ba24e29..8fbb9ab 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java @@ -24,9 +24,8 @@ package org.rhq.enterprise.server.resource.disambiguation;
import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collections; import java.util.List; -import java.util.Map;
/** * This class partitions the reports inserted into it by chunking them up @@ -41,18 +40,30 @@ public class ReportPartitions<T> {
private static final long serialVersionUID = 1L; private DisambiguationPolicy disambiguationPolicy; - private Map<Integer, List<MutableDisambiguationReport<T>>> partitions; + private List<List<MutableDisambiguationReport<T>>> partitions;
/** - * @see MutableDisambiguationReport#getComparisonForLevel(int) + * Constructs a new instance with no partitions in it. * - * @param comparisonLevel + * @param disambiguationPolicy the policy that decides if reports are ambiguous. */ public ReportPartitions(DisambiguationPolicy disambiguationPolicy) { this.disambiguationPolicy = disambiguationPolicy; - partitions = new HashMap<Integer, List<MutableDisambiguationReport<T>>>(); + partitions = new ArrayList<List<MutableDisambiguationReport<T>>>(); }
+ public ReportPartitions(DisambiguationPolicy disambiguationPolicy, ReportPartitions<T> other) { + this(disambiguationPolicy); + putAll(other); + } + + public ReportPartitions(DisambiguationPolicy disambiguationPolicy, List<List<MutableDisambiguationReport<T>>> partitions) { + this(disambiguationPolicy); + for(List<MutableDisambiguationReport<T>> partition : partitions) { + putAll(partition); + } + } + public DisambiguationPolicy getDisambiguationPolicy() { return disambiguationPolicy; } @@ -60,7 +71,7 @@ public class ReportPartitions<T> { public List<List<MutableDisambiguationReport<T>>> getAmbiguousPartitions() { List<List<MutableDisambiguationReport<T>>> ret = new ArrayList<List<MutableDisambiguationReport<T>>>();
- for (List<MutableDisambiguationReport<T>> partition : partitions.values()) { + for (List<MutableDisambiguationReport<T>> partition : partitions) { if (partition.size() > 1) { ret.add(partition); } @@ -72,7 +83,7 @@ public class ReportPartitions<T> { public List<List<MutableDisambiguationReport<T>>> getUniquePartitions() { List<List<MutableDisambiguationReport<T>>> ret = new ArrayList<List<MutableDisambiguationReport<T>>>();
- for (List<MutableDisambiguationReport<T>> partition : partitions.values()) { + for (List<MutableDisambiguationReport<T>> partition : partitions) { if (partition.size() == 1) { ret.add(partition); } @@ -81,17 +92,21 @@ public class ReportPartitions<T> { return ret; }
+ public List<List<MutableDisambiguationReport<T>>> getAllPartitions() { + return Collections.unmodifiableList(partitions); + } + public void put(MutableDisambiguationReport<T> value) { boolean found = false; - for (Map.Entry<Integer, List<MutableDisambiguationReport<T>>> entry : partitions.entrySet()) { - for (MutableDisambiguationReport<T> partitionPrototype : entry.getValue()) { + for (List<MutableDisambiguationReport<T>> partition : partitions) { + for (MutableDisambiguationReport<T> partitionPrototype : partition) { if (disambiguationPolicy.areAmbiguous(partitionPrototype, value)) { found = true; break; } } if (found) { - entry.getValue().add(value); + partition.add(value); break; } } @@ -99,7 +114,7 @@ public class ReportPartitions<T> { if (!found) { List<MutableDisambiguationReport<T>> newPartition = new ArrayList<MutableDisambiguationReport<T>>(); newPartition.add(value); - partitions.put(partitions.size(), newPartition); + partitions.add(newPartition); } }
@@ -109,37 +124,14 @@ public class ReportPartitions<T> { } }
- /** - * Updates the reports in the unique partitions. - * - * @return if the current policy is determined "repartitionable", the returned partitions instance splits the current - * unique reports by some other policy. If the current policy is not repartitionable, a null value is returned. - */ - public ReportPartitions<T> updateUniqueReports() { - List<MutableDisambiguationReport<T>> uniqueReports = new ArrayList<MutableDisambiguationReport<T>>(); - for (List<MutableDisambiguationReport<T>> val : partitions.values()) { - if (val.size() == 1) { - uniqueReports.addAll(val); - } + public void putAll(ReportPartitions<T> other) { + for (List<MutableDisambiguationReport<T>> partition : other.getAllPartitions()) { + putAll(partition); } - - DisambiguationPolicy repartitioningPolicy = disambiguationPolicy.getNextRepartitioningPolicy(); - if (repartitioningPolicy != null) { - ReportPartitions<T> ret = new ReportPartitions<T>(repartitioningPolicy); - ret.putAll(uniqueReports); - - return ret; - } - - for (MutableDisambiguationReport<T> report : uniqueReports) { - disambiguationPolicy.update(report); - } - - return null; } - + public boolean isPartitionsUnique() { - for (List<MutableDisambiguationReport<T>> partition : partitions.values()) { + for (List<MutableDisambiguationReport<T>> partition : partitions) { if (partition.size() > 1) { return false; } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ResourceResolution.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ResourceResolution.java index bc5d89c..054f05d 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ResourceResolution.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ResourceResolution.java @@ -28,22 +28,12 @@ public enum ResourceResolution { public boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b) { return (a.id != b.id && a.name.equals(b.name)); } - - @Override - public void update(MutableDisambiguationReport.Resource resource) { - resource.resourceType.plugin = null; - } }, TYPE { public boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b) { return ((a.resourceType.id != b.resourceType.id) && (a.resourceType.name.equals(b.resourceType.name))) || (a.resourceType.id == b.resourceType.id && NAME.areAmbiguous(a, b)); } - - @Override - public void update(MutableDisambiguationReport.Resource resource) { - resource.resourceType.plugin = null; - } }, PLUGIN { public boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b) { @@ -52,9 +42,5 @@ public enum ResourceResolution { } };
- public abstract boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b); - - public void update(MutableDisambiguationReport.Resource resource) { - //by default do nothing - } + public abstract boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b); } \ No newline at end of file
commit c02b9d0969fd72e7300c681386fa26b0897eda49 Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 10 15:28:42 2010 +0200
Imports cleanup
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java index 8de734b..39c7f92 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java @@ -24,7 +24,6 @@ package org.rhq.enterprise.server.resource.disambiguation;
import java.util.ArrayList; -import java.util.EnumSet;
/** * A disambiguation policy determines whether two disambiguation reports are still ambiguous or not. @@ -175,7 +174,7 @@ public class DisambiguationPolicy extends ArrayList<ResourceResolution> {
//don't replicate the plugin information on the parents if it was reported //on the resource already. - //this has to be done on all the parents, not just the ones that are immediatelly needed + //this has to be done on all the parents, not just the ones that are immediately needed //for disambiguation. The parents update strategies might leave more parents than those needed. if (resourceResolution == ResourceResolution.PLUGIN) { for (MutableDisambiguationReport.Resource parent : report.parents) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java index bbd5934..2390a69 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java @@ -32,11 +32,9 @@ import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.Query;
-import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; import org.rhq.core.util.IntExtractor; -import org.rhq.core.util.jdbc.JDBCUtil;
/** * This is basically a helper class that provides the disambiguation method. diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java index 7b57270..ba24e29 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java @@ -24,7 +24,6 @@ package org.rhq.enterprise.server.resource.disambiguation;
import java.util.ArrayList; -import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map;
commit 47f9c51efdd0536fb8639f08094e8474b0d98ee4 Author: Lukas Krejci lkrejci@redhat.com Date: Fri May 7 21:44:25 2010 +0200
Major update of the way disambiguation works as well as how it is displayed in the search results. More work on the UI side is needed as well as on the backend (make the DisambiguationPolicy and ResourceResolution interfaces to be more flexible for the future?).
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java index 5ce12d0..6d9b93a 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java @@ -61,9 +61,15 @@ public class DisambiguationReport<T> implements Serializable { public String getName() { return name; } + + /** + * @return the plugin that defines this type or null if such information + * isn't needed to disambiguate this type. + */ public String getPlugin() { return plugin; } + public boolean isSingleton() { return singleton; } @@ -99,6 +105,10 @@ public class DisambiguationReport<T> implements Serializable { return name; }
+ /** + * @return the resource type to use to disambiguate the concrete resource or null + * if no type disambiguation is needed. + */ public ResourceType getType() { return type; } @@ -118,6 +128,10 @@ public class DisambiguationReport<T> implements Serializable { return original; }
+ /** + * @return the list of parents to disambiguate the original. Empty if no disambiguation using + * parents is needed. + */ public List<Resource> getParents() { return parents; } @@ -134,6 +148,7 @@ public class DisambiguationReport<T> implements Serializable {
/** * @return the ResourceType of the resource represented by the {@link #getOriginal()} + * or null if type disambiguation isn't needed. */ public ResourceType getResourceType() { return resourceType; diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java index 5d2bf2d..a12053f 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceNamesDisambiguationResult.java @@ -38,8 +38,11 @@ public class ResourceNamesDisambiguationResult<T> implements Serializable { private static final long serialVersionUID = 1L;
private List<DisambiguationReport<T>> resolution; + @Deprecated private boolean typeResolutionNeeded; + @Deprecated private boolean pluginResolutionNeeded; + @Deprecated private boolean parentResolutionNeeded;
public ResourceNamesDisambiguationResult(List<DisambiguationReport<T>> resolution, boolean needsTypeResolution, @@ -62,6 +65,7 @@ public class ResourceNamesDisambiguationResult<T> implements Serializable { /** * This tells the caller whether the result set contained resources with different types. */ + @Deprecated public boolean isTypeResolutionNeeded() { return typeResolutionNeeded; } @@ -69,6 +73,7 @@ public class ResourceNamesDisambiguationResult<T> implements Serializable { /** * This is true when the resources come from different parents. */ + @Deprecated public boolean isParentResolutionNeeded() { return parentResolutionNeeded; } @@ -77,6 +82,7 @@ public class ResourceNamesDisambiguationResult<T> implements Serializable { * This is true if the results contained resources of different types with the same name. * In that case, the types need to be augmented with the plugin they come from. */ + @Deprecated public boolean isPluginResolutionNeeded() { return pluginResolutionNeeded; } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java index d6e12a9..9cd471e 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java @@ -72,22 +72,41 @@ public class ResourcePartialLineageRenderer extends Renderer { }
private void encodeUrl(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + encodePreName(writer, parent); writer.startElement("a", null); writer.writeAttribute("href", getUrl(parent), null); - encodeSimple(writer, parent); + writer.writeText(parent.getName(), null); writer.endElement("a"); + encodePostName(writer, parent); }
private void encodeSimple(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + encodePreName(writer, parent); writer.writeText(parent.getName(), null); - if (!parent.getType().isSingleton()) { - writer.writeText(" (", null); - writer.writeText(parent.getType().getName(), null); - writer.writeText(")", null); - } + encodePostName(writer, parent); }
private static String getUrl(DisambiguationReport.Resource parent) { return RESOURCE_URL + "?id=" + parent.getId(); } + + private void encodePreName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + if (!parent.getType().isSingleton()) { + writer.writeText(parent.getType().getName(), null); + writer.writeText(" ", null); + if (parent.getType().getPlugin() != null) { + writer.writeText(" (", null); + writer.writeText(parent.getType().getPlugin(), null); + writer.writeText(" plugin) ", null); + } + } + } + + private void encodePostName(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + if (parent.getType().isSingleton() && parent.getType().getPlugin() != null) { + writer.writeText(" (", null); + writer.writeText(parent.getType().getPlugin(), null); + writer.writeText(" plugin) ", null); + } + } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java index 6672fbe..74ae826 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceSelectUIBean.java @@ -28,7 +28,6 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ResourceComposite; import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; -import org.rhq.core.domain.resource.composite.ResourceParentFlyweight; import org.rhq.core.domain.util.PageControl; import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; @@ -68,7 +67,7 @@ public class ResourceSelectUIBean { * @param resourceTypePluginName */ public DisambiguationReportWrapper(DisambiguationReport<ResourceComposite> report, boolean typeResolutionNeeded, boolean parentResolutionNeeded, boolean pluginResolutionNeeded) { - super(report.getOriginal(), report.getParents(), report.getResourceTypeName(), report.getResourceTypePluginName()); + super(report.getOriginal(), report.getParents(), report.getResourceType()); this.typeResolutionNeeded = typeResolutionNeeded; this.parentResolutionNeeded = parentResolutionNeeded; this.pluginResolutionNeeded = pluginResolutionNeeded; diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml index b58a0b9..b1c3495 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml @@ -126,20 +126,30 @@ rich:column <f:facet name="header"> <onc:sortableColumnHeader sort="r.name"> - <h:outputText styleClass="headerText" value="Name" /> + <h:outputText styleClass="headerText" value="Resource" /> </onc:sortableColumnHeader> </f:facet>
+ <h:outputText value="#{item.resourceType.singleton ? '' : item.resourceType.name}" /> + <h:outputText value="#{item.resourceType.singleton ? '' : ' '}" /> + <h:outputText value="#{not item.resourceType.singleton and item.resourceType.plugin != null ? '(' : ''}" /> + <h:outputText value="#{not item.resourceType.singleton and item.resourceType.plugin != null ? item.resourceType.plugin : ''}" /> + <h:outputText value="#{not item.resourceType.singleton and item.resourceType.plugin != null ? ' plugin) ' : ''}" /> <h:outputLink value="#{onf:getDefaultResourceTabURL()}"> <f:param name="id" value="#{item.original.resource.id}" /> - <h:outputText value="#{item.original.resource.name}" /> - <!-- - <h:outputText value=" (#{item.original.resource.resourceType.name})" /> - --> + <!-- + <h:outputText value="#{item.original.resource.name}" /> <h:outputText value="#{item.resourceType.singleton ? '' : ' ('}" /> <h:outputText value="#{item.resourceType.singleton ? '' : item.original.resource.resourceType.name}" /> + <h:outputText value="#{not item.resourceType.singleton and browseResourcesDataModel.currentPageNeedsPluginResolution ? ', plugin ' : ''}" /> + <h:outputText value="#{not item.resourceType.singleton and browseResourcesDataModel.currentPageNeedsPluginResolution ? item.resourceType.plugin : ''}" /> <h:outputText value="#{item.resourceType.singleton ? '' : ')'}" /> + --> + <h:outputText value="#{item.original.resource.name}" /> </h:outputLink> + <h:outputText value="#{item.resourceType.singleton and item.resourceType.plugin != null ? ' (' : ''}" /> + <h:outputText value="#{item.resourceType.singleton and item.resourceType.plugin != null ? item.resourceType.plugin : ''}" /> + <h:outputText value="#{item.resourceType.singleton and item.resourceType.plugin != null ? ' plugin)' : ''}" /> </rich:column> <!-- rich:column diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java index a427db1..d04e6cd 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java @@ -23,16 +23,19 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.Set;
import javax.ejb.EJB; import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; +import javax.persistence.DiscriminatorType; import javax.persistence.EntityManager; import javax.persistence.NoResultException; import javax.persistence.PersistenceContext; @@ -118,6 +121,11 @@ import org.rhq.enterprise.server.core.AgentManagerLocal; import org.rhq.enterprise.server.jaxb.adapter.ResourceListAdapter; import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal; import org.rhq.enterprise.server.operation.OperationManagerLocal; +import org.rhq.enterprise.server.resource.disambiguation.DisambiguationPolicy; +import org.rhq.enterprise.server.resource.disambiguation.Disambiguator; +import org.rhq.enterprise.server.resource.disambiguation.MutableDisambiguationReport; +import org.rhq.enterprise.server.resource.disambiguation.DisambiguationUpdateStrategy; +import org.rhq.enterprise.server.resource.disambiguation.ReportPartitions; import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; import org.rhq.enterprise.server.util.CriteriaQueryGenerator; import org.rhq.enterprise.server.util.CriteriaQueryRunner; @@ -2097,148 +2105,9 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
public <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, boolean alwaysIncludeParent, IntExtractor<? super T> extractor) { - - if (results.isEmpty()) { - return new ResourceNamesDisambiguationResult<T>(new ArrayList<DisambiguationReport<T>>(), false, false, - false); - } - - boolean typeResolutionNeeded = false; - boolean pluginResolutionNeeded = false; - boolean parentResolutionNeeded = false; - - //we can't assume the ordering of the provided results and the disambiguation query results - //will be the same. - - //this list contains the resulting reports in the same order as the original results - List<MutableDisambiguationReport<T>> reports = new ArrayList<MutableDisambiguationReport<T>>(results.size()); - - //this maps the reports to resourceIds. More than one report can correspond to a single - //resource id. The reports in this map are the same instances as in the reports list. - Map<Integer, List<MutableDisambiguationReport<T>>> reportsByResourceId = new HashMap<Integer, List<MutableDisambiguationReport<T>>>(); - for (T r : results) { - MutableDisambiguationReport<T> value = new MutableDisambiguationReport<T>(); - value.original = r; - int resourceId = extractor.extract(r); - if (resourceId > 0) { - List<MutableDisambiguationReport<T>> correspondingResults = reportsByResourceId.get(resourceId); - if (correspondingResults == null) { - correspondingResults = new ArrayList<MutableDisambiguationReport<T>>(); - reportsByResourceId.put(resourceId, correspondingResults); - } - correspondingResults.add(value); - } - reports.add(value); - } - - //check that we still have something to disambiguate - if (reportsByResourceId.size() > 0) { - //first find out how many ancestors we are going to require to disambiguate the resuls - String query = Resource.NATIVE_QUERY_FIND_DISAMBIGUATION_LEVEL; - - query = JDBCUtil.transformQueryForMultipleInParameters(query, "@@RESOURCE_IDS@@", results.size()); - Query disambiguateQuery = entityManager.createNativeQuery(query); - int i = 1; - for (T r : results) { - disambiguateQuery.setParameter(i++, extractor.extract(r)); - } - - Object[] rs = (Object[]) disambiguateQuery.getSingleResult(); - - int disambiguationLevel = Resource.MAX_SUPPORTED_RESOURCE_HIERARCHY_DEPTH; //the max we support - - Long targetCnt = ((Number) rs[0]).longValue(); - Long typeCnt = ((Number) rs[1]).longValue(); - Long typeAndPluginCnt = ((Number) rs[2]).longValue(); - for (i = 1; i <= Resource.MAX_SUPPORTED_RESOURCE_HIERARCHY_DEPTH; ++i) { - Long levelCnt = ((Number) rs[2 + i]).longValue(); - if (levelCnt == targetCnt) { - disambiguationLevel = i - 1; - break; - } - } - - if (alwaysIncludeParent && disambiguationLevel == 0) { - disambiguationLevel = 1; - } - - typeResolutionNeeded = typeAndPluginCnt > 1L; - pluginResolutionNeeded = typeAndPluginCnt > typeCnt; - parentResolutionNeeded = disambiguationLevel > 0; - - //k, now let's construct the JPQL query to get the parents and type infos... - StringBuilder selectBuilder = new StringBuilder( - "SELECT r0.id, r0.resourceType.name, r0.resourceType.plugin, r0.resourceType.singleton"); - StringBuilder fromBuilder = new StringBuilder("FROM Resource r0"); - - for (i = 1; i <= disambiguationLevel; ++i) { - int pi = i - 1; - selectBuilder.append(", r").append(i).append(".id"); - selectBuilder.append(", r").append(i).append(".name"); - selectBuilder.append(", r").append(i).append(".resourceType.name"); - selectBuilder.append(", r").append(i).append(".resourceType.plugin"); - selectBuilder.append(", r").append(i).append(".resourceType.singleton"); - - fromBuilder.append(" left join r").append(pi).append(".parentResource r").append(i); - } - - fromBuilder.append(" WHERE r0.id IN (:resourceIds)"); - - Query parentsQuery = entityManager.createQuery(selectBuilder.append(" ").append(fromBuilder).toString()); - - parentsQuery.setParameter("resourceIds", reportsByResourceId.keySet()); - - @SuppressWarnings("unchecked") - List<Object[]> parentsResults = (List<Object[]>) parentsQuery.getResultList(); - for (Object[] parentsResult : parentsResults) { - List<DisambiguationReport.Resource> parents = new ArrayList<DisambiguationReport.Resource>(disambiguationLevel); - Integer resourceId = (Integer) parentsResult[0]; - String typeName = (String) parentsResult[1]; - String pluginName = (String) parentsResult[2]; - Boolean singleton = (Boolean) parentsResult[3]; - - DisambiguationReport.ResourceType resourceType = new DisambiguationReport.ResourceType(typeName, pluginName, singleton); - - for (i = 0; i < disambiguationLevel; ++i) { - Integer parentId = (Integer) parentsResult[4 + 5 * i]; - if (parentId == null) - break; - String parentName = (String) parentsResult[4 + 5 * i + 1]; - String parentType = (String) parentsResult[4 + 5 * i + 2]; - String parentPlugin = (String) parentsResult[4 + 5 * i + 3]; - Boolean parentSingleton = (Boolean) parentsResult[4 + 5 * i + 4]; - - DisambiguationReport.ResourceType type = new DisambiguationReport.ResourceType(parentType, parentPlugin, parentSingleton); - - parents.add(new DisambiguationReport.Resource(parentId, parentName, type)); - } - - //update all the reports that correspond to this resourceId - for (MutableDisambiguationReport<T> report : reportsByResourceId.get(resourceId)) { - report.resourceType = resourceType; - report.parents = parents; - } - } - } - - List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size()); - - for (MutableDisambiguationReport<T> report : reports) { - resolution.add(report.getReport()); - } - - return new ResourceNamesDisambiguationResult<T>(resolution, typeResolutionNeeded, parentResolutionNeeded, - pluginResolutionNeeded); - } - - private static class MutableDisambiguationReport<T> { - public T original; - public DisambiguationReport.ResourceType resourceType; - public List<DisambiguationReport.Resource> parents; - - public DisambiguationReport<T> getReport() { - return new DisambiguationReport<T>(original, parents == null ? Collections - .<DisambiguationReport.Resource> emptyList() : parents, resourceType); - } + //TODO the alwaysIncludeParents is obsolete and ignored + //DisambiguationUpdateStrategy strategy = DisambiguationUpdateStrategy.KEEP_PARENTS_TO_TOPMOST_SERVERS; + DisambiguationUpdateStrategy strategy = DisambiguationUpdateStrategy.KEEP_ALL_PARENTS; + return Disambiguator.disambiguate(results, strategy, extractor, entityManager); } } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java index 066aae4..9ce98c3 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerLocal.java @@ -51,6 +51,7 @@ import org.rhq.core.domain.resource.group.composite.AutoGroupComposite; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.util.IntExtractor; +import org.rhq.enterprise.server.resource.disambiguation.Disambiguator; import org.rhq.enterprise.server.resource.group.ResourceGroupNotFoundException;
/** @@ -454,25 +455,7 @@ public interface ResourceManagerLocal { Resource getParentResource(Subject subject, int resourceId);
/** - * Given a list of results, this method produces an object decorates the provided original results - * with data needed to disambiguate the results with respect to resource names, their types and ancestory. - * <p> - * The disambiguation result contains information on what types of information are needed to make the resources - * in the original result unambiguous and contains the decorated original data in the same order as the - * supplied result list. - * <p> - * The objects in results do not necessarily need to correspond to a resource. In case of such objects, - * the resourceIdExtractor should return 0. In the resulting report such objects will still be wrapped - * in a {@link DisambiguationReport} but the parent list will be empty and resource type and plugin name will - * be null. - * - * @see ResourceNamesDisambiguationResult - * - * @param <T> the type of the result elements - * @param results the results to disambiguate - * @param alwayIncludeParent if true, the parent disambiguation will always be included in the result - * even if the results wouldn't have to be disambiguated using parents. - * @param resourceIdExtractor an object able to extract resource id from an instance of type parameter. + * @see Disambiguator#disambiguate(List, boolean, IntExtractor, javax.persistence.EntityManager) * @return the disambiguation result or null on error */ <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, boolean alwayIncludeParent, diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java new file mode 100644 index 0000000..8de734b --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationPolicy.java @@ -0,0 +1,207 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.server.resource.disambiguation; + +import java.util.ArrayList; +import java.util.EnumSet; + +/** + * A disambiguation policy determines whether two disambiguation reports are still ambiguous or not. + * <p> + * The policy is basically a list of {@link ResourceResolution} instances each corresponding to either + * the resource itself of some of its parent in the hierarchy. Each of the {@link ResourceResolution} instances + * in the list determines how the appropriate part of the report is disambiguated. + * <p> + * Only last element in this list actually decides whether the two reports are still ambiguous. The thinking + * behind this is that the previous resolutions in the chain are "decided" and the last one is the one + * we are currently trying to determine the correct resolution for. + * + * + * @author Lukas Krejci + */ +public class DisambiguationPolicy extends ArrayList<ResourceResolution> { + private static final long serialVersionUID = 1L; + + private DisambiguationUpdateStrategy parentsUpdateStrategy; + + public DisambiguationPolicy(DisambiguationUpdateStrategy parentsDisambiguationStrategy) { + this.parentsUpdateStrategy = parentsDisambiguationStrategy; + } + + public DisambiguationPolicy(DisambiguationPolicy other) { + super(other); + this.parentsUpdateStrategy = other.parentsUpdateStrategy; + } + + public static DisambiguationPolicy getUniqueNamePolicy(DisambiguationUpdateStrategy parentsDisambiguationStrategy) { + DisambiguationPolicy ret = new DisambiguationPolicy(parentsDisambiguationStrategy); + ret.add(ResourceResolution.NAME); + + return ret; + } + + public DisambiguationUpdateStrategy getParentsUpdateStrategy() { + return parentsUpdateStrategy; + } + + public void setParentsUpdateStrategy(DisambiguationUpdateStrategy parentsUpdateStrategy) { + this.parentsUpdateStrategy = parentsUpdateStrategy; + } + + /** + * Tells whether the last resolution in this policy determines the reports ambiguous. + * + * @param <T> + * @param a + * @param b + * @return + */ + public <T> boolean areAmbiguous(MutableDisambiguationReport<T> a, MutableDisambiguationReport<T> b) { + MutableDisambiguationReport.Resource ra = getComparingResource(a); + MutableDisambiguationReport.Resource rb = getComparingResource(b); + + if (ra == null || rb == null) + return false; + + ResourceResolution resolution = get(size() - 1); + + return resolution.areAmbiguous(ra, rb); + } + + /** + * @return the currently deciding {@link ResourceResolution} (i.e. the last element in this + * policy) + */ + public ResourceResolution getCurrentResourceResolution() { + return size() > 0 ? get(size() - 1) : null; + } + + /** + * If the user of this class determines that this policy can't disambiguate some list of reports, + * s/he can get the next policy to try by calling this method. + * + * @return the next policy in "chain" of possible policies + */ + public DisambiguationPolicy getNext() { + int lastIdx = size() - 1; + ResourceResolution lastResolution = get(lastIdx); + + DisambiguationPolicy ret = new DisambiguationPolicy(this); + + switch (lastResolution) { + case NAME: + ret.set(lastIdx, ResourceResolution.TYPE); + break; + case TYPE: + ret.set(lastIdx, ResourceResolution.PLUGIN); + break; + case PLUGIN: + ret.add(ResourceResolution.NAME); + break; + } + + return ret; + } + + /** + * @return a policy to be used to repartition unique reports using some other criteria or null + * if the current policy doesn't require repartitioning of unique reports. + */ + public DisambiguationPolicy getNextRepartitioningPolicy() { + ResourceResolution currentResolution = get(size() - 1); + + if (parentsUpdateStrategy.alwaysRepartitionableResolutions().contains(currentResolution) || (size() == 1) + && parentsUpdateStrategy.resourceLevelRepartitionableResolutions().contains(currentResolution)) { + + DisambiguationPolicy newPolicy = getNext(); + + //this policy is used for reports uniquely identified by type, but we are repartitioning them further. + //but this doesn't mean that they need to be repartitioned by plugin name because that would + //only supplement the information that is already evident from the type partitioning. + //therefore, skip the plugin resolution in that case. + if (currentResolution == ResourceResolution.TYPE) { + newPolicy = newPolicy.getNext(); + newPolicy.set(newPolicy.size() - 2, ResourceResolution.TYPE); + } + + return newPolicy; + } + + return null; + } + + public <T> void update(MutableDisambiguationReport<T> report) { + ResourceResolution resourceResolution = this.get(0); + resourceResolution.update(report.resource); + + int disambiguationPolicyIndex = 1; + while (disambiguationPolicyIndex < this.size() && disambiguationPolicyIndex - 1 < report.parents.size()) { + ResourceResolution parentResolution = this.get(disambiguationPolicyIndex); + MutableDisambiguationReport.Resource parent = report.parents.get(disambiguationPolicyIndex - 1); + parentResolution.update(parent); + + disambiguationPolicyIndex++; + } + + disambiguationPolicyIndex--; + + //because the parents update strategy might leave more parents than this policy requires for disambiguation + //we need to treat those parents as well. Because they are not needed for disambiguation, treat them as + //if only the name and type was needed for them. + for (; disambiguationPolicyIndex < report.parents.size(); ++disambiguationPolicyIndex) { + ResourceResolution.TYPE.update(report.parents.get(disambiguationPolicyIndex)); + } + + //don't replicate the plugin information on the parents if it was reported + //on the resource already. + //this has to be done on all the parents, not just the ones that are immediatelly needed + //for disambiguation. The parents update strategies might leave more parents than those needed. + if (resourceResolution == ResourceResolution.PLUGIN) { + for (MutableDisambiguationReport.Resource parent : report.parents) { + if (report.resource.resourceType.plugin.equals(parent.resourceType.plugin)) { + + parent.resourceType.plugin = null; + } + } + } + + parentsUpdateStrategy.update(this, report); + } + + private <T> MutableDisambiguationReport.Resource getComparingResource(MutableDisambiguationReport<T> report) { + int size = size(); + if (size == 0) + return null; + + if (size == 1) { + return report.resource; + } else { + int parentIdx = size - 2; + if (report.parents.size() > parentIdx) { + return report.parents.get(parentIdx); + } + } + return null; + } +} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java new file mode 100644 index 0000000..03b046a --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/DisambiguationUpdateStrategy.java @@ -0,0 +1,132 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.server.resource.disambiguation; + +import java.util.EnumSet; + +/** + * This enumerates different strategies that can be used to update the results to produce disambiguated list. + * + * @author Lukas Krejci + */ +public enum DisambiguationUpdateStrategy { + + /** + * The disambiguation policy is followed precisely. + */ + EXACT { + public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + int nofParents = policy.size() - 1; + if (nofParents < 0) + nofParents = 0; + + if (nofParents == 0) { + report.parents.clear(); + } else { + while (report.parents.size() > nofParents) { + report.parents.remove(report.parents.size() - 1); + } + } + } + }, + + /** + * Even if the disambiguation policy determined that parents are not needed to disambiguate the + * results, at least one of them is kept in the report. + */ + KEEP_AT_LEAST_ONE_PARENT { + public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + int nofParents = policy.size() - 1; + if (nofParents < 1) + nofParents = 1; + + while (report.parents.size() > nofParents) { + report.parents.remove(report.parents.size() - 1); + } + } + + @Override + public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { + return EnumSet.allOf(ResourceResolution.class); + } + }, + + /** + * The parentage of the report is retained at least up to the server/service directly under platform. + * If the policy needs the platform to stay, it is of course preserved. + */ + KEEP_PARENTS_TO_TOPMOST_SERVERS { + public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + //only remove the platform, if the policy doesn't dictate its presence... + if (policy.size() > 1 && report.parents.size() > policy.size() - 1) { + report.parents.remove(report.parents.size() - 1); + } + } + + @Override + public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { + return EnumSet.allOf(ResourceResolution.class); + } + }, + + /** + * All parents are preserved no matter what the policy says. + */ + KEEP_ALL_PARENTS { + public <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report) { + //do nothing to the parents, keep them as they are... + } + + @Override + public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { + return EnumSet.allOf(ResourceResolution.class); + } + }; + + /** + * Updates the report using the policy. + * + * @param <T> + * @param policy + * @param report + */ + public abstract <T> void update(DisambiguationPolicy policy, MutableDisambiguationReport<T> report); + + /** + * @return a set of resolutions for which the unique reports need to be repartitioned at the resource level. + * In another words this forces the disambiguation to continue on up the disambiguation chain even if the + * it disambiguates the resuts successfully at the resource level. + */ + public EnumSet<ResourceResolution> resourceLevelRepartitionableResolutions() { + return EnumSet.noneOf(ResourceResolution.class); + } + + /** + * @return a set of resolutions for which uniquely disambiguated reports are to be repartitioned further. + * The resolutions from this set apply on the parents (on any level), unlike the resolutions from {@link #resourceLevelRepartitionableResolutions()}. + */ + public EnumSet<ResourceResolution> alwaysRepartitionableResolutions() { + return EnumSet.noneOf(ResourceResolution.class); + } +} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java new file mode 100644 index 0000000..bbd5934 --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/Disambiguator.java @@ -0,0 +1,274 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.server.resource.disambiguation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.composite.DisambiguationReport; +import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; +import org.rhq.core.util.IntExtractor; +import org.rhq.core.util.jdbc.JDBCUtil; + +/** + * This is basically a helper class that provides the disambiguation method. + * It is intended to be used in an SLSB context. + * + * @author Lukas Krejci + */ +public class Disambiguator { + + public static final int MAXIMUM_DISAMBIGUATED_TREE_DEPTH = 7; + + private Disambiguator() { + + } + + /** + * Given a list of results, this method produces an object decorates the provided original results + * with data needed to disambiguate the results with respect to resource names, their types and ancestory. + * <p> + * The disambiguation result contains information on what types of information are needed to make the resources + * in the original result unambiguous and contains the decorated original data in the same order as the + * supplied result list. + * <p> + * The objects in results do not necessarily need to correspond to a resource. In case of such objects, + * the resourceIdExtractor should return 0. In the resulting report such objects will still be wrapped + * in a {@link DisambiguationReport} but the parent list will be empty and resource type and plugin name will + * be null. + * + * @see ResourceNamesDisambiguationResult + * + * @param <T> the type of the result elements + * @param results the results to disambiguate + * @param parentsDisambiguationStrategy how are the parents going to be disambiguated + * @param resourceIdExtractor an object able to extract resource id from an instance of type parameter. + * @param entityManager an entityManager to be used to access the database + * @return the disambiguation result or null on error + */ + public static <T> ResourceNamesDisambiguationResult<T> disambiguate(List<T> results, DisambiguationUpdateStrategy parentsDisambiguationStrategy, + IntExtractor<? super T> extractor, EntityManager entityManager) { + + if (results.isEmpty()) { + return new ResourceNamesDisambiguationResult<T>(new ArrayList<DisambiguationReport<T>>(), false, false, + false); + } + + //this is obsolete + boolean typeResolutionNeeded = true; + boolean pluginResolutionNeeded = true; + boolean parentResolutionNeeded = true; + + //we can't assume the ordering of the provided results and the disambiguation query results + //will be the same. + + //this list contains the resulting reports in the same order as the original results + List<MutableDisambiguationReport<T>> reports = new ArrayList<MutableDisambiguationReport<T>>(results.size()); + + //this maps the reports to resourceIds. More than one report can correspond to a single + //resource id. The reports in this map are the same instances as in the reports list. + Map<Integer, List<MutableDisambiguationReport<T>>> reportsByResourceId = new HashMap<Integer, List<MutableDisambiguationReport<T>>>(); + for (T r : results) { + int resourceId = extractor.extract(r); + MutableDisambiguationReport<T> value = new MutableDisambiguationReport<T>(); + value.original = r; + if (resourceId > 0) { + List<MutableDisambiguationReport<T>> correspondingResults = reportsByResourceId.get(resourceId); + if (correspondingResults == null) { + correspondingResults = new ArrayList<MutableDisambiguationReport<T>>(); + reportsByResourceId.put(resourceId, correspondingResults); + } + correspondingResults.add(value); + } + reports.add(value); + } + + //check that we still have something to disambiguate + if (reportsByResourceId.size() > 0) { + //k, now let's construct the JPQL query to get the parents and type infos... + StringBuilder selectBuilder = new StringBuilder( + "SELECT r0.id, r0.name, r0.resourceType.id, r0.resourceType.name, r0.resourceType.plugin, r0.resourceType.singleton"); + StringBuilder fromBuilder = new StringBuilder("FROM Resource r0"); + + for (int i = 1; i <= MAXIMUM_DISAMBIGUATED_TREE_DEPTH; ++i) { + int pi = i - 1; + selectBuilder.append(", r").append(i).append(".id"); + selectBuilder.append(", r").append(i).append(".name"); + selectBuilder.append(", rt").append(i).append(".id"); + selectBuilder.append(", rt").append(i).append(".name"); + selectBuilder.append(", rt").append(i).append(".plugin"); + selectBuilder.append(", rt").append(i).append(".singleton"); + + fromBuilder.append(" left join r").append(pi).append(".parentResource r").append(i); + fromBuilder.append(" left join r").append(i).append(".resourceType rt").append(i); + } + + fromBuilder.append(" WHERE r0.id IN (:resourceIds)"); + + Query parentsQuery = entityManager.createQuery(selectBuilder.append(" ").append(fromBuilder).toString()); + + parentsQuery.setParameter("resourceIds", reportsByResourceId.keySet()); + + //ok, now I will obtain all the information about the parents and types + //using the above defined JPQL query. + //I will partition the resulting reports by resource name.to create groups of + //resources that are "mutually ambiguous". Because each such group potenitally + //requires different level of disambiguation, I will then process them individually. + + ReportPartitions<T> partitionedReports = new ReportPartitions<T>(DisambiguationPolicy.getUniqueNamePolicy(parentsDisambiguationStrategy)); + + @SuppressWarnings("unchecked") + List<Object[]> parentsResults = (List<Object[]>) parentsQuery.getResultList(); + for (Object[] parentsResult : parentsResults) { + List<MutableDisambiguationReport.Resource> parents = new ArrayList<MutableDisambiguationReport.Resource>(MAXIMUM_DISAMBIGUATED_TREE_DEPTH); + Integer resourceId = (Integer) parentsResult[0]; + String resourceName = (String) parentsResult[1]; + Integer typeId = (Integer) parentsResult[2]; + String typeName = (String) parentsResult[3]; + String pluginName = (String) parentsResult[4]; + Boolean singleton = (Boolean) parentsResult[5]; + + MutableDisambiguationReport.ResourceType resourceType = new MutableDisambiguationReport.ResourceType(); + resourceType.id = typeId; + resourceType.name = typeName; + resourceType.plugin = pluginName; + resourceType.singleton = singleton; + + MutableDisambiguationReport.Resource resource = new MutableDisambiguationReport.Resource(); + resource.id = resourceId; + resource.name = resourceName; + resource.resourceType = resourceType; + + for (int i = 0; i < MAXIMUM_DISAMBIGUATED_TREE_DEPTH; ++i) { + Integer parentId = (Integer) parentsResult[6 + 6 * i]; + if (parentId == null) + break; + String parentName = (String) parentsResult[6 + 6 * i + 1]; + Integer parentTypeId = (Integer) parentsResult[6 + 6 * i + 2]; + String parentType = (String) parentsResult[6 + 6 * i + 3]; + String parentPlugin = (String) parentsResult[6 + 6 * i + 4]; + Boolean parentSingleton = (Boolean) parentsResult[6 + 6 * i + 5]; + + MutableDisambiguationReport.ResourceType type = new MutableDisambiguationReport.ResourceType(); + type.id = parentTypeId; + type.name = parentType; + type.plugin = parentPlugin; + type.singleton = parentSingleton; + + MutableDisambiguationReport.Resource parent = new MutableDisambiguationReport.Resource(); + parent.id = parentId; + parent.name = parentName; + parent.resourceType = type; + + parents.add(parent); + } + + //update all the reports that correspond to this resourceId + for (MutableDisambiguationReport<T> report : reportsByResourceId.get(resourceId)) { + report.resource = resource; + report.parents = parents; + + partitionedReports.put(report); + } + } + + //ok, now I have the reports partitioned by resource name. let's go through each partition + //and figure out the disambiguation needed for it. + + List<ReportPartitions<T>> ambiguousSubPartitions = new ArrayList<ReportPartitions<T>>(); + + if (!partitionedReports.isPartitionsUnique()) { + ambiguousSubPartitions.add(partitionedReports); + } else { + ReportPartitions<T> repartition = partitionedReports.updateUniqueReports(); + while (repartition != null) { + if(!repartition.isPartitionsUnique()) { + ambiguousSubPartitions.add(repartition); + repartition = null; + } else { + repartition = repartition.updateUniqueReports(); + } + } + } + + while (ambiguousSubPartitions.size() > 0) { + Iterator<ReportPartitions<T>> subPartitionIterator = ambiguousSubPartitions.iterator(); + List<ReportPartitions<T>> newAmbiguousPartitions = new ArrayList<ReportPartitions<T>>(); + + while(subPartitionIterator.hasNext()) { + ReportPartitions<T> subPartition = subPartitionIterator.next(); + + ReportPartitions<T> repartition = subPartition.updateUniqueReports(); + while (repartition != null) { + if(!repartition.isPartitionsUnique()) { + newAmbiguousPartitions.add(repartition); + repartition = null; + } else { + repartition = repartition.updateUniqueReports(); + } + } + + for(List<MutableDisambiguationReport<T>> partitionReports : subPartition.getAmbiguousPartitions()) { + ReportPartitions<T> replacementSubpartition = new ReportPartitions<T>(subPartition.getDisambiguationPolicy().getNext()); + replacementSubpartition.putAll(partitionReports); + if (!replacementSubpartition.isPartitionsUnique()) { + newAmbiguousPartitions.add(replacementSubpartition); + } else { + repartition = replacementSubpartition.updateUniqueReports(); + while (repartition != null) { + if(!repartition.isPartitionsUnique()) { + newAmbiguousPartitions.add(repartition); + repartition = null; + } else { + repartition = repartition.updateUniqueReports(); + } + } + } + } + subPartitionIterator.remove(); + } + + for(ReportPartitions<T> newPartition : newAmbiguousPartitions) { + ambiguousSubPartitions.add(newPartition); + } + } + } + + List<DisambiguationReport<T>> resolution = new ArrayList<DisambiguationReport<T>>(results.size()); + + for (MutableDisambiguationReport<T> report : reports) { + resolution.add(report.getReport()); + } + + return new ResourceNamesDisambiguationResult<T>(resolution, typeResolutionNeeded, parentResolutionNeeded, + pluginResolutionNeeded); + } +} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java new file mode 100644 index 0000000..68995d9 --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/MutableDisambiguationReport.java @@ -0,0 +1,87 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.server.resource.disambiguation; + +import java.util.ArrayList; +import java.util.List; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; + +/** + * This is a helper class representing a disambiguation report during the process of disambiguation + * where a writable access is needed to the report's properties. The resulting {@link DisambiguationReport} + * is an immutable class. + * + * @param <T> the type of the instances being disambiguated + * + * @author Lukas Krejci + */ +public class MutableDisambiguationReport<T> { + public static class ResourceType { + public int id; + public String name; + public String plugin; + public boolean singleton; + + public DisambiguationReport.ResourceType getResourceType() { + return new DisambiguationReport.ResourceType(name, plugin, singleton); + } + + public String toString() { + return "MutableResourceType[id=" + id + ", name='" + name + "', plugin='" + plugin + "', singleton=" + singleton + "]"; + } + } + + public static class Resource { + public int id; + public String name; + public MutableDisambiguationReport.ResourceType resourceType; + + public DisambiguationReport.Resource getResource() { + return new DisambiguationReport.Resource(id, name, resourceType.getResourceType()); + } + + public String toString() { + return "MutableResource[id=" + id + ", name='" + name + ", resourceType=" + resourceType + "]"; + } + } + + public T original; + public MutableDisambiguationReport.Resource resource; + public List<MutableDisambiguationReport.Resource> parents; + + public DisambiguationReport<T> getReport() { + List<DisambiguationReport.Resource> realParents = new ArrayList<DisambiguationReport.Resource>(); + if (parents != null) { + for(MutableDisambiguationReport.Resource p : parents) { + realParents.add(p.getResource()); + } + } + return new DisambiguationReport<T>(original, realParents, resource.resourceType.getResourceType()); + } + + public String toString() { + return "MutableDisambiguationReport[resource=" + resource + ", parents=" + parents + "]"; + } +} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java new file mode 100644 index 0000000..7b57270 --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ReportPartitions.java @@ -0,0 +1,154 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.server.resource.disambiguation; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * This class partitions the reports inserted into it by chunking them up + * into sublists containing mutually ambiguous reports. The ambiguity is determined using + * a {@link DisambiguationPolicy}. + * + * @param <T> the type of the original instances the are being disambiguated. + * + * @author Lukas Krejci + */ +public class ReportPartitions<T> { + + private static final long serialVersionUID = 1L; + private DisambiguationPolicy disambiguationPolicy; + private Map<Integer, List<MutableDisambiguationReport<T>>> partitions; + + /** + * @see MutableDisambiguationReport#getComparisonForLevel(int) + * + * @param comparisonLevel + */ + public ReportPartitions(DisambiguationPolicy disambiguationPolicy) { + this.disambiguationPolicy = disambiguationPolicy; + partitions = new HashMap<Integer, List<MutableDisambiguationReport<T>>>(); + } + + public DisambiguationPolicy getDisambiguationPolicy() { + return disambiguationPolicy; + } + + public List<List<MutableDisambiguationReport<T>>> getAmbiguousPartitions() { + List<List<MutableDisambiguationReport<T>>> ret = new ArrayList<List<MutableDisambiguationReport<T>>>(); + + for (List<MutableDisambiguationReport<T>> partition : partitions.values()) { + if (partition.size() > 1) { + ret.add(partition); + } + } + + return ret; + } + + public List<List<MutableDisambiguationReport<T>>> getUniquePartitions() { + List<List<MutableDisambiguationReport<T>>> ret = new ArrayList<List<MutableDisambiguationReport<T>>>(); + + for (List<MutableDisambiguationReport<T>> partition : partitions.values()) { + if (partition.size() == 1) { + ret.add(partition); + } + } + + return ret; + } + + public void put(MutableDisambiguationReport<T> value) { + boolean found = false; + for (Map.Entry<Integer, List<MutableDisambiguationReport<T>>> entry : partitions.entrySet()) { + for (MutableDisambiguationReport<T> partitionPrototype : entry.getValue()) { + if (disambiguationPolicy.areAmbiguous(partitionPrototype, value)) { + found = true; + break; + } + } + if (found) { + entry.getValue().add(value); + break; + } + } + + if (!found) { + List<MutableDisambiguationReport<T>> newPartition = new ArrayList<MutableDisambiguationReport<T>>(); + newPartition.add(value); + partitions.put(partitions.size(), newPartition); + } + } + + public void putAll(List<MutableDisambiguationReport<T>> values) { + for (MutableDisambiguationReport<T> v : values) { + put(v); + } + } + + /** + * Updates the reports in the unique partitions. + * + * @return if the current policy is determined "repartitionable", the returned partitions instance splits the current + * unique reports by some other policy. If the current policy is not repartitionable, a null value is returned. + */ + public ReportPartitions<T> updateUniqueReports() { + List<MutableDisambiguationReport<T>> uniqueReports = new ArrayList<MutableDisambiguationReport<T>>(); + for (List<MutableDisambiguationReport<T>> val : partitions.values()) { + if (val.size() == 1) { + uniqueReports.addAll(val); + } + } + + DisambiguationPolicy repartitioningPolicy = disambiguationPolicy.getNextRepartitioningPolicy(); + if (repartitioningPolicy != null) { + ReportPartitions<T> ret = new ReportPartitions<T>(repartitioningPolicy); + ret.putAll(uniqueReports); + + return ret; + } + + for (MutableDisambiguationReport<T> report : uniqueReports) { + disambiguationPolicy.update(report); + } + + return null; + } + + public boolean isPartitionsUnique() { + for (List<MutableDisambiguationReport<T>> partition : partitions.values()) { + if (partition.size() > 1) { + return false; + } + } + return true; + } + + public String toString() { + return "ReportPartitions[policy=" + disambiguationPolicy + ", partitions=" + partitions + "]"; + } +} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ResourceResolution.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ResourceResolution.java new file mode 100644 index 0000000..bc5d89c --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/disambiguation/ResourceResolution.java @@ -0,0 +1,60 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.server.resource.disambiguation; + +public enum ResourceResolution { + NAME { + public boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b) { + return (a.id != b.id && a.name.equals(b.name)); + } + + @Override + public void update(MutableDisambiguationReport.Resource resource) { + resource.resourceType.plugin = null; + } + }, + TYPE { + public boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b) { + return ((a.resourceType.id != b.resourceType.id) && (a.resourceType.name.equals(b.resourceType.name))) + || (a.resourceType.id == b.resourceType.id && NAME.areAmbiguous(a, b)); + } + + @Override + public void update(MutableDisambiguationReport.Resource resource) { + resource.resourceType.plugin = null; + } + }, + PLUGIN { + public boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b) { + return (a.resourceType.id != b.resourceType.id) && (a.resourceType.name.equals(b.resourceType.name)) && (a.resourceType.plugin.equals(b.resourceType.plugin)) + || (a.resourceType.id == b.resourceType.id && NAME.areAmbiguous(a, b)); + } + }; + + public abstract boolean areAmbiguous(MutableDisambiguationReport.Resource a, MutableDisambiguationReport.Resource b); + + public void update(MutableDisambiguationReport.Resource resource) { + //by default do nothing + } +} \ No newline at end of file
commit 6b776093a7ed0b998801763ae3448c423682e59f Author: Lukas Krejci lkrejci@redhat.com Date: Thu Apr 29 15:29:49 2010 +0200
Set of changes to implement the different variants of search page results.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java index dd359da..5ce12d0 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/DisambiguationReport.java @@ -36,34 +36,110 @@ public class DisambiguationReport<T> implements Serializable { private static final long serialVersionUID = 1L;
private T original; - private List<ResourceParentFlyweight> parents; - private String resourceTypeName; - private String resourceTypePluginName; + private List<Resource> parents; + private ResourceType resourceType;
- public DisambiguationReport(T original, List<ResourceParentFlyweight> parents, String resourceTypeName, String resourceTypePluginName) { + public static class ResourceType implements Serializable { + + private static final long serialVersionUID = 1L; + private String name; + private String plugin; + private boolean singleton; + + /** + * @param name + * @param plugin + * @param singleton + */ + public ResourceType(String name, String plugin, boolean singleton) { + super(); + this.name = name; + this.plugin = plugin; + this.singleton = singleton; + } + + public String getName() { + return name; + } + public String getPlugin() { + return plugin; + } + public boolean isSingleton() { + return singleton; + } + + public String toString() { + return "ResourceType[name='" + name + "', plugin='" + plugin + "'" + "]"; + } + } + + public static class Resource implements Serializable { + + private static final long serialVersionUID = 1L; + private int id; + private String name; + private ResourceType type; + + /** + * @param id + * @param name + * @param type + */ + public Resource(int id, String name, ResourceType type) { + this.id = id; + this.name = name; + this.type = type; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public ResourceType getType() { + return type; + } + + public String toString() { + return "Resource[id=" + id + ", name='" + name + "', type=" + type + "]"; + } + } + + public DisambiguationReport(T original, List<Resource> parents, ResourceType resourceType) { this.original = original; this.parents = Collections.unmodifiableList(parents); - this.resourceTypeName = resourceTypeName; - this.resourceTypePluginName = resourceTypePluginName; + this.resourceType = resourceType; }
public T getOriginal() { return original; }
- public List<ResourceParentFlyweight> getParents() { + public List<Resource> getParents() { return parents; }
+ @Deprecated public String getResourceTypeName() { - return resourceTypeName; + return resourceType.getName(); }
+ @Deprecated public String getResourceTypePluginName() { - return resourceTypePluginName; + return resourceType.getPlugin(); + } + + /** + * @return the ResourceType of the resource represented by the {@link #getOriginal()} + */ + public ResourceType getResourceType() { + return resourceType; }
public String toString() { - return "DisambiguationReport(type=" + resourceTypeName + ", plugin=" + resourceTypePluginName + ", parents=" + parents + ", original=" + original + ")"; + return "DisambiguationReport(type=" + resourceType + ", parents=" + parents + ", original=" + original + ")"; } } \ No newline at end of file diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceParentFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceParentFlyweight.java deleted file mode 100644 index c0d09ca..0000000 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceParentFlyweight.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.rhq.core.domain.resource.composite; - -import java.io.Serializable; - -/** - * A light-weight representation of a resource parent. - * - * @author Lukas Krejci - */ -public class ResourceParentFlyweight implements Serializable { - - private static final long serialVersionUID = 1L; - private int parentId; - private String parentName; - private String parentResourceTypeName; - - /** - * @param parentId - * @param parentName - */ - public ResourceParentFlyweight(int parentId, String parentName, String parentResourceTypeName) { - this.parentId = parentId; - this.parentName = parentName; - this.parentResourceTypeName = parentResourceTypeName; - } - - public int getParentId() { - return parentId; - } - - public String getParentName() { - return parentName; - } - - public String getParentResourceTypeName() { - return parentResourceTypeName; - } - - public String toString() { - return "ResourceParentFlyweight(id=" + parentId + ", name=" + parentName + ")"; - } -} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageComponent.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageComponent.java index fdfde42..98502bc 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageComponent.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageComponent.java @@ -28,7 +28,7 @@ import java.util.List; import javax.faces.component.UIComponentBase; import javax.faces.context.FacesContext;
-import org.rhq.core.domain.resource.composite.ResourceParentFlyweight; +import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.gui.util.FacesComponentUtility;
/** @@ -49,7 +49,7 @@ public class ResourcePartialLineageComponent extends UIComponentBase {
private Boolean renderLinks; private String separator; - private List<ResourceParentFlyweight> parents; + private List<DisambiguationReport.Resource> parents;
public String getFamily() { return COMPONENT_FAMILY; @@ -86,7 +86,7 @@ public class ResourcePartialLineageComponent extends UIComponentBase { }
@SuppressWarnings("unchecked") - public List<ResourceParentFlyweight> getParents() { + public List<DisambiguationReport.Resource> getParents() { if (parents == null) { //do *NOT* store this value into the parents explicitly //unless dynamic updates (if the expression is in loop for example) @@ -97,7 +97,7 @@ public class ResourcePartialLineageComponent extends UIComponentBase { } }
- public void setParents(List<ResourceParentFlyweight> parents) { + public void setParents(List<DisambiguationReport.Resource> parents) { this.parents = parents; }
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java index 63eeda4..d6e12a9 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java @@ -32,7 +32,7 @@ import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.render.Renderer;
-import org.rhq.core.domain.resource.composite.ResourceParentFlyweight; +import org.rhq.core.domain.resource.composite.DisambiguationReport;
/** * Renderer for {@link ResourcePartialLineageComponent} @@ -47,13 +47,13 @@ public class ResourcePartialLineageRenderer extends Renderer { ResourcePartialLineageComponent lineageComponent = (ResourcePartialLineageComponent) component;
String separator = lineageComponent.getSeparator(); - List<ResourceParentFlyweight> parents = lineageComponent.getParents(); + List<DisambiguationReport.Resource> parents = lineageComponent.getParents(); boolean renderLinks = lineageComponent.getRenderLinks();
if (parents != null && parents.size() > 0) { ResponseWriter writer = context.getResponseWriter();
- Iterator<ResourceParentFlyweight> parentsIt = parents.iterator(); + Iterator<DisambiguationReport.Resource> parentsIt = parents.iterator();
if (renderLinks) { encodeUrl(writer, parentsIt.next()); @@ -71,21 +71,23 @@ public class ResourcePartialLineageRenderer extends Renderer { } }
- private void encodeUrl(ResponseWriter writer, ResourceParentFlyweight parent) throws IOException { + private void encodeUrl(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { writer.startElement("a", null); writer.writeAttribute("href", getUrl(parent), null); encodeSimple(writer, parent); writer.endElement("a"); }
- private void encodeSimple(ResponseWriter writer, ResourceParentFlyweight parent) throws IOException { - writer.writeText(parent.getParentName(), null); - writer.writeText(" (", null); - writer.writeText(parent.getParentResourceTypeName(), null); - writer.writeText(")", null); + private void encodeSimple(ResponseWriter writer, DisambiguationReport.Resource parent) throws IOException { + writer.writeText(parent.getName(), null); + if (!parent.getType().isSingleton()) { + writer.writeText(" (", null); + writer.writeText(parent.getType().getName(), null); + writer.writeText(")", null); + } }
- private static String getUrl(ResourceParentFlyweight parent) { - return RESOURCE_URL + "?id=" + parent.getParentId(); + private static String getUrl(DisambiguationReport.Resource parent) { + return RESOURCE_URL + "?id=" + parent.getId(); } } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java index 589b54c..082425d 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java @@ -39,7 +39,6 @@ import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; -import org.rhq.core.domain.resource.composite.ResourceParentFlyweight; import org.rhq.core.domain.resource.group.GroupCategory; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.util.PageControl; @@ -189,5 +188,44 @@ public class AddGroupResourcesFormPrepareAction extends Action { }
return resourceCategoryTypes; - } -} \ No newline at end of file + } + + // + // These two methods are to support the resource names disambiguation in the above code. + // Hopefully this page gets rewritten in JSF so that we don't have to employ this kind of + // nasties. + // + + private static PageList<Resource> buildResourceList(ResourceNamesDisambiguationResult<Resource> results, int totalSize, PageControl pageControl) { + ArrayList<Resource> convertedResults = new ArrayList<Resource>(results.getResolution().size()); + + for(DisambiguationReport<Resource> dr : results.getResolution()) { + Resource resource = dr.getOriginal(); + + Resource parent = resource.getParentResource(); + //platforms don't have parents, need to check for null here + if (parent != null) { + parent.setName(buildLineage(dr.getParents())); + } + + convertedResults.add(resource); + } + return new PageList<Resource>(convertedResults, totalSize, pageControl); + } + + private static String buildLineage(List<DisambiguationReport.Resource> parents) { + if (parents == null || parents.size() == 0) { + return ""; + } + + Iterator<DisambiguationReport.Resource> it = parents.iterator(); + + StringBuilder bld = new StringBuilder(it.next().getName()); + + while (it.hasNext()) { + bld.append(ResourcePartialLineageComponent.DEFAULT_SEPARATOR).append(it.next().getName()); + } + + return bld.toString(); + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml index 0e66beb..b58a0b9 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml @@ -126,17 +126,32 @@ rich:column <f:facet name="header"> <onc:sortableColumnHeader sort="r.name"> - <h:outputText styleClass="headerText" value="Resource" /> + <h:outputText styleClass="headerText" value="Name" /> </onc:sortableColumnHeader> </f:facet>
<h:outputLink value="#{onf:getDefaultResourceTabURL()}"> <f:param name="id" value="#{item.original.resource.id}" /> <h:outputText value="#{item.original.resource.name}" /> + <!-- <h:outputText value=" (#{item.original.resource.resourceType.name})" /> + --> + <h:outputText value="#{item.resourceType.singleton ? '' : ' ('}" /> + <h:outputText value="#{item.resourceType.singleton ? '' : item.original.resource.resourceType.name}" /> + <h:outputText value="#{item.resourceType.singleton ? '' : ')'}" /> </h:outputLink> </rich:column> - +<!-- + <rich:column> + <f:facet name="header"> + <onc:sortableColumnHeader sort="r.resourceType.name"> + <h:outputText styleClass="headerText" value="Type" /> + </onc:sortableColumnHeader> + </f:facet> + + <h:outputText value="#{item.original.resource.resourceType.name}" /> + </rich:column> + --> rich:column <f:facet name="header"> <h:outputText styleClass="headerText" value="Location" /> diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java index f4cde3a..a427db1 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java @@ -95,7 +95,6 @@ import org.rhq.core.domain.resource.composite.ResourceHealthComposite; import org.rhq.core.domain.resource.composite.ResourceIdFlyWeight; import org.rhq.core.domain.resource.composite.ResourceInstallCount; import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; -import org.rhq.core.domain.resource.composite.ResourceParentFlyweight; import org.rhq.core.domain.resource.composite.ResourceWithAvailability; import org.rhq.core.domain.resource.flyweight.FlyweightCache; import org.rhq.core.domain.resource.flyweight.ResourceFlyweight; @@ -2169,7 +2168,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
//k, now let's construct the JPQL query to get the parents and type infos... StringBuilder selectBuilder = new StringBuilder( - "SELECT r0.id, r0.resourceType.name, r0.resourceType.plugin"); + "SELECT r0.id, r0.resourceType.name, r0.resourceType.plugin, r0.resourceType.singleton"); StringBuilder fromBuilder = new StringBuilder("FROM Resource r0");
for (i = 1; i <= disambiguationLevel; ++i) { @@ -2177,6 +2176,9 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage selectBuilder.append(", r").append(i).append(".id"); selectBuilder.append(", r").append(i).append(".name"); selectBuilder.append(", r").append(i).append(".resourceType.name"); + selectBuilder.append(", r").append(i).append(".resourceType.plugin"); + selectBuilder.append(", r").append(i).append(".resourceType.singleton"); + fromBuilder.append(" left join r").append(pi).append(".parentResource r").append(i); }
@@ -2189,25 +2191,31 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage @SuppressWarnings("unchecked") List<Object[]> parentsResults = (List<Object[]>) parentsQuery.getResultList(); for (Object[] parentsResult : parentsResults) { - List<ResourceParentFlyweight> parents = new ArrayList<ResourceParentFlyweight>(disambiguationLevel); + List<DisambiguationReport.Resource> parents = new ArrayList<DisambiguationReport.Resource>(disambiguationLevel); Integer resourceId = (Integer) parentsResult[0]; String typeName = (String) parentsResult[1]; String pluginName = (String) parentsResult[2]; - + Boolean singleton = (Boolean) parentsResult[3]; + + DisambiguationReport.ResourceType resourceType = new DisambiguationReport.ResourceType(typeName, pluginName, singleton); + for (i = 0; i < disambiguationLevel; ++i) { - Integer parentId = (Integer) parentsResult[3 + 3 * i]; + Integer parentId = (Integer) parentsResult[4 + 5 * i]; if (parentId == null) break; - String parentName = (String) parentsResult[3 + 3 * i + 1]; - String parentType = (String) parentsResult[3 + 3 * i + 2]; + String parentName = (String) parentsResult[4 + 5 * i + 1]; + String parentType = (String) parentsResult[4 + 5 * i + 2]; + String parentPlugin = (String) parentsResult[4 + 5 * i + 3]; + Boolean parentSingleton = (Boolean) parentsResult[4 + 5 * i + 4]; + + DisambiguationReport.ResourceType type = new DisambiguationReport.ResourceType(parentType, parentPlugin, parentSingleton);
- parents.add(new ResourceParentFlyweight(parentId, parentName, parentType)); + parents.add(new DisambiguationReport.Resource(parentId, parentName, type)); }
//update all the reports that correspond to this resourceId for (MutableDisambiguationReport<T> report : reportsByResourceId.get(resourceId)) { - report.typeName = typeName; - report.pluginName = pluginName; + report.resourceType = resourceType; report.parents = parents; } } @@ -2225,13 +2233,12 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
private static class MutableDisambiguationReport<T> { public T original; - public String typeName; - public String pluginName; - public List<ResourceParentFlyweight> parents; + public DisambiguationReport.ResourceType resourceType; + public List<DisambiguationReport.Resource> parents;
public DisambiguationReport<T> getReport() { return new DisambiguationReport<T>(original, parents == null ? Collections - .<ResourceParentFlyweight> emptyList() : parents, typeName, pluginName); + .<DisambiguationReport.Resource> emptyList() : parents, resourceType); } } }
commit 1ae4b54324d310c4e7e3ccc15ba811b332c99a51 Author: Lukas Krejci lkrejci@redhat.com Date: Wed Apr 21 09:44:37 2010 +0200
Preliminary version of search results UI.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceParentFlyweight.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceParentFlyweight.java index 1298df4..c0d09ca 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceParentFlyweight.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceParentFlyweight.java @@ -35,14 +35,16 @@ public class ResourceParentFlyweight implements Serializable { private static final long serialVersionUID = 1L; private int parentId; private String parentName; - + private String parentResourceTypeName; + /** * @param parentId * @param parentName */ - public ResourceParentFlyweight(int parentId, String parentName) { + public ResourceParentFlyweight(int parentId, String parentName, String parentResourceTypeName) { this.parentId = parentId; this.parentName = parentName; + this.parentResourceTypeName = parentResourceTypeName; }
public int getParentId() { @@ -53,6 +55,10 @@ public class ResourceParentFlyweight implements Serializable { return parentName; }
+ public String getParentResourceTypeName() { + return parentResourceTypeName; + } + public String toString() { return "ResourceParentFlyweight(id=" + parentId + ", name=" + parentName + ")"; } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java index a526a53..63eeda4 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourcePartialLineageRenderer.java @@ -80,6 +80,9 @@ public class ResourcePartialLineageRenderer extends Renderer {
private void encodeSimple(ResponseWriter writer, ResourceParentFlyweight parent) throws IOException { writer.writeText(parent.getParentName(), null); + writer.writeText(" (", null); + writer.writeText(parent.getParentResourceTypeName(), null); + writer.writeText(")", null); }
private static String getUrl(ResourceParentFlyweight parent) { diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml index 571d93d..0e66beb 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml @@ -65,7 +65,7 @@ value="#{browseResourcesDataModel}" var="item" width="100%" - columnsWidth="1%, 5%, 20%, 20%, 5%, 10%, 10%, 25%, 4%" + columnsWidth="1%, 5%, 30%, 44%, 19%, 1%" headerClass="tableRowHeader" footerClass="on-pager-footer" onRowMouseOver="this.style.backgroundColor='#E7E7E7'" @@ -125,20 +125,21 @@
rich:column <f:facet name="header"> - <onc:sortableColumnHeader sort="name"> - <h:outputText styleClass="headerText" value="Name" /> + <onc:sortableColumnHeader sort="r.name"> + <h:outputText styleClass="headerText" value="Resource" /> </onc:sortableColumnHeader> </f:facet>
<h:outputLink value="#{onf:getDefaultResourceTabURL()}"> <f:param name="id" value="#{item.original.resource.id}" /> <h:outputText value="#{item.original.resource.name}" /> + <h:outputText value=" (#{item.original.resource.resourceType.name})" /> </h:outputLink> </rich:column>
rich:column <f:facet name="header"> - <h:outputText styleClass="headerText" value="Parent" /> + <h:outputText styleClass="headerText" value="Location" /> </f:facet>
<onc:resourcePartialLineage parents="#{item.parents}" renderLinks="true"/> @@ -146,37 +147,7 @@
rich:column <f:facet name="header"> - <onc:sortableColumnHeader sort="resourceType.category"> - <h:outputText styleClass="headerText" value="Category" /> - </onc:sortableColumnHeader> - </f:facet> - - <h:outputText value="#{item.original.resource.resourceType.category.name}" /> - </rich:column> - - rich:column - <f:facet name="header"> - <onc:sortableColumnHeader sort="resourceType.name"> - <h:outputText styleClass="headerText" value="Type" /> - </onc:sortableColumnHeader> - </f:facet> - - <h:outputText value="#{item.original.resource.resourceType.name}" /> - </rich:column> - - rich:column - <f:facet name="header"> - <onc:sortableColumnHeader sort="resourceType.plugin"> - <h:outputText styleClass="headerText" value="Plugin" /> - </onc:sortableColumnHeader> - </f:facet> - - <h:outputText value="#{item.original.resource.resourceType.plugin}" /> - </rich:column> - - rich:column - <f:facet name="header"> - <onc:sortableColumnHeader sort="description"> + <onc:sortableColumnHeader sort="r.description"> <h:outputText styleClass="headerText" value="Description" /> </onc:sortableColumnHeader> </f:facet> @@ -196,7 +167,7 @@
<f:facet name="footer"> rich:columnGroup - <rich:column colspan="9" width="100%"> + <rich:column colspan="6" width="100%"> <onc:selectCommandButton action="#{BrowseResourcesUIBean.uninventorySelectedResources}" value="UNINVENTORY SELECTED" target="selectedItems" styleClass="on-pager-button buttonsmall" rendered="#{GlobalPermissionsUIBean.inventory}" /> diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java index 5fbbaa6..f4cde3a 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java @@ -2176,6 +2176,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage int pi = i - 1; selectBuilder.append(", r").append(i).append(".id"); selectBuilder.append(", r").append(i).append(".name"); + selectBuilder.append(", r").append(i).append(".resourceType.name"); fromBuilder.append(" left join r").append(pi).append(".parentResource r").append(i); }
@@ -2193,12 +2194,14 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage String typeName = (String) parentsResult[1]; String pluginName = (String) parentsResult[2];
- for (i = 1; i <= disambiguationLevel; ++i) { - Integer parentId = (Integer) parentsResult[2 * i + 1]; + for (i = 0; i < disambiguationLevel; ++i) { + Integer parentId = (Integer) parentsResult[3 + 3 * i]; if (parentId == null) break; - String parentName = (String) parentsResult[2 * i + 2]; - parents.add(new ResourceParentFlyweight(parentId, parentName)); + String parentName = (String) parentsResult[3 + 3 * i + 1]; + String parentType = (String) parentsResult[3 + 3 * i + 2]; + + parents.add(new ResourceParentFlyweight(parentId, parentName, parentType)); }
//update all the reports that correspond to this resourceId
commit 7bdf38a07aaf771c5d9c0136d2eccf251d9dfb59 Author: Lukas Krejci lkrejci@redhat.com Date: Tue May 4 14:01:30 2010 +0200
BZ 580919 - The "Has Alerts or Currently Unavailable" (aka problemResources) portlet uses resource names disambiguation.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java index 0e8a6a2..6fc3516 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/problemresources/ViewAction.java @@ -38,23 +38,33 @@ import org.apache.struts.tiles.actions.TilesAction; import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.resource.composite.ProblemResourceComposite; import org.rhq.core.domain.util.PageControl; +import org.rhq.core.domain.util.PageList; +import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.WebUserPreferences.ProblemResourcesPortletPreferences; +import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.server.measurement.MeasurementProblemManagerLocal; import org.rhq.enterprise.server.measurement.util.MeasurementUtils; +import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.util.LookupUtil;
public class ViewAction extends TilesAction {
private static final Log log = LogFactory.getLog(ViewAction.class);
+ private static final IntExtractor<ProblemResourceComposite> RESOURCE_ID_EXTRACTOR = new IntExtractor<ProblemResourceComposite>() { + public int extract(ProblemResourceComposite object) { + return object.getResourceId(); + } + }; + @Override public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- List<ProblemResourceComposite> list = new ArrayList<ProblemResourceComposite>(); + List<DisambiguatedResourceListUtil.Record<ProblemResourceComposite>> disambiguatedList = new ArrayList<DisambiguatedResourceListUtil.Record<ProblemResourceComposite>>();
String timeRange = getResources(request).getMessage("dash.home.ProblemResources.timeRangeUnlimited"); try { @@ -88,9 +98,15 @@ public class ViewAction extends TilesAction {
try { MeasurementProblemManagerLocal problemManager = LookupUtil.getMeasurementProblemManager(); + ResourceManagerLocal resourceManager = LookupUtil.getResourceManager(); long start = System.currentTimeMillis(); - list = problemManager.findProblemResources(subject, begin, new PageControl(0, + PageList<ProblemResourceComposite> list = problemManager.findProblemResources(subject, begin, new PageControl(0, problemResourcePreferences.range)); + + disambiguatedList = DisambiguatedResourceListUtil.buildResourceList( + resourceManager.disambiguate(list, true, RESOURCE_ID_EXTRACTOR), + list.getTotalSize(), list.getPageControl(), true); + long end = System.currentTimeMillis(); log.debug("Performance: Took [" + (end - start) + "]ms to find " + problemResourcePreferences.range + " problem resources"); @@ -105,7 +121,7 @@ public class ViewAction extends TilesAction { } } finally { request.setAttribute("timeRange", timeRange); - context.putAttribute("problemResources", list); + context.putAttribute("problemResources", disambiguatedList); }
return null; diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java index e0c3b5b..24a373a 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java @@ -52,10 +52,12 @@ public class DisambiguatedResourceListUtil {
private T original; private String lineage; + private String originalResourceTypeName;
- public Record(T original, String lineage) { + public Record(T original, String resourceTypeName, String lineage) { this.original = original; this.lineage = lineage; + this.originalResourceTypeName = resourceTypeName; }
public T getOriginal() { @@ -65,13 +67,21 @@ public class DisambiguatedResourceListUtil { public String getLineage() { return lineage; } + + public String getOriginalResourceTypeName() { + return originalResourceTypeName; + } }
public static <T> PageList<Record<T>> buildResourceList(ResourceNamesDisambiguationResult<T> results, int totalSize, PageControl pageControl, boolean renderLinks) { ArrayList<Record<T>> convertedResults = new ArrayList<Record<T>>(results.getResolution().size());
for(DisambiguationReport<T> dr : results.getResolution()) { - convertedResults.add(new Record<T>(dr.getOriginal(), buildLineage(dr.getParents(), renderLinks))); + String typeName = dr.getResourceTypeName(); + if (results.isPluginResolutionNeeded()) { + typeName += " (" + dr.getResourceTypePluginName() + " plugin)"; + } + convertedResults.add(new Record<T>(dr.getOriginal(), typeName, buildLineage(dr.getParents(), renderLinks))); } return new PageList<Record<T>>(convertedResults, totalSize, pageControl); } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp index f7cea49..93695da 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/problemResources/View.jsp @@ -32,19 +32,21 @@ </c:when> <c:when test="${not empty problemResources}"> <display:table cellspacing="0" cellpadding="0" width="100%" action="/Dashboard.do" - var="probres" items="${problemResources}" > - <display:column width="60%" href="/rhq/resource/summary/overview.xhtml?id=${probres.resourceId}" property="resourceName" title="dash.home.TableHeader.ResourceName"/> - <display:column width="10%" property="numAlerts" title="dash.home.TableHeader.Alerts" align="center"/> - <display:column width="10%" property="availabilityType" title="resource.common.monitor.visibility.CAvailabilityTH" align="center" > - display:availabilitydecorator/ - </display:column> - display:footer - <tr class="ListRow"> - <td class="ListCell" colspan="4"> - <i><c:out value="${timeRange}"/></i> - </td> - </tr> - </display:footer> + var="obj" items="${problemResources}" > + <display:column width="20%" href="/rhq/resource/summary/overview.xhtml?id=${obj.original.resourceId}" property="original.resourceName" title="dash.home.TableHeader.ResourceName"/> + <display:column width="20%" property="originalResourceTypeName" title="dash.home.TableHeader.Type"/> + <display:column width="20%" property="lineage" title="dash.home.TableHeader.Location"/> + <display:column width="10%" property="original.numAlerts" title="dash.home.TableHeader.Alerts" align="center"/> + <display:column width="10%" property="original.availabilityType" title="resource.common.monitor.visibility.CAvailabilityTH" align="center" > + display:availabilitydecorator/ + </display:column> + display:footer + <tr class="ListRow"> + <td class="ListCell" colspan="4"> + <i><c:out value="${timeRange}"/></i> + </td> + </tr> + </display:footer> </display:table> </c:when> <c:otherwise>
commit dd31f7bea3ac6e1d53c8661e3945d22ee0c966fa Author: Lukas Krejci lkrejci@redhat.com Date: Tue May 4 12:58:06 2010 +0200
BZ 580919 - Operations (aka controlActions) portlet converted to disambiguate resources.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java index e91edd2..a59c02f 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/controlactions/ViewAction.java @@ -36,17 +36,32 @@ import org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposit import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.domain.util.PageOrdering; +import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.WebUserPreferences.OperationPortletPreferences; +import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.server.operation.OperationManagerLocal; +import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.util.LookupUtil;
public class ViewAction extends TilesAction {
private static final Log log = LogFactory.getLog(ViewAction.class);
+ private static final IntExtractor<ResourceOperationLastCompletedComposite> RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR = new IntExtractor<ResourceOperationLastCompletedComposite>() { + public int extract(ResourceOperationLastCompletedComposite object) { + return object.getResourceId(); + } + }; + + private static final IntExtractor<ResourceOperationScheduleComposite> RESOURCE_OPERATION_SCHEDULE_RESOURCE_ID_EXTRACTOR = new IntExtractor<ResourceOperationScheduleComposite>() { + public int extract(ResourceOperationScheduleComposite object) { + return object.getResourceId(); + } + }; + @Override public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -54,9 +69,9 @@ public class ViewAction extends TilesAction { boolean displayLastCompleted = false; boolean displayNextScheduled = false;
- PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = new PageList<ResourceOperationLastCompletedComposite>(); + PageList<DisambiguatedResourceListUtil.Record<ResourceOperationLastCompletedComposite>> disambiguatedLastCompletedResourceOps = new PageList<DisambiguatedResourceListUtil.Record<ResourceOperationLastCompletedComposite>>(); PageList<GroupOperationLastCompletedComposite> lastCompletedGroupOps = new PageList<GroupOperationLastCompletedComposite>(); - PageList<ResourceOperationScheduleComposite> nextScheduledResourceOps = new PageList<ResourceOperationScheduleComposite>(); + PageList<DisambiguatedResourceListUtil.Record<ResourceOperationScheduleComposite>> disambiguatedNextScheduledResourceOps = new PageList<DisambiguatedResourceListUtil.Record<ResourceOperationScheduleComposite>>(); PageList<GroupOperationScheduleComposite> nextScheduledGroupOps = new PageList<GroupOperationScheduleComposite>();
try { @@ -74,13 +89,18 @@ public class ViewAction extends TilesAction { displayNextScheduled = operationPreferences.useNextScheduled;
OperationManagerLocal manager = LookupUtil.getOperationManager(); - + ResourceManagerLocal resourceManager = LookupUtil.getResourceManager(); + if (operationPreferences.useLastCompleted) { PageControl pageControl = new PageControl(0, operationPreferences.lastCompleted); pageControl.initDefaultOrderingField("ro.createdTime", PageOrdering.DESC); - lastCompletedResourceOps = manager.findRecentlyCompletedResourceOperations(user.getSubject(), null, - pageControl); + PageList<ResourceOperationLastCompletedComposite> lastCompletedResourceOps = + manager.findRecentlyCompletedResourceOperations(user.getSubject(), null, pageControl);
+ disambiguatedLastCompletedResourceOps = DisambiguatedResourceListUtil.buildResourceList( + resourceManager.disambiguate(lastCompletedResourceOps, true, RESOURCE_OPERATION_RESOURCE_ID_EXTRACTOR), + lastCompletedResourceOps.getTotalSize(), lastCompletedResourceOps.getPageControl(), true); + pageControl = new PageControl(0, operationPreferences.lastCompleted); pageControl.initDefaultOrderingField("go.createdTime", PageOrdering.DESC); lastCompletedGroupOps = manager.findRecentlyCompletedGroupOperations(user.getSubject(), pageControl); @@ -88,9 +108,14 @@ public class ViewAction extends TilesAction {
if (operationPreferences.useNextScheduled) { PageControl pageControl = new PageControl(0, operationPreferences.nextScheduled); - nextScheduledResourceOps = manager.findCurrentlyScheduledResourceOperations(user.getSubject(), + PageList<ResourceOperationScheduleComposite> nextScheduledResourceOps = + manager.findCurrentlyScheduledResourceOperations(user.getSubject(), pageControl);
+ disambiguatedNextScheduledResourceOps = DisambiguatedResourceListUtil.buildResourceList( + resourceManager.disambiguate(nextScheduledResourceOps, true, RESOURCE_OPERATION_SCHEDULE_RESOURCE_ID_EXTRACTOR), + nextScheduledResourceOps.getTotalSize(), nextScheduledResourceOps.getPageControl(), true); + pageControl = new PageControl(0, operationPreferences.nextScheduled); nextScheduledGroupOps = manager.findCurrentlyScheduledGroupOperations(user.getSubject(), pageControl); } @@ -103,9 +128,9 @@ public class ViewAction extends TilesAction { } finally { context.putAttribute("displayLastCompleted", displayLastCompleted); context.putAttribute("displayNextScheduled", displayNextScheduled); - context.putAttribute("lastCompletedResource", lastCompletedResourceOps); + context.putAttribute("lastCompletedResource", disambiguatedLastCompletedResourceOps); context.putAttribute("lastCompletedGroup", lastCompletedGroupOps); - context.putAttribute("nextScheduledResource", nextScheduledResourceOps); + context.putAttribute("nextScheduledResource", disambiguatedNextScheduledResourceOps); context.putAttribute("nextScheduledGroup", nextScheduledGroupOps); }
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp index e198032..810963c 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/controlactions/View.jsp @@ -45,32 +45,34 @@ <c:otherwise> <c:if test="${!empty lastCompletedResource}"> <tr> - <td width="40%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ResourceName"/></td> + <td width="25%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ResourceName"/></td> <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Type"/></td> + <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Location"/></td> <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> - <td width="25%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> + <td width="20%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> <td width="5%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Status"/></td> </tr> <c:forEach items="${lastCompletedResource}" var="obj"> <tr class="ListRow"> - <td class="ListCell"><html:link page="/rhq/resource/summary/overview.xhtml?id=${obj.resourceId}"><c:out value="${obj.resourceName}"/></html:link></td> - <td class="ListCell"><c:out value="${obj.resourceTypeName}"/></td> - <td class="ListCell"><c:out value="${obj.operationName}"/></td> - <td class="ListCell"><hq:dateFormatter value="${obj.operationStartTime}"/></td> + <td class="ListCell"><html:link page="/rhq/resource/summary/overview.xhtml?id=${obj.original.resourceId}"><c:out value="${obj.original.resourceName}"/></html:link></td> + <td class="ListCell"><c:out value="${obj.original.resourceTypeName}"/></td> + <td class="ListCell"><c:out value="${obj.lineage}" escapeXml="false"/></td> + <td class="ListCell"><c:out value="${obj.original.operationName}"/></td> + <td class="ListCell"><hq:dateFormatter value="${obj.original.operationStartTime}"/></td> <td class="ListCell" align="center"> - <html:link page="/rhq/resource/operation/resourceOperationHistoryDetails.xhtml?id=${obj.resourceId}&opId=${obj.operationHistoryId}"> + <html:link page="/rhq/resource/operation/resourceOperationHistoryDetails.xhtml?id=${obj.original.resourceId}&opId=${obj.original.operationHistoryId}"> <c:choose> - <c:when test="${obj.operationStatus == 'SUCCESS'}"> - <html:img page="/images/icons/availability_green_16.png" alt="${obj.operationStatus}" title="${obj.operationStatus}" /> + <c:when test="${obj.original.operationStatus == 'SUCCESS'}"> + <html:img page="/images/icons/availability_green_16.png" alt="${obj.original.operationStatus}" title="${obj.original.operationStatus}" /> </c:when> - <c:when test="${obj.operationStatus == 'FAILURE'}"> - <html:img page="/images/icons/availability_red_16.png" alt="${obj.operationStatus}" title="${obj.operationStatus}" /> + <c:when test="${obj.original.operationStatus == 'FAILURE'}"> + <html:img page="/images/icons/availability_red_16.png" alt="${obj.original.operationStatus}" title="${obj.original.operationStatus}" /> </c:when> - <c:when test="${obj.operationStatus == 'CANCELED'}"> - <html:img page="/images/icons/availability_yellow_16.png" alt="${obj.operationStatus}" title="${obj.operationStatus}" /> + <c:when test="${obj.original.operationStatus == 'CANCELED'}"> + <html:img page="/images/icons/availability_yellow_16.png" alt="${obj.original.operationStatus}" title="${obj.original.operationStatus}" /> </c:when> <c:otherwise> - <html:img page="/images/icons/availability_grey_16.png" alt="${obj.operationStatus}" title="${obj.operationStatus}"/> + <html:img page="/images/icons/availability_grey_16.png" alt="${obj.original.operationStatus}" title="${obj.original.operationStatus}"/> </c:otherwise> </c:choose> </html:link> @@ -81,7 +83,7 @@ <c:if test="${!empty lastCompletedGroup}"> <tr> <td width="40%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.GroupName"/></td> - <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.GroupResourceType"/></td> + <td width="35%" class="ListHeaderInactive" colspan="2"><fmt:message key="dash.home.TableHeader.GroupResourceType"/></td> <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> <td width="25%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> <td width="5%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Status"/></td> @@ -89,7 +91,7 @@ <c:forEach items="${lastCompletedGroup}" var="obj"> <tr class="ListRow"> <td class="ListCell"><html:link page="/rhq/groups/monitor/graphs.xhtml?category=COMPATIBLE&groupId=${obj.groupId}"><c:out value="${obj.groupName}"/></html:link></td> - <td class="ListCell"><c:out value="${obj.groupResourceTypeName}"/></td> + <td class="ListCell" colspan="2"><c:out value="${obj.groupResourceTypeName}"/></td> <td class="ListCell"><c:out value="${obj.operationName}"/></td> <td class="ListCell"><hq:dateFormatter value="${obj.operationStartTime}"/></td> <td class="ListCell" align="center"> @@ -138,31 +140,33 @@ <c:otherwise> <c:if test="${!empty nextScheduledResource}"> <tr> - <td width="37" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ResourceName"/></td> - <td width="21%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Type"/></td> - <td width="21%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> - <td width="21%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> + <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ResourceName"/></td> + <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Type"/></td> + <td width="35%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Location"/></td> + <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> + <td width="15%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> </tr> - <c:forEach items="${nextScheduledResource}" var="schedule"> + <c:forEach items="${nextScheduledResource}" var="obj"> <tr class="ListRow"> - <td class="ListCell"><html:link page="/rhq/resource/operation/resourceOperationScheduleDetails.xhtml?id=${schedule.resourceId}&jobId=${schedule.operationJobId}"><c:out value="${schedule.resourceName}"/></html:link></td> - <td class="ListCell"><c:out value="${schedule.resourceTypeName}"/></td> - <td class="ListCell"><c:out value="${schedule.operationName}"/></td> - <td class="ListCell"><hq:dateFormatter value="${schedule.operationNextFireTime}"/></td> + <td class="ListCell"><html:link page="/rhq/resource/operation/resourceOperationScheduleDetails.xhtml?id=${obj.original.resourceId}&jobId=${obj.original.operationJobId}"><c:out value="${obj.original.resourceName}"/></html:link></td> + <td class="ListCell"><c:out value="${obj.original.resourceTypeName}"/></td> + <td class="ListCell"><c:out value="${obj.lineage}" escapeXml="false" /></td> + <td class="ListCell"><c:out value="${obj.original.operationName}"/></td> + <td class="ListCell"><hq:dateFormatter value="${obj.original.operationNextFireTime}"/></td> </tr> </c:forEach> </c:if> <c:if test="${!empty nextScheduledGroup}"> <tr> - <td width="37" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.GroupName"/></td> - <td width="21%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.GroupResourceType"/></td> - <td width="21%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> - <td width="21%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> + <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.GroupName"/></td> + <td width="50%" class="ListHeaderInactive" colspan="2"><fmt:message key="dash.home.TableHeader.GroupResourceType"/></td> + <td width="15%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.ControlAction"/></td> + <td width="15%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.DateTime"/><html:img page="/images/tb_sortdown_inactive.gif" width="9" height="9" border="0"/></td> </tr> <c:forEach items="${nextScheduledGroup}" var="schedule"> <tr class="ListRow"> <td class="ListCell"><html:link page="/rhq/group/operation/groupOperationScheduleDetails.xhtml?groupId=${schedule.groupId}&jobId=${schedule.operationJobId}&category=COMPATIBLE"><c:out value="${schedule.groupName}"/></html:link></td> - <td class="ListCell"><c:out value="${schedule.groupResourceTypeName}"/></td> + <td class="ListCell" colspan="2"><c:out value="${schedule.groupResourceTypeName}"/></td> <td class="ListCell"><c:out value="${schedule.operationName}"/></td> <td class="ListCell"><hq:dateFormatter value="${schedule.operationNextFireTime}"/></td> </tr>
commit 972b649c0e6de9f8539d85b6d0cd69192965d09d Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 3 21:53:38 2010 +0200
BZ 580919 - Recent alerts (aka criticalAlerts) portlet converted to use resource disambiguation.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java index c26fa9f..fe1baf0 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/addresource/AddResourcesPrepareAction.java @@ -40,10 +40,12 @@ import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.gui.util.StringUtility; +import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.legacy.Constants; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.util.DashboardUtils; +import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.gui.legacy.util.RequestUtils; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.WebUtility; @@ -59,6 +61,12 @@ import org.rhq.enterprise.server.util.LookupUtil; public class AddResourcesPrepareAction extends Action { private static final int DEFAULT_RESOURCE_TYPE = -1;
+ private static final IntExtractor<Resource> RESOURCE_ID_EXTRACTOR = new IntExtractor<Resource>() { + public int extract(Resource object) { + return object.getId(); + } + }; + @Override @SuppressWarnings( { "unchecked", "deprecation" }) public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, @@ -101,10 +109,14 @@ public class AddResourcesPrepareAction extends Action { PageList<Resource> pendingResources = resourceManager.findResourceByIds(subject, pendingResourceArray, false, pcPending);
+ PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedPendingResources = + DisambiguatedResourceListUtil.buildResourceList(resourceManager.disambiguate(pendingResources, true, RESOURCE_ID_EXTRACTOR), + pendingResources.getTotalSize(), pendingResources.getPageControl(), false); + // give 'em to the jsp page log.debug("put selected page of pending resources in request"); - request.setAttribute(Constants.PENDING_RESOURCES_ATTR, pendingResources); - request.setAttribute(Constants.NUM_PENDING_RESOURCES_ATTR, pendingResources.getTotalSize()); + request.setAttribute(Constants.PENDING_RESOURCES_ATTR, disambiguatedPendingResources); + request.setAttribute(Constants.NUM_PENDING_RESOURCES_ATTR, disambiguatedPendingResources.getTotalSize());
// available resources are all resources in the system that are not associated with the user and are not pending log.debug("determine if user wants to filter available resources"); @@ -119,9 +131,14 @@ public class AddResourcesPrepareAction extends Action { availableResources = resourceManager.findAvailableResourcesForDashboardPortlet(subject, typeIdFilter, categoryFilter, excludeIds, pcAvail);
+ PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedAvailableResources = + DisambiguatedResourceListUtil.buildResourceList(resourceManager.disambiguate(availableResources, true, RESOURCE_ID_EXTRACTOR), + availableResources.getTotalSize(), availableResources.getPageControl(), false); + + log.debug("put selected page of available resources in request"); - request.setAttribute(Constants.AVAIL_RESOURCES_ATTR, availableResources); - request.setAttribute(Constants.NUM_AVAIL_RESOURCES_ATTR, availableResources.getTotalSize()); + request.setAttribute(Constants.AVAIL_RESOURCES_ATTR, disambiguatedAvailableResources); + request.setAttribute(Constants.NUM_AVAIL_RESOURCES_ATTR, disambiguatedAvailableResources.getTotalSize());
log.debug("get the available resources user can filter by"); setDropDowns(addForm, request, subject, categoryFilter); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java index f3133c1..b500a72 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/PrepareAction.java @@ -32,16 +32,26 @@ import org.apache.struts.tiles.actions.TilesAction; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; +import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.legacy.Constants; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.WebUserPreferences.AlertsPortletPreferences; +import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.WebUtility; import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.util.LookupUtil;
public class PrepareAction extends TilesAction { + + private static final IntExtractor<Resource> RESOURCE_ID_EXTRACTOR = new IntExtractor<Resource>() { + + public int extract(Resource object) { + return object.getId(); + } + }; + @Override public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -65,8 +75,12 @@ public class PrepareAction extends TilesAction { PageList<Resource> resources = resourceManager.findResourceByIds(user.getSubject(), alertPrefs.asArray(), false, pageControl);
- request.setAttribute("criticalAlertsList", resources); - request.setAttribute("criticalAlertsTotalSize", resources.getTotalSize()); + PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedResources = + DisambiguatedResourceListUtil.buildResourceList(resourceManager.disambiguate(resources, true, RESOURCE_ID_EXTRACTOR), + resources.getTotalSize(), resources.getPageControl(), false); + + request.setAttribute("criticalAlertsList", disambiguatedResources); + request.setAttribute("criticalAlertsTotalSize", disambiguatedResources.getTotalSize());
return null; } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java index c96920f..77da660 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/criticalalerts/ViewAction.java @@ -33,23 +33,32 @@ import org.rhq.core.domain.alert.Alert; import org.rhq.core.domain.alert.AlertPriority; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; +import org.rhq.core.util.IntExtractor; import org.rhq.core.util.collection.ArrayUtils; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.WebUserPreferences.AlertsPortletPreferences; +import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.server.alert.AlertManagerLocal; +import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.util.LookupUtil;
public class ViewAction extends TilesAction {
private static final Log log = LogFactory.getLog(ViewAction.class);
+ static final IntExtractor<Alert> RESOURCE_ID_EXTRACTOR = new IntExtractor<Alert>() { + public int extract(Alert object) { + return object.getAlertDefinition().getResource().getId(); + } + }; + @Override public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- PageList<Alert> alerts = new PageList<Alert>(); + PageList<DisambiguatedResourceListUtil.Record<Alert>> disambiguatedAlerts = new PageList<DisambiguatedResourceListUtil.Record<Alert>>(); try { WebUser user = SessionUtils.getWebUser(request.getSession()); if (user == null) { @@ -64,9 +73,13 @@ public class ViewAction extends TilesAction {
PageControl pageControl = new PageControl(0, alertPrefs.count); AlertManagerLocal alertManager = LookupUtil.getAlertManager(); - alerts = alertManager.findAlerts(user.getSubject(), ("all".equals(alertPrefs.displayAll) ? null + ResourceManagerLocal resourceManager = LookupUtil.getResourceManager(); + PageList<Alert> alerts = alertManager.findAlerts(user.getSubject(), ("all".equals(alertPrefs.displayAll) ? null : ArrayUtils.wrapInArray(alertPrefs.asArray())), AlertPriority.getByLegacyIndex(alertPrefs.priority), alertPrefs.timeRange, pageControl); + + disambiguatedAlerts = DisambiguatedResourceListUtil.buildResourceList(resourceManager.disambiguate(alerts, true, RESOURCE_ID_EXTRACTOR) + , alerts.getTotalSize(), alerts.getPageControl(), true); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Dashboard Portlet [CriticalAlerts] experienced an error: " + e.getMessage(), e); @@ -74,7 +87,7 @@ public class ViewAction extends TilesAction { log.error("Dashboard Portlet [CriticalAlerts] experienced an error: " + e.getMessage()); } } finally { - context.putAttribute("criticalAlerts", alerts); + context.putAttribute("criticalAlerts", disambiguatedAlerts); }
return null; diff --git a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties index 2893eb1..3c46731 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties +++ b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties @@ -877,6 +877,8 @@ dash.settings.SelectedResources=Selected Resources dash.settings.Resources=Resources dash.settings.AddToList=Add To List dash.settings.ListHeader.Resource=Resource +dash.settings.ListHeader.Type=Resource Type +dash.settings.ListHeader.Location=Location dash.settings.ListHeader.ResourceChart=Resource Chart dash.settings.FormLabel.FilterBy=Filter List By Type: dash.settings.FormLabel.NameContains=Name Contains: diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp index 4ca4d79..35e9965 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/addresources/AddResourcesForm.jsp @@ -364,20 +364,24 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') <display:table cellpadding="0" cellspacing="0" border="0" width="100%" action="${selfPaAction}" items="${AvailableResources}" - var="resource" + var="item" padRows="true" rightSidebar="true" styleId="fromTable" postfix="a" > - <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="fromToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> + <display:column width="1%" property="original.id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="fromToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> <display:checkboxdecorator name="availableResources" onclick="ToggleSelection(this, widgetProperties)" styleClass="availableListMember"/> </display:column> - <display:column property="name" title="common.header.ResourceName" - width="40%" + <display:column property="original.name" title="common.header.ResourceName" + width="30%" sortAttr="res.name" /> - <display:column property="description" title="common.header.Description" - width="59%" - sortAttr="res.resourceType.description" /> + <display:column property="original.resourceType.name" title="resource.group.inventory.TypeTH" + width="39%" + sortAttr="res.resourceType.name" > + </display:column> + <display:column property="lineage" title="resource.group.inventory.ParentTH" + width="30%" /> + </display:table> </div> <!-- / --> @@ -416,15 +420,18 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') leftSidebar="true" styleId="toTable" postfix="p" > - <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="toToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> + <display:column width="1%" property="original.id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="toToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> <display:checkboxdecorator name="pendingResources" onclick="ToggleSelection(this, widgetProperties)" styleClass="pendingListMember"/> </display:column> - <display:column property="name" title="common.header.ResourceName" - width="40%" + <display:column property="original.name" title="common.header.ResourceName" + width="30%" sortAttr="res.name" /> - <display:column property="description" title="common.header.Description" - width="59%" - sortAttr="res.resourceType.description" /> + <display:column property="original.resourceType.name" title="resource.group.inventory.TypeTH" + width="39%" + sortAttr="res.resourceType.name" > + </display:column> + <display:column property="lineage" title="resource.group.inventory.ParentTH" + width="30%" /> </display:table> </div> <!-- / --> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp index 59c062e..4221584 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/Properties.jsp @@ -99,8 +99,10 @@ var help = 'hq:help/'; <display:checkboxdecorator name="ids" onclick="ToggleSelection(this, widgetProperties, true)" styleClass="listMember"/> </display:column>
- <display:column width="50%" property="name" sortAttr="res.name" title="dash.settings.ListHeader.Resource" /> - <display:column width="50%" property="description" sortAttr="res.description" title="common.header.Description" /> + <display:column width="25%" property="original.name" sortAttr="res.name" title="dash.settings.ListHeader.Resource" /> + <display:column width="25%" property="original.resourceType.name" title="dash.settings.ListHeader.Type" /> + <display:column width="25%" property="lineage" title="dash.settings.ListHeader.Location" /> + <display:column width="25%" property="original.description" sortAttr="res.description" title="common.header.Description" />
</display:table>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp index 23357b0..7e0205e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/criticalAlerts/View.jsp @@ -32,24 +32,30 @@ <c:when test="${not empty criticalAlerts}"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> - <td width="60%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.ResourceName"/><html:img page="/images/tb_sortup_inactive.gif" width="9" height="9" border="0"/></td> + <td width="20%" class="ListHeaderInactiveSorted"><fmt:message key="dash.home.TableHeader.ResourceName"/><html:img page="/images/tb_sortup_inactive.gif" width="9" height="9" border="0"/></td> + <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Type"/></td> + <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.Location"/></td> <td width="20%" class="ListHeaderInactive"><fmt:message key="dash.home.TableHeader.AlertName"/></td> <td width="20%" class="ListHeaderInactiveCenter"><fmt:message key="dash.home.TableHeader.DateTime"/></td> </tr> - <c:forEach items="${criticalAlerts}" var="alert"> + <c:forEach items="${criticalAlerts}" var="item"> <tr class="ListRow"> - <td class="ListCell"> <c:choose> - <c:when test="{alert.resource eq null}"> - <fmt:message key="dash.home.removed.resource"/> + <c:when test="{item.original.alertDefinition.resource eq null}"> + <td class="ListCell" colspan="3"> + <fmt:message key="dash.home.removed.resource"/> + </td> </c:when> <c:otherwise> - <html:link page="/rhq/resource/summary/overview.xhtml?id=${alert.alertDefinition.resource.id}"><c:out value="${alert.alertDefinition.resource.name}"/> </html:link> + <td class="ListCell"> + <html:link page="/rhq/resource/summary/overview.xhtml?id=${item.original.alertDefinition.resource.id}"><c:out value="${item.original.alertDefinition.resource.name}"/> </html:link> + </td> + <td class="ListCell"><c:out value="${item.original.alertDefinition.resource.resourceType.name}" /></td> + <td class="ListCell"><c:out value="${item.lineage}" /> </td> </c:otherwise> </c:choose> - </td> - <td class="ListCell"><html:link page="/alerts/Alerts.do?mode=viewAlert&id=${alert.alertDefinition.resource.id}&a=${alert.id}"><c:out value="${alert.alertDefinition.name}"/> </html:link></td> - <td class="ListCell" align="center"><hq:dateFormatter value="${alert.ctime}"/> </td> + <td class="ListCell"><html:link page="/alerts/Alerts.do?mode=viewAlert&id=${item.original.alertDefinition.resource.id}&a=${item.original.id}"><c:out value="${item.original.alertDefinition.name}"/> </html:link></td> + <td class="ListCell" align="center"><hq:dateFormatter value="${item.original.ctime}"/> </td> </tr> </c:forEach> </table> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp index 4240d33..2b6c3cc 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp @@ -400,7 +400,7 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') rightSidebar="true" styleId="fromTable" postfix="a" > - <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="fromToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> + <display:column width="1%" property="original.id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="fromToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> <display:checkboxdecorator name="availableResource" onclick="ToggleSelection(this, widgetProperties)" styleClass="availableListMember" /> </display:column> <display:column property="original.name" title="resource.group.inventory.NameTH" @@ -453,7 +453,7 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') leftSidebar="true" styleId="toTable" postfix="p" > - <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="toToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> + <display:column width="1%" property="original.id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="toToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> <display:checkboxdecorator name="pendingResource" onclick="ToggleSelection(this, widgetProperties)" styleClass="pendingListMember" /> </display:column> <display:column property="original.name" title="resource.group.inventory.NameTH"
commit f3cf404cff2166bf04d639f39d3cea44df48afdd Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 3 18:02:06 2010 +0200
BZ 580919 - This makes the group member addition page in line with the way the resources are disambiguated in the rest of the UI.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java index 808f331..589b54c 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/group/inventory/AddGroupResourcesFormPrepareAction.java @@ -48,6 +48,7 @@ import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageComponent; import org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageRenderer; import org.rhq.enterprise.gui.legacy.Constants; +import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.gui.legacy.util.RequestUtils; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.WebUtility; @@ -124,10 +125,11 @@ public class AddGroupResourcesFormPrepareAction extends Action { ResourceNamesDisambiguationResult<Resource> pendingResourcesDisambiguation = resourceManager.disambiguate(pendingResources, true, RESOURCE_ID_EXTRACTOR);
- pendingResources = buildResourceList(pendingResourcesDisambiguation, pendingResources.getTotalSize(), pendingResources.getPageControl()); + PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedpeningResources = + DisambiguatedResourceListUtil.buildResourceList(pendingResourcesDisambiguation, pendingResources.getTotalSize(), pendingResources.getPageControl(), false);
- request.setAttribute(Constants.PENDING_RESOURCES_ATTR, pendingResources); - request.setAttribute(Constants.NUM_PENDING_RESOURCES_ATTR, pendingResources.size()); + request.setAttribute(Constants.PENDING_RESOURCES_ATTR, disambiguatedpeningResources); + request.setAttribute(Constants.NUM_PENDING_RESOURCES_ATTR, disambiguatedpeningResources.size());
/* * available resources are all resources in the system that are not associated with the user and are not pending @@ -155,10 +157,11 @@ public class AddGroupResourcesFormPrepareAction extends Action { ResourceNamesDisambiguationResult<Resource> availableResourcesDisambiguation = resourceManager.disambiguate(availableResources, true, RESOURCE_ID_EXTRACTOR);
- availableResources = buildResourceList(availableResourcesDisambiguation, availableResources.getTotalSize(), availableResources.getPageControl()); + PageList<DisambiguatedResourceListUtil.Record<Resource>> disambiguatedAvailResources = + DisambiguatedResourceListUtil.buildResourceList(availableResourcesDisambiguation, availableResources.getTotalSize(), availableResources.getPageControl(), false);
- request.setAttribute(Constants.AVAIL_RESOURCES_ATTR, availableResources); - request.setAttribute(Constants.NUM_AVAIL_RESOURCES_ATTR, availableResources.size()); + request.setAttribute(Constants.AVAIL_RESOURCES_ATTR, disambiguatedAvailResources); + request.setAttribute(Constants.NUM_AVAIL_RESOURCES_ATTR, disambiguatedAvailResources.size());
return null; } @@ -186,44 +189,5 @@ public class AddGroupResourcesFormPrepareAction extends Action { }
return resourceCategoryTypes; - } - - // - // These two methods are to support the resource names disambiguation in the above code. - // Hopefully this page gets rewritten in JSF so that we don't have to employ this kind of - // nasties. - // - - private static PageList<Resource> buildResourceList(ResourceNamesDisambiguationResult<Resource> results, int totalSize, PageControl pageControl) { - ArrayList<Resource> convertedResults = new ArrayList<Resource>(results.getResolution().size()); - - for(DisambiguationReport<Resource> dr : results.getResolution()) { - Resource resource = dr.getOriginal(); - - Resource parent = resource.getParentResource(); - //platforms don't have parents, need to check for null here - if (parent != null) { - parent.setName(buildLineage(dr.getParents())); - } - - convertedResults.add(resource); - } - return new PageList<Resource>(convertedResults, totalSize, pageControl); - } - - private static String buildLineage(List<ResourceParentFlyweight> parents) { - if (parents == null || parents.size() == 0) { - return ""; - } - - Iterator<ResourceParentFlyweight> it = parents.iterator(); - - StringBuilder bld = new StringBuilder(it.next().getParentName()); - - while (it.hasNext()) { - bld.append(ResourcePartialLineageComponent.DEFAULT_SEPARATOR).append(it.next().getParentName()); - } - - return bld.toString(); - } + } } \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java index a3deb88..aa6a17b 100755 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/RSSAction.java @@ -29,7 +29,9 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources;
+import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ResourceHealthComposite; +import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.common.tag.FunctionTagLibrary; @@ -39,6 +41,7 @@ import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.WebUserPreferences.FavoriteResourcePortletPreferences; import org.rhq.enterprise.gui.legacy.portlet.BaseRSSAction; import org.rhq.enterprise.gui.legacy.portlet.RSSFeed; +import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.util.LookupUtil;
@@ -66,22 +69,29 @@ public class RSSAction extends BaseRSSAction { favoriteResourcePreferences.asArray(), PageControl.getUnlimitedInstance());
if ((results != null) && (results.size() > 0)) { - for (ResourceHealthComposite summary : results) { + ResourceNamesDisambiguationResult<ResourceHealthComposite> disambiguatedLResults = manager.disambiguate(results, true, ViewAction.RESOURCE_ID_EXTRACTOR); + + PageList<DisambiguatedResourceListUtil.Record<ResourceHealthComposite>> list = DisambiguatedResourceListUtil.buildResourceList(disambiguatedLResults, results.getTotalSize(), results.getPageControl(), false); + + for (DisambiguatedResourceListUtil.Record<ResourceHealthComposite> summary : list) { String link = feed.getBaseUrl() + FunctionTagLibrary.getDefaultResourceTabURL() + "?id=" - + summary.getId(); + + summary.getOriginal().getId();
String availText = res.getMessage("dash.home.ResourceHealth.rss.item.availability", summary - .getAvailabilityType().toString()); + .getOriginal().getAvailabilityType().toString()); String alertsText = res.getMessage("dash.home.ResourceHealth.rss.item.alerts", Long.valueOf(summary - .getAlerts())); + .getOriginal().getAlerts())); String typeText = res.getMessage("dash.home.ResourceHealth.rss.item.resourceType", summary - .getTypeName()); - + .getOriginal().getTypeName()); + String parentsText = res.getMessage("dash.home.ResourceHealth.rss.item.resourceParents", summary.getLineage()); + long now = System.currentTimeMillis();
StringBuffer desc = new StringBuffer(); desc.append("<table><tr><td align="left">").append(typeText).append("</td></tr>");
+ desc.append("<tr><td align="left">").append(parentsText).append("</td></tr>"); + if (favoriteResourcePreferences.showAvailability) { desc.append("<tr><td align="left">").append(availText).append("</td></tr>"); } @@ -92,7 +102,7 @@ public class RSSAction extends BaseRSSAction {
desc.append("</table>");
- feed.addItem(summary.getName(), link, desc.toString(), now); + feed.addItem(summary.getOriginal().getName(), link, desc.toString(), now); } }
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java index 6afe922..7db8562 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java @@ -48,7 +48,7 @@ public class ViewAction extends TilesAction {
private static final Log log = LogFactory.getLog(ViewAction.class);
- private static final IntExtractor<ResourceHealthComposite> RESOURCE_ID_EXTRACTOR = new IntExtractor<ResourceHealthComposite>() { + static final IntExtractor<ResourceHealthComposite> RESOURCE_ID_EXTRACTOR = new IntExtractor<ResourceHealthComposite>() {
public int extract(ResourceHealthComposite object) { return object.getId(); diff --git a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties index a4b54ff..2893eb1 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties +++ b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties @@ -710,6 +710,7 @@ dash.home.ResourceHealth=Favorite Resources dash.home.ResourceHealth.rss.item.availability=Current Availability: {0} dash.home.ResourceHealth.rss.item.alerts=Number of Alerts: {0} dash.home.ResourceHealth.rss.item.resourceType=Resource Type: {0} +dash.home.ResourceHealth.rss.item.resourceParents=Resource Parents: {0} dash.home.RecentlyApproved=Recently Added Resources dash.home.CriticalAlerts=Recent Alerts dash.home.Inventory=Recent Inventory Changes diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp index 0c0dbfe..4240d33 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/group/inventory/AddResourcesForm.jsp @@ -403,15 +403,15 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="fromToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> <display:checkboxdecorator name="availableResource" onclick="ToggleSelection(this, widgetProperties)" styleClass="availableListMember" /> </display:column> - <display:column property="name" title="resource.group.inventory.NameTH" + <display:column property="original.name" title="resource.group.inventory.NameTH" width="30%" sortAttr="res.name" /> - <display:column property="parentResource.name" title="resource.group.inventory.ParentTH" - width="30%" /> - <display:column property="resourceType.name" title="resource.group.inventory.TypeTH" + <display:column property="original.resourceType.name" title="resource.group.inventory.TypeTH" width="39%" sortAttr="res.resourceType.name" > </display:column> + <display:column property="lineage" title="resource.group.inventory.ParentTH" + width="30%" /> </display:table>
</div> @@ -456,17 +456,16 @@ widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>') <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, widgetProperties)" name="toToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox"> <display:checkboxdecorator name="pendingResource" onclick="ToggleSelection(this, widgetProperties)" styleClass="pendingListMember" /> </display:column> - <display:column property="name" title="resource.group.inventory.NameTH" + <display:column property="original.name" title="resource.group.inventory.NameTH" width="30%" sortAttr="res.name" /> - <display:column property="parentResource.name" title="resource.group.inventory.ParentTH" - width="30%" - sortAttr="parent.name" /> - <display:column property="resourceType.name" title="resource.group.inventory.TypeTH" + <display:column property="original.resourceType.name" title="resource.group.inventory.TypeTH" width="39%" sortAttr="res.resourceType.name" > <%-- TODO GH: I don't see this doing anything at all? <display:resourcedecorator resource="${resource}" type="true" />--%> </display:column> + <display:column property="lineage" title="resource.group.inventory.ParentTH" + width="30%" /> </display:table>
</div>
commit 2ebbc4cf78ed504cd49c3a846176665425a0cc41 Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 3 16:21:55 2010 +0200
BZ 580919 - favorite resources (aka resource health) portlet shows disambiguated names.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java index bda2130..6afe922 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/portlet/resourcehealth/ViewAction.java @@ -29,12 +29,16 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.tiles.ComponentContext; import org.apache.struts.tiles.actions.TilesAction;
+import org.rhq.core.domain.resource.composite.DisambiguationReport; import org.rhq.core.domain.resource.composite.ResourceHealthComposite; +import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; +import org.rhq.core.util.IntExtractor; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.WebUserPreferences.FavoriteResourcePortletPreferences; +import org.rhq.enterprise.gui.legacy.util.DisambiguatedResourceListUtil; import org.rhq.enterprise.gui.legacy.util.SessionUtils; import org.rhq.enterprise.gui.util.WebUtility; import org.rhq.enterprise.server.resource.ResourceManagerLocal; @@ -44,11 +48,18 @@ public class ViewAction extends TilesAction {
private static final Log log = LogFactory.getLog(ViewAction.class);
+ private static final IntExtractor<ResourceHealthComposite> RESOURCE_ID_EXTRACTOR = new IntExtractor<ResourceHealthComposite>() { + + public int extract(ResourceHealthComposite object) { + return object.getId(); + } + }; + @Override public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- PageList<ResourceHealthComposite> list = new PageList<ResourceHealthComposite>(); + PageList<DisambiguatedResourceListUtil.Record<ResourceHealthComposite>> list = new PageList<DisambiguatedResourceListUtil.Record<ResourceHealthComposite>>(); boolean showAvailability = true; boolean showAlerts = true; try { @@ -65,7 +76,12 @@ public class ViewAction extends TilesAction { .getFavoriteResourcePortletPreferences();
ResourceManagerLocal manager = LookupUtil.getResourceManager(); - list = manager.findResourceHealth(user.getSubject(), favoriteResourcePreferences.asArray(), pc); + PageList<ResourceHealthComposite> lst = manager.findResourceHealth(user.getSubject(), favoriteResourcePreferences.asArray(), pc); + + ResourceNamesDisambiguationResult<ResourceHealthComposite> disambiguatedList = manager.disambiguate(lst, true, RESOURCE_ID_EXTRACTOR); + + list = DisambiguatedResourceListUtil.buildResourceList(disambiguatedList, lst.getTotalSize(), lst.getPageControl(), true); + showAvailability = favoriteResourcePreferences.showAvailability; showAlerts = favoriteResourcePreferences.showAlerts; } catch (Exception e) { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java new file mode 100644 index 0000000..e0c3b5b --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/util/DisambiguatedResourceListUtil.java @@ -0,0 +1,110 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.enterprise.gui.legacy.util; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.rhq.core.domain.resource.composite.DisambiguationReport; +import org.rhq.core.domain.resource.composite.ResourceNamesDisambiguationResult; +import org.rhq.core.domain.resource.composite.ResourceParentFlyweight; +import org.rhq.core.domain.util.PageControl; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.inventory.resource.ResourcePartialLineageComponent; + +/** + * A utility class to provide page lists of disambiguated resource lists for the + * Struts legacy UI. + * + * @author Lukas Krejci + */ +public class DisambiguatedResourceListUtil { + + private static final String RESOURCE_URL = "/rhq/resource/summary/overview.xhtml"; + + private DisambiguatedResourceListUtil() { + + } + + public static class Record<T> { + + private T original; + private String lineage; + + public Record(T original, String lineage) { + this.original = original; + this.lineage = lineage; + } + + public T getOriginal() { + return original; + } + + public String getLineage() { + return lineage; + } + } + + public static <T> PageList<Record<T>> buildResourceList(ResourceNamesDisambiguationResult<T> results, int totalSize, PageControl pageControl, boolean renderLinks) { + ArrayList<Record<T>> convertedResults = new ArrayList<Record<T>>(results.getResolution().size()); + + for(DisambiguationReport<T> dr : results.getResolution()) { + convertedResults.add(new Record<T>(dr.getOriginal(), buildLineage(dr.getParents(), renderLinks))); + } + return new PageList<Record<T>>(convertedResults, totalSize, pageControl); + } + + private static String buildLineage(List<ResourceParentFlyweight> parents, boolean renderLinks) { + if (parents == null || parents.size() == 0) { + return ""; + } + + Iterator<ResourceParentFlyweight> it = parents.iterator(); + + StringBuilder bld = new StringBuilder(); + + appendParentName(bld, it.next(), renderLinks); + + while (it.hasNext()) { + bld.append(ResourcePartialLineageComponent.DEFAULT_SEPARATOR); + appendParentName(bld, it.next(), renderLinks); + } + + return bld.toString(); + } + + private static void appendParentName(StringBuilder bld, ResourceParentFlyweight parent, boolean renderLinks) { + if (renderLinks) { + bld.append("<a href="").append(RESOURCE_URL).append("?id=").append(parent.getParentId()) + .append("">"); + } + + bld.append(parent.getParentName()); + + if (renderLinks) { + bld.append("</a>"); + } + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties index ca4439f..a4b54ff 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties +++ b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties @@ -823,6 +823,7 @@ dash.home.TableHeader.Title=Title dash.home.TableHeader.Product=Product dash.home.TableHeader.SoftwareType=Type dash.home.TableHeader.SoftwareSource=Source +dash.home.TableHeader.Location=Location
dash.home.DisplayCategory.PlatformTotal=Platform Total dash.home.DisplayCategory.ServerTotal=Server Total diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp index ef8ba0c..a347bb3 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/resourceHealth/View.jsp @@ -27,15 +27,16 @@ <c:when test="${not empty resourceHealth}">
<display:table cellspacing="0" cellpadding="0" width="100%" action="/Dashboard.do" - var="resource" items="${resourceHealth}" > + var="item" items="${resourceHealth}" >
- <display:column width="50%" href="/rhq/resource/summary/overview.xhtml?id=${resource.id}" property="name" sortAttr="res.name" title="dash.home.TableHeader.ResourceName"/> - <display:column width="25%" property="typeName" title="dash.home.TableHeader.Type"/> + <display:column width="25%" href="/rhq/resource/summary/overview.xhtml?id=${item.original.id}" property="original.name" sortAttr="res.name" title="dash.home.TableHeader.ResourceName"/> + <display:column width="25%" property="original.typeName" title="dash.home.TableHeader.Type"/> + <display:column width="25%" property="lineage" title="dash.home.TableHeader.Location"/> <c:if test="${alerts}"> - <display:column width="10%" property="alerts" title="dash.home.TableHeader.Alerts" align="center"/> + <display:column width="10%" property="original.alerts" title="dash.home.TableHeader.Alerts" align="center"/> </c:if> <c:if test="${availability}"> - <display:column width="15%" property="availabilityType" title="resource.common.monitor.visibility.AvailabilityTH" align="center" + <display:column width="15%" property="original.availabilityType" title="resource.common.monitor.visibility.AvailabilityTH" align="center" sortAttr="avail.availabilityType" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox" valign="middle"> display:availabilitydecorator/ </display:column>
commit 7b20873d50bbe2bbf2d7d3605ed5c54252ceddc9 Author: Lukas Krejci lkrejci@redhat.com Date: Mon May 3 16:04:01 2010 +0200
BZ 580919 - recently added resources portlet now shows the type name.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java index 72521d4..f7b2381 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java @@ -182,27 +182,27 @@ import org.rhq.core.domain.util.Summary; + " FROM Resource res " // + " WHERE res.parentResource = :parent "), @NamedQuery(name = Resource.QUERY_RECENTLY_ADDED_PLATFORMS, query = "" // - + " SELECT DISTINCT new org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite(res.id, res.name, res.itime) " + + " SELECT DISTINCT new org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite(res.id, res.name, res.resourceType.name, res.itime) " + " FROM Resource res JOIN res.childResources child JOIN res.implicitGroups g JOIN g.roles r JOIN r.subjects s " + " WHERE (res.itime >= :oldestEpochTime OR ((child.itime >= :oldestEpochTime) AND (child.inventoryStatus = 'COMMITTED'))) " + " AND res.resourceType.category = 'PLATFORM' " + " AND res.inventoryStatus = 'COMMITTED' " + " AND s = :subject " + "ORDER BY res.itime DESC "), @NamedQuery(name = Resource.QUERY_RECENTLY_ADDED_PLATFORMS_ADMIN, query = "" // - + " SELECT DISTINCT new org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite(res.id, res.name, res.itime) " + + " SELECT DISTINCT new org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite(res.id, res.name, res.resourceType.name, res.itime) " + " FROM Resource res JOIN res.childResources child " + " WHERE ((res.itime >= :oldestEpochTime) OR ((child.itime >= :oldestEpochTime) AND (child.inventoryStatus = 'COMMITTED'))) " + " AND res.resourceType.category = 'PLATFORM' " + " AND res.inventoryStatus = 'COMMITTED' " + "ORDER BY res.itime DESC "), @NamedQuery(name = Resource.QUERY_RECENTLY_ADDED_SERVERS, query = "" - + " SELECT DISTINCT new org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite(res.id, res.name, res.itime) " + + " SELECT DISTINCT new org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite(res.id, res.name, res.resourceType.name, res.itime) " + " FROM Resource res JOIN res.implicitGroups g JOIN g.roles r JOIN r.subjects s " + " WHERE res.itime >= :oldestEpochTime " + " AND res.resourceType.category = 'SERVER' " + " AND res.inventoryStatus = 'COMMITTED' " + " AND res.parentResource.id = :platformId " + " AND s = :subject " + "ORDER BY res.itime DESC "), @NamedQuery(name = Resource.QUERY_RECENTLY_ADDED_SERVERS_ADMIN, query = "" - + " SELECT DISTINCT new org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite(res.id, res.name, res.itime) " + + " SELECT DISTINCT new org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite(res.id, res.name, res.resourceType.name, res.itime) " + " FROM Resource res " + " WHERE res.itime >= :oldestEpochTime " + " AND res.resourceType.category = 'SERVER' " + " AND res.inventoryStatus = 'COMMITTED' " + " AND res.parentResource.id = :platformId " + "ORDER BY res.itime DESC "), diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/RecentlyAddedResourceComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/RecentlyAddedResourceComposite.java index 0018621..f34e28d 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/RecentlyAddedResourceComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/RecentlyAddedResourceComposite.java @@ -36,13 +36,15 @@ public class RecentlyAddedResourceComposite implements Serializable { private long ctime; private boolean showChildren; private List<RecentlyAddedResourceComposite> children; - - public RecentlyAddedResourceComposite() { + private String resourceTypeName; + + public RecentlyAddedResourceComposite() { } - - public RecentlyAddedResourceComposite(int id, String name, long ctime) { + + public RecentlyAddedResourceComposite(int id, String name, String resourceTypeName, long ctime) { this.id = id; this.name = name; + this.resourceTypeName = resourceTypeName; this.ctime = ctime; }
@@ -58,6 +60,10 @@ public class RecentlyAddedResourceComposite implements Serializable { return name; }
+ public String getResourceTypeName() { + return resourceTypeName; + } + public long getCtime() { return ctime; } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/recentlyApproved/View.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/recentlyApproved/View.jsp index 824857c..4970c00 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/portlet/recentlyApproved/View.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/portlet/recentlyApproved/View.jsp @@ -24,7 +24,8 @@ <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="3%" class="ListHeaderInactive"> </td> - <td width="67%" class="ListHeaderInactive" align="left"><fmt:message key="dash.home.TableHeader.ResourceName"/></td> + <td width="37%" class="ListHeaderInactive" align="left"><fmt:message key="dash.home.TableHeader.ResourceName"/></td> + <td width="30%" class="ListHeaderInactive" align="left"><fmt:message key="dash.home.TableHeader.Type"/></td> <td width="30%" class="ListHeaderInactive" align="left"><fmt:message key="dash.home.TableHeader.DateTime"/></td> </tr> <c:forEach items="${recentlyApproved}" var="platform"> @@ -48,6 +49,7 @@ </c:choose> </td> <td class="ListCell" align="left"><html:link page="/rhq/resource/summary/overview.xhtml?id=${platform.id}"><c:out value="${platform.name}"/> </html:link></td> + <td class="ListCell" align="left"><c:out value="${platform.resourceTypeName}"/></td> <td class="ListCell" align="left"><hq:dateFormatter value="${platform.ctime}"/> </td> </tr> <c:if test="${platform.showChildren}"> @@ -56,6 +58,7 @@ <tr class="ListRow"> <td class="ListCell"></td> <td class="ListCell" align="left"><html:link page="/rhq/resource/summary/overview.xhtml?id=${server.id}"><c:out value="${server.name}"/> </html:link></td> + <td class="ListCell" align="left"><c:out value="${server.resourceTypeName}"/></td> <td class="ListCell" align="left"><hq:dateFormatter value="${server.ctime}"/> </td> </tr> </c:forEach> <!-- For each server -->
commit 484cf431e96da323dad56167a1765e179e822e6d Author: Joseph Marques joseph@redhat.com Date: Mon May 31 06:36:14 2010 -0400
BZ-598053: prevent dynamic outline for text boxes used in the SearchBar
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/css/search.css b/modules/enterprise/gui/coregui/src/main/webapp/css/search.css index 4eccb09..4d572cf 100644 --- a/modules/enterprise/gui/coregui/src/main/webapp/css/search.css +++ b/modules/enterprise/gui/coregui/src/main/webapp/css/search.css @@ -29,6 +29,7 @@ div { margin: 0; border-color: white; border-style: none; + outline: none; }
.patternNameLabel { @@ -49,6 +50,7 @@ div { border-color: gray; border-style: dotted; border-width: thin; + outline: none; }
commit e1424094013722e3b6563bfe00eaa62ce75d2904 Author: Joseph Marques joseph@redhat.com Date: Mon May 31 05:38:30 2010 -0400
BZ-598027: keep the cursor where it was for up/down arrow events when suggestions are showing
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java index a79f248..120c474 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/search/suggest/SuggestTextBox_v3.java @@ -203,7 +203,7 @@ public class SuggestTextBox_v3 extends Composite implements HasText, HasAllFocus suggestionMenu.moveSelectionDown(); } } - //suggestionMenu.selectItem(suggestionMenu.getSelectedItemIndex() + 1); + event.preventDefault(); break; case KeyCodes.KEY_UP: suggestionMenu.moveSelectionUp(); @@ -214,7 +214,7 @@ public class SuggestTextBox_v3 extends Composite implements HasText, HasAllFocus suggestionMenu.moveSelectionUp(); } } - //suggestionMenu.selectItem(suggestionMenu.getSelectedItemIndex() - 1); + event.preventDefault(); break; case KeyCodes.KEY_ENTER: if (suggestionMenu.getSelectedItemIndex() < 0) {
rhq-commits@lists.fedorahosted.org