Class: UU::OS::VUC::ViewTemplate

Inherits:
Object
  • Object
show all
Defined in:
uu_adk-0.28.16/lib/uu/os/vuc/view_template.rb

Overview

View template that can be used for setting custom view.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (ViewTemplate) initialize(data = nil)

Returns a new instance of ViewTemplate



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view_template.rb', line 47

def initialize(data = nil)
  if data.nil?
    @raw_attrs = {}
    return
  end
  if data.kind_of?String
    data = JSON.parse(data, :symbolize_names => true)
  end
  if data.kind_of?Hash
    @raw_attrs = data
  elsif data.kind_of?ViewTemplate
    if data.raw_attrs
      @raw_attrs = data.raw_attrs
    else
      @raw_attrs = {}
    end
  else
    raise ArgumentError.new("ViewTemplate data must be JSON String or Hash, but was #{data.class}.")
  end
end

Instance Attribute Details

- (String) data_uri

Note:

This parameters can be set only in on_before_init method, if you set data_uri in another method, it will have no effect.

UESURI of sheet that will be used as form template. Default value is the main sheet of registered VUC. You can use sheets from this VUC only, it's means that only sheets related to VUC artifact (from parameter context.use_case_realization_uri) are allowed, otherwise form execution fails with error. If you set non-exists uri than form execution will fail as well.

Examples:

# uri of default VUC
UCR_URI = "ues:UNI:CDS.GUESTBOOK/COMMENT/CREATE"

# code of sheet with extended form
EXTENDED_FORM_CODE = "EXTENDED_FORM"

def on_before_init(ctx)

  # get default view template => main sheet on VUC
  view_template_uri = ctx.view_template.data_uri # String ues:UNI:CDS.GUESTBOOK/COMMENT/CREATE:DEFAULT_FORM

  use_extended_form = ... # some logic to find out if use can see extended form

  if use_extended_form
    # set new sheet with extended form
    ctx.view_template.data_uri = UU::OS::UESURIBuilder.parse_uesuri(UCR_URI).set_object_code(EXTENDED_FORM_CODE).to_uesuri
  end

  # if you do not set data_uri so default is used

end

Returns:

  • (String)


44
45
46
# File 'uu_adk-0.28.16/lib/uu/os/vuc/view_template.rb', line 44

def data_uri
  @data_uri
end