Search in sources :

Example 6 with Permission

use of com.axelor.auth.db.Permission in project axelor-open-suite by axelor.

the class AccessConfigImportServiceImpl method createObjectRoles.

private void createObjectRoles(Map<Integer, AccessConfig> accessMap, Row row) {
    Iterator<Cell> cellIter = row.iterator();
    String obj = cellIter.next().getStringCellValue();
    while (cellIter.hasNext()) {
        Cell cell = cellIter.next();
        String value = cell.getStringCellValue();
        if (Strings.isNullOrEmpty(value) || invalidValue(value)) {
            continue;
        }
        AccessConfig config = accessMap.get(cell.getColumnIndex());
        Permission permission = getPermission(obj, value.trim(), config);
        addRole(config, permission);
    }
}
Also used : Permission(com.axelor.auth.db.Permission) AccessConfig(com.axelor.apps.base.db.AccessConfig) Cell(org.apache.poi.ss.usermodel.Cell)

Example 7 with Permission

use of com.axelor.auth.db.Permission in project axelor-open-suite by axelor.

the class PermissionAssistantService method updatePermission.

public void updatePermission(Role role, String objectName, MetaField field, String[] row) {
    String[] objectNames = objectName.split("\\.");
    String permName = getPermissionName(field, objectNames[objectNames.length - 1], role.getName());
    Permission permission = permissionRepository.all().filter("self.name = ?1", permName).fetchOne();
    boolean newPermission = false;
    if (permission == null) {
        newPermission = true;
        permission = new Permission();
        permission.setName(permName);
        permission.setObject(objectName);
    }
    permission.setCanRead(row[0].equalsIgnoreCase("x"));
    permission.setCanWrite(row[1].equalsIgnoreCase("x"));
    permission.setCanCreate(row[2].equalsIgnoreCase("x"));
    permission.setCanRemove(row[3].equalsIgnoreCase("x"));
    permission.setCanExport(row[4].equalsIgnoreCase("x"));
    permission.setCondition(row[5]);
    permission.setConditionParams(row[6]);
    if (newPermission) {
        role.addPermission(permission);
    }
}
Also used : MetaPermission(com.axelor.meta.db.MetaPermission) Permission(com.axelor.auth.db.Permission)

Aggregations

Permission (com.axelor.auth.db.Permission)7 MetaPermission (com.axelor.meta.db.MetaPermission)3 Transactional (com.google.inject.persist.Transactional)3 AccessConfig (com.axelor.apps.base.db.AccessConfig)1 Group (com.axelor.auth.db.Group)1 Role (com.axelor.auth.db.Role)1 GroupRepository (com.axelor.auth.db.repo.GroupRepository)1 RoleRepository (com.axelor.auth.db.repo.RoleRepository)1 MetaField (com.axelor.meta.db.MetaField)1 HashSet (java.util.HashSet)1 Cell (org.apache.poi.ss.usermodel.Cell)1