/**
  * @param counter
  * @param queryId can be null and then the id of the query will be set to the counter name
  * @param style
  */
 public SingleCounterQueryDef(ResourceId counter, String queryId, Style style) {
   super();
   // Add a timestamp resource and the counter resource to the query
   List<ResourceDef> listResources = new LinkedList<ResourceDef>();
   ResourceId ridTimestamp =
       new ResourceId(
           counter.getHostId(),
           counter.getAgentId(),
           counter.getEntityId(),
           CounterDescriptor.TIMESTAMP_ID);
   listResources.add(new ResourceDef(ridTimestamp));
   ResourceDef resourceDef;
   if (style == null) {
     resourceDef = new ResourceDef(counter);
     resourceDef.setIName("$counter");
   } else {
     resourceDef = new ResourceDef(counter, style.getStyleDef());
     if (Utils.isEmptyString(style.getIName())) {
       resourceDef.setIName(queryId);
     }
   }
   listResources.add(resourceDef);
   String counterName = counter.getCounterId().toString();
   // set up
   if (!Utils.isEmptyString(queryId)) {
     this.id = queryId;
   } else {
     this.id = counterName;
   }
   this.resources.addAll(listResources);
 }
 /**
  * NOTE: this method will change the context of the calling thread and the caller must insure that
  * prepareThreadOnExit(String) is invoked at the end of the operation.
  *
  * @param identifier plugin instance identifier
  * @param classToLoad the class to load
  * @param jars jars with entity code and resources; path relative to application.home property
  * @param pluginData
  * @return
  * @throws AppException
  * @throws ClassNotFoundException
  * @throws MalformedURLException
  * @throws URISyntaxException
  */
 public Class<?> getClass(
     String identifier, String classToLoad, String[] jars, PluginDescriptor pluginData)
     throws AppException, ClassNotFoundException, MalformedURLException, URISyntaxException {
   Class<?> clazz = null;
   String classpath = null;
   if (pluginData != null) {
     classpath = pluginData.getClasspath();
     if (classpath != null) {
       // if cutom classpath is specified, the jars are mandatory
       if (jars == null) {
         AppException e = new AppException("Code location information is missing");
         e.setIsInternalAppError();
         throw e;
       }
     }
   }
   if (jars != null) {
     List<String> pathList = new LinkedList<String>();
     for (int i = 0; i < jars.length; i++) {
       // now complete jars information
       pathList.add(Utils.getPath(jars[i]));
     }
     if (classpath != null) {
       pathList.add(classpath);
     }
     // check class loader id
     String classLoaderId = pluginData.getClassLoaderId();
     RegexClassLoader loader;
     if (Utils.isEmptyString(classLoaderId)) {
       loader =
           new RegexClassLoader(
               pathList.toArray(new String[pathList.size()]),
               pluginData.useParentLastClassloader());
     } else {
       // check if a classloader with the same id already created
       loader = fLoadersPerId.get(classLoaderId);
       String[] path = pathList.toArray(new String[pathList.size()]);
       if (loader == null) {
         // add it to the map
         loader = new RegexClassLoader(path, pluginData.useParentLastClassloader());
         fLoadersPerId.put(classLoaderId, loader);
       } else {
         // check for consistency: the classpath must be the same
         if (!loader.isCompatibleWithClasspath(path)) {
           throw new IncompatibleClassloaderError(
               classLoaderId,
               loader.getClasspathAsString(),
               RegexClassLoader.convertClasspathToString(path));
         }
       }
     }
     fLoadersPerExternalId.put(identifier, loader);
     prepareThreadOnEnter(identifier);
     clazz = Class.forName(classToLoad, true, loader);
   }
   if (clazz == null) {
     clazz = Class.forName(classToLoad);
   }
   return clazz;
 }
 /** @see com.ixora.rms.ui.artefacts.ArtefactSelectorPanel#handleRemoveArtefact() */
 protected void handleRemoveArtefact() {
   try {
     JTable table = getJTableArtefacts();
     int[] sel = table.getSelectedRows();
     if (Utils.isEmptyArray(sel)) {
       return;
     }
     for (int idx : sel) {
       DashboardInfo gi = (DashboardInfo) table.getModel().getValueAt(idx, 1);
       DashboardMap map = fDashboardRepository.getDashboardMap(fContext);
       if (map == null) {
         logger.error("Couldn't find query gruop map for context: " + this.fContext);
         return;
       }
       // ask for confitmation
       if (!UIUtils.getBooleanOkCancelInput(
           this.fViewContainer.getAppFrame(),
           MessageRepository.get(Msg.TITLE_CONFIRM_REMOVE_DASHBOARD),
           MessageRepository.get(
               Msg.TEXT_CONFIRM_REMOVE_DASHBOARD, new String[] {gi.getTranslatedName()}))) {
         return;
       }
       // remove the dashboard only for the current fSUOVersion
       map.remove(gi.getDashboard().getName(), fSUOVersion);
       fDashboardRepository.setDashboardMap(fContext, map);
       fDashboardRepository.save();
       // update model
       fSessionData.getDashboardHelper().removeDashboard(fContext, gi.getDashboard().getName());
       // refresh table model
       refreshTableModel();
     }
   } catch (Exception ex) {
     UIExceptionMgr.userException(ex);
   }
 }
 /** Launches the external browser with the given url. */
 private void handleSeeURL(URL url) {
   try {
     Utils.launchBrowser(url);
   } catch (Throwable e) {
     UIExceptionMgr.userException(e);
   }
 }
  /**
   * Sets the flag for the given dashboard.
   *
   * @param flag
   * @param context
   * @param dbName
   * @param value
   * @param commit
   */
  public void setDashboardFlag(
      int flag, ResourceId context, String dbName, boolean value, boolean commit) {
    // get views first
    DataViewInfoData[] data = getDataViewInfoData(context, dbName);
    if (data != null) {
      ResourceId rid;
      DataViewInfoData d;
      DataViewInfo dvinfo;
      for (int i = 0; i < data.length; i++) {
        d = data[i];
        dvinfo = d.getInfo();
        rid = d.getContext();
        model
            .getDataViewHelper()
            .setDataViewFlag(flag, rid, dvinfo.getDataView().getName(), value, commit);
      }
    }

    // now work with counters
    CounterInfoData[] counters = getCounterInfoData(context, dbName);
    if (!Utils.isEmptyArray(counters)) {
      // check that all counters are present
      for (CounterInfoData cid : counters) {
        ResourceInfo cInfo = model.getCounterHelper().getCounterInfo(cid.counterId);
        if (cInfo != null) {
          switch (flag) {
            case DashboardInfo.ENABLED:
              // if enabled is false then change the flag only for
              // counters which are not committed (this is to avoid a query
              // disabling the commited counters of another one)
              // @see QueryRealizerLiveSession for an excuse
              if (value || !cInfo.getCounterInfo().isCommitted()) {
                model
                    .getCounterHelper()
                    .setCounterFlag(cid.counterId, CounterInfo.ENABLED, value, true);
              }
              break;
            case DashboardInfo.ACTIVATED:
              model
                  .getCounterHelper()
                  .setCounterFlag(cid.counterId, CounterInfo.ACTIVATED, value, true);
          }
        }
      }
    }

    ArtefactInfoContainerImpl ac = model.getArtefactContainerImplForResource(context, true);
    if (ac == null) {
      if (logger.isTraceEnabled()) {
        logger.error("Couldn't find container for dashboard " + context);
      }
      return;
    }

    // enable the dashboard
    ac.setDashboardFlag(flag, dbName, value, commit);
    // refresh context node
    model.refreshNode(context);
  }
 /**
  * Implementations should process here exceptions thrown when using this generic JMX classes.<br>
  * This gives the agent a chance to return a meaningfull error to the client.
  *
  * @param t
  * @throws
  */
 protected void processException(Throwable t) throws Throwable {
   if (t instanceof RMSException) {
     throw t;
   }
   if (Utils.getTrace(t).indexOf("Connection refused to host") >= 0) {
     throw new JMXCommunicationError(t);
   }
   throw t;
 }
 /** @see com.ixora.common.xml.XMLExternalizable#fromXML(org.w3c.dom.Node) */
 public void fromXML(Node node) throws XMLException {
   Node n = XMLUtils.findChild(node, "class");
   if (n == null) {
     throw new XMLNodeMissing("class");
   }
   this.fBoardClass = XMLUtils.getText(n);
   n = XMLUtils.findChild(node, "counterFilterClass");
   if (n != null) {
     this.fBoardCounterFilterClass = XMLUtils.getText(n);
   }
   n = XMLUtils.findChild(node, "name");
   if (n == null) {
     throw new XMLNodeMissing("name");
   }
   this.fBoardName = XMLUtils.getText(n);
   n = XMLUtils.findChild(node, "viewName");
   if (n == null) {
     throw new XMLNodeMissing("viewName");
   }
   this.fViewName = XMLUtils.getText(n);
   n = XMLUtils.findChild(node, "component");
   if (n == null) {
     throw new XMLNodeMissing("component");
   }
   this.fBoardComponenName = XMLUtils.getText(n);
   n = XMLUtils.findChild(node, "icon");
   if (n == null) {
     throw new XMLNodeMissing("icon");
   }
   this.fBoardIcon = XMLUtils.getText(n);
   n = XMLUtils.findChild(node, "allowUserToCreateView");
   if (n != null) {
     fAllowUserToCreateView = Boolean.parseBoolean(XMLUtils.getText(n));
   } else { // default
     fAllowUserToCreateView = true;
   }
   n = XMLUtils.findChild(node, "preference");
   if (n == null) {
     throw new XMLNodeMissing("preference");
   }
   this.fPreferenceIndex = Integer.parseInt(XMLUtils.getText(n));
   n = XMLUtils.findChild(node, "samples");
   if (n != null) {
     List<Node> lst = XMLUtils.findChildren(n, "sample");
     if (lst != null) {
       this.fSamples = new LinkedList<DataViewBoardSampleData>();
       for (Node n1 : lst) {
         String fileName = XMLUtils.getText(n1);
         if (!Utils.isEmptyString(fileName)) {
           fSamples.add(new DataViewBoardSampleData(fileName));
         }
       }
     }
   }
 }
 private void handleChangeInLogNameTextField(Document document) {
   if (document == fTextFieldLogOne.getDocument()) {
     String txt = fTextFieldLogOne.getText().trim();
     if (!Utils.isEmptyString(txt)) {
       fLogOne = txt;
       fActionOk.setEnabled(true);
     } else {
       fActionOk.setEnabled(false);
     }
   }
 }
  /** @param context */
  public void rollbackDashboards(ResourceId context) {
    // rollback data views
    DataViewInfoData[] data = getDataViewInfoData(context);
    if (data != null) {
      ResourceId rid;
      DataViewInfoData d;
      DataViewInfo dvinfo;
      for (int i = 0; i < data.length; i++) {
        d = data[i];
        dvinfo = d.getInfo();
        rid = d.getContext();
        if (!dvinfo.isCommitted()) {
          model.getDataViewHelper().rollbackDataView(rid, dvinfo.getDataView().getName());
        }
      }
    }

    // rollback counters
    CounterInfoData[] counters = getCounterInfoData(context);
    if (!Utils.isEmptyArray(counters)) {
      // check that all counters are present
      for (CounterInfoData cid : counters) {
        model.getCounterHelper().rollbackCounter(cid.counterId, true);
      }
    }

    ArtefactInfoContainerImpl qc = model.getArtefactContainerImplForResource(context, true);
    if (qc == null) {
      if (logger.isTraceEnabled()) {
        logger.error("Couldn't find container for: " + context);
      }
      return;
    }
    Collection<DashboardInfoImpl> dis = qc.getDashboardInfoImpl();
    if (!Utils.isEmptyCollection(dis)) {
      for (DashboardInfoImpl di : dis) {
        di.rollback();
      }
    }
  }
  /** @see com.ixora.rms.ui.artefacts.ArtefactSelectorPanel#handlePlotArtefact() */
  protected void handlePlotArtefact() {
    try {
      final JTable table = getJTableArtefacts();
      final int[] sel = table.getSelectedRows();
      if (Utils.isEmptyArray(sel)) {
        return;
      }

      this.fViewContainer
          .getAppWorker()
          .runJobSynch(
              new UIWorkerJobDefault(
                  fViewContainer.getAppFrame(),
                  Cursor.WAIT_CURSOR,
                  MessageRepository.get(Msg.TEXT_PLOTTING_DASHBOARD)) {
                public void work() throws Exception {
                  for (int idx : sel) {
                    DashboardInfo di = (DashboardInfo) table.getModel().getValueAt(idx, 1);

                    Dashboard dtls = di.getDashboard();
                    if (dtls == null) {
                      logger.error("No dashboard");
                      return;
                    }

                    DataViewId[] members = dtls.getViews();
                    ResourceId[] counters = dtls.getCounters();
                    if (Utils.isEmptyArray(members) && Utils.isEmptyArray(counters)) {
                      // TODO localize
                      throw new RMSException(
                          "Dashboard " + di.getTranslatedName() + " has no data views.");
                    }

                    if (!di.getFlag(DataViewInfo.ENABLED) && di.isCommitted()) {
                      // enable it first
                      ((DashboardTableModel) fTableModelArtefacts).enableDashboard(idx);
                      applyChangesLocally();
                    }

                    callback.plot(new DashboardId(fContext, dtls.getName()));
                  }
                }

                public void finished(Throwable ex) {
                  ; // nothing, synched job
                }
              });
    } catch (Exception ex) {
      UIExceptionMgr.userException(ex);
    }
  }
  /**
   * @see
   *     com.ixora.rms.client.model.DashboardModelHelper#isDashboardReady(com.ixora.rms.internal.ResourceId,
   *     com.ixora.rms.repository.QueryGroup)
   */
  public boolean isDashboardReady(ResourceId context, Dashboard dashboard) {
    boolean ready = true;
    ResourceId[] counters = dashboard.getCounters();
    if (!Utils.isEmptyArray(counters)) {
      // check that all counters are present
      for (ResourceId c : counters) {
        if (context != null) {
          c = c.complete(context);
        }
        CounterInfo cinfo = model.getCounterInfo(c, true);
        if (cinfo == null) {
          return false;
        }
      }
    }

    // now check that all views are ready
    DataViewId[] views = dashboard.getViews();
    if (ready && !Utils.isEmptyArray(views)) {
      // find now query info on every member query
      for (DataViewId m : views) {
        if (context != null) {
          m = m.complete(context);
        }
        DataViewInfo dvinfo = model.getDataViewInfo(m, true);
        if (dvinfo == null) {
          return false;
        }
        if (!model
            .getQueryHelper()
            .isQueryReady(m.getContext(), dvinfo.getDataView().getQueryDef())) {
          return false;
        }
      }
    }
    return ready;
  }
Example #12
0
  /** @see com.ixora.rms.agents.impl.jmx.JMXAbstractAgent#getJMXConnectionURL() */
  protected String getJMXConnectionURL() {
    // pass credentials if present
    String username =
        fConfiguration.getAgentCustomConfiguration().getString(Configuration.USERNAME);
    if (!Utils.isEmptyString(username)) {
      String password =
          fConfiguration.getAgentCustomConfiguration().getString(Configuration.PASSWORD);
      if (password == null) {
        password = "";
      }
      String[] credentials = new String[] {username, password};
      fEnvMap.put(JMXConnector.CREDENTIALS, credentials);
    }

    return ((Configuration) this.fConfiguration.getCustom()).getString(Msg.JMX_CONNECTION_STRING);
  }
 /** @see com.ixora.rms.client.model.DashboardModelHelper#getAllCommittedDashboards(int) */
 @SuppressWarnings("unchecked")
 public Collection<DashboardId> getAllCommittedDashboards(int flag) {
   Collection<DashboardId> ret = new LinkedList<DashboardId>();
   Enumeration<SessionModelTreeNode> e = model.getSessionNode().breadthFirstEnumeration();
   while (e.hasMoreElements()) {
     SessionModelTreeNode sn = (SessionModelTreeNode) e.nextElement();
     Collection<DashboardInfo> dashboards = sn.getArtefactInfoContainer().getDashboardInfo();
     if (!Utils.isEmptyCollection(dashboards)) {
       for (DashboardInfo di : dashboards) {
         if (di.isCommitted() && di.getFlag(flag)) {
           ret.add(new DashboardId(sn.getResourceId(), di.getDashboard().getName()));
         }
       }
     }
   }
   return ret;
 }
  /** Applies only changes made to the current context. */
  private void applyChangesLocally() {
    // get all dashboards  to realize
    Collection<DashboardInfo> dashboards = getDashboardTableModel().getDashboardsToRealize();
    if (dashboards != null) {
      for (DashboardInfo dinfo : dashboards) {
        // register views with the query realizer
        DataViewId[] views = dinfo.getDashboard().getViews();
        if (!Utils.isEmptyArray(views)) {
          for (DataViewId view : views) {
            if (fContext != null) {
              view = view.complete(fContext);
            }
            // ask the locator for info on the required data view
            final SessionDataViewInfo dvInfo = this.fArtefactInfoLocator.getDataViewInfo(view);
            if (dvInfo == null) {
              if (logger.isTraceEnabled()) {
                logger.error("Couldn't find data view info for: " + view + ". Skipping...");
              }
              continue;
            }
            final DataViewId fv = view;
            // Note: this method is reading from the session model
            // and as a result it can only be used safely from
            // the event dispatching thread
            this.fViewContainer
                .getAppWorker()
                .runJobSynch(
                    new UIWorkerJobDefault(
                        fViewContainer.getAppFrame(),
                        Cursor.WAIT_CURSOR,
                        MessageRepository.get(
                            Msg.TEXT_REALIZING_DATAVIEW,
                            new String[] {dvInfo.getTranslatedName()})) {
                      public void work() throws Exception {
                        fQueryRealizer.realizeQuery(
                            fv.getContext(),
                            dvInfo.getDataView().getQueryDef(),
                            new QueryRealizer.Callback() {
                              public boolean acceptIncreaseInMonitoringLevel(
                                  List<ResourceInfo> counters) {
                                boolean ret =
                                    UIUtils.getBooleanYesNoInput(
                                        fViewContainer.getAppFrame(),
                                        MessageRepository.get(
                                            Msg.TITLE_CONFIRM_MONITORING_LEVEL_INCREASE),
                                        MessageRepository.get(
                                            Msg
                                                .TEXT_CONFIRM_MONITORING_LEVEL_INCREASE_FOR_DATA_VIEW,
                                            new String[] {dvInfo.getTranslatedName()}));
                                if (!ret) {
                                  // undo changes
                                  fSessionData
                                      .getDataViewHelper()
                                      .rollbackDataView(fv.getContext(), fv.getName());
                                }
                                return ret;
                              }
                            });
                      }

                      public void finished(Throwable ex) {}
                    });
          }
        }
        // register counters with the query realizer
        // for every counter create a query and register it
        ResourceId[] counters = dinfo.getDashboard().getCounters();
        if (!Utils.isEmptyArray(counters)) {
          for (ResourceId counter : counters) {
            if (fContext != null) {
              counter = counter.complete(fContext);
            }
            final SingleCounterQueryDef query = new SingleCounterQueryDef(counter, null, null);
            final ResourceId counterContext = counter.getSubResourceId(ResourceId.ENTITY);

            // add query to the model
            fSessionData.getQueryHelper().addQuery(counterContext, query);

            String translatedCounterName = counter.getCounterId().toString();
            // ask the locator for info on this counter
            SessionResourceInfo rInfo = this.fArtefactInfoLocator.getResourceInfo(counter);
            if (rInfo != null && rInfo.getCounterInfo() != null) {
              translatedCounterName = rInfo.getCounterInfo().getTranslatedName();
            }
            final String finalTranslatedCounterName = translatedCounterName;
            final ResourceId fc = counter;
            // Note: this method is reading from the session model
            // and as a result it can only be used safely from
            // the event dispatching thread
            this.fViewContainer
                .getAppWorker()
                .runJobSynch(
                    new UIWorkerJobDefault(
                        fViewContainer.getAppFrame(),
                        Cursor.WAIT_CURSOR,
                        MessageRepository.get(
                            Msg.TEXT_REALIZING_DATAVIEW, new String[] {translatedCounterName})) {
                      public void work() throws Exception {
                        fQueryRealizer.realizeQuery(
                            counterContext,
                            query,
                            new QueryRealizer.Callback() {
                              public boolean acceptIncreaseInMonitoringLevel(
                                  List<ResourceInfo> counters) {
                                boolean ret =
                                    UIUtils.getBooleanYesNoInput(
                                        fViewContainer.getAppFrame(),
                                        MessageRepository.get(
                                            Msg.TITLE_CONFIRM_MONITORING_LEVEL_INCREASE),
                                        MessageRepository.get(
                                            Msg.TEXT_CONFIRM_MONITORING_LEVEL_INCREASE_FOR_COUNTER,
                                            new String[] {finalTranslatedCounterName}));
                                if (!ret) {
                                  // undo changes
                                  fSessionData.getCounterHelper().rollbackCounter(fc, true);
                                }
                                return ret;
                              }
                            });
                      }

                      public void finished(Throwable ex) {
                        if (ex != null) {
                          UIExceptionMgr.userException(ex);
                        }
                      }
                    });
          }
        }
      }
    }

    // get all dashboards to unrealize
    dashboards = getDashboardTableModel().getDashboardsToUnRealize();
    if (dashboards != null) {
      for (DashboardInfo dinfo : dashboards) {
        // unregister views with the query realizer
        DataViewId[] views = dinfo.getDashboard().getViews();
        // get views
        if (!Utils.isEmptyArray(views)) {
          for (DataViewId view : views) {
            if (fContext != null) {
              view = view.complete(fContext);
            }
            // ask the locator for info on the required data view
            String viewTranslatedName = view.getName();
            final SessionDataViewInfo dvInfo = this.fArtefactInfoLocator.getDataViewInfo(view);
            if (dvInfo == null) {
              if (logger.isTraceEnabled()) {
                logger.error("Couldn't find data view info for: " + view);
              }
            } else {
              viewTranslatedName = dvInfo.getTranslatedName();
            }
            final DataViewId fv = view;
            // Note: this method is reading from the session model
            // and as a result it can only be used safely from
            // the event dispatching thread
            this.fViewContainer
                .getAppWorker()
                .runJobSynch(
                    new UIWorkerJobDefault(
                        fViewContainer.getAppFrame(),
                        Cursor.WAIT_CURSOR,
                        MessageRepository.get(
                            Msg.TEXT_REALIZING_DATAVIEW, new String[] {viewTranslatedName})) {
                      public void work() throws Exception {
                        QueryId qid = new QueryId(fv.getContext(), fv.getName());
                        fQueryRealizer.unrealizeQuery(qid, false);
                      }

                      public void finished(Throwable ex) {
                        if (ex != null) {
                          UIExceptionMgr.userException(ex);
                        }
                      }
                    });
          }

          // unregister counters with the query realizer
          ResourceId[] counters = dinfo.getDashboard().getCounters();
          if (!Utils.isEmptyArray(counters)) {
            for (ResourceId counter : counters) {
              if (fContext != null) {
                counter = counter.complete(fContext);
              }
              final ResourceId counterContext = counter.getSubResourceId(ResourceId.ENTITY);
              String translatedCounterName = counter.getCounterId().toString();
              // ask the locator for info on this counter
              SessionResourceInfo rInfo = this.fArtefactInfoLocator.getResourceInfo(counter);
              if (rInfo != null && rInfo.getCounterInfo() != null) {
                translatedCounterName = rInfo.getCounterInfo().getTranslatedName();
              }
              final ResourceId finalCounter = counter;
              // Note: this method is reading from the session model
              // and as a result it can only be used safely from
              // the event dispatching thread
              this.fViewContainer
                  .getAppWorker()
                  .runJobSynch(
                      new UIWorkerJobDefault(
                          fViewContainer.getAppFrame(),
                          Cursor.WAIT_CURSOR,
                          MessageRepository.get(
                              Msg.TEXT_REALIZING_DATAVIEW, new String[] {translatedCounterName})) {
                        public void work() throws Exception {
                          QueryId queryId =
                              new QueryId(counterContext, finalCounter.getCounterId().toString());
                          fQueryRealizer.unrealizeQuery(queryId, false);
                        }

                        public void finished(Throwable ex) {
                          if (ex != null) {
                            UIExceptionMgr.userException(ex);
                          }
                        }
                      });
            }
          }

          String dashboardName = dinfo.getDashboard().getName();
          fSessionData
              .getDashboardHelper()
              .setDashboardFlag(ArtefactInfo.ENABLED, fContext, dashboardName, false, true);
        }
      }
    }
    fSessionData.getDashboardHelper().recalculateDashboardsStatus(fContext);
    getDashboardTableModel().fireTableDataChanged();
    fActionApply.setEnabled(false);
    fActionCancel.setEnabled(false);
  }
  // the behaviour is as follows:
  // if the dashboard is not commited, the state will not be changed
  // else the state of the dasboard will be updated only if there is at least
  // one view already in the session model that belongs to this dashboard and
  // it is not enabled
  public void recalculateDashboardsStatus(ResourceId context) {
    ArtefactInfoContainerImpl acimpl = model.getArtefactContainerImplForResource(context, true);
    if (acimpl == null) {
      if (logger.isTraceEnabled()) {
        logger.error("Couldn't find container for: " + context);
      }
      return;
    }
    Collection<DashboardInfoImpl> cs = acimpl.getDashboardInfoImpl();
    if (cs == null) {
      return;
    }

    for (DashboardInfoImpl dinfo : cs) {
      if (dinfo.isCommitted()) {
        Dashboard db = dinfo.getDashboard();
        // flags to update
        boolean enabled = dinfo.getFlag(DashboardInfo.ENABLED);
        boolean plotted = dinfo.getFlag(DashboardInfo.ACTIVATED);
        boolean committed = dinfo.isCommitted();

        // check counters
        ResourceId[] counters = db.getCounters();
        if (!Utils.isEmptyArray(counters)) {
          // disable this dashboard only if one of it's counters
          // exists in the model and it's disabled
          for (ResourceId c : counters) {
            if (context != null) {
              c = c.complete(context);
            }
            CounterInfo cinfo = model.getCounterInfo(c, false);
            if (cinfo == null) {
              if (logger.isTraceEnabled()) {
                logger.error("Couldn't find counter: " + c);
              }
              break;
            }
            if (!cinfo.getFlag(CounterInfo.ENABLED)) {
              enabled = false;
            }
            if (!cinfo.getFlag(CounterInfo.ACTIVATED)) {
              plotted = false;
            }
            if (!cinfo.isCommitted()) {
              committed = false;
            }
          }
        }

        // check data views
        DataViewId[] views = db.getViews();
        if (!Utils.isEmptyArray(views)) {
          // disable this dashboard only if one of it's queries
          // exists in the model and it's disabled

          // find now info on every member
          DataViewId m;
          DataViewInfo dvinfo;
          for (int i = 0; i < views.length; i++) {
            m = views[i];
            if (context != null) {
              m = m.complete(context);
            }
            // refresh data views first
            model.getDataViewHelper().recalculateDataViewsStatus(m.getContext());
            dvinfo = model.getDataViewInfo(m, false);
            if (dvinfo == null) {
              // this query no longer exists...
              // ignore it with a warning in logs
              if (logger.isInfoEnabled()) {
                logger.error(
                    "Couldn't find view info for: "
                        + m
                        + ". Dashboard "
                        + dinfo.getTranslatedName()
                        + " will be incomplete.");
              }
              break;
            }
            // query exists and it will contribute to the state
            // of this dashboard
            if (!dvinfo.getFlag(QueryInfo.ENABLED)) {
              enabled = false;
            }
            if (!dvinfo.getFlag(QueryInfo.ACTIVATED)) {
              plotted = false;
            }
            if (!dvinfo.isCommitted()) {
              committed = false;
            }
          }
        }

        dinfo.setFlag(DashboardInfo.ENABLED, enabled);
        dinfo.setFlag(DashboardInfo.ACTIVATED, plotted);
        if (committed) {
          dinfo.commit();
        }
      } else {
        // just commit it
        dinfo.commit();
      }
    }
  }