use of com.axelor.auth.db.repo.RoleRepository 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.auth.db.repo.RoleRepository in project axelor-open-suite by axelor.
the class ImportPermission method importPermissionToRole.
@Transactional
public Object importPermissionToRole(Object bean, Map<String, Object> values) {
assert bean instanceof Permission;
Permission permission = (Permission) bean;
String roleName = values.get("roleName").toString();
if (Strings.isNullOrEmpty(roleName)) {
return bean;
}
RoleRepository roleRepository = Beans.get(RoleRepository.class);
Role role = roleRepository.findByName(roleName);
if (role == null) {
return bean;
}
role.addPermission(permission);
return bean;
}
Aggregations