* @return created role instance
* @throws ObjectNotFoundException
* - if something wasn't found
*/
public IRoleInstanceMetaInfo createRoleInstance(IRoleMetaInfo roleTemplate) throws ObjectNotFoundException {
IRoleInstanceMetaInfo roleInstance = roleInstanceService.getRoleInstanceImpl(roleTemplate.getModelId());
roleInstance.setRoleId(roleTemplate.getId());
roleInstance.setName(roleTemplate.getName());
for (IPermissionMetaInfo permission : roleTemplate.getPermissions()) {
IPermissionInstanceMetaInfo permissionInstance = permissionInstanceService.getPermissionInstanceImpl();
permissionInstance.setPermissionId(permission.getId());
permissionInstance.setRoleInstance(roleInstance);
for (IAttributeMetaInfo attribute : permission.getAttributes()) {
IPermissionParameter param = permissionInstanceService.getPermissionParameterImpl();
param.setAttributeName(attribute.getName());
param.setPermissionInstance(permissionInstance);
permissionInstance.addPermissionParameter(param);
}
roleInstance.addPermissionInstance(permissionInstance);
}
return roleInstance;
}