use of com.axelor.meta.db.MetaView in project axelor-open-suite by axelor.
the class AppController method configure.
public void configure(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
MetaView formView = null;
String code = (String) context.get("code");
String appName = Inflector.getInstance().camelize(code);
Model config = (Model) context.get("app" + appName);
String model = "com.axelor.apps.base.db.App" + appName;
if (config != null) {
formView = Beans.get(MetaViewRepository.class).all().filter("self.type = 'form' AND self.model = ? AND self.name like '%-config-form'", model).fetchOne();
}
if (formView == null) {
response.setFlash(I18n.get(IExceptionMessages.NO_CONFIG_REQUIRED));
} else {
response.setView(ActionView.define(I18n.get("Configure") + ": " + context.get("name")).add("form", formView.getName()).model(model).context("_showRecord", config.getId()).param("forceEdit", "true").map());
}
}
use of com.axelor.meta.db.MetaView in project axelor-open-suite by axelor.
the class StudioMetaService method generateMetaView.
/**
* Creates or Updates metaView from AbstractView.
*
* @param viewIterator ViewBuilder iterator
*/
@Transactional
public MetaView generateMetaView(AbstractView view) {
String name = view.getName();
String xmlId = view.getXmlId();
String model = view.getModel();
String viewType = view.getType();
log.debug("Search view name: {}, xmlId: {}", name, xmlId);
MetaView metaView;
if (xmlId != null) {
metaView = metaViewRepo.all().filter("self.name = ?1 and self.xmlId = ?2 and self.type = ?3", name, xmlId, viewType).fetchOne();
} else {
metaView = metaViewRepo.all().filter("self.name = ?1 and self.type = ?2", name, viewType).fetchOne();
}
log.debug("Meta view found: {}", metaView);
if (metaView == null) {
metaView = metaViewRepo.all().filter("self.name = ?1 and self.type = ?2", name, viewType).order("-priority").fetchOne();
Integer priority = 20;
if (metaView != null) {
priority = metaView.getPriority() + 1;
}
metaView = new MetaView();
metaView.setName(name);
metaView.setXmlId(xmlId);
metaView.setModel(model);
metaView.setPriority(priority);
metaView.setType(viewType);
metaView.setTitle(view.getTitle());
}
String viewXml = XMLViews.toXml(view, true);
metaView.setXml(viewXml);
return metaViewRepo.save(metaView);
}
use of com.axelor.meta.db.MetaView in project axelor-open-suite by axelor.
the class ActionBuilderController method addActionBuilderView.
private void addActionBuilderView(List<ActionBuilderView> views, String model, String type, boolean isJson, int sequence) {
String viewName = model + "-" + type;
if (isJson) {
viewName = "custom-model-" + model + "-" + type;
}
MetaView view = Beans.get(MetaViewRepository.class).findByName(viewName);
if (view == null) {
return;
}
ActionBuilderView builderView = new ActionBuilderView();
builderView.setViewName(view.getName());
builderView.setViewType(view.getType());
builderView.setSequence(sequence);
views.add(builderView);
}
use of com.axelor.meta.db.MetaView in project axelor-open-suite by axelor.
the class DashboardBuilderRepo method remove.
@Override
public void remove(DashboardBuilder dashboardBuilder) {
MetaView metaView = dashboardBuilder.getMetaViewGenerated();
if (metaView != null) {
metaViewRepo.remove(metaView);
}
super.remove(dashboardBuilder);
}
Aggregations