use of com.axelor.studio.db.MenuBuilder in project axelor-open-suite by axelor.
the class StudioMetaService method removeMetaMenu.
@Transactional
public void removeMetaMenu(MetaMenu metaMenu) {
Preconditions.checkNotNull(metaMenu, "metaMenu cannot be null.");
List<MetaMenu> subMenus = metaMenuRepo.all().filter("self.parent = ?1", metaMenu).fetch();
for (MetaMenu subMenu : subMenus) {
subMenu.setParent(null);
}
List<MenuBuilder> subBuilders = menuBuilderRepo.all().filter("self.parentMenu = ?1", metaMenu).fetch();
for (MenuBuilder subBuilder : subBuilders) {
subBuilder.setParentMenu(null);
menuBuilderRepo.save(subBuilder);
}
metaMenuRepo.remove(metaMenu);
}
use of com.axelor.studio.db.MenuBuilder in project axelor-open-suite by axelor.
the class MenuBuilderController method showMenuBuilderRecords.
public void showMenuBuilderRecords(ActionRequest request, ActionResponse response) {
MenuBuilder menuBuilder = request.getContext().asType(MenuBuilder.class);
if (menuBuilder.getMetaMenu() == null || menuBuilder.getMetaMenu().getAction() == null) {
return;
}
try {
MetaAction metaAction = menuBuilder.getMetaMenu().getAction();
ObjectViews objectViews = XMLViews.fromXML(metaAction.getXml());
ActionView actionView = (ActionView) objectViews.getActions().get(0);
ActionViewBuilder actionViewBuilder = ActionView.define(I18n.get(actionView.getTitle()));
actionViewBuilder.model(actionView.getModel());
actionViewBuilder.icon(actionView.getIcon());
actionViewBuilder.domain(actionView.getDomain());
actionViewBuilder.context("jsonModel", menuBuilder.getActionBuilder().getModel());
actionView.getViews().forEach(view -> actionViewBuilder.add(view.getType(), view.getName()));
if (ObjectUtils.notEmpty(actionView.getParams())) {
actionView.getParams().forEach(param -> actionViewBuilder.param(param.getName(), param.getValue()));
}
response.setView(actionViewBuilder.map());
} catch (Exception e) {
}
}
use of com.axelor.studio.db.MenuBuilder in project axelor-open-suite by axelor.
the class MetaJsonModelController method removeMenuBuilder.
@Transactional
public void removeMenuBuilder(ActionRequest request, ActionResponse response) {
MetaJsonModel metaJsonModel = request.getContext().asType(MetaJsonModel.class);
if (metaJsonModel.getMenuBuilder() != null && metaJsonModel.getMenuBuilder().getId() != null && metaJsonModel.getMenuBuilder().getMetaMenu() != null) {
MenuBuilder menuBuilder = Beans.get(MenuBuilderRepository.class).find(metaJsonModel.getMenuBuilder().getId());
metaJsonModel = Beans.get(MetaJsonModelRepo.class).find(metaJsonModel.getId());
metaJsonModel.setMenuBuilder(null);
Beans.get(MetaJsonModelRepo.class).save(metaJsonModel);
Beans.get(MenuBuilderRepo.class).remove(menuBuilder);
response.setReload(true);
}
}
Aggregations