Module: UU::OS::Sheet

Extended by:
Sheet
Included in:
Sheet
Defined in:
uu_os-0.29.16/lib/uu/os/sheet/sheet_delete_version.rb,
uu_os-0.29.16/lib/uu/os/sheet.rb,
uu_os-0.29.16/lib/uu/os/sheet/mime_type.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_create.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_check_in.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_check_out.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_width_type.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_attributes.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_get_sheet_data.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_get_image_data.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_get_sheet_list.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_delete_versions.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_get_version_list.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_delete_component.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_get_version_data.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_replace_component.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_get_component_data.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_version_attributes.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_get_component_content.rb,
uu_os-0.29.16/lib/uu/os/sheet/sheet_get_version_attributes.rb

Overview

Module Sheet.

Defined Under Namespace

Classes: MimeType, SheetAttributes, SheetCheckIn, SheetCheckOut, SheetCreate, SheetDeleteComponent, SheetDeleteVersion, SheetDeleteVersions, SheetGetComponentContent, SheetGetComponentData, SheetGetImageData, SheetGetSheetData, SheetGetSheetList, SheetGetVersionAttributes, SheetGetVersionData, SheetGetVersionList, SheetReplaceComponent, SheetSetAttributes, SheetVersionAttributes, SheetWidthType

Constant Summary

PATH =

Service path

'ues/core/content/UESSheet'

Instance Method Summary (collapse)

Instance Method Details

- (Object) check_in(sheet_uri, sheet = nil)

This command changes the content of the public sheet version and unlocks it by default. Sheet content is in UXML or UDF format, data are streamed.Sheet must be unlocked or the user must be the lock owner.

If using XML format document cannot contain links to property of object from other territory.

Parameters:

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

    URI of the sheet.

  • sheet (SheetCheckIn) (defaults to: nil)

    Attributes of importing sheet



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 106

def check_in(sheet_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = UU::OS::Sheet::SheetCheckIn.new(sheet)
  payload = dto.to_hash
  payload.delete(:content)
  tmpfile = Tempfile.new("SheetCheckIn")
  tmpfile.binmode
  begin
    if (!dto.content.kind_of?(UU::OS::REST::BinaryValue))
      dto.content = UU::OS::REST::BinaryValue.new(dto.content)
    end
    if (dto.content.data.respond_to?(:read))
      if (dto.content.data.respond_to?(:path))
        payload[:content] = dto.content.to_hash(false)
      else
        dto.content.data.rewind
        tmpfile.write(dto.content.data.read)
        payload[:content] = tmpfile
      end
    else
      tmpfile.write(dto.content.data)
      payload[:content] = tmpfile
    end
    tmpfile.flush
    tmpfile.rewind

    UU::OS::QoS::QoSHandler.auto_retry do
      svc.post('checkIn', sheet_uri, payload)
    end
  ensure
  tmpfile.close
  tmpfile.unlink
  end
end

- (UU::OS::REST::BinaryValue) check_out(sheet_uri, sheet = nil)

This command locks the sheet for further modification, locks the given sheet of artifact. When lock succeed or sheet is currently locked by the user,sheet data can be returned. Sheet lock failure throws UESSheetRTException.

Parameters:

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

    URI of sheet to be locked.

  • sheet (SheetCheckOut) (defaults to: nil)

    Specify when stream will be returned and which type of data

Returns:



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 83

def check_out(sheet_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = UU::OS::Sheet::SheetCheckOut.new(sheet)
  payload = dto.to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    if dto.lock_only == TRUE || dto.return_stream_handler == FALSE
      svc.post('checkOut', sheet_uri, payload)
      return nil
    else
      return svc.post_binary('checkOut', sheet_uri, payload)
    end
  end
end

- (UU::OS::UESURI) create(artifact_uri, sheet = nil)

Command creates a new sheet in the specified artifact. Initial sheet content could be specified. Content is streamed.

Parameters:

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

    URI of artifact

  • sheet (SheetCreate) (defaults to: nil)

    DTO with sheet content

Returns:



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 176

def create(artifact_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = UU::OS::Sheet::SheetCreate.new(sheet)
  payload = dto.to_hash
  payload.delete(:content)
  tmpfile = Tempfile.new("SheetCreate")
  tmpfile.binmode
  begin
    if (!dto.content.nil?)
      if (!dto.content.kind_of?(UU::OS::REST::BinaryValue))
        dto.content = UU::OS::REST::BinaryValue.new(dto.content)
      end
      if (dto.content.data.respond_to?(:read))
        if (dto.content.data.respond_to?(:path))
          payload[:content] = dto.content.to_hash(false)
        else
          dto.content.data.rewind
          tmpfile.write(dto.content.data.read)
          payload[:content] = tmpfile
        end
      else
        tmpfile.write(dto.content.data)
        payload[:content] = tmpfile
      end
    end
    tmpfile.flush
    tmpfile.rewind

    UU::OS::QoS::QoSHandler.auto_retry do
      res = svc.post('create', artifact_uri, payload)
      return UU::OS::UESURI.new(res)
    end
  ensure
  tmpfile.close
  tmpfile.unlink
  end
end

- (Object) delete(sheet_uri)

Deletes the sheet from the system.

Parameters:

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

    UESURI of the sheet which is about to be deleted.



307
308
309
310
311
312
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 307

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

- (Object) delete_component(sheet_uri, sheet = nil)

Deletes specified component from the sheet.

Parameters:



318
319
320
321
322
323
324
325
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 318

def delete_component(sheet_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  payload = UU::OS::Sheet::SheetDeleteComponent.new(sheet).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('deleteComponent', sheet_uri, payload)
  end
end

- (Object) delete_version(sheet_uri, version = nil)

Deletes the version from the system.

Examples:

# Delete sheet version (uri needs to be replaced with one of an existing sheet for the example to work)
UU::OS::Sheet.delete_version('ues:TERRITORY:ARTIFACT:SHEET', :version_id => 123456789)

Parameters:

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

    UESURI of the sheet whose version is about to be deleted.

  • version (SheetDeleteVersion) (defaults to: nil)

    Object containing ID of the version which is to be deleted.

Options Hash (version):

  • :version_id (Integer)

    ID of the sheet version. It cannot be left nil or blank.



398
399
400
401
402
403
404
405
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 398

def delete_version(sheet_uri, version = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  payload = UU::OS::Sheet::SheetDeleteVersion.new(version).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('deleteVersion', sheet_uri, payload)
  end
end

- (Object) delete_versions(sheet_uri, versions = nil)

Deletes unlabeled historic versions of a given sheet, based on provided criteria. If olderThanTs timestamp is specified, only versions older than given timestamp will be deleted, otherwise will be deleted a year or more old versions. If olderThanTs is set as a date in the future, all unlabeled historic version will be deleted. Historic versions are deleted asynchronously, together with all the image mappings and images.

Examples:

# Delete sheet versions from midnight of 23 October 2017 and older (uri needs to be replaced with one of an existing sheet for the example to work)
UU::OS::Sheet.delete_versions('ues:TERRITORY:ARTIFACT:SHEET', :older_than_ts => '2017-10-23 00:00:00')

Parameters:

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

    UESURI of the sheet, which historic versions will be deleted.

  • versions (SheetDeleteVersions) (defaults to: nil)

    Object containing optional timestamp

Options Hash (versions):

  • :older_than_ts (String)

    Timestamp specifies that only historic versions that are older will be deleted. Format must be yyyy-MM-dd HH:mm:ss



419
420
421
422
423
424
425
426
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 419

def delete_versions(sheet_uri, versions = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  payload = UU::OS::Sheet::SheetDeleteVersions.new(versions).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('deleteVersions', sheet_uri, payload)
  end
end

- (SheetAttributes) get_attributes(sheet_uri)

Returns attributes representing the sheet specified by the sheetUri attribute.

Parameters:

Returns:



37
38
39
40
41
42
43
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 37

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

- (UU::OS::REST::BinaryValue) get_component_data(sheet_uri, sheet = nil)

Returns the content of specified sheet component. The result is streamed in the BB code format by default. Available output data formats are UXML or BB code.

Parameters:

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

    UESURI of the sheet

  • sheet (SheetGetComponentData) (defaults to: nil)

    Specify which component data will be returned and type of data

Returns:



238
239
240
241
242
243
244
245
246
247
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 238

def get_component_data(sheet_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = UU::OS::Sheet::SheetGetComponentData.new(sheet)
  svc.add_parameter("componentId", dto.component_id)
  svc.add_parameter("requestedMimeType", dto.requested_mime_type)

  UU::OS::QoS::QoSHandler.auto_retry do
    return svc.get_binary('getComponentData', sheet_uri)
  end
end

- (Object) get_image_data(sheet_uri, image)

Returns streamed data of the image from the specified content.

Examples:

# Get image identified by UUID a89ad302b98373e4140188114f2756a020-7fff from the sheet (main entity).
UU::OS::Sheet.get_image_data('ues:TERRITORY:ARTIFACT:SHEET', :image_id => 'a89ad302b98373e4140188114f2756a020-7fff')

Parameters:

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

    Not nil. UESURI of the sheet containing the image which should be returned.

  • image (SheetGetImageData)

    Specific options.

Options Hash (image):

  • :image_id (String)

    Not nil. ID of the image from the specified sheet. It can be found in the attribute UUID of the element core:image contained in XML (UUXML) representation of the sheet.



437
438
439
440
441
442
443
444
445
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 437

def get_image_data(sheet_uri, image)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = UU::OS::Sheet::SheetGetImageData.new(image)
  svc.add_parameter('image', dto.image_id)

  UU::OS::QoS::QoSHandler.auto_retry do
    return svc.get_binary('getImageData',sheet_uri)
  end
end

- (UU::OS::REST::BinaryValue) get_sheet_data(sheet_uri, sheet = nil)

Returns the content of the sheet specified by sheetUri. Data are streamed. Available output data formats are UXML file, UDF archive, and a zip archive with the sheet content exported as HTML document (see SheetGetSheetData for more details).

Examples:

# Get sheet content as UXML (uri needs to be replaced with one of an existing sheet for the example to work)
UU::OS::Sheet.get_sheet_data('ues:TERRITORY:ARTIFACT:SHEET',
:requested_mime_type=>UU::OS::Sheet::MimeType::UXML)

Parameters:

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

    URI of the sheet.

  • sheet (SheetGetSheetData) (defaults to: nil)

    Specify when stream will be returned and which type of data

Returns:



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

def get_sheet_data(sheet_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = UU::OS::Sheet::SheetGetSheetData.new(sheet)
  svc.add_parameter('requestedMimeType', dto.requested_mime_type)
  UU::OS::QoS::QoSHandler.auto_retry do
    result = svc.get_binary('getSheetData', sheet_uri)
    if (dto.requested_mime_type == UU::OS::Sheet::MimeType::UXML)
      return UU::OS::REST::BinaryValue.new(StringIO.new(result.data.read.force_encoding("UTF-8")),false)
    else
    return result
    end
  end
end

- (Object) get_sheet_list(artifact_uri, criteria = nil)

This command returns a list of sheets on the specified artifact. Command does not return all sheets, only a sublist. The list of returned sheets couldbe filtered by the name, code, main, order of a sheet and state of the lock. The list is sorted by the name (and codes in case are equal) of asheet by default, or it can be sorted arbitrarily by any of sheet attributes usable for the filtering or these attributes combinations.

for selecting sheets. Available parameters are: name, code, order, main, locked, lockTime, visible and width : SheetWidthType.

See UESQuery Documentation.

Parameters:

Returns:

  • List with sheets of artifact



63
64
65
66
67
68
69
70
71
72
73
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 63

def get_sheet_list(artifact_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = Sheet::SheetGetSheetList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getSheetList', artifact_uri)
    return UU::OS::REST::ResultList.new(Sheet::SheetGetSheetList, Sheet::SheetAttributes, res)
  end
end

- (SheetVersionAttributes) get_version_attributes(sheet_uri, version = nil)

The uuCommand returns attributes of given sheet version.

Examples:

# Get sheet version attributes (uri needs to be replaced with one of an existing sheet for the example to work)
attributes = UU::OS::Sheet.get_version_attributes('ues:TERRITORY:ARTIFACT:SHEET', :version_id => 123456789)

Parameters:

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

    UESURI of the sheet whose version is being searched.

  • version (SheetGetVersionAttributes) (defaults to: nil)

    Object containing ID of the searched version.

Options Hash (version):

  • :version_id (Integer)

    ID of the searched sheet version. It cannot be left null or blank.

Returns:



354
355
356
357
358
359
360
361
362
363
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 354

def get_version_attributes(sheet_uri, version = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = UU::OS::Sheet::SheetGetVersionAttributes.new(version)
  svc.add_parameter('versionID', dto.version_id)

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getVersionAttributes', sheet_uri)
    return Sheet::SheetVersionAttributes.new(res)
  end
end

- (UU::OS::REST::BinaryValue) get_version_data(sheet_uri, version)

Retrieves the specified historical version of the given sheet in xml format.

Examples:

# Get version of the sheet 'ues:TER:ART:SHEET' identified by its OID = 456232122
UU::OS::Sheet.get_version_data('ues:TER:ART:SHEET', :versionID => "456232122", :requestedMimeType => "application/ues-content-xml")

Parameters:

Options Hash (version):

  • :version_id (String)

    Not nil. Id of version which data will be retrieved by command.

  • :requested_mime_type (String)

    Format of data retrieved by command. Only possible value is ‘application/ues-content-xml’.

Returns:



459
460
461
462
463
464
465
466
467
468
469
470
471
472
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 459

def get_version_data(sheet_uri, version)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = UU::OS::Sheet::SheetGetVersionData.new(version)
  svc.add_parameter('requestedMimeType', dto.requested_mime_type)
  svc.add_parameter('versionID', dto.version_id)
  UU::OS::QoS::QoSHandler.auto_retry do
    result = svc.get_binary('getVersionData', sheet_uri)
    if (dto.requested_mime_type == UU::OS::Sheet::MimeType::UXML)
      return UU::OS::REST::BinaryValue.new(StringIO.new(result.data.read.force_encoding("UTF-8")),false)
    else
    return result
    end
  end
end

- (Array) get_version_list(sheet_uri, criteria = nil)

The uuCommand returns a list of sheet versions of the specified sheet.

Examples:

# Get sheet versions ordered by revision number in ascending order (uri needs to be replaced with one of an existing sheet for the example to work)
list = UU::OS::Sheet.get_version_list('ues:TERRITORY:ARTIFACT:SHEET', :query => "ORDER BY revision ASC")

Parameters:

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

    URI of the sheet whose versions will be retrieved.

  • criteria (SheetGetVersionList) (defaults to: nil)

    Criteria for selecting sheets.

Options Hash (criteria):

  • :query (String)

    Query for filtering and ordering of the result list (more information in uuQuery - Guideline). It is possible to filter the result list by label, creationTime, creationStamp and revision.

Returns:



376
377
378
379
380
381
382
383
384
385
386
387
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 376

def get_version_list(sheet_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  dto = Sheet::SheetGetVersionList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getVersionList', sheet_uri)
    return UU::OS::REST::ResultList.new(Sheet::SheetGetVersionList, Sheet::SheetVersionAttributes, res)
  end
end

- (Object) publish(sheet_uri)

Publishes private version and opens the lock sheet. All changes made in private version are published.

Parameters:



287
288
289
290
291
292
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 287

def publish(sheet_uri)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('publish', sheet_uri)
  end
end

- (Array) replace_component(sheet_uri, sheet = nil)

The uuCommand replaces specified component with given content.

Examples:

# Replace the content of a paragraph (uri needs to be replaced with one of an existing sheet for the example to work)
UU::OS::Sheet.replace_component('ues:TERRITORY:ARTIFACT:SHEET',
:component_id=>"583c10bfdbd326ba1ebfbd146d29e6392-7fff",
:content=>REST::BinaryValue.new(:data=>'[ues.p]New content.[/ues.p]'),
:requested_mime_type=>'BBCODE')

Parameters:

Options Hash (sheet):

  • :component_id (String)

    Identification code of the component in the given sheet (id of a paragraph etc.). Cannot be null.

  • :content (UU::OS::REST::BinaryValue)

    New content which is to be inserted at the component position. It must be in BB code format and cannot be null.

  • :requested_mime_type (String)

    Specifies the format of data in the input stream. Only BBCODE is supported at the moment. If null is set, MIME type must not be null on content attribute.

  • :preserve_lock_state (TrueClass, FalseClass)

    When true is set, the command preserves the state of the sheet lock. Therefore if the sheet is locked before the command execution, it also remains locked after the execution. When false or null is set, the sheet is unlocked after the command execution.

Returns:

  • (Array)

    List of IDs of the inserted components.



273
274
275
276
277
278
279
280
281
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 273

def replace_component(sheet_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  payload = UU::OS::Sheet::SheetReplaceComponent.new(sheet).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('replaceComponent',sheet_uri, payload)
    return JSON.parse(res).values[0]
  end
end

- (UU::OS::UESURI) set_attributes(sheet_uri, sheet = nil)

This command updates basic attributes of an sheet.

Parameters:

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

    UESURI of the sheet whose attributes are to be changed.

  • sheet (SheetSetAttributes) (defaults to: nil)

    DTO containingthe sheet attributes.

Returns:



333
334
335
336
337
338
339
340
341
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 333

def set_attributes(sheet_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  payload = UU::OS::Sheet::SheetSetAttributes.new(sheet).to_json

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

- (Object) unlock(sheet_uri)

Unlocks the specified sheet. Allows to unlock the sheet locked by another user

Parameters:



297
298
299
300
301
302
# File 'uu_os-0.29.16/lib/uu/os/sheet.rb', line 297

def unlock(sheet_uri)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('unlock', sheet_uri)
  end
end