use of com.axelor.auth.db.repo.GroupRepository in project axelor-open-suite by axelor.
the class ImportPermission method importPermission.
@Transactional
public Object importPermission(Object bean, Map<String, Object> values) {
assert bean instanceof Permission;
try {
GroupRepository groupRepository = Beans.get(GroupRepository.class);
Permission permission = (Permission) bean;
String groups = (String) values.get("group");
if (permission.getId() != null) {
if (groups != null && !groups.isEmpty()) {
for (Group group : groupRepository.all().filter("code in ?1", Arrays.asList(groups.split("\\|"))).fetch()) {
Set<Permission> permissions = group.getPermissions();
if (permissions == null)
permissions = new HashSet<Permission>();
permissions.add(permissionRepo.find(permission.getId()));
group.setPermissions(permissions);
groupRepository.save(group);
}
}
}
return permission;
} catch (Exception e) {
e.printStackTrace();
}
return bean;
}
Aggregations