use of com.axelor.meta.db.MetaView in project axelor-open-suite by axelor.
the class ChartBuilderService method build.
/**
* Root Method to access the service it generate AbstractView from ViewBuilder.
*
* @param viewBuilder ViewBuilder object of type chart.
* @return AbstractView from meta schema.
* @throws JAXBException
* @throws AxelorException
*/
public void build(ChartBuilder chartBuilder) throws JAXBException, AxelorException {
if (chartBuilder.getName().contains(" ")) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.CHART_BUILDER_1));
}
searchFields = new ArrayList<String>();
// onNewFields = new ArrayList<RecordField>();
joins = new ArrayList<String>();
categType = "text";
String[] queryString = prepareQuery(chartBuilder);
// setOnNewAction(chartBuilder);
String xml = createXml(chartBuilder, queryString);
log.debug("Chart xml: {}", xml);
ObjectViews chartView = XMLViews.fromXML(xml);
MetaView metaView = metaService.generateMetaView(chartView.getViews().get(0));
if (metaView != null) {
chartBuilder.setMetaViewGenerated(metaView);
}
}
use of com.axelor.meta.db.MetaView 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);
}
use of com.axelor.meta.db.MetaView in project axelor-open-suite by axelor.
the class ReportBuilderService method createTable.
/**
* Process panelRelated to find right grid view of reference model. Grid view used to create html
* table.
*
* @param panelRelated PanelRelated to use.
* @param refModel Name of model refer by panelRelated.
* @return Html table string created.
*/
private String createTable(PanelRelated panelRelated, String refModel) {
List<AbstractWidget> items = panelRelated.getItems();
if (items != null && !items.isEmpty()) {
return getHtmlTable(panelRelated.getName(), items, refModel);
}
MetaView gridView = findGridView(panelRelated.getGridView(), refModel);
if (gridView != null) {
try {
ObjectViews views = XMLViews.fromXML(gridView.getXml());
GridView grid = (GridView) views.getViews().get(0);
return getHtmlTable(panelRelated.getName(), grid.getItems(), refModel);
} catch (JAXBException e) {
e.printStackTrace();
}
}
return "";
}
use of com.axelor.meta.db.MetaView in project axelor-open-suite by axelor.
the class ChartBuilderRepo method remove.
@Override
public void remove(ChartBuilder chartBuilder) {
MetaView metaView = chartBuilder.getMetaViewGenerated();
List<ChartBuilder> chartBuilders = all().filter("self.metaViewGenerated = ?1 and self.id != ?2", metaView, chartBuilder.getId()).fetch();
for (ChartBuilder builder : chartBuilders) {
builder.setMetaViewGenerated(null);
}
if (metaView != null) {
metaViewRepo.remove(metaView);
}
super.remove(chartBuilder);
}
use of com.axelor.meta.db.MetaView in project axelor-open-suite by axelor.
the class DashboardBuilderRepo method save.
@Override
public DashboardBuilder save(DashboardBuilder dashboardBuilder) {
dashboardBuilder = super.save(dashboardBuilder);
MetaView metaView = dashboardBuilderService.build(dashboardBuilder);
if (metaView != null) {
dashboardBuilder.setMetaViewGenerated(metaView);
} else {
metaView = dashboardBuilder.getMetaViewGenerated();
if (metaView != null) {
metaViewRepo.remove(metaView);
}
}
return dashboardBuilder;
}
Aggregations