Module: UU::OS::Cast

Extended by:
Cast
Included in:
Cast
Defined in:
uu_os_client-0.10.6/lib/uu/os/cast.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_state.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_level.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_create.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_delete.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_exists.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_direction.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_get_cast_list.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_get_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_set_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_access_role_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/cast/cast_get_access_role_cast_list.rb

Overview

Module Cast.

Defined Under Namespace

Classes: CastAccessRoleAttributes, CastAttributes, CastCreate, CastDelete, CastDirection, CastExists, CastGetAccessRoleCastList, CastGetAttributes, CastGetCastList, CastLevel, CastSetAttributes, CastState

Constant Summary

PATH =

Service path

'ues/core/role/UESCast'

Instance Method Summary (collapse)

Instance Method Details

- (Object) create(subject_uri, cast = nil)

Casts a subject (role or group) to another subject (role or group). Only roles and groups from the same territory are supported at the moment(therefore it is not possible to cast across territories and form pseudo business access role relation at the moment). Cast is not an entity, it is a relation between two subjects (and these two subjects identify the relation). Note that only some combinations of subjects in a cast relation are permitted:

Parameters:

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

    UESURI of the subject into which another subject is casted

  • cast (CastCreate) (defaults to: nil)

    DTO containing attributes of the cast



36
37
38
39
40
41
42
43
# File 'uu_os_client-0.10.6/lib/uu/os/cast.rb', line 36

def create(subject_uri, cast = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  payload = UU::OS::Cast::CastCreate.new(cast).to_json

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

- (Object) delete(subject_uri, cast = nil)

This command deletes the cast from the system. Any change of user authorization resulting from the cast modification will take effect approximately after 15 minutes. The last active executive cast cannot be deleted when this role has an active assistance or guest cast (active casts of these types cannot exist without at least one active executive cast). The last active executive cast for this role cannot be deleted when the role is competent for at least one artifact (a role without an active cast cannot be competent for any artifacts).

Parameters:

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

    UESURI of the subject to which the other is casted.

  • cast (CastDelete) (defaults to: nil)

    DTO containing ues uri of the casted subject.



139
140
141
142
143
144
145
146
# File 'uu_os_client-0.10.6/lib/uu/os/cast.rb', line 139

def delete(subject_uri, cast = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  payload = UU::OS::Cast::CastDelete.new(cast).to_json

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

- (Boolean) exists(subject_uri, cast)

The uuCommand checks whether the role (specified in casted_subject_parameter) has cast to another role (specified in subject_uri parameter as main entity). Only direct cast existence is checked by default. In current uuCommand version it is possible to check indirect cast only for access roles.

Examples:

# Check direct cast existence (the role has cast to another role or group).
UU::OS::Cast.exists('ues:TERRITORY:GROUP', :casted_subject_uri => 'ues:TERRITORY:ROLE')

# Check indirect access role cast existence (the access role has cast to a role which has cast to another role).
UU::OS::Cast.exists('ues:TERRITORY:ROLE', :casted_subject_uri => 'ues:TERRITORY:ACCESS_ROLE', :recursive => true)

Parameters:

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

    UESURI of the role (role or group) for which the uuCommand checks whether another role (role, group or access role) is casted to.

  • cast (CastExists)

    Specific options.

Options Hash (cast):

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

    UESURI of the role (role, group or access role) which has cast to another role (specified in subject_uri parameter as main entity). Cannot be nil.

  • :recursive (Boolean)

    Flag indicating whether the uuCommand checks indirect cast existence. In current uuCommand version it is possible to check indirect cast only for access roles. Default value is false.

Returns:

  • (Boolean)

    True if cast exists, else false.



166
167
168
169
170
171
172
173
174
175
# File 'uu_os_client-0.10.6/lib/uu/os/cast.rb', line 166

def exists(subject_uri, cast)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  dto = UU::OS::Cast::CastExists.new(cast)
  svc.add_parameter('castedSubjectUri', dto.casted_subject_uri)
  svc.add_parameter('recursive', dto.recursive)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('exists', subject_uri)
    return (res == 'true') || (res == '"true"')
  end
end

- (Array) get_access_role_cast_list(subject_uri, criteria = nil)

Returns list of access roles (personal access roles and uuEEs) casted directly or indirectly to the specified subject (role or group). The list is sorted by the casted subject name and subsequently by casted subject code by default.

Examples:

# Returns ordered list of casted access roles whose name starts with 'Name Prefix' and code with 'Code Prefix'
UU::OS::Cast.get_access_role_cast_list('ues:TERRITORY:ROLE_OR_GROUP',
      :query => 'castedSubjectName="Name Prefix%" AND castedSubjectCode="Code Prefix%" ORDER BY castedSubjectName')

Parameters:

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

    UESURI of the subject into which the personal access roles are casted.

  • criteria (CastGetCastList) (defaults to: nil)

    Object containing paging and filtering criteria.

Options Hash (criteria):

  • :query (String)

    Query for filtering and ordering of the result list (more information in uuQuery - Guideline). It is possible to filter the result list by castedSubjectName and castedSubjectCode.

Returns:



103
104
105
106
107
108
109
110
111
112
113
# File 'uu_os_client-0.10.6/lib/uu/os/cast.rb', line 103

def get_access_role_cast_list(subject_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  dto = Cast::CastGetAccessRoleCastList.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('getAccessRoleCastList', subject_uri)
    return UU::OS::REST::ResultList.new(Cast::CastGetAccessRoleCastList, Cast::CastAccessRoleAttributes, res)
  end
end

- (CastAttributes) get_attributes(subject_uri, dto)

This command returns attributes of one cast. Cast is identified by two subjects. The main entity (a subject to which the other is casted) and parameter castedSubjectUri in the DTO (the casted subject).

Parameters:

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

    UESURI of the subject to which the other is casted

  • dto (CastGetAttributes)

    DTO containing ues uri of the casted subject

Returns:



53
54
55
56
57
58
59
60
61
# File 'uu_os_client-0.10.6/lib/uu/os/cast.rb', line 53

def get_attributes(subject_uri, dto)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  get_dto = UU::OS::Cast::CastGetAttributes.new(dto)
  svc.add_parameter('castedSubjectUri', get_dto.casted_subject_uri)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getAttributes', subject_uri)
    return Cast::CastAttributes.new(res)
  end
end

- (Array) get_cast_list(subject_uri, criteria = nil)

The uuCommand returns list of casts to the specified subject (role or group). The list is sorted by the date of creation of a cast by default and due to backwards compatibility are returned only casts with UU::OS::Cast::CastDirection::IN cast direction by default.

castedSubjectName, castedSubjectCode, dateFrom, state, level, primary and castDirection.

Examples:

# Returns list of casts
UU::OS::Cast.get_cast_list('ues:TERRITORY:ROLE', :query => 'castDirection=TO AND primary=true')

Parameters:

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

    UESURI of the subject whose casts will be listed.

  • criteria (CastGetCastList) (defaults to: nil)

    Specific options.

Options Hash (criteria):

  • :query (String)

    Query for filtering and ordering of the result list (more information in uuQuery - Guideline). It is possible to filter the result list by

Returns:

  • (Array)

    An Array with the command result. Contains instances of CastAttributes.



77
78
79
80
81
82
83
84
85
86
87
# File 'uu_os_client-0.10.6/lib/uu/os/cast.rb', line 77

def get_cast_list(subject_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  dto = Cast::CastGetCastList.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('getCastList', subject_uri)
    return UU::OS::REST::ResultList.new(Cast::CastGetCastList, Cast::CastAttributes, res)
  end
end

- (Object) set_attributes(subject_uri, cast = nil)

Sets basic attributes of the cast. Cast is not an entity, it is a relation between two subjects (and these two subjects identify the relation).

Parameters:

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

    UESURI of the subject into which another subject is casted

  • cast (CastSetAttributes) (defaults to: nil)

    DTO containing attributes of the cast



120
121
122
123
124
125
126
127
# File 'uu_os_client-0.10.6/lib/uu/os/cast.rb', line 120

def set_attributes(subject_uri, cast = nil)
  svc = UU::OS::REST::RemoteClient.new(Cast)
  payload = UU::OS::Cast::CastSetAttributes.new(cast).to_json

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