Search in sources :

Example 1 with MenuBuilder

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);
}
Also used : MetaMenu(com.axelor.meta.db.MetaMenu) MenuBuilder(com.axelor.studio.db.MenuBuilder) Transactional(com.google.inject.persist.Transactional)

Example 2 with MenuBuilder

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) {
    }
}
Also used : ActionView(com.axelor.meta.schema.actions.ActionView) ObjectViews(com.axelor.meta.schema.ObjectViews) MetaAction(com.axelor.meta.db.MetaAction) MenuBuilder(com.axelor.studio.db.MenuBuilder) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 3 with MenuBuilder

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);
    }
}
Also used : MetaJsonModel(com.axelor.meta.db.MetaJsonModel) MenuBuilderRepo(com.axelor.studio.db.repo.MenuBuilderRepo) MetaJsonModelRepo(com.axelor.studio.db.repo.MetaJsonModelRepo) MenuBuilder(com.axelor.studio.db.MenuBuilder) MenuBuilderRepository(com.axelor.studio.db.repo.MenuBuilderRepository) Transactional(com.google.inject.persist.Transactional)

Aggregations

MenuBuilder (com.axelor.studio.db.MenuBuilder)3 Transactional (com.google.inject.persist.Transactional)2 MetaAction (com.axelor.meta.db.MetaAction)1 MetaJsonModel (com.axelor.meta.db.MetaJsonModel)1 MetaMenu (com.axelor.meta.db.MetaMenu)1 ObjectViews (com.axelor.meta.schema.ObjectViews)1 ActionView (com.axelor.meta.schema.actions.ActionView)1 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)1 MenuBuilderRepo (com.axelor.studio.db.repo.MenuBuilderRepo)1 MenuBuilderRepository (com.axelor.studio.db.repo.MenuBuilderRepository)1 MetaJsonModelRepo (com.axelor.studio.db.repo.MetaJsonModelRepo)1