Ejemplo n.º 1
0
  private void displayError(String msg, Throwable caught) {
    CoreGUI.getErrorHandler().handleError(msg, caught);
    String rootCause = ErrorHandler.getRootCauseMessage(caught);

    // JSch returns very bad error messages, transform them here before returning to the customer
    String fullMsg = null;
    if (rootCause != null && msg != null) {
      String runtimeException = "java.lang.RuntimeException";
      if ("com.jcraft.jsch.JSchException:Auth cancel".equals(rootCause)) {
        fullMsg = MSG.view_remoteAgentInstall_error_authFailed();
      } else if (rootCause.indexOf("java.net.UnknownHostException") != -1) {
        fullMsg = MSG.view_remoteAgentInstall_error_unknownHost();
      } else if ("java.net.ConnectException:Connection refused".equals(rootCause)) {
        fullMsg = MSG.view_remoteAgentInstall_error_connRefused();
      } else if (rootCause.indexOf(runtimeException) != -1) {
        int exceptionEnd =
            rootCause.indexOf(runtimeException) + runtimeException.length() + 1; // remove : also
        fullMsg = rootCause.substring(exceptionEnd);
      }
    }

    // Fallback
    if (fullMsg == null) {
      fullMsg = (rootCause == null) ? msg : msg + ": " + rootCause;
    }
    SC.warn(fullMsg);
  }
 protected void onUninventorySuccess() {
   refresh(true);
   // refresh the entire gui so it encompasses any relevant tree view. Don't just call
   // this.refresh(),
   // because CoreGUI.refresh is more comprehensive.
   CoreGUI.refresh();
 }
/** @author Greg Hinkle */
public class ResourceLookupComboBoxItem extends ComboBoxItem {
  private static final Messages MSG = CoreGUI.getMessages();

  public ResourceLookupComboBoxItem(String name, String title) {
    super(name, title);
    setHint(MSG.widget_resourceSelector_selectResource());
    setShowHintInField(false);

    setOptionDataSource(new ResourceDatasource());

    ListGridField nameField = new ListGridField("name", MSG.common_title_name(), 250);
    nameField.setShowHover(true);
    nameField.setHoverCustomizer(
        new HoverCustomizer() {

          public String hoverHTML(
              Object value, ListGridRecord listGridRecord, int rowNum, int colNum) {
            return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
          }
        });

    ListGridField ancestryField =
        new ListGridField(AncestryUtil.RESOURCE_ANCESTRY, MSG.common_title_ancestry(), 300);
    // needs to use a different cell formatter than what AncestryUtil.setupAncestryListGridField
    // creates
    ancestryField.setCellFormatter(
        new CellFormatter() {
          public String format(Object o, ListGridRecord listGridRecord, int rowNum, int colNum) {
            return AncestryUtil.getAncestryValue(listGridRecord, false);
          }
        });
    AncestryUtil.setupAncestryListGridFieldHover(ancestryField);

    ListGridField descriptionField =
        new ListGridField("description", MSG.common_title_description());
    ListGridField categoryField = new ListGridField("category", MSG.common_title_category(), 60);
    ListGridField availabilityField =
        new ListGridField("currentAvailability", MSG.common_title_availability(), 55);
    availabilityField.setAlign(Alignment.CENTER);

    setPickListFields(nameField, ancestryField, descriptionField, categoryField, availabilityField);

    setValueField("id");
    setDisplayField("name");
    setPickListWidth(800);
    setTextMatchStyle(TextMatchStyle.SUBSTRING);
    setCompleteOnTab(true);
    setAddUnknownValues(false);
  }
}
Ejemplo n.º 4
0
  public FavoritesButton() {
    super(CoreGUI.getMessages().favorites());

    // this is the main menu - the "favorites" button shown in the UI the user initially clicks
    favoritesMenu = new Menu();
    favoritesMenu.setSubmenuDirection("left");
    setMenu(favoritesMenu);
    setAutoFit(true);

    // these are the child menus directly under the main favorites button
    favoriteResourcesMenu = new Menu();
    favoriteGroupsMenu = new Menu();
    recentlyViewedMenu = new Menu();
    favoriteResourcesMenu.setSubmenuDirection("left");
    favoriteResourcesMenu.setAutoWidth();
    favoriteGroupsMenu.setSubmenuDirection("left");
    favoriteGroupsMenu.setAutoWidth();
    recentlyViewedMenu.setSubmenuDirection("left");
    recentlyViewedMenu.setAutoWidth();
    MenuItem favoriteResourcesMenuItem =
        new MenuItem(MSG.favorites_resources(), "Favorite_Resource_16.png");
    favoriteResourcesMenuItem.setSubmenu(favoriteResourcesMenu);
    favoriteResourcesMenu.setEmptyMessage(MSG.common_val_none());

    MenuItem favoriteGroupsMenuItem = new MenuItem(MSG.favorites_groups(), "Favorite_Group_16.png");
    favoriteGroupsMenuItem.setSubmenu(favoriteGroupsMenu);
    favoriteGroupsMenu.setEmptyMessage(MSG.common_val_none());

    MenuItem recentlyViewedMenuItem =
        new MenuItem(MSG.favorites_recentlyViewed(), "global/Recent_16.png");
    recentlyViewedMenuItem.setSubmenu(recentlyViewedMenu);
    recentlyViewedMenu.setEmptyMessage(MSG.common_val_none());

    favoritesMenu.setItems(
        favoriteResourcesMenuItem, favoriteGroupsMenuItem, recentlyViewedMenuItem);
    addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent clickEvent) {
            // Cancel the click event. We'll call show() on the menu ourselves only if we're able to
            // load the
            // favorite Resources successfully.
            clickEvent.cancel();
            showMenu();
          }
        });
  }
Ejemplo n.º 5
0
  private void viewBundleVersion(BundleVersion version, ViewId nextViewId) {
    // Whenever a new view request comes in, make sure to clean house to avoid ID conflicts for
    // sub-widgets
    this.destroyMembers();

    this.version = version;

    addMember(
        new BackButton(
            MSG.view_bundle_version_backToBundle() + ": " + version.getBundle().getName(),
            LinkManager.getBundleLink(version.getBundle().getId())));

    addMember(
        new HeaderLabel(
            Canvas.getImgURL("subsystems/bundle/BundleVersion_24.png"),
            version.getName() + ": " + version.getVersion()));

    // conditionally add tags. Defaults to true, not available in JON builds.
    if (CoreGUI.isTagsEnabledForUI()) {
      addMember(createTagEditor());
    }

    addMember(createSummaryForm());

    TabSet tabs = new TabSet();
    tabs.addTab(createRecipeTab());
    tabs.addTab(createLiveDeploymentsTab());
    tabs.addTab(createFilesTab());
    addMember(tabs);

    if (nextViewId != null) {
      if (nextViewId.getPath().equals("recipe")) {
        tabs.selectTab(0);
      } else if (nextViewId.getPath().equals("deployments")) {
        tabs.selectTab(1);
      } else if (nextViewId.getPath().equals("files")) {
        tabs.selectTab(2);
      } else {
        // should we throw an exception? someone gave a bad URL; just bring them to first tab
        tabs.selectTab(0);
      }
    }

    markForRedraw();
  }
Ejemplo n.º 6
0
/**
 * @author Greg Hinkle
 * @author Ian Springer
 * @author John Mazzitelli
 */
public class FavoritesButton extends IMenuButton {

  private Messages MSG = CoreGUI.getMessages();
  final Menu favoriteResourcesMenu;
  final Menu favoriteGroupsMenu;
  final Menu recentlyViewedMenu;
  final Menu favoritesMenu;

  public FavoritesButton() {
    super(CoreGUI.getMessages().favorites());

    // this is the main menu - the "favorites" button shown in the UI the user initially clicks
    favoritesMenu = new Menu();
    favoritesMenu.setSubmenuDirection("left");
    setMenu(favoritesMenu);
    setAutoFit(true);

    // these are the child menus directly under the main favorites button
    favoriteResourcesMenu = new Menu();
    favoriteGroupsMenu = new Menu();
    recentlyViewedMenu = new Menu();
    favoriteResourcesMenu.setSubmenuDirection("left");
    favoriteResourcesMenu.setAutoWidth();
    favoriteGroupsMenu.setSubmenuDirection("left");
    favoriteGroupsMenu.setAutoWidth();
    recentlyViewedMenu.setSubmenuDirection("left");
    recentlyViewedMenu.setAutoWidth();
    MenuItem favoriteResourcesMenuItem =
        new MenuItem(MSG.favorites_resources(), "Favorite_Resource_16.png");
    favoriteResourcesMenuItem.setSubmenu(favoriteResourcesMenu);
    favoriteResourcesMenu.setEmptyMessage(MSG.common_val_none());

    MenuItem favoriteGroupsMenuItem = new MenuItem(MSG.favorites_groups(), "Favorite_Group_16.png");
    favoriteGroupsMenuItem.setSubmenu(favoriteGroupsMenu);
    favoriteGroupsMenu.setEmptyMessage(MSG.common_val_none());

    MenuItem recentlyViewedMenuItem =
        new MenuItem(MSG.favorites_recentlyViewed(), "global/Recent_16.png");
    recentlyViewedMenuItem.setSubmenu(recentlyViewedMenu);
    recentlyViewedMenu.setEmptyMessage(MSG.common_val_none());

    favoritesMenu.setItems(
        favoriteResourcesMenuItem, favoriteGroupsMenuItem, recentlyViewedMenuItem);
    addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent clickEvent) {
            // Cancel the click event. We'll call show() on the menu ourselves only if we're able to
            // load the
            // favorite Resources successfully.
            clickEvent.cancel();
            showMenu();
          }
        });
  }

  public void showMenu() {
    setLeft(DOM.getElementById(MenuBarView.BTN_FAV_ID).getAbsoluteLeft());
    final Set<Integer> favoriteResourceIds =
        UserSessionManager.getUserPreferences().getFavoriteResources();
    final Set<Integer> favoriteGroupIds =
        UserSessionManager.getUserPreferences().getFavoriteResourceGroups();
    final List<Integer> recentResourceIds =
        UserSessionManager.getUserPreferences().getRecentResources();
    final List<Integer> recentGroupIds =
        UserSessionManager.getUserPreferences().getRecentResourceGroups();

    // if we have no menu items at all, then show the empty menu now
    if (favoriteGroupIds.isEmpty()
        && favoriteResourceIds.isEmpty()
        && recentResourceIds.isEmpty()
        && recentGroupIds.isEmpty()) {
      favoritesMenu.showNextTo(FavoritesButton.this, "bottom");
      return;
    }

    // keep a list of all the ids we need to pull from the db. combine favs and recents to minimize
    // db round trips.
    Set<Integer> resourceIds = new HashSet<Integer>();
    Set<Integer> groupIds = new HashSet<Integer>();

    resourceIds.addAll(favoriteResourceIds);
    resourceIds.addAll(recentResourceIds);
    groupIds.addAll(favoriteGroupIds);
    groupIds.addAll(recentGroupIds);

    fetchFavorites(
        resourceIds,
        groupIds,
        new AsyncCallback<Favorites>() {

          public void onFailure(Throwable caught) {
            CoreGUI.getErrorHandler().handleError(MSG.view_dashboard_favorites_error1(), caught);
          }

          public void onSuccess(final Favorites favorites) {
            // For Ancestry we need all the resource types and ancestry resource types loaded
            HashSet<Integer> typesSet = new HashSet<Integer>();
            HashSet<String> ancestries = new HashSet<String>();
            for (Resource resource : favorites.resources) {
              typesSet.add(resource.getResourceType().getId());
              ancestries.add(resource.getAncestry());
            }

            // In addition to the types of the result resources, get the types of their ancestry
            typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));

            ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
            typeRepo.getResourceTypes(
                typesSet.toArray(new Integer[typesSet.size()]),
                new TypesLoadedCallback() {
                  @Override
                  public void onTypesLoaded(Map<Integer, ResourceType> types) {
                    // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a
                    // pojo.
                    AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);

                    // generate the menus
                    buildFavoriteResourcesMenu(
                        favorites, favoriteResourcesMenu, favoriteResourceIds, typesWrapper);
                    buildFavoriteGroupsMenu(favorites, favoriteGroupsMenu, favoriteGroupIds);
                    buildRecentlyViewedMenu(
                        favorites,
                        recentlyViewedMenu,
                        recentResourceIds,
                        recentGroupIds,
                        typesWrapper);

                    favoritesMenu.showNextTo(FavoritesButton.this, "bottom");
                  }
                });
          }
        });
  }

  private void buildFavoriteResourcesMenu(
      Favorites favorites,
      Menu menu,
      Set<Integer> resourceIds,
      AncestryUtil.MapWrapper typesWrapper) {

    if (resourceIds.isEmpty()) {
      menu.setItems();
      return;
    }

    List<MenuItem> items = new ArrayList<MenuItem>(resourceIds.size());

    for (final Integer resourceId : resourceIds) {
      Resource resource = favorites.getResource(resourceId);
      if (null == resource) {
        // if the resource is gone just skip it
        continue;
      }

      MenuItem item = new MenuItem(resource.getName());
      item.setIcon(ImageManager.getResourceIcon(resource));

      // build a subMenu to display a disambiguated resource
      item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId);
      item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
      item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
      item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
      item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
      Menu ancestryMenu = new Menu();
      MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, -1));
      ancestryItem.setEnabled(false);
      ancestryMenu.setItems(ancestryItem);
      ancestryMenu.setSubmenuDirection("left");
      ancestryMenu.setAutoWidth();
      item.setSubmenu(ancestryMenu);

      item.addClickHandler(
          new com.smartgwt.client.widgets.menu.events.ClickHandler() {
            public void onClick(MenuItemClickEvent event) {
              CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
            }
          });

      items.add(item);
    }

    menu.setCanSelectParentItems(Boolean.TRUE);
    menu.setItems(items.toArray(new MenuItem[items.size()]));
  }

  private void buildFavoriteGroupsMenu(Favorites favorites, Menu menu, Set<Integer> groupIds) {

    if (groupIds.isEmpty()) {
      menu.setItems();
      return;
    }

    List<MenuItem> items = new ArrayList<MenuItem>(groupIds.size());

    for (final Integer groupId : groupIds) {
      ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
      if (null == groupComposite) {
        // if the resource group is gone just skip it
        continue;
      }
      final ResourceGroup group = groupComposite.getResourceGroup();

      MenuItem item = new MenuItem(String.valueOf(groupId));
      item.setTitle(group.getName());
      item.setIcon(
          ImageManager.getGroupIcon(
              group.getGroupCategory(), groupComposite.getExplicitAvailabilityType()));

      item.addClickHandler(
          new com.smartgwt.client.widgets.menu.events.ClickHandler() {
            public void onClick(MenuItemClickEvent event) {
              CoreGUI.goToView(LinkManager.getResourceGroupLink(group));
            }
          });
      items.add(item);
    }
    menu.setItems(items.toArray(new MenuItem[items.size()]));
  }

  private void buildRecentlyViewedMenu(
      Favorites favorites,
      Menu menu,
      List<Integer> recentResourceIds,
      List<Integer> recentGroupIds,
      AncestryUtil.MapWrapper typesWrapper) {

    if (recentResourceIds.isEmpty() && recentGroupIds.isEmpty()) {
      return;
    }
    List<MenuItem> items =
        new ArrayList<MenuItem>(recentResourceIds.size() + recentGroupIds.size() + 1);

    for (final Integer resourceId : recentResourceIds) {
      Resource resource = favorites.getResource(resourceId);
      if (null == resource) {
        // if the resource is gone just skip it
        continue;
      }

      MenuItem item = new MenuItem(resource.getName());
      item.setIcon(ImageManager.getResourceIcon(resource));

      // build a subMenu to display a disambiguated resource
      item.setAttribute(AncestryUtil.RESOURCE_ID, resourceId);
      item.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
      item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
      item.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());
      item.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);

      Menu ancestryMenu = new Menu();
      MenuItem ancestryItem = new MenuItem(AncestryUtil.getAncestryHoverHTML(item, -1));
      ancestryItem.setEnabled(false);
      ancestryMenu.setItems(ancestryItem);
      ancestryMenu.setSubmenuDirection("left");
      ancestryMenu.setAutoWidth();
      item.setSubmenu(ancestryMenu);

      item.addClickHandler(
          new com.smartgwt.client.widgets.menu.events.ClickHandler() {
            public void onClick(MenuItemClickEvent event) {
              CoreGUI.goToView(LinkManager.getResourceLink(resourceId));
            }
          });

      items.add(item);
    }

    if (!recentResourceIds.isEmpty() && !recentGroupIds.isEmpty()) {
      items.add(new MenuItemSeparator());
    }

    for (final Integer groupId : recentGroupIds) {
      ResourceGroupComposite groupComposite = favorites.getGroupComposite(groupId);
      if (null == groupComposite) {
        // if the resource group is gone just skip it
        continue;
      }
      final ResourceGroup group = groupComposite.getResourceGroup();

      MenuItem item = new MenuItem(String.valueOf(groupId));
      item.setTitle(group.getName());
      item.setIcon(
          ImageManager.getGroupIcon(
              group.getGroupCategory(), groupComposite.getExplicitAvailabilityType()));

      item.addClickHandler(
          new com.smartgwt.client.widgets.menu.events.ClickHandler() {
            public void onClick(MenuItemClickEvent event) {
              CoreGUI.goToView(LinkManager.getResourceGroupLink(group));
            }
          });
      items.add(item);
    }

    menu.setCanSelectParentItems(Boolean.TRUE);
    menu.setItems(items.toArray(new MenuItem[items.size()]));
  }

  private void fetchFavorites(
      Set<Integer> resourceIds,
      final Set<Integer> groupIds,
      final AsyncCallback<Favorites> callback) {

    ResourceCriteria criteria = new ResourceCriteria();
    criteria.addFilterIds(resourceIds.toArray(new Integer[resourceIds.size()]));
    GWTServiceLookup.getResourceService()
        .findResourcesByCriteria(
            criteria,
            new AsyncCallback<PageList<Resource>>() {
              public void onFailure(Throwable caught) {
                callback.onFailure(caught);
              }

              public void onSuccess(final PageList<Resource> resources) {

                if (groupIds.isEmpty()) {
                  callback.onSuccess(
                      new Favorites(resources, new PageList<ResourceGroupComposite>()));
                  return;
                }

                ResourceGroupCriteria criteria = new ResourceGroupCriteria();
                criteria.addFilterIds(groupIds.toArray(new Integer[groupIds.size()]));
                GWTServiceLookup.getResourceGroupService()
                    .findResourceGroupCompositesByCriteria(
                        criteria,
                        new AsyncCallback<PageList<ResourceGroupComposite>>() {
                          public void onFailure(Throwable caught) {
                            callback.onFailure(caught);
                          }

                          public void onSuccess(PageList<ResourceGroupComposite> groups) {
                            callback.onSuccess(new Favorites(resources, groups));
                          }
                        });
              }
            });
  }

  private static class Favorites {
    private PageList<Resource> resources;
    private PageList<ResourceGroupComposite> groupComposites;

    public Favorites(
        PageList<Resource> resources, PageList<ResourceGroupComposite> groupComposites) {
      this.resources = resources;
      this.groupComposites = groupComposites;
    }

    public Resource getResource(int resourceId) {
      for (Resource resource : resources) {
        if (resourceId == resource.getId()) {
          return resource;
        }
      }
      return null;
    }

    public ResourceGroupComposite getGroupComposite(int groupId) {
      for (ResourceGroupComposite groupComposite : groupComposites) {
        if (groupId == groupComposite.getResourceGroup().getId()) {
          return groupComposite;
        }
      }
      return null;
    }
  }
}
/** @author Joseph Marques */
public class ResourceGroupCompositeDataSource
    extends RPCDataSource<ResourceGroupComposite, ResourceGroupCriteria> {

  private static final Messages MSG = CoreGUI.getMessages();

  public static final String FILTER_GROUP_IDS = "resourceGroupIds";

  ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();

  private static ResourceGroupCompositeDataSource INSTANCE;

  public static ResourceGroupCompositeDataSource getInstance() {
    if (INSTANCE == null) {
      INSTANCE = new ResourceGroupCompositeDataSource();
    }
    return INSTANCE;
  }

  public ResourceGroupCompositeDataSource() {
    super();
    List<DataSourceField> fields = addDataSourceFields();
    addFields(fields);
  }

  @Override
  protected List<DataSourceField> addDataSourceFields() {
    List<DataSourceField> fields = super.addDataSourceFields();

    DataSourceField idDataField = new DataSourceIntegerField("id", MSG.common_title_id(), 50);
    idDataField.setPrimaryKey(true);
    idDataField.setCanEdit(false);
    fields.add(idDataField);

    DataSourceTextField nameDataField =
        new DataSourceTextField(NAME.propertyName(), NAME.title(), 200);
    nameDataField.setCanEdit(false);
    fields.add(nameDataField);

    DataSourceTextField descriptionDataField =
        new DataSourceTextField(DESCRIPTION.propertyName(), DESCRIPTION.title());
    descriptionDataField.setCanEdit(false);
    fields.add(descriptionDataField);

    DataSourceTextField typeNameDataField =
        new DataSourceTextField(TYPE.propertyName(), TYPE.title());
    fields.add(typeNameDataField);

    DataSourceTextField pluginNameDataField =
        new DataSourceTextField(PLUGIN.propertyName(), PLUGIN.title());
    fields.add(pluginNameDataField);

    DataSourceTextField categoryDataField =
        new DataSourceTextField(CATEGORY.propertyName(), CATEGORY.title());
    fields.add(categoryDataField);

    return fields;
  }

  @Override
  public void executeFetch(
      final DSRequest request, final DSResponse response, final ResourceGroupCriteria criteria) {
    groupService.findResourceGroupCompositesByCriteria(
        criteria,
        new AsyncCallback<PageList<ResourceGroupComposite>>() {
          public void onFailure(Throwable caught) {
            if (caught.getMessage().contains("SearchExpressionException")) {
              Message message =
                  new Message(MSG.view_searchBar_suggest_noSuggest(), Message.Severity.Error);
              CoreGUI.getMessageCenter().notify(message);
            } else {
              CoreGUI.getErrorHandler().handleError(MSG.view_inventory_groups_loadFailed(), caught);
            }
            response.setStatus(RPCResponse.STATUS_FAILURE);
            processResponse(request.getRequestId(), response);
          }

          private PageList<ResourceGroupComposite> applyAvailabilitySearchFilter(
              PageList<ResourceGroupComposite> result) {

            if (!isAvailabilitySearch(criteria)) {
              return result;
            }
            PageList<ResourceGroupComposite> pageList =
                new PageList<ResourceGroupComposite>(result.getPageControl());

            for (ResourceGroupComposite rgc : result) {
              if (rgc.getExplicitCount() > 0) {
                pageList.add(rgc);
              }
            }

            return pageList;
          }

          public void onSuccess(PageList<ResourceGroupComposite> result) {
            PageList<ResourceGroupComposite> filteredResult = applyAvailabilitySearchFilter(result);
            response.setData(buildRecords(filteredResult));
            setPagingInfo(response, result);
            processResponse(request.getRequestId(), response);
          }
        });
  }

  private boolean isAvailabilitySearch(ResourceGroupCriteria criteria) {
    return criteria.getSearchExpression() != null
        && criteria.getSearchExpression().startsWith("availability");
  }

  @Override
  protected ResourceGroupCriteria getFetchCriteria(final DSRequest request) {
    ResourceGroupCriteria criteria = new ResourceGroupCriteria();

    criteria.addFilterId(getFilter(request, "id", Integer.class));
    criteria.addFilterName(getFilter(request, NAME.propertyName(), String.class));
    criteria.addFilterGroupCategory(
        getFilter(request, CATEGORY.propertyName(), GroupCategory.class));
    criteria.addFilterDownMemberCount(getFilter(request, "downMemberCount", Long.class));
    criteria.addFilterExplicitResourceIds(getFilter(request, "explicitResourceId", Integer.class));
    criteria.addFilterGroupDefinitionId(getFilter(request, "groupDefinitionId", Integer.class));
    criteria.setSearchExpression(getFilter(request, "search", String.class));
    criteria.addFilterIds(getArrayFilter(request, FILTER_GROUP_IDS, Integer.class));

    return criteria;
  }

  @Override
  public ResourceGroupComposite copyValues(Record from) {
    Integer idAttrib = from.getAttributeAsInt("id");
    String nameAttrib = from.getAttribute(NAME.propertyName());
    String descriptionAttrib = from.getAttribute(DESCRIPTION.propertyName());
    String typeNameAttrib = from.getAttribute(TYPE.propertyName());

    ResourceGroup rg = new ResourceGroup(nameAttrib);
    rg.setId(idAttrib);
    rg.setDescription(descriptionAttrib);
    if (typeNameAttrib != null) {
      ResourceType rt = new ResourceType();
      rt.setName(typeNameAttrib);
      String pluginNameAttrib = from.getAttribute(PLUGIN.propertyName());
      rt.setPlugin(pluginNameAttrib);
      rg.setResourceType(rt);
    }

    Long explicitCount = Long.valueOf(from.getAttribute("explicitCount"));
    Long explicitDown = Long.valueOf(from.getAttribute("explicitDown"));
    Long explicitUnknown = Long.valueOf(from.getAttribute("explicitUnknown"));
    Long explicitDisabled = Long.valueOf(from.getAttribute("explicitDisabled"));
    Long implicitCount = Long.valueOf(from.getAttribute("implicitCount"));
    Long implicitDown = Long.valueOf(from.getAttribute("implicitDown"));
    Long implicitUnknown = Long.valueOf(from.getAttribute("implicitUnknown"));
    Long implicitDisabled = Long.valueOf(from.getAttribute("implicitDisabled"));

    ResourceGroupComposite composite =
        new ResourceGroupComposite(
            explicitCount,
            explicitDown,
            explicitUnknown,
            explicitDisabled,
            implicitCount,
            implicitDown,
            implicitUnknown,
            implicitDisabled,
            rg);

    return composite;
  }

  @Override
  public ListGridRecord copyValues(ResourceGroupComposite from) {
    ListGridRecord record = new ListGridRecord();
    record.setAttribute("group", from);
    record.setAttribute("id", from.getResourceGroup().getId());
    record.setAttribute(NAME.propertyName(), from.getResourceGroup().getName());
    record.setAttribute(DESCRIPTION.propertyName(), from.getResourceGroup().getDescription());
    record.setAttribute(CATEGORY.propertyName(), from.getResourceGroup().getGroupCategory().name());

    record.setAttribute("explicitCount", String.valueOf(from.getExplicitCount()));
    record.setAttribute("explicitDown", String.valueOf(from.getExplicitDown()));
    record.setAttribute("explicitDisabled", String.valueOf(from.getExplicitDisabled()));
    record.setAttribute("implicitCount", String.valueOf(from.getImplicitCount()));
    record.setAttribute("implicitDown", String.valueOf(from.getImplicitDown()));
    record.setAttribute("implicitDisabled", String.valueOf(from.getImplicitDisabled()));

    record.setAttribute(AVAIL_CHILDREN.propertyName(), getExplicitFormatted(from));
    record.setAttribute(AVAIL_DESCENDANTS.propertyName(), getImplicitFormatted(from));

    if (from.getResourceGroup().getResourceType() != null) {
      record.setAttribute("resourceType", from.getResourceGroup().getResourceType());
      record.setAttribute(TYPE.propertyName(), from.getResourceGroup().getResourceType().getName());
      record.setAttribute(
          PLUGIN.propertyName(), from.getResourceGroup().getResourceType().getPlugin());
    }

    return record;
  }

  private String getExplicitFormatted(ResourceGroupComposite from) {
    return getAlignedAvailabilityResults(
        from.getExplicitCount(),
        from.getExplicitUp(),
        from.getExplicitDown(),
        from.getExplicitUnknown(),
        from.getExplicitDisabled());
  }

  private String getImplicitFormatted(ResourceGroupComposite from) {
    return getAlignedAvailabilityResults(
        from.getImplicitCount(),
        from.getImplicitUp(),
        from.getImplicitDown(),
        from.getImplicitUnknown(),
        from.getImplicitDisabled());
  }

  private String getAlignedAvailabilityResults(
      long total, long up, long down, long unknown, long disabled) {
    StringBuilder results = new StringBuilder();

    results.append("<table><tr>");
    if (0 == total) {
      results.append(
          getColumn(
              false,
              "<img height=\"12\" width=\"12\" src=\""
                  + ImageManager.getFullImagePath(ImageManager.getAvailabilityIcon(null))
                  + "\" /> 0"));
      results.append(getColumn(true));
      results.append(getColumn(false));

    } else {
      if (up > 0) {
        String imagePath =
            ImageManager.getFullImagePath(
                ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.UP));
        results.append(
            getColumn(false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", up));
      } else {
        results.append(
            getColumn(
                false,
                "&nbsp;<img src=\""
                    + ImageManager.getBlankIcon()
                    + "\" width=\"12px\" height=\"12px\" />"));
      }

      if (down > 0) {
        String imagePath =
            ImageManager.getFullImagePath(
                ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.DOWN));
        results.append(
            getColumn(
                false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", down));
      } else {
        results.append(
            getColumn(
                false,
                "&nbsp;<img src=\""
                    + ImageManager.getBlankIcon()
                    + "\" width=\"12px\" height=\"12px\" />"));
      }

      if (disabled > 0) {
        String imagePath =
            ImageManager.getFullImagePath(
                ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.DISABLED));
        results.append(
            getColumn(
                false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", disabled));
      } else {
        results.append(
            getColumn(
                false,
                "&nbsp;<img src=\""
                    + ImageManager.getBlankIcon()
                    + "\" width=\"12px\" height=\"12px\" />"));
      }

      if (unknown > 0) {
        String imagePath =
            ImageManager.getFullImagePath(
                ImageManager.getAvailabilityIconFromAvailType(AvailabilityType.UNKNOWN));
        results.append(
            getColumn(
                false, " <img height=\"12\" width=\"12\" src=\"" + imagePath + "\" />", unknown));
      } else {
        results.append(
            getColumn(
                false,
                "&nbsp;<img src=\""
                    + ImageManager.getBlankIcon()
                    + "\" width=\"1px\" height=\"1px\" />"));
      }
    }
    results.append("</tr></table>");
    return results.toString();
  }

  private String getColumn(boolean isSpacerColumn, Object... data) {
    StringBuilder results = new StringBuilder();
    if (isSpacerColumn) {
      results.append(
          "<td nowrap=\"nowrap\" style=\"white-space:nowrap;\" width=\"10px\" align=\"left\" >");
    } else {
      results.append(
          "<td nowrap=\"nowrap\" style=\"white-space:nowrap;\" width=\"45px\" align=\"left\" >");
    }
    if (data == null) {
      results.append("&nbsp;");
    } else {
      for (Object datum : data) {
        results.append(datum == null ? "&nbsp;" : datum);
      }
    }
    results.append("</td>");
    return results.toString();
  }
}
Ejemplo n.º 8
0
 private void displayMessage(String msg) {
   CoreGUI.getMessageCenter()
       .notify(
           new Message(
               msg, Message.Severity.Info, EnumSet.of(Message.Option.BackgroundJobResult)));
 }
Ejemplo n.º 9
0
/**
 * The data portion of the graphs making these methods accessible via JSNI to classes extending this
 * and implementing graphs. Provide i18n labels and format the json data for the graph.
 *
 * @see AbstractMetricGraph
 * @author Mike Thompson
 */
public class MetricGraphData implements JsonMetricProducer {

  private static final Integer DEFAULT_CHART_HEIGHT = 200;
  // i18n
  protected final Messages MSG = CoreGUI.getMessages();
  private final String chartTitleMinLabel = MSG.chart_title_min_label();
  private final String chartTitleAvgLabel = MSG.chart_title_avg_label();
  private final String chartTitlePeakLabel = MSG.chart_title_peak_label();
  private final String chartDateLabel = MSG.chart_date_label();
  private final String chartTimeLabel = MSG.chart_time_label();
  private final String chartDownLabel = MSG.chart_down_label();
  private final String chartUnknownLabel = MSG.chart_unknown_label();
  private final String chartNoDataLabel = MSG.chart_no_data_label();
  private final String chartSingleValueLabel = MSG.chart_single_value_label();
  private final String chartHoverStartLabel = MSG.chart_hover_start_label();
  private final String chartHoverEndLabel = MSG.common_title_end();
  private final String chartHoverPeriodLabel = MSG.chart_hover_period_label();
  private final String chartHoverBarLabel = MSG.chart_hover_bar_label();
  private final String chartHoverTimeFormat = MSG.chart_hover_time_format();
  private final String chartHoverDateFormat = MSG.chart_hover_date_format();
  private int entityId = 0;
  private String entityName;
  private int definitionId;
  private int portalId;
  private MeasurementUnits adjustedMeasurementUnits;
  private MeasurementDefinition definition;
  private List<MeasurementDataNumericHighLowComposite> metricData;
  private PageList<MeasurementOOBComposite> measurementOOBCompositeList;
  private MeasurementOOBComposite lastOOB;
  private Integer chartHeight;
  private boolean isPortalGraph;
  private boolean isSummaryGraph;
  private boolean hideLegend;
  private double average = 0.0;
  private double min = Double.MAX_VALUE;
  private double max = Double.MIN_VALUE;

  private MetricGraphData(int portalId) {
    isPortalGraph = true;
    this.portalId = portalId;
  }

  public static MetricGraphData createForDashboard(int portalId) {
    return new MetricGraphData(portalId);
  }

  private MetricGraphData(
      int entityId,
      String entityName,
      MeasurementDefinition def,
      List<MeasurementDataNumericHighLowComposite> metricData) {
    this.entityName = entityName;
    setEntityId(entityId);
    setDefinitionId(def.getId());
    this.definition = def;
    this.metricData = metricData;
    this.isPortalGraph = false;

    calcMinMaxAvg(metricData);
  }

  public static MetricGraphData createForResourceGroup(
      int groupId,
      String groupName,
      MeasurementDefinition def,
      List<MeasurementDataNumericHighLowComposite> metricData) {
    return new MetricGraphData(groupId, groupName, def, metricData);
  }

  private MetricGraphData(
      int entityId,
      String entityName,
      MeasurementDefinition measurementDef,
      List<MeasurementDataNumericHighLowComposite> metricData,
      PageList<MeasurementOOBComposite> measurementOOBCompositeList,
      boolean summaryGraph) {
    this.entityName = entityName;
    setEntityId(entityId);
    setDefinitionId(measurementDef.getId());
    this.definition = measurementDef;
    this.metricData = metricData;
    this.measurementOOBCompositeList = measurementOOBCompositeList;
    this.isPortalGraph = false;
    this.isSummaryGraph = summaryGraph;
    calcMinMaxAvg(metricData);
  }

  public static MetricGraphData createForResource(
      int resourceId,
      String resourceName,
      MeasurementDefinition measurementDef,
      List<MeasurementDataNumericHighLowComposite> metrics,
      PageList<MeasurementOOBComposite> measurementOOBCompositeList) {
    return new MetricGraphData(
        resourceId, resourceName, measurementDef, metrics, measurementOOBCompositeList, false);
  }

  public static MetricGraphData createForResourceSummary(
      int resourceId,
      String resourceName,
      MeasurementDefinition measurementDef,
      List<MeasurementDataNumericHighLowComposite> metrics,
      PageList<MeasurementOOBComposite> measurementOOBCompositeList) {
    return new MetricGraphData(
        resourceId, resourceName, measurementDef, metrics, measurementOOBCompositeList, true);
  }

  private void calcMinMaxAvg(List<MeasurementDataNumericHighLowComposite> metricData) {
    int averageCount = 0;
    for (MeasurementDataNumericHighLowComposite measurement : metricData) {
      if (!Double.isNaN(measurement.getLowValue())) {
        min = Math.min(min, measurement.getLowValue());
      }
      if (!Double.isNaN(measurement.getHighValue())) {
        max = Math.max(max, measurement.getHighValue());
      }
      if (!Double.isNaN(measurement.getValue())) {
        average = average + measurement.getValue();
        averageCount++;
      }
    }
    average = average / averageCount;
  }

  public int getEntityId() {
    return this.entityId;
  }

  public void setEntityId(int entityId) {
    this.entityId = entityId;
  }

  public void setEntityName(String entityName) {
    this.entityName = entityName;
  }

  public int getDefinitionId() {
    return definitionId;
  }

  public void setDefinitionId(int definitionId) {
    this.definitionId = definitionId;
  }

  public MeasurementDefinition getDefinition() {
    return definition;
  }

  public void setDefinition(MeasurementDefinition definition) {
    this.definition = definition;
  }

  public String getChartId() {
    if (isPortalGraph) {
      if (definition != null) {
        return entityId + "-" + definition.getId();
      } else {
        // case when portlet has not been configured yet
        return "";
      }
    } else {
      return entityId + "-" + definitionId;
    }
  }

  public void setMetricData(List<MeasurementDataNumericHighLowComposite> metricData) {
    this.metricData = metricData;
  }

  public String getChartTitleMinLabel() {
    return chartTitleMinLabel;
  }

  public String getChartTitleAvgLabel() {
    return chartTitleAvgLabel;
  }

  public String getChartTitlePeakLabel() {
    return chartTitlePeakLabel;
  }

  public String getChartAverage() {
    if (average != 0.0) {
      return AbstractActivityView.convertLastValueForDisplay(average, definition);
    } else {
      return "";
    }
  }

  public String getChartMax() {
    if (max != Double.MIN_VALUE) {
      return AbstractActivityView.convertLastValueForDisplay(max, definition);
    } else {
      return "";
    }
  }

  public String getChartMin() {
    if (min != Double.MAX_VALUE) {
      return AbstractActivityView.convertLastValueForDisplay(min, definition);
    } else {
      return "";
    }
  }

  public String getChartDateLabel() {
    return chartDateLabel;
  }

  public String getChartDownLabel() {
    return chartDownLabel;
  }

  public String getChartTimeLabel() {
    return chartTimeLabel;
  }

  public String getChartUnknownLabel() {
    return chartUnknownLabel;
  }

  public String getChartNoDataLabel() {
    return chartNoDataLabel;
  }

  public String getChartSingleValueLabel() {
    return chartSingleValueLabel;
  }

  public String getChartHoverStartLabel() {
    return chartHoverStartLabel;
  }

  public String getChartHoverEndLabel() {
    return chartHoverEndLabel;
  }

  public String getChartHoverPeriodLabel() {
    return chartHoverPeriodLabel;
  }

  public String getChartHoverBarLabel() {
    return chartHoverBarLabel;
  }

  public String getChartHoverTimeFormat() {
    return chartHoverTimeFormat;
  }

  public String getChartHoverDateFormat() {
    return chartHoverDateFormat;
  }

  public int getPortalId() {
    return portalId;
  }

  public Integer getChartHeight() {
    if (null != chartHeight) {
      return chartHeight;
    } else {

      return DEFAULT_CHART_HEIGHT;
    }
  }

  public void setChartHeight(Integer chartHeight) {
    this.chartHeight = chartHeight;
  }

  public boolean isPortalGraph() {
    return isPortalGraph;
  }

  public boolean isHideLegend() {
    return hideLegend;
  }

  public void setHideLegend(boolean hideLegend) {
    this.hideLegend = hideLegend;
  }

  public String getChartTitle() {

    if (definition != null) {
      return (entityName == null)
          ? definition.getDisplayName()
          : entityName + " - " + definition.getDisplayName();
    } else {
      // handle case when dashboard portlet has not been configured yet.
      return "";
    }
  }

  /**
   * Returns the y-axis units normalized to highest scale (Bytes -> Gb). NOTE: this requires a
   * dependency such that getJsonMetrics is called before this method as the
   * adjustedMeasurementUnits are calculated in that method.
   *
   * @return yAxisUnits -- normalized to highest UOM.
   */
  public String getYAxisUnits() {
    if (adjustedMeasurementUnits == null) {
      Log.warn(
          "ResourceMetricD3GraphView.adjustedMeasurementUnits is populated by getJsonMetrics. Make sure it is called first.");
      return "";
    } else {
      return adjustedMeasurementUnits.toString();
    }
  }

  public String getXAxisTitle() {
    return MSG.view_charts_time_axis_label();
  }

  public String getXAxisTimeFormatHours() {
    return MSG.chart_xaxis_time_format_hours();
  }

  public String getXAxisTimeFormatHoursMinutes() {
    return MSG.chart_xaxis_time_format_hours_minutes();
  }

  @Override
  /**
   * Format the json for the front JSNI(javascript) UI to consume.
   *
   * @todo: future: this should really use GSON or some Json marshaller
   */
  public String getJsonMetrics() {
    StringBuilder sb = new StringBuilder();
    if (null != metricData) {
      sb = new StringBuilder("[");
      long firstBarTime = metricData.get(0).getTimestamp();
      long secondBarTime = metricData.get(1).getTimestamp();
      long barDuration = secondBarTime - firstBarTime;
      String barDurationString =
          MeasurementConverterClient.format(
              (double) barDuration, MeasurementUnits.MILLISECONDS, true);

      calculateOOB();

      // find the lowest value and use it's UOM to translated everything else into
      MeasurementDataNumericHighLowComposite lowestValue = null;
      for (MeasurementDataNumericHighLowComposite measurement : metricData) {
        if (!Double.isNaN(measurement.getValue())) {
          if (null == lowestValue) {
            lowestValue = measurement;
          }
          if (measurement.getLowValue() < lowestValue.getLowValue()) {
            lowestValue = measurement;
          }
        }
      }
      MeasurementNumericValueAndUnits adjustedMeasurementUnitsAndValue =
          MeasurementConverterClient.fit(lowestValue.getLowValue(), definition.getUnits());
      adjustedMeasurementUnits = adjustedMeasurementUnitsAndValue.getUnits();

      for (MeasurementDataNumericHighLowComposite measurement : metricData) {
        sb.append("{ \"x\":" + measurement.getTimestamp() + ",");

        if (null != lastOOB) {
          sb.append(" \"baselineMin\":" + lastOOB.getBlMin() + ", ");
          sb.append(" \"baselineMax\":" + lastOOB.getBlMax() + ", ");
        }

        if (!Double.isNaN(measurement.getValue())) {

          Double newHigh =
              normalizeUnitsAndValues(
                  new MeasurementNumericValueAndUnits(
                      measurement.getHighValue(), definition.getUnits()),
                  adjustedMeasurementUnits);
          Double newAvg =
              normalizeUnitsAndValues(
                  new MeasurementNumericValueAndUnits(
                      measurement.getValue(), definition.getUnits()),
                  adjustedMeasurementUnits);
          Double newLow =
              normalizeUnitsAndValues(
                  new MeasurementNumericValueAndUnits(
                      measurement.getLowValue(), definition.getUnits()),
                  adjustedMeasurementUnits);

          sb.append(" \"barDuration\": \"" + barDurationString + "\", ");
          sb.append(" \"high\":" + newHigh + ",");
          sb.append(
              " \"highFormatted\":\""
                  + MeasurementConverterClient.format(
                      measurement.getHighValue(), definition.getUnits(), true, 0, 3)
                  + "\",");
          sb.append(" \"low\":" + cleanseLow(newLow, newAvg, newHigh) + ",");
          sb.append(
              " \"lowFormatted\":\""
                  + MeasurementConverterClient.format(
                      cleanseLow(
                          measurement.getLowValue(),
                          measurement.getValue(),
                          measurement.getHighValue()),
                      definition.getUnits(),
                      true,
                      0,
                      3)
                  + "\",");
          sb.append(" \"avg\":" + newAvg + ",");
          sb.append(
              " \"avgFormatted\":\""
                  + MeasurementConverterClient.format(
                      measurement.getValue(), definition.getUnits(), true, 0, 3)
                  + "\"},");
        } else {
          // give it some values so that we dont have NaN
          sb.append(" \"high\":0,");
          sb.append(" \"low\":0,");
          sb.append(" \"avg\":0,");
          sb.append(" \"nodata\":true },");
        }
        if (!sb.toString().endsWith("},")) {
          sb.append(" },");
        }
      }
      sb.setLength(sb.length() - 1); // delete the last ','
      sb.append("]");
    }
    Log.debug("Json data for: " + getChartTitle());
    Log.debug(sb.toString());
    return sb.toString();
  }

  public static Double normalizeUnitsAndValues(
      MeasurementNumericValueAndUnits valueAndUnits, MeasurementUnits targetUnits) {
    if (valueAndUnits.getUnits() == MeasurementUnits.PERCENTAGE) {
      return valueAndUnits.getValue() * 100;
    }
    Double multiplier = MeasurementUnits.calculateOffset(valueAndUnits.getUnits(), targetUnits);
    return valueAndUnits.getValue() * multiplier;
  }

  /**
   * This is cleaning the data as sometimes the data coming from the metric query is erroneous: for
   * instance the low is greater than the high. This causes the geometries to get weird. We normally
   * should not have to do this!
   *
   * @todo: Remove this data cleansing once we have fixed it at the metric query.
   * @param low supposed low value
   * @param high supposed high value
   * @return the real low value
   */
  private Double cleanseLow(Double low, Double avg, Double high) {
    double highLowMin = Math.min(low, high);
    return Math.min(highLowMin, avg);
  }

  /**
   * When the scale is adjusted down to a level where bars no longer have highs and lows different
   * from the avg value then have probably hit a scale where aggregates no longer exist and we are
   * looking the individual values. At the very least the data is less interesting and a trendline
   * connecting the points has less meaning because we are essentially a scatterplot. A different
   * algorithm could be used here but this will suffice.
   *
   * @return true if the graphs should show the bar avg line meaning there is aggregates in the data
   * @see StackedBarMetricGraphImpl
   */
  public boolean showBarAvgTrendLine() {
    int numberOfAggBars = 0;
    for (MeasurementDataNumericHighLowComposite measurement : metricData) {
      boolean noValuesInCurrentBarUndefined =
          (!Double.isNaN(measurement.getValue())
              && !Double.isNaN(measurement.getHighValue())
              && !Double.isNaN(measurement.getLowValue()));
      boolean foundAggregateBar =
          (measurement.getValue() != measurement.getHighValue()
              || measurement.getHighValue() != measurement.getLowValue());
      // if there exists a even one aggregate bar then I can short circuit this and exit
      if (noValuesInCurrentBarUndefined && foundAggregateBar) {
        numberOfAggBars++;
        if (numberOfAggBars > 4) {
          return true;
        }
      }
    }
    return false;
  }

  public boolean isSummaryGraph() {
    return isSummaryGraph;
  }

  private void calculateOOB() {
    if (measurementOOBCompositeList != null && !measurementOOBCompositeList.isEmpty()) {
      Log.debug("OOB List size: " + measurementOOBCompositeList.size());
      List<MeasurementOOBComposite> selectedOOBs = new ArrayList<MeasurementOOBComposite>();
      for (MeasurementOOBComposite measurementOOBComposite : measurementOOBCompositeList) {
        Log.debug("measurementOOBComposite = " + measurementOOBComposite);
        if (measurementOOBComposite.getDefinitionId() == definitionId) {
          selectedOOBs.add(measurementOOBComposite);
        }
      }
      // take the last one (most current) matching the defId
      lastOOB = selectedOOBs.isEmpty() ? null : selectedOOBs.get(selectedOOBs.size() - 1);
    } else {
      lastOOB = null;
    }
  }

  @Override
  public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("MetricGraphData");
    sb.append("{chartTitleMinLabel='").append(chartTitleMinLabel).append('\'');
    sb.append(", chartTitleAvgLabel='").append(chartTitleAvgLabel).append('\'');
    sb.append(", chartTitlePeakLabel='").append(chartTitlePeakLabel).append('\'');
    sb.append(", chartDateLabel='").append(chartDateLabel).append('\'');
    sb.append(", chartTimeLabel='").append(chartTimeLabel).append('\'');
    sb.append(", chartDownLabel='").append(chartDownLabel).append('\'');
    sb.append(", chartUnknownLabel='").append(chartUnknownLabel).append('\'');
    sb.append(", chartNoDataLabel='").append(chartNoDataLabel).append('\'');
    sb.append(", chartHoverStartLabel='").append(chartHoverStartLabel).append('\'');
    sb.append(", chartHoverEndLabel='").append(chartHoverEndLabel).append('\'');
    sb.append(", chartHoverPeriodLabel='").append(chartHoverPeriodLabel).append('\'');
    sb.append(", chartHoverBarLabel='").append(chartHoverBarLabel).append('\'');
    sb.append(", chartHoverTimeFormat='").append(chartHoverTimeFormat).append('\'');
    sb.append(", chartHoverDateFormat='").append(chartHoverDateFormat).append('\'');
    sb.append(", entityId=").append(entityId);
    sb.append(", entityName='").append(entityName).append('\'');
    sb.append(", definitionId=").append(definitionId);
    sb.append(", isPortalGraph=").append(isPortalGraph);
    sb.append('}');
    return sb.toString();
  }
}