Search in sources :

Example 1 with Dashboard

use of com.axelor.meta.schema.views.Dashboard in project axelor-open-suite by axelor.

the class DashboardBuilderService method build.

/**
 * Method to generate Dashboard (meta schema) from View Builder.
 *
 * @param viewBuilder ViewBuilder of type dashboard.
 * @return Dashboard.
 */
public MetaView build(DashboardBuilder dashboardBuilder) {
    log.debug("Processing dashboard: {}", dashboardBuilder.getName());
    log.debug("Dashlet list: {}", dashboardBuilder.getDashletBuilderList());
    if (dashboardBuilder.getDashletBuilderList() == null || dashboardBuilder.getDashletBuilderList().isEmpty()) {
        return null;
    }
    Dashboard dashboard = new Dashboard();
    String boardName = dashboardBuilder.getName();
    dashboard.setTitle(dashboardBuilder.getTitle());
    dashboard.setName(dashboardBuilder.getName());
    List<AbstractWidget> dashlets = new ArrayList<AbstractWidget>();
    dashboardBuilder.clearGeneratedActions();
    for (DashletBuilder dashletBuilder : dashboardBuilder.getDashletBuilderList()) {
        Dashlet dashlet = new Dashlet();
        String name = null;
        String model = null;
        MetaView metaView = dashletBuilder.getMetaView();
        MetaAction action = dashletBuilder.getAction();
        String actionName = null;
        if (metaView != null) {
            name = metaView.getName();
            model = metaView.getModel();
            MetaAction metaAction = getAction(boardName, name, model, dashletBuilder);
            actionName = metaAction.getName();
            dashboardBuilder.addGeneratedAction(metaAction);
        } else if (action != null) {
            model = action.getModel();
            actionName = action.getName();
        }
        dashlet.setAction(actionName);
        dashlet.setHeight("350");
        Integer colSpan = dashletBuilder.getColspan();
        if (colSpan > 12) {
            colSpan = 12;
        } else if (colSpan <= 0) {
            colSpan = 6;
        }
        dashlet.setColSpan(colSpan);
        dashlets.add(dashlet);
    }
    if (dashlets.isEmpty()) {
        return null;
    }
    dashboard.setItems(dashlets);
    MetaStore.clear();
    return metaService.generateMetaView(dashboard);
}
Also used : DashletBuilder(com.axelor.studio.db.DashletBuilder) ArrayList(java.util.ArrayList) Dashboard(com.axelor.meta.schema.views.Dashboard) AbstractWidget(com.axelor.meta.schema.views.AbstractWidget) Dashlet(com.axelor.meta.schema.views.Dashlet) MetaView(com.axelor.meta.db.MetaView) MetaAction(com.axelor.meta.db.MetaAction)

Aggregations

MetaAction (com.axelor.meta.db.MetaAction)1 MetaView (com.axelor.meta.db.MetaView)1 AbstractWidget (com.axelor.meta.schema.views.AbstractWidget)1 Dashboard (com.axelor.meta.schema.views.Dashboard)1 Dashlet (com.axelor.meta.schema.views.Dashlet)1 DashletBuilder (com.axelor.studio.db.DashletBuilder)1 ArrayList (java.util.ArrayList)1