use of com.axelor.meta.db.MetaMenu in project axelor-open-suite by axelor.
the class CalendarConfigurationService method deleteEntryMenu.
@Transactional
public void deleteEntryMenu(CalendarConfiguration calendarConfiguration) {
MetaAction metaAction = calendarConfiguration.getMetaAction();
Role role = calendarConfiguration.getRole();
Group group = calendarConfiguration.getCalendarGroup();
calendarConfiguration.setMetaAction(null);
calendarConfiguration.setRole(null);
calendarConfiguration.getCalendarUser().removeRole(role);
if (group != null) {
group.removeRole(role);
}
String menuName = NAME + calendarConfiguration.getName().toLowerCase() + "-" + calendarConfiguration.getId();
MetaMenuRepository metaMenuRepository = Beans.get(MetaMenuRepository.class);
MetaMenu metaMenu = metaMenuRepository.findByName(menuName);
metaMenuRepository.remove(metaMenu);
MetaActionRepository metaActionRepository = Beans.get(MetaActionRepository.class);
metaActionRepository.remove(metaAction);
RoleRepository roleRepository = Beans.get(RoleRepository.class);
roleRepository.remove(role);
}
use of com.axelor.meta.db.MetaMenu in project axelor-open-suite by axelor.
the class CalendarConfigurationService method createEntryMenu.
@Transactional
public void createEntryMenu(CalendarConfiguration calendarConfiguration) {
String menuName = NAME + calendarConfiguration.getName().toLowerCase() + "-" + calendarConfiguration.getId();
String subName = menuName.replaceAll("[-\\s]", ".");
String title = calendarConfiguration.getName();
User user = calendarConfiguration.getCalendarUser();
Group group = calendarConfiguration.getCalendarGroup();
MetaAction metaAction = this.createMetaAction("action." + subName, title);
MetaMenu metaMenu = this.createMetaMenu(menuName, title, metaAction, calendarConfiguration.getParentMetaMenu());
Beans.get(MetaMenuRepository.class).save(metaMenu);
Role role = new Role();
role.setName("role." + subName);
role.addMenu(metaMenu);
Beans.get(RoleRepository.class).save(role);
user.addRole(role);
Beans.get(UserRepository.class).save(user);
if (group != null) {
group.addRole(role);
Beans.get(GroupRepository.class).save(group);
}
calendarConfiguration.setRole(role);
calendarConfiguration.setMetaAction(metaAction);
calendarConfigurationRepo.save(calendarConfiguration);
}
use of com.axelor.meta.db.MetaMenu 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.meta.db.MetaMenu in project axelor-open-suite by axelor.
the class MenuBuilderService method build.
@Transactional
public MetaMenu build(MenuBuilder builder) {
MetaMenu menu = metaService.createMenu(builder);
ActionBuilder actionBuilder = builder.getActionBuilder();
if (actionBuilder != null) {
if (actionBuilder.getName() == null) {
actionBuilder.setName(menu.getName());
}
actionBuilder.setXmlId(builder.getXmlId());
actionBuilder.setTitle(menu.getTitle());
actionBuilder.setAppBuilder(builder.getAppBuilder());
menu.setAction(actionBuilderService.build(actionBuilder));
}
MetaStore.clear();
return menu;
}
use of com.axelor.meta.db.MetaMenu in project axelor-open-suite by axelor.
the class MenuBuilderRepo method remove.
@Override
public void remove(MenuBuilder menuBuilder) {
MetaMenu metaMenu = menuBuilder.getMetaMenu();
menuBuilder.setMetaMenu(null);
if (metaMenu != null) {
metaService.removeMetaMenu(metaMenu);
}
ActionBuilder actionBuilder = menuBuilder.getActionBuilder();
menuBuilder.setActionBuilder(null);
if (actionBuilder != null) {
try {
actionBuilderRepo.remove(actionBuilder);
} catch (RuntimeException e) {
TraceBackService.trace(e);
throw e;
}
}
MetaStore.clear();
super.remove(menuBuilder);
}
Aggregations