Module: UU::OS::Command

Extended by:
Command
Included in:
Command
Defined in:
uu_os-0.29.16/lib/uu/os/command.rb,
uu_os-0.29.16/lib/uu/os/command/command_create.rb,
uu_os-0.29.16/lib/uu/os/command/command_export.rb,
uu_os-0.29.16/lib/uu/os/command/command_attributes.rb,
uu_os-0.29.16/lib/uu/os/command/command_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/command/command_get_export_data.rb

Overview

Module Command.

Defined Under Namespace

Classes: CommandAttributes, CommandCreate, CommandExport, CommandGetExportData, CommandSetAttributes

Constant Summary

PATH =

Service path

'uu/os/Command'

Instance Method Summary (collapse)

Instance Method Details

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

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

Examples:

# Create command
cmd_uri = UU::OS::Command.create('ues:TERRITORY:APP_PACKAGE', :name => 'New Command', :code => 'NEW_COMMAND',
          :controller_url_path => '/ObjectType/command', :meta_artifact_uri => 'ues:TERRITORY:META_ARTIFACT',
          :asynchronous => false)

Parameters:

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

    URI of the uuApp Package where the command should be created.

  • criteria (CommandCreate) (defaults to: nil)

    Object containing attributes for the new command.

Options Hash (criteria):

  • :name (String)

    Name of the new command. If nil is set, default name from meta artifact is used if set, otherwise the create command fails.

  • :code (String)

    Code of the new command. 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.

  • :description (String)

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

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

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

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

    URI of the command’s icon. If nil is set, 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}’.

  • :controller_url_path (String)

    Path at which the controller will be deployed. Value must start with ‘/’ and contain only valid URL characters.

  • :asynchronous (String)

    Flag if command is asynchronous. Defaults to false (command is created as synchronous by default).

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

    URI of the competent role. If nil is set, the executive role from authorization is used. If no role is authorized to create the command 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 command or if it doesn’t belong to one of superior organizational units, the create command fails.

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

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

Returns:



43
44
45
46
47
48
49
50
51
# File 'uu_os-0.29.16/lib/uu/os/command.rb', line 43

def create(location_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Command)
  payload = UU::OS::Command::CommandCreate.new(criteria).to_json

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

- (void) delete(uri)

This method returns an undefined value.

The command deletes the specified command from the system. The command fails when the specified command is referenced by some use case.

Examples:

# Delete command
UU::OS::Command.delete('ues:TERRITORY:COMMAND')

Parameters:



63
64
65
66
67
68
# File 'uu_os-0.29.16/lib/uu/os/command.rb', line 63

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

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

Exports a command 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 Process and in Future.

Examples:

# Start exporting a command.
process_uri = UU::OS::Command.export('ues:TERRITORY:COMMAND')

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

Parameters:

Returns:



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

def export(uri)
  svc = UU::OS::REST::RemoteClient.new(Command)
  payload = UU::OS::Command::CommandExport.new(nil).to_json

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

- (CommandAttributes) get_attributes(command_uri)

This command returns attributes representing the command specified by the command_uri parameter.

Examples:

# Get command attributes.
attributes = UU::OS::Command.get_attributes('ues:TERRITORY:COMMAND')

Parameters:

Returns:



79
80
81
82
83
84
85
# File 'uu_os-0.29.16/lib/uu/os/command.rb', line 79

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

- (UU::OS::REST::BinaryValue) get_export_data(command_uri, command = nil)

Returns a XML file generated by the export command export.

Examples:

# Start exporting a command
process_uri = UU::OS::Command.export('ues:TERRITORY:COMMAND')

# 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::Command.get_export_data(export_uri, :requested_mime_type => 'application/xml')

Parameters:

Options Hash (command):

  • :requested_mime_type (String)

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

Returns:



156
157
158
159
160
161
162
163
164
165
# File 'uu_os-0.29.16/lib/uu/os/command.rb', line 156

def get_export_data(command_uri, command = nil)
  svc = UU::OS::REST::RemoteClient.new(Command)
  dto = UU::OS::Command::CommandGetExportData.new(command)
  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', command_uri)
  end
end

- (UU::OS::UESURI) set_attributes(uri, criteria = nil)

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

Examples:

# Set command attributes.
cmd_uri = UU::OS::Command.set_attributes('ues:TERRITORY:COMMAND', :description => 'Command designated for testing purposes',
  :name => 'New Command', :asynchronous => true)

Parameters:

Options Hash (criteria):

  • :name (String)

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

  • :code (String)

    The new code of the command. If nil is set, the code is not modified.

  • :description (String)

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

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

    Security level of the command. If nil is set, the security level is not modified.

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

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

  • :controller_url_path (String)

    Path at which the controller will be deployed. If nil is set, the controller_url_path is not modified. Value must start with ‘/’ and contain only valid URL characters.

  • :asynchronous (String)

    Flag if command is asynchronous. If nil is set, the asynchronous flag is not modified.

Returns:



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

def set_attributes(uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Command)
  payload = UU::OS::Command::CommandSetAttributes.new(criteria).to_json

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