/**
   * 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);
  }
 /**
  * @see com.ixora.rms.client.model.DashboardModelHelper#removeDashboard(com.ixora.rms.ResourceId,
  *     java.lang.String)
  */
 public void removeDashboard(ResourceId id, String dbName) {
   ArtefactInfoContainerImpl ac = model.getArtefactContainerImplForResource(id, false);
   if (ac == null) {
     if (logger.isTraceEnabled()) {
       logger.error("Couldn't find container for: " + id);
     }
     return;
   }
   ac.removeDashboard(dbName);
   model.refreshNode(id);
 }
 /**
  * @see com.ixora.rms.client.model.DashboardModelHelper#addDashboard(com.ixora.rms.ResourceId,
  *     com.ixora.rms.repository.QueryGroup)
  */
 public void addDashboard(ResourceId id, Dashboard group) {
   ArtefactInfoContainerImpl ac = model.getArtefactContainerImplForResource(id, false);
   if (ac == null) {
     if (logger.isTraceEnabled()) {
       logger.error("Couldn't find container for: " + id);
     }
     return;
   }
   ac.addDashboard(group);
   recalculateDashboardsStatus(id);
   model.refreshNode(id);
 }
 /**
  * Sets the dashboards associated with the given resource.
  *
  * @param id a valid, non regex resource id
  * @param q
  */
 public void setDashboards(ResourceId id, Dashboard[] groups) {
   ArtefactInfoContainerImpl qc = model.getArtefactContainerImplForResource(id, true);
   if (qc == null) {
     if (logger.isTraceEnabled()) {
       logger.error("Couldn't find query container for: " + id.toString());
     }
     return;
   }
   qc.setDashboards(groups);
   recalculateDashboardsStatus(id);
   model.refreshNode(id);
 }