Class: UU::OS::VUC::Action

Inherits:
Object
  • Object
show all
Defined in:
uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb

Overview

Class is used for building action response which cause user navigation, opens dialog or trigger file download. Action can be:

* back - Returns to previous Use case, actual use case is finished
* super uc - Execute super Use case instead of this one and this one is finished
* forward - Navigate to another Use case, actual use case is finished
* dialog - Open modal dialog, actual use case is not finished but only suspended
* progress dialog - Open progress dialog, , actual use case is not finished but only suspended
* download - Creates action for launching download from client (browser)

Examples:

def on_submit(ctx)
  uu_uri = ctx.uu_uri

  # ...

  result = {format: 'PDF'}

  if #...

    info_msg = UU::OS::GVC::Message.new({})
    return ctx.action.forward(uu_uri, :uuMessages => [info_msg])

  else

    return ctx.action.back(:uuResult => result)

  end
end

Constant Summary

Instance Method Summary (collapse)

Constructor Details

- (Action) initialize(ctx)

Returns a new instance of Action

Parameters:



40
41
42
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb', line 40

def initialize(ctx)
  @ctx = ctx
end

Instance Method Details

- (UU::OS::VUC::Action) back(params = {})

Cause back action, user is navigated to previous use case. Actual use case is finished.

Examples:

# back action
return ctx.action.back()

# same as previous, but info message is included, in this example 'Info message.' text is displayed
# at previous use case. In most cases, at most 1 message can be used and it must be of information
# severity. The exception is usage from on_before_init method - arbitrary messages can be used there.
info_msg = UU::OS::GVC::Message.new(
{
     code: "CODE",
     severity: UU::OS::GVC::Message::MessageSeverity::INFO,
     text: "Info message."
})
return ctx.action.back(:uuMessages => [info_msg])

# include result to back action
return ctx.action.back(:uuResult => 'Some result')

# combination of result and messages
return ctx.action.back(:uuMessages => [info_msg], :uuResult => 'Some result')

Parameters:

  • params (Hash) (defaults to: {})

    Additional parameters.

Options Hash (params):

  • :uuMessages (Array)

    Array of GVC::Message objects used as message to user.

  • :uuResult (Object)

    Result can be small arbitrary object serializable to JSON.

Returns:



70
71
72
73
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb', line 70

def back(params = {})
  @action = UU::OS::VUC::ActionHelper.create_back_uri(@ctx, params)
  return self
end

- (UU::OS::VUC::Action) download(uu_uri, params = {})

Creates action for launching download from client (browser).

Examples:

#download attachment
return ctx.action.download('ues:TER:ART:ATTACHMENT')

# download attachment with callback action downloadCallback, it means that on_download_callback method will be called
return ctx.action.download('ues:TER:ART:ATTACHMENT', :uuCallback => 'downloadCallback')

Parameters:

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

    The UESURI which will end with download when used.

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • uuCallback (String)

    Name of action to call when download starts.

Returns:



197
198
199
200
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb', line 197

def download(uu_uri, params = {})
  @action = UU::OS::VUC::ActionHelper.create_download_uri(@ctx, uu_uri, params)
  return self
end

- (UU::OS::VUC::Action) execute_super_uc(params = {})

Cause super use case, user is navigated to the super use case implementation. Actual use case is finished.

Examples:

# cause super uc action
return ctx.action.execute_super_uc()

# same as previous, but info message is included, in this example 'Info message.' text is displayed
# at super use case.
info_msg = UU::OS::GVC::Message.new(
{
     code: "CODE",
     severity: UU::OS::GVC::Message::MessageSeverity::INFO,
     text: "Info message."
})
return ctx.action.execute_super_uc(:uuMessages => [info_msg])

Parameters:

  • params (Hash) (defaults to: {})

    Additional parameters.

Options Hash (params):

  • :uuMessages (Array)

Returns:



93
94
95
96
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb', line 93

def execute_super_uc(params = {})
  @action = UU::OS::VUC::ActionHelper.create_super_uc_uri(@ctx, params)
  return self
end

- (UU::OS::VUC::Action) forward(uu_uri, params = {})

Navigate to use case passed by 'uu_uri' parameter. Actual use case is finished.

Examples:

#navigate to artifact's default action
return ctx.action.forward('ues:TER:ART')

# navigate to UC1
return ctx.action.forward('ues:TER:ART?UC1')

# navigate to UC1 with some params
return ctx.action.forward('ues:TER:ART?UC1&name=Thor&age=41')

# same as previous, but info message is included, in this example 'Info message.' text is displayed
# at next use case.
info_msg = UU::OS::GVC::Message.new(
 {
     code: "CODE",
     severity: UU::OS::GVC::Message::MessageSeverity::INFO,
     text: "Info message."
  })
return ctx.action.forward('ues:TER:ART?UC1&name=Thor&age=41', :uuMessages => [info_msg])

# same as previous, including result
return ctx.action.forward('ues:TER:ART?UC1&name=Thor&age=41', :uuResult => 'Some result')

# combination of result and messages
return ctx.action.forward('ues:TER:ART?UC1&name=Thor&age=41', :uuMessages => [info_msg], :uuResult => 'Some result')

Parameters:

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

    Uri of Use case

  • params (Hash) (defaults to: {})

    Adsditional parameters.

Options Hash (params):

  • :uuMessages (Array)

Returns:



130
131
132
133
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb', line 130

def forward(uu_uri, params = {})
  @action = UU::OS::VUC::ActionHelper.create_forward_uri(@ctx, uu_uri, params)
  return self
end

- (UU::OS::VUC::Action) open_dialog(uu_uri, params = {})

Action opens use case in modal window. Actual use case is not finished but only suspended.

Examples:

# opens use case in modal window
return ctx.action.open_dialog('ues:TER:DIALOG?VUC&name=Thor')

# opens dialog with specified width and height
return ctx.action.open_dialog('ues:TER:DIALOG?VUC', :width => 400, :height => 300)

# opens dialog with callback action dialogClosed, it means that on_dialog_closed method will be called when
# dialog is closed
return ctx.action.open_dialog('ues:TER:DIALOG?VUC', :width => 400, :height => 300, :uuCallback => 'dialogClosed')

Parameters:

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

    The use case to show in the dialog.

  • params (Hash) (defaults to: {})

    Additional parameters.

Options Hash (params):

  • :width (Integer)

    Dialog width

  • :height (Integer)

    Dialog height

  • :uuCallback (String)

    Callback action.

Returns:



154
155
156
157
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb', line 154

def open_dialog(uu_uri, params = {})
  @action = UU::OS::VUC::ActionHelper.create_dialog_uri(@ctx, uu_uri, params)
  return self
end

- (UU::OS::VUC::Action) open_progress_dialog(process_uri, params = {})

Action opens progress dialog that waits for specific process. Actual use case is not finished but only suspended.

Examples:

# get process uri
process_uri = #...

# open progress dialog, that waits for specific process
return ctx.action.open_progress_dialog(process_uri)

# open progress dialog, that waits for specific resultCode
return ctx.action.open_progress_dialog(process_uri, :resultCode => 'ARTIFACT_CREATED')

# open progress dialog with callback action progressDialogClosed, it means that on_progress_dialog_closed method will be called
# when dialog is closed
return ctx.action.open_progress_dialog(process_uri, :resultCode => 'ARTIFACT_CREATED', :uuCallback => 'progressDialogClosed')

Parameters:

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

    UESURI of asynchronous process.

  • params (Hash) (defaults to: {})

    Additional parameters.

Options Hash (params):

  • :resultCode (Integer)

    Code of process event providing result.

  • :uuCallback (String)

    Callback action.

Returns:



180
181
182
183
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb', line 180

def open_progress_dialog(process_uri, params = {})
  @action = UU::OS::VUC::ActionHelper.create_progress_dialog_uri(@ctx, process_uri, params)
  return self
end

- (Object) to_json(opt = {})

Serialize object to JSON in format corresponding to schema ues:SYSTEM:UU.OS.VUC/ACTION_MESSAGE-SCHEMA-V3

Parameters:

  • opt (Hash) (defaults to: {})

    Optional parameters.

See Also:

  • #JSON


206
207
208
209
210
211
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action.rb', line 206

def to_json(opt = {})
  response = {}
  response[:schemaUri] = ACTION_JSON_SCHEMA_URI
  response[:action] = @action
  return response.to_json(opt)
end