Class: UU::OS::UESURIBuilder

Inherits:
Object
  • Object
show all
Defined in:
uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb

Overview

Builder for creating UESURI.

Examples:

Usage:

uri = UESURIBuilder.set_territory_id('123').set_artifact_code('artCode').set_object_id('456').to_uesuri

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (UESURIBuilder) initialize

Creates new instance of UESURIBuilder.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 13

def initialize
  @role_id = nil
  @role_code = nil
  @territory_id = nil
  @territory_code = nil
  @artifact_id = nil
  @artifact_code = nil
  @object_id = nil
  @object_code = nil
  @use_case_id = nil
  @use_case_code = nil
  @action = nil
  @parameters = nil
  @fragment = nil
end

Class Method Details

+ (UESURIBuilder) add_parameter(name, value)

Adds parameter for the new UESURI.

Parameters:

  • name (String)

    Parameter name

  • value (String)

    Parameter value

Returns:



324
325
326
327
328
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 324

def self.add_parameter(name, value)
  builder = UESURIBuilder.new
  builder.add_parameter(name, value)
  return builder
end

+ (UESURIBuilder) parse_uesuri(uesuri)

Parses specified string into UESURIBuilder instance.

Parameters:

Returns:



34
35
36
37
38
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 34

def self.parse_uesuri(uesuri)
  builder = UESURIBuilder.new
  builder.parse_uesuri(uesuri)
  return builder
end

+ (UESURIBuilder) set_action(action)

Sets use case action for the new UESURI.

Parameters:

  • action (String)

    Use case action

Returns:



294
295
296
297
298
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 294

def self.set_action(action)
  builder = UESURIBuilder.new
  builder.set_action(action)
  return builder
end

+ (UESURIBuilder) set_artifact_code(artifact_code)

Sets artifact code for the new UESURI. In case artifact code and artifact ID are not set, territory UESURI part is used as artifact UESURI part (forming valid territory UESURI).

Parameters:

  • artifact_code (String)

    Artifact code

Returns:



187
188
189
190
191
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 187

def self.set_artifact_code(artifact_code)
  builder = UESURIBuilder.new
  builder.set_artifact_code(artifact_code)
  return builder
end

+ (UESURIBuilder) set_artifact_id(artifact_id)

Sets artifact ID for the new UESURI. In case artifact code and artifact ID are not set, territory UESURI part is used as artifact UESURI part (forming valid territory UESURI).

Parameters:

  • artifact_id (String)

    Artifact ID

Returns:



162
163
164
165
166
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 162

def self.set_artifact_id(artifact_id)
  builder = UESURIBuilder.new
  builder.set_artifact_id(artifact_id)
  return builder
end

+ (UESURIBuilder) set_fragment(fragment)

Sets fragment for the new UESURI.

Parameters:

  • fragment (String)

    Fragment

Returns:



349
350
351
352
353
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 349

def self.set_fragment(fragment)
  builder = UESURIBuilder.new
  builder.set_fragment(fragment)
  return builder
end

+ (UESURIBuilder) set_object_code(object_code)

Sets object code for the new UESURI.

Parameters:

  • object_code (String)

    Object code

Returns:



231
232
233
234
235
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 231

def self.set_object_code(object_code)
  builder = UESURIBuilder.new
  builder.set_object_code(object_code)
  return builder
end

+ (UESURIBuilder) set_object_id(object_id)

Sets object ID for the new UESURI.

Parameters:

  • object_id (String)

    Object ID

Returns:



210
211
212
213
214
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 210

def self.set_object_id(object_id)
  builder = UESURIBuilder.new
  builder.set_object_id(object_id)
  return builder
end

+ (UESURIBuilder) set_role_code(role_code)

Sets role code for the new UESURI.

Parameters:

  • role_code (String)

    Role code

Returns:



89
90
91
92
93
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 89

def self.set_role_code(role_code)
  builder = UESURIBuilder.new
  builder.set_role_code(role_code)
  return builder
end

+ (UESURIBuilder) set_role_id(role_id)

Sets role ID for the new UESURI.

Parameters:

  • role_id (String)

    Role ID

Returns:



68
69
70
71
72
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 68

def self.set_role_id(role_id)
  builder = UESURIBuilder.new
  builder.set_role_id(role_id)
  return builder
end

+ (UESURIBuilder) set_territory_code(territory_code)

Sets territory code for the new UESURI. In case artifact code and artifact ID are not set, given territory code is also used in artifact UESURI part (forming valid territory UESURI).

Parameters:

  • territory_code (String)

    Territory code

Returns:



137
138
139
140
141
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 137

def self.set_territory_code(territory_code)
  builder = UESURIBuilder.new
  builder.set_territory_code(territory_code)
  return builder
end

+ (UESURIBuilder) set_territory_id(territory_id)

Sets territory ID for the new UESURI. In case artifact code and artifact ID are not set, given territory ID is also used in artifact UESURI part (forming valid territory UESURI).

Parameters:

  • territory_id (String)

    Territory ID

Returns:



112
113
114
115
116
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 112

def self.set_territory_id(territory_id)
  builder = UESURIBuilder.new
  builder.set_territory_id(territory_id)
  return builder
end

+ (UESURIBuilder) set_use_case_code(use_case_code)

Sets use case code for the new UESURI.

Parameters:

  • use_case_code (String)

    Use case code

Returns:



273
274
275
276
277
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 273

def self.set_use_case_code(use_case_code)
  builder = UESURIBuilder.new
  builder.set_use_case_code(use_case_code)
  return builder
end

+ (UESURIBuilder) set_use_case_id(use_case_id)

Sets use case ID for the new UESURI.

Parameters:

  • use_case_id (String)

    Use case ID

Returns:



252
253
254
255
256
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 252

def self.set_use_case_id(use_case_id)
  builder = UESURIBuilder.new
  builder.set_use_case_id(use_case_id)
  return builder
end

Instance Method Details

- (UESURIBuilder) add_parameter(name, value)

Adds parameter for the new UESURI.

Parameters:

  • name (String)

    Parameter name

  • value (String)

    Parameter value

Returns:



336
337
338
339
340
341
342
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 336

def add_parameter(name, value)
  if !@parameters
    @parameters = []
  end
  @parameters << UU::OS::UESURI::Parameter.new(name, value)
  return self
end

- (UESURIBuilder) clear_parameters

Clears any existing UESURI parameters.

Returns:



313
314
315
316
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 313

def clear_parameters
  @parameters = nil
  return self
end

- (UESURIBuilder) parse_uesuri(uesuri)

Parses specified string into UESURIBuilder instance.

Parameters:

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 45

def parse_uesuri(uesuri)
  uri = UU::OS::UESURI.new(uesuri)
  @role_id = uri.role_id
  @role_code = uri.role_code
  @territory_id = uri.territory_id
  @territory_code = uri.territory_code
  @artifact_id = uri.artifact_id
  @artifact_code = uri.artifact_code
  @object_id = uri.object_id
  @object_code = uri.object_code
  @use_case_id = uri.use_case_id
  @use_case_code = uri.use_case_code
  @action = uri.action
  @parameters = uri.parameters
  @fragment = uri.fragment
  return self
end

- (UESURIBuilder) set_action(action)

Sets use case action for the new UESURI.

Parameters:

  • action (String)

    Use case action

Returns:



305
306
307
308
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 305

def set_action(action)
  @action = action
  return self
end

- (UESURIBuilder) set_artifact_code(artifact_code)

Sets artifact code for the new UESURI. In case artifact code and artifact ID are not set, territory UESURI part is used as artifact UESURI part (forming valid territory UESURI).

Parameters:

  • artifact_code (String)

    Artifact code

Returns:



200
201
202
203
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 200

def set_artifact_code(artifact_code)
  @artifact_code = artifact_code
  return self
end

- (UESURIBuilder) set_artifact_id(artifact_id)

Sets artifact ID for the new UESURI. In case artifact code and artifact ID are not set, territory UESURI part is used as artifact UESURI part (forming valid territory UESURI).

Parameters:

  • artifact_id (String)

    Artifact ID

Returns:



175
176
177
178
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 175

def set_artifact_id(artifact_id)
  @artifact_id = artifact_id
  return self
end

- (UESURIBuilder) set_fragment(fragment)

Sets fragment for the new UESURI.

Parameters:

  • fragment (String)

    Fragment

Returns:



360
361
362
363
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 360

def set_fragment(fragment)
  @fragment = fragment
  return self
end

- (UESURIBuilder) set_object_code(object_code)

Sets object code for the new UESURI.

Parameters:

  • object_code (String)

    Object code

Returns:



242
243
244
245
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 242

def set_object_code(object_code)
  @object_code = object_code
  return self
end

- (UESURIBuilder) set_object_id(object_id)

Sets object ID for the new UESURI.

Parameters:

  • object_id (String)

    Object ID

Returns:



221
222
223
224
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 221

def set_object_id(object_id)
  @object_id = object_id
  return self
end

- (UESURIBuilder) set_role_code(role_code)

Sets role code for the new UESURI.

Parameters:

  • role_code (String)

    Role code

Returns:



100
101
102
103
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 100

def set_role_code(role_code)
  @role_code = role_code
  return self
end

- (UESURIBuilder) set_role_id(role_id)

Sets role ID for the new UESURI.

Parameters:

  • role_id (String)

    Role ID

Returns:



79
80
81
82
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 79

def set_role_id(role_id)
  @role_id = role_id
  return self
end

- (UESURIBuilder) set_territory_code(territory_code)

Sets territory code for the new UESURI. In case artifact code and artifact ID are not set, given territory code is also used in artifact UESURI part (forming valid territory UESURI).

Parameters:

  • territory_code (String)

    Territory code

Returns:



150
151
152
153
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 150

def set_territory_code(territory_code)
  @territory_code = territory_code
  return self
end

- (UESURIBuilder) set_territory_id(territory_id)

Sets territory ID for the new UESURI. In case artifact code and artifact ID are not set, given territory ID is also used in artifact UESURI part (forming valid territory UESURI).

Parameters:

  • territory_id (String)

    Territory ID

Returns:



125
126
127
128
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 125

def set_territory_id(territory_id)
  @territory_id = territory_id
  return self
end

- (UESURIBuilder) set_use_case_code(use_case_code)

Sets use case code for the new UESURI.

Parameters:

  • use_case_code (String)

    Use case code

Returns:



284
285
286
287
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 284

def set_use_case_code(use_case_code)
  @use_case_code = use_case_code
  return self
end

- (UESURIBuilder) set_use_case_id(use_case_id)

Sets use case ID for the new UESURI.

Parameters:

  • use_case_id (String)

    Use case ID

Returns:



263
264
265
266
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 263

def set_use_case_id(use_case_id)
  @use_case_id = use_case_id
  return self
end

- (UU::OS::UESURI) to_uesuri

Creates new instance of UESURI.

Returns:



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'uu_os_framework-0.29.16/lib/uu/os/uesuri_builder.rb', line 368

def to_uesuri
  if (!@territory_id) && (!@territory_code)
    raise 'Territory must be set in order to create valid UESURI.'
  end
  uri_string = 'ues:'
  if (@role_code) || (@role_id)
    uri_string << url_encode(@role_code.to_s) if @role_code
    uri_string << "[#{@role_id.to_s}]" if @role_id
    uri_string << '@'
  end
  if (@territory_code) || (@territory_id)
    uri_string << url_encode(@territory_code.to_s) if @territory_code
    uri_string << "[#{@territory_id.to_s}]" if @territory_id
  end
  if (@artifact_code) || (@artifact_id)
    uri_string << ':'
    uri_string << url_encode(@artifact_code.to_s) if @artifact_code
    uri_string << "[#{@artifact_id.to_s}]" if @artifact_id
  else
    uri_string << ':'
    uri_string << url_encode(@territory_code.to_s) if @territory_code
    uri_string << "[#{@territory_id.to_s}]" if @territory_id
  end
  if (@object_code) || (@object_id)
    uri_string << ':'
    uri_string << url_encode(@object_code.to_s) if @object_code
    uri_string << "[#{@object_id.to_s}]" if @object_id
  end
  if (@use_case_code) || (@use_case_id) || (@action) || (@parameters)
    uri_string << '?'
    if (@use_case_code) || (@use_case_id)
      uri_string << url_encode(@use_case_code.to_s) if @use_case_code
      uri_string << "[#{@use_case_id.to_s}]" if @use_case_id
    end
    uri_string << ":#{@action}" if (!@action.nil?) && (!@action.empty?)
    if (@parameters)
      @parameters.each do |parameter|
        uri_string << "&#{parameter}"
      end
    end
  end
  if (@fragment)
    uri_string << "##{url_encode(@fragment.to_s)}"
  end
  UU::OS::UESURI.new(uri_string)
end