/** * @see * com.ixora.rms.client.model.DashboardModelHelper#commitDashboard(com.ixora.rms.internal.ResourceId, * java.lang.String) */ public void commitDashboard(ResourceId context, String dashboard) { ArtefactInfoContainerImpl qc = model.getArtefactContainerImplForResource(context, true); if (qc == null) { return; } DashboardInfoImpl di = qc.getDashboardInfoImpl(dashboard); if (di == null) { if (logger.isTraceEnabled()) { logger.error("Couldn't find dashboard info for: " + di); } return; } di.commit(); }
/** @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(); } } }
// 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(); } } }