use of com.axelor.studio.db.DashletBuilder 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);
}
Aggregations