Module: UU::OS::Folder

Extended by:
Folder
Included in:
Folder
Defined in:
uu_os-0.29.16/lib/uu/os/folder/folder_create.rb,
uu_os-0.29.16/lib/uu/os/folder.rb,
uu_os-0.29.16/lib/uu/os/folder/folder_export.rb,
uu_os-0.29.16/lib/uu/os/folder/folder_entry_type.rb,
uu_os-0.29.16/lib/uu/os/folder/folder_attributes.rb,
uu_os-0.29.16/lib/uu/os/folder/folder_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/folder/folder_get_entry_list.rb,
uu_os-0.29.16/lib/uu/os/folder/folder_get_export_data.rb,
uu_os-0.29.16/lib/uu/os/folder/folder_entry_attributes.rb

Overview

Module Folder.

Defined Under Namespace

Classes: FolderAttributes, FolderCreate, FolderEntryAttributes, FolderEntryType, FolderExport, FolderGetEntryList, FolderGetExportData, FolderSetAttributes

Constant Summary

PATH =

Service path

'ues/core/container/UESFolder'

Instance Method Summary (collapse)

Instance Method Details

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

Creates a folder of class Folder. Command creates new folder in specified container. At the very least meta artifact must be specified in artifactCreate Object. Competent role for artifact 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 ArtifactCreate Object.

Examples:

# Create new folder.
UU::OS::Folder.create('ues:TERRITORY:ORGANIZATIONAL_UNIT', :code => 'NEW_FOLDER', :name => 'New Folder')

# Verifying that new folder can be created.
UU::OS::Folder.create('ues:TERRITORY:ORGANIZATIONAL_UNIT', :code => 'NEW_FOLDER', :name => 'New Folder', :dryRun => true)      

Parameters:

Options Hash (folder):

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

    UESURI of the meta artifact. Only meta artifact with template class of Folder (not descendants of Folder) can be used. If meta artifact is not allowed to be created in container specified in first parameter of command UESFolder.create(UESURI, UESFolderCreate), create command will fail.

  • :code (String)

    Code of the new folder. When null is set, the code will be 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 folder. When null is set, meta artifact’s tName will be used if set, otherwise the create command will fail.

  • :description (String)

    Description of the folder. When null is set, meta artifact’s tDescription will be used if set, otherwise no description will be set on the created folder.

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

    UESURI of the competent role. When null is set, competent role will be taken from authorization. Executive role for creating artifact into container specified in first parameter of command UESFolder.create(UESURI, UESFolderCreate), will be used. If no role is authorized to create artifact into specified container, create command will fail. If selected role has not connected role interface with selected meta artifact, create command will fail.

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

    Security level. When null is set, security level will be taken from meta artifact tSecurityLevel. If meta artifact tSecurityLevel is higher than user’s security clearance, the create command will fail. If security level is higher than users security clearance, create command will fail.

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

    URI of the folder’s icon. When null is set, the folder 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 Folder is component content. Default value is false.

Returns:



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

def create(location_uri, folder = nil)
  svc = UU::OS::REST::RemoteClient.new(Folder)
  payload = UU::OS::Folder::FolderCreate.new(folder).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(folder_uri)

This command deletes the specified folder from the system. The folder is deleted even if it contains a locked sheet or attachment. The folder cannot be deleted when:

the folder is not empty.
the folder's workflow is not created 
a property contains a reference to this folder 
a time sheet exists with a reference to this folder

Examples:

# Delete folder with specified uri.
UU::OS::Folder.delete('ues:TERRITORY:FOLDER')

Parameters:

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

    UESURI of the folder which is about to be deleted.



123
124
125
126
127
128
# File 'uu_os-0.29.16/lib/uu/os/folder.rb', line 123

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

- (UU::OS::UESURI) export(folder_uri)

Exports a folder to the XML file, which is saved to the export storage. The export is an asynchronous process.
It is possible to wait for the end of the process. More information in Env::Process and in REST::Future.

Examples:

# Start exporting a folder.
process_uri = UU::OS::Folder.export('ues:TERRITORY:FOLDER')

# Wait for the end of the process.
export_uri = UU::OS::REST::Future.new(proces).get(:timeout=>600)

Parameters:

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

    UESURI of the folder to export.

Returns:



171
172
173
174
175
176
177
178
179
# File 'uu_os-0.29.16/lib/uu/os/folder.rb', line 171

def export(folder_uri)
  svc = UU::OS::REST::RemoteClient.new(Folder)
  payload = UU::OS::Folder::FolderExport.new(nil).to_json

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

- (FolderAttributes) get_attributes(folder_uri)

Reads folder specified by the folderUri attribute and returns its attributes.

Examples:

# Get attributes of specified folder.
getAttributes = UU::OS::Folder.get_attributes('ues:TERRITORY:FOLDER')

Parameters:

Returns:



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

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

- (UU::OS::REST::ResultList<Folder::FolderGetEntryList, Folder::FolderEntryAttributes>) get_entry_list(folder_uri, criteria = nil)

This command returns a list of entries (artifacts or shortcuts) enlisted in the specified folder (entity type of main entity of the command could be a Folder, Organizational Unit, Territory or Meta Model Dictionary). 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.

be a Folder, Organizational Unit, Territory or Meta Model Dictionary.

Examples:

# Get entries of folder in descending order and even with entries of inner folders - flag recursive is set to true.
getEntryList = UU::OS::Folder.get_entry_list('ues:TERRITORY:FOLDER', :query=>'ORDER BY name DESC', :recursive=>true)

Parameters:

Options Hash (criteria):

  • :query (String)

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

  • :recursive (Boolean)

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

Returns:



97
98
99
100
101
102
103
104
105
106
107
108
# File 'uu_os-0.29.16/lib/uu/os/folder.rb', line 97

def get_entry_list(folder_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Folder)
  dto = Folder::FolderGetEntryList.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', folder_uri)
    return UU::OS::REST::ResultList.new(Folder::FolderGetEntryList, Folder::FolderEntryAttributes, res)
  end
end

- (UU::OS::REST::BinaryValue) get_export_data(folder_uri, folder = nil)

Returns a XML file generated by the export command Folder Export.

Examples:

# Start exporting a folder
process_uri = UU::OS::Folder.export('ues:TERRITORY:FOLDER')

# Wait for the end of the process.
export_uri = UU::OS::REST::Future.new(process_uri).get(nil, 600)

# Get exported XML file.
exported_data = UU::OS::Folder.get_export_data(export_uri, :requested_mime_type => 'application/xml')

Parameters:

Options Hash (folder):

  • :requested_mime_type (String)

    MIME type of the returned value. All possible MIME types can be found as constants in Artifact::ExportMimeType class. ZIP is returned by default.

Returns:



198
199
200
201
202
203
204
205
206
207
# File 'uu_os-0.29.16/lib/uu/os/folder.rb', line 198

def get_export_data(folder_uri, folder = nil)
  svc = UU::OS::REST::RemoteClient.new(Folder)
  dto = UU::OS::Folder::FolderGetExportData.new(folder)
  if dto.requested_mime_type
    svc.add_parameter('requestedMimeType', dto.requested_mime_type)
  end
  UU::OS::QoS::QoSHandler.auto_retry do
    return svc.get_binary('getExportData', folder_uri)
  end
end

- (UU::OS::UESURI) set_attributes(folder_uri, folder = nil)

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

Examples:

# Set folder basic attributes.
UU::OS::Folder.set_attributes('ues:TERRITORY:FOLDER', :code=>'NEW_CODE', :name=>'Folder name', :description=>'Some sample description.')

Parameters:

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

    UESURI of the folder whose attributes are to be changed.

  • folder (FolderSetAttributes) (defaults to: nil)

    Object containing new attributes the folder.

Options Hash (folder):

  • :code (String)

    Code of the folder. When nil is set, the code is not modified.

  • :name (String)

    Name of the folder. When nil is set, the name is not modified.

  • :description (String)

    Description of the folder. When nil is set, the description is not modified.

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

    Security level of the folder. When nil is set, the security level is not modified.

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

    URI of the folder’s icon. When nil is set, the icon is not modified. If nil URI (“ues:[-1]:[-1]:”) is set, the folder icon is removed and the folder 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 Folder is component content. Default value is false.

Returns:

  • (UU::OS::UESURI)

    UESURI of the folder whose attributes are to be changed.



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

def set_attributes(folder_uri, folder = nil)
  svc = UU::OS::REST::RemoteClient.new(Folder)
  payload = UU::OS::Folder::FolderSetAttributes.new(folder).to_json

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