Search in sources :

Example 1 with MetaPermission

use of com.axelor.meta.db.MetaPermission in project axelor-open-suite by axelor.

the class PermissionAssistantService method getMetaPermission.

public MetaPermission getMetaPermission(Group group, String objectName) {
    String[] objectNames = objectName.split("\\.");
    String groupName = group.getCode();
    String permName = getPermissionName(null, objectNames[objectNames.length - 1], group.getCode());
    MetaPermission metaPermission = metaPermissionRepository.all().filter("self.name = ?1", permName).fetchOne();
    if (metaPermission == null) {
        LOG.debug("Create metaPermission group: {}, object: {}", groupName, objectName);
        metaPermission = new MetaPermission();
        metaPermission.setName(permName);
        metaPermission.setObject(objectName);
        group.addMetaPermission(metaPermission);
    }
    return metaPermission;
}
Also used : MetaPermission(com.axelor.meta.db.MetaPermission)

Example 2 with MetaPermission

use of com.axelor.meta.db.MetaPermission in project axelor-open-suite by axelor.

the class PermissionAssistantService method getMetaPermission.

public MetaPermission getMetaPermission(Role role, String objectName) {
    String[] objectNames = objectName.split("\\.");
    String roleName = role.getName();
    String permName = getPermissionName(null, objectNames[objectNames.length - 1], roleName);
    MetaPermission metaPermission = metaPermissionRepository.all().filter("self.name = ?1", permName).fetchOne();
    if (metaPermission == null) {
        LOG.debug("Create metaPermission role: {}, object: {}", roleName, objectName);
        metaPermission = new MetaPermission();
        metaPermission.setName(permName);
        metaPermission.setObject(objectName);
        role.addMetaPermission(metaPermission);
    }
    return metaPermission;
}
Also used : MetaPermission(com.axelor.meta.db.MetaPermission)

Aggregations

MetaPermission (com.axelor.meta.db.MetaPermission)2