Module: UU::OS::OrganizationalUnit

Extended by:
OrganizationalUnit
Included in:
OrganizationalUnit
Defined in:
uu_os-0.29.16/lib/uu/os/organizational_unit/organizational_unit_create.rb,
uu_os-0.29.16/lib/uu/os/organizational_unit.rb,
uu_os-0.29.16/lib/uu/os/organizational_unit/organizational_unit_attributes.rb,
uu_os-0.29.16/lib/uu/os/organizational_unit/organizational_unit_entry_type.rb,
uu_os-0.29.16/lib/uu/os/organizational_unit/organizational_unit_get_entry_list.rb,
uu_os-0.29.16/lib/uu/os/organizational_unit/organizational_unit_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/organizational_unit/organizational_unit_entry_attributes.rb

Overview

Module Organizational Unit.

Defined Under Namespace

Classes: OrganizationalUnitAttributes, OrganizationalUnitCreate, OrganizationalUnitEntryAttributes, OrganizationalUnitEntryType, OrganizationalUnitGetEntryList, OrganizationalUnitSetAttributes

Constant Summary

PATH =

Service path

'ues/core/container/UESOrganizationalUnit'

Instance Method Summary (collapse)

Instance Method Details

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

Creates a new organizational unit. The command creates a new organizational unit in a specified location. At the very least meta artifact must be specified in OrganizationalUnitCreate DTO. Competent role for the organizational unit 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 OrganizationalUnitCreate DTO.

Examples:

# Create a new organizational unit.
UU::OS::OrganizationalUnit.create('ues:TERRITORY:ORGANIZATIONAL_UNIT', :code => 'NEW_ORGANIZATIONAL_UNIT', :name => 'New Organizational Unit')

# Verifying that new organizational unit can be created.
UU::OS::OrganizationalUnit.create('ues:TERRITORY:ORGANIZATIONAL_UNIT', :code => 'NEW_ORGANIZATIONAL_UNIT', :name => 'New Organizational Unit', :dryRun => true)

Parameters:

Options Hash (organizational_unit):

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

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

  • :code (String)

    Code of the new organizational unit. When 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 organizational unit. When nil is set, tName from meta artifact is used if set, otherwise the create command fails.

  • :description (String)

    Description of the new organizational unit. When nil is set, tDescription from meta artifact is used if set, otherwise no description is set on the new organizational unit.

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

    URI of the competent role. When nil is set, the executive role from authorization is used. If no role is authorized to create the new organizational unit 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 one of superior organizational units, the create command fails.

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

    Security level. When 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.

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

    URI of the organizational unit’s icon. When nil is set, the organizational unit uses icon from meta artifact. An example of icon URI: ‘ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_077}’.

  • :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 Organizational Unit is component content. Default value is false.

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
# File 'uu_os-0.29.16/lib/uu/os/organizational_unit.rb', line 44

def create(location_uri, organizational_unit = nil)
  svc = UU::OS::REST::RemoteClient.new(OrganizationalUnit)
  payload = UU::OS::OrganizationalUnit::OrganizationalUnitCreate.new(organizational_unit).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(org_unit_uri)

This command deletes the specified organizational unit from the system. The organizational unit is deleted even if it contains a locked sheet or attachment. The organizational unit cannot be deleted when: the org. unit is not empty, the org. unit's workflow is not created, a property contains a reference to this org. unit, a time sheet exists with a reference to this org. unit.

Examples:

# Deletes an organizational unit.
UU::OS::OrganizationalUnit.delete('ues:TERRITORY:ORGANIZATIONAL_UNIT')

Parameters:

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

    URI of the organizational unit which is about to be deleted.



116
117
118
119
120
121
# File 'uu_os-0.29.16/lib/uu/os/organizational_unit.rb', line 116

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

- (OrganizationalUnitAttributes) get_attributes(organizational_unit_uri)

This command returns attributes representing the organizational unit specified by the organizationalUnitUri parameter. The command does not change the state of the organizational unit in the system.

Examples:

# Get attributes of an organizational unit
UU::OS::OrganizationalUnit.get_attributes('ues:TERRITORY:ORGANIZATIONAL_UNIT')

Parameters:

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

    URI of an organizational unit whose attributes are returned

Returns:



68
69
70
71
72
73
74
# File 'uu_os-0.29.16/lib/uu/os/organizational_unit.rb', line 68

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

- (UU::OS::REST::ResultList<OrganizationalUnit::OrganizationalUnitGetEntryList, OrganizationalUnit::OrganizationalUnitEntryAttributes>) get_entry_list(organizational_unit_uri, criteria = nil)

This command returns a list of entries (artifacts or shortcuts) enlisted in the specified organizational unit. Only entries listed exactly in the specified organizational units are considered (so subordinate organizational units are not considered). The command does not return all entries, only a sublist. The list of returned entries could be filtered by the name, code or type of an entry. The list is sorted by the name (and codes in case are equal) of a entry by default, or it can be sorted arbitrarily by any of entry attributes usable for the filtering or these attributes combinations. See the UES query documentation for more information.

See UESQuery Documentation.

Examples:

# Returns list of containers (folders, organizational units and meta models) from an organizational unit.
UU::OS::OrganizationalUnit.get_entry_list('ues:TERRITORY:ORGANIZATIONAL_UNIT',
   :query => 'type=container')

Parameters:

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

    URI of the organizational unit from where entries (artifacts or shortcuts) are listed.

  • criteria (OrganizationalUnitGetEntryList) (defaults to: nil)

    Specific options.

Options Hash (criteria):

  • :query (String)

    Query for filtering and ordering of the result list. It has to conform the ues query syntax (see the documentation below for more info). If it is not specified, no filtering is applied and entries are ordered by name of referenced artifact (and code and type as the second and the third criteria). Otherwise, it is possible to filter and sort the result list by the following attributes: name, code and type : OrganizationalUnitEntryType.

  • :recursive (Boolean)

    Flag for recursive listing. It means that if the listed organizational unit contains inner folders and the recursive flag is true, entries of the all inner folders are in result too. If the recursive flag is nil or false, only entries exactly from the listed organizational unit are returned.

Returns:



145
146
147
148
149
150
151
152
153
154
155
156
# File 'uu_os-0.29.16/lib/uu/os/organizational_unit.rb', line 145

def get_entry_list(organizational_unit_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(OrganizationalUnit)
  dto = OrganizationalUnit::OrganizationalUnitGetEntryList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)
  svc.add_parameter('recursive', dto.recursive)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getEntryList', organizational_unit_uri)
    return UU::OS::REST::ResultList.new(OrganizationalUnit::OrganizationalUnitGetEntryList, OrganizationalUnit::OrganizationalUnitEntryAttributes, res)
  end
end

- (UU::OS::UESURI) set_attributes(organizational_unit_uri, organizational_unit = nil)

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

Examples:

# Set a different name and security_level of an existing organizational unit.
UU::OS::OrganizationalUnit.set_attributes('ues:TERRITORY:ORGANIZATIONAL_UNIT', :name => 'New Name of Organizational Unit', :security_level => UU::OS::Artifact::SecurityLevel::INTERNAL_USE)

Parameters:

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

    URI of the organizational unit whose attributes are to be changed

  • organizational_unit (OrganizationalUnitSetAttributes) (defaults to: nil)

    DTO containing new attributes the organizational unit

Options Hash (organizational_unit):

  • :name (String)

    The new name of the organizational unit. If nil is set, the name is not modified.

  • :code (String)

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

  • :description (String)

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

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

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

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

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

  • :component_content (Boolean)

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

Returns:



93
94
95
96
97
98
99
100
101
# File 'uu_os-0.29.16/lib/uu/os/organizational_unit.rb', line 93

def set_attributes(organizational_unit_uri, organizational_unit = nil)
  svc = UU::OS::REST::RemoteClient.new(OrganizationalUnit)
  payload = UU::OS::OrganizationalUnit::OrganizationalUnitSetAttributes.new(organizational_unit).to_json

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