コード例 #1
0
  /**
   * 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);
  }
コード例 #2
0
  /** @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();
      }
    }
  }