Module: UU::OS::Role

Extended by:
Role
Included in:
Role
Defined in:
uu_os-0.29.16/lib/uu/os/role/role_create.rb,
uu_os-0.29.16/lib/uu/os/role.rb,
uu_os-0.29.16/lib/uu/os/role/role_attributes.rb,
uu_os-0.29.16/lib/uu/os/role/role_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/role/role_get_artifact_list.rb,
uu_os-0.29.16/lib/uu/os/role/role_add_role_interface.rb,
uu_os-0.29.16/lib/uu/os/role/role_remove_role_interface.rb,
uu_os-0.29.16/lib/uu/os/role/role_get_artifact_list_item.rb,
uu_os-0.29.16/lib/uu/os/role/role_get_role_interface_list.rb,
uu_os-0.29.16/lib/uu/os/role/role_get_role_interface_list_item.rb

Overview

Module Role.

Defined Under Namespace

Classes: RoleAddRoleInterface, RoleAttributes, RoleCreate, RoleGetArtifactList, RoleGetArtifactListItem, RoleGetRoleInterfaceList, RoleGetRoleInterfaceListItem, RoleRemoveRoleInterface, RoleSetAttributes

Constant Summary

PATH =

Service path

'ues/core/role/UESRole'

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_role_interface(role_uri, role = nil)

Creates new role interface connection to the specified role. The role interface has to be in an active state and mustn't be already connected. The role interface has to be connected to the one of the authorized roles for this command, or the authorized role has to be casted to the default group of meta model where the role interface is located.

Examples:

# Add role interface to specified role.
UU::OS::Role.add_role_interface('ues:TERRITORY:ROLE', :role_interface_uri=>'ues:TERRITORY:ROLE_ITERFACE')

Parameters:

  • role_uri (String, UU::OS::UESURI)

    UESURI of the role where the role interface will be connected

  • role (RoleAddRoleInterface) (defaults to: nil)

    DTO containing role interface that to be connected

Options Hash (role):

  • :role_interface_uri (String, UU::OS::UESURI)

    UESURI of the role interface that to be connected to the specified role. If nil is set, the command fails.



176
177
178
179
180
181
182
183
# File 'uu_os-0.29.16/lib/uu/os/role.rb', line 176

def add_role_interface(role_uri, role = nil)
  svc = UU::OS::REST::RemoteClient.new(Role)
  payload = UU::OS::Role::RoleAddRoleInterface.new(role).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('addRoleInterface', role_uri, payload)
  end
end

- (UU::OS::UESURI) create(location_uri, role = nil)

Creates a new role. The command creates a new role in a specified location.At the very least meta artifact must be specified in RoleCreate DTO. Competent role for the new role will be selected as the most suitable according to specified container and meta artifact (executive/authorized role with connected interface), or can be also specified in RoleCreate DTO.

Examples:

# Create new role.
UU::OS::Role.create('ues:TERRITORY:FOLDER', :code => 'NEW_ROLE', :name => 'New Role')

# Verifying that new role can be created.
UU::OS::Role.create('ues:TERRITORY:FOLDER', :code => 'NEW_ROLE', :name => 'New Role', :dry_run => true)

Parameters:

  • location_uri (String, UU::OS::UESURI)

    UESURI of the folder/org. unit/meta model where the role will be created.

  • role (UU::OS::Role::RoleCreate) (defaults to: nil)

    Specific options.

Options Hash (role):

  • :meta_artifact_uri (String, UU::OS::UESURI)

    UESURI of the meta artifact. Only a meta artifact with the template class of Role (not its descendants) can be used. If the rights does not permit to create a new role from the meta artifact in the specified location, the create command fails.

  • :code (String)

    Code of the new role. If nil is set, the code is generated automatically using the system sequence. The code must be unique in the given territory, otherwise the create command fails.

  • :name (String)

    Name of the new role. If nil is set, tName from meta artifact is used if set, otherwise the create command fails. Note that the role name is automatically extended by the name of casted access roles names. Therefore the name attribute returned by getAttributes command returns a different string.

  • :description (String)

    Description of the new role. If nil is set, tDescription from meta artifact is used if set, otherwise no description is set on the new role.

  • :competent_role_uri (String, UU::OS::UESURI)

    UESURI of the competent role. If nil is set, the executive role from authorization is used. If no role is authorized to create the role into specified container, the create command fails. If the selected role doesn’t have connected the role interface with the selected meta artifact, the create command fails. If the selected role doesn’t belong to the same organizational unit as a new role or if it doesn’t belong to one of superior organizational units,the create command fails.

  • :security_level (String, UU::OS::Artifact::SecurityLevel)

    Security level. If nil is set, security level is taken from the meta artifact tSecurityLevel. If the meta artifact tSecurityLevel is higher than the user’s security clearance, the create command fails.

  • :searchable_in_territory (Boolean)

    Specifies if it is possible to search the new role in its territory. If attribute is nil, value will be set according to the value of meta artifact (The create command fails if the value also is nil).

  • :searchable_across_territories (Boolean)

    Deprecated. Specifies if it is possible to search and cast the new role in other territories. If attribute is nil, value will be set according to the value of meta artifact (The create command fails if the value also is nil). This attribute has been deprecated and will not be supported in the future.

  • :territory_switch_visible (Boolean)

    Deprecated. Specifies if the organizational unit of this role should be visible in visual usecase for displaying list of territories and organizational units. If true is set then related organizational unit is displayed. If false is set then related organizational unit is not visible unless there is another role with this flag set to true. If nil is set, tTerritorySwitchVisible from meta artifact is used if set, otherwise the create command fails. This attribute has been deprecated. The visual use case for displaying territories and organizational units, which this attribute was used for, is no longer supported.

  • :icon_uri (String, UU::OS::UESURI)

    URI of the role’s icon. If nil is set, the icon is not modified. If nil URI (“ues:[-1]:[-1]:”) is set, the role icon is removed and the role uses icon from meta artifact. An example of icon URI: ‘ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_077}’.

  • :grant_all_from_organizational_unit (Boolean)

    Deprecated. Specifies if the role will be included among All roles from organizational unit. If true or nil is set, the role will be included,otherwise it will not be included among All roles from organizational unit.

  • :dry_run (Boolean)

    Specifies whether this is only a test run to verify that the object can be created. The default value is false.

  • :component_content (Boolean)

    Defines whether the primarily displayed content of the created Role is component content. Default value is false.

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
# File 'uu_os-0.29.16/lib/uu/os/role.rb', line 53

def create(location_uri, role = nil)
  svc = UU::OS::REST::RemoteClient.new(Role)
  payload = UU::OS::Role::RoleCreate.new(role).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('create', location_uri, payload)
    # res is nil if dry_run was set to true. In that case, return nil (do nothing)
    if !(res.nil? || res.empty?)
      return UU::OS::UESURI.new(res)
    end
  end
end

- (Object) delete(role_uri)

Deletes the specified role from the system. The role is deleted even if it contains a locked sheet or attachment. The role cannot be deleted if:

the role is not in an active cast
the role's workflow is not created
a property contains a reference to this role
a time sheet exists with a reference to this role
an artifact exists with this role as competent role
an activity exists with this role as competent role

Examples:

# Delete role specified by UESURI.
UU::OS::Role.delete('ues:TERRITORY:DELETE')

Parameters:

  • role_uri (String, UU::OS::UESURI)

    UESURI of the role which is about to be deleted.



130
131
132
133
134
135
# File 'uu_os-0.29.16/lib/uu/os/role.rb', line 130

def delete(role_uri)
  svc = UU::OS::REST::RemoteClient.new(Role)
  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('delete', role_uri)
  end
end

- (UU::OS::REST::ResultList<Role::RoleGetArtifactList, Role::RoleGetArtifactListItem>) get_artifact_list(role_uri, criteria = nil)

Returns a list of entries representing the artifacts for that the specified role is competent. The list is sorted by the name(and codes in case are equal) of a entry by default.

Examples:

# Get role artifact list.
UU::OS::Role.get_artifact_list('ues:TERRITORY:ROLE')

Parameters:

  • role_uri (String, UU::OS::UESURI)

    UESURI of the role that is competent for the searched artifacts

  • criteria (RoleGetArtifactList) (defaults to: nil)

    DTO containing criteria for listing role’sartifacts.

Returns:



150
151
152
153
154
155
156
157
158
159
160
# File 'uu_os-0.29.16/lib/uu/os/role.rb', line 150

def get_artifact_list(role_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Role)
  dto = Role::RoleGetArtifactList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getArtifactList', role_uri)
    return UU::OS::REST::ResultList.new(Role::RoleGetArtifactList, Role::RoleGetArtifactListItem, res)
  end
end

- (RoleAttributes) get_attributes(role_uri)

Returns attributes representing the role specified by theroleUri parameter. The command does not change the state of the role in the system.

Examples:

# Get role attributes
UU::OS::Role.get_attributes('ues:TERRITORY:ROLE')

Parameters:

Returns:



76
77
78
79
80
81
82
# File 'uu_os-0.29.16/lib/uu/os/role.rb', line 76

def get_attributes(role_uri)
  svc = UU::OS::REST::RemoteClient.new(Role)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getAttributes', role_uri)
    return Role::RoleAttributes.new(res)
  end
end

- (UU::OS::REST::ResultList<Role::RoleGetRoleInterfaceList, Role::RoleGetRoleInterfaceListItem>) get_role_interface_list(role_uri, criteria = nil)

Returns list of the role interfaces that are connected to the specified role. Returned list does not contain any objects filtered out by executed UESQuery.

Examples:

# Get role interface list descend ordered by code.
roleIfcList = UU::OS::Role.get_role_interface_list('ues:TERRITORY:ACCESSROLE', :query=>'ORDER BY code DESC')

Parameters:

Options Hash (criteria):

  • :query (String)

    # The UES query string. It has to conform the UESQ syntax (see documentation for more info). Filtering and order of the result list can be specified there. If nil is set, no filtering is applied and entries are ordered by name of casted subjects (and code as the second criteria).

Returns:



217
218
219
220
221
222
223
224
225
226
227
# File 'uu_os-0.29.16/lib/uu/os/role.rb', line 217

def get_role_interface_list(role_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Role)
  dto = Role::RoleGetRoleInterfaceList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getRoleInterfaceList', role_uri)
    return UU::OS::REST::ResultList.new(Role::RoleGetRoleInterfaceList, Role::RoleGetRoleInterfaceListItem, res)
  end
end

- (Object) remove_role_interface(role_uri, role = nil)

Removes role interface connection from the specified role.Only connected interfaces can be disconnected from role.

Examples:

# Remove role interface for specified role.
UU::OS::Role.remove_role_interface('ues:TERRITORY:ROLE', :role_interface_uri=>'ues:TERRITORY:ROLE_IFC')

Parameters:

  • role_uri (String, UU::OS::UESURI)

    UESURI of the role where the role interface will be disconnected.

  • role (RoleRemoveRoleInterface) (defaults to: nil)

    DTO containing role interface that to be disconnected

Options Hash (role):

  • :role_interface_uri (String, UU::OS::UESURI)

    UESURI of the role interface that to be disconnected from the specified role. If nil is set, the command fails.



196
197
198
199
200
201
202
203
# File 'uu_os-0.29.16/lib/uu/os/role.rb', line 196

def remove_role_interface(role_uri, role = nil)
  svc = UU::OS::REST::RemoteClient.new(Role)
  payload = UU::OS::Role::RoleRemoveRoleInterface.new(role).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('removeRoleInterface', role_uri, payload)
  end
end

- (UU::OS::UESURI) set_attributes(role_uri, role = nil)

Command for setting attributes of a role. The command can't modify references to objects like location, competent role and so on.

Examples:

# Set attributes of role - make it non searchable in territory.
UU::OS::Role.set_attributes('ues:TERRITORY:ROLE', :name=>'John', :code=>'NEWCODE', :description=>'Some sample description', :searchable_in_territory=>false)

Parameters:

  • role_uri (String, UU::OS::UESURI)

    UESURI of the role whose attributes are to be changed

  • role (RoleSetAttributes) (defaults to: nil)

    DTO containing new attributes for the role

Options Hash (role):

  • :name (String)

    The new name of the role. If nil is set, the name is not modified.
    Note that the role name is automatically extended by the name of casted access roles names, if this attribute is not nil. Therefore the name attribute returned by the getAttributescommand contains different string.

  • :code (String)

    The new code of the role. If nil is set, the code is not modified.The code must be unique in a given territory, otherwise thesetAttributes command fails.

  • :description (String)

    The new description of the role. If nil is set, the description is not modified.

  • :security_level (String, UU::OS::Artifact::SecurityLevel)

    The new security level of the role. If nil is set, the security level is not modified. If the meta artifact tSecurityLevel is higher than the user’s security clearance, the setAttributescommand fails.

  • :searchable_in_territory (Boolean)

    Specifies if it is possible to search the role in its territory. If nil is set, this attribute on the role is not modified.

  • :searchable_across_territories (Boolean)

    Deprecated. Specifies if it is possible to search and cast the role in other territories. If nil is set, this attribute on the role is not modified.

  • :territory_switch_visible (Boolean)

    Deprecated. Specifies if the organizational unit of this role should be visible in visual usecase for displaying list of territories and organizational units. If true is set then related organizational unit is displayed. If false is set then related organizational unit is not visible unless there is another role with this flag set to true.

  • :icon_uri (String, UU::OS::UESURI)

    URI of the role’s icon. If nil is set, the icon is not modified. If nil UESURI (“ues:[-1]:[-1]:”) is set, the role icon is removed and the role uses icon from meta artifact. Allowed format of icon URI: ‘ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{CODE_OF_ICON}’. An example of icon URI: ‘ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_077}’.

  • :grant_all_from_organizational_unit (Boolean)

    Deprecated. Specifies if the role will be included among All roles from organizational unit. If nil is set, this attribute on the role is not modified.

  • :component_content (Boolean)

    Defines whether the primarily displayed content of the created Role is component content. Default value is false.

Returns:



105
106
107
108
109
110
111
112
113
# File 'uu_os-0.29.16/lib/uu/os/role.rb', line 105

def set_attributes(role_uri, role = nil)
  svc = UU::OS::REST::RemoteClient.new(Role)
  payload = UU::OS::Role::RoleSetAttributes.new(role).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('setAttributes', role_uri, payload)
    return UU::OS::UESURI.new(res)
  end
end