Module: UU::OS::Sheet

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

Overview

Module Sheet.

Defined Under Namespace

Classes: MimeType, SheetAttributes, SheetCheckIn, SheetCheckOut, SheetCreate, SheetDeleteComponent, SheetDeleteVersion, SheetGetComponentContent, SheetGetComponentData, SheetGetSheetData, SheetGetSheetList, SheetGetVersionAttributes, 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.

Parameters:

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

    URI of the sheet.

  • sheet (SheetCheckIn) (defaults to: nil)

    Attributes of importing sheet



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 101

def check_in(sheet_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  payload = UU::OS::Sheet::SheetCheckIn.new(sheet).to_hash
  stream_value = false
  if payload[:content].kind_of?File
  # If data is File, send request as multipart stream
  stream_value = true        
  else
    if payload[:content].kind_of?StringIO
      payload[:content] = UU::OS::REST::BinaryValue.new(payload[:content])
    end
  # Any other data will be serialized to JSON and sent as normal request
  payload = payload.to_json
  end

  UU::OS::QoS::QoSHandler.auto_retry do
    if stream_value
      # Reset stream before each call in order to send all data
      payload[:content].rewind
    end

    svc.post('checkIn', sheet_uri, payload)
  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 whenstream will be returned and which type of data

Returns:



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 81

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

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('checkOut', sheet_uri, payload)
    if res
      return UU::OS::REST::BinaryValue.new(res,true)
    else
      return nil
    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:



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

def create(artifact_uri, sheet = nil)
  svc = UU::OS::REST::RemoteClient.new(Sheet)
  payload = UU::OS::Sheet::SheetCreate.new(sheet)
  if payload.content.kind_of?StringIO
    payload.content = UU::OS::REST::BinaryValue.new(payload.content)
  end
  payload = payload.to_json
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('create', artifact_uri, payload)
    return UU::OS::UESURI.new(res)
  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.



261
262
263
264
265
266
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 261

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:



272
273
274
275
276
277
278
279
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 272

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 null or blank.



352
353
354
355
356
357
358
359
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 352

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

- (SheetAttributes) get_attributes(sheet_uri)

Returns attributes representing the sheet specified by the sheetUri attribute.

Parameters:

Returns:



35
36
37
38
39
40
41
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 35

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 in the BB code format. The result is streamed.

Parameters:

Returns:



192
193
194
195
196
197
198
199
200
201
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 192

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 UU::OS::REST::BinaryValue.new(svc.get('getComponentData', sheet_uri),true)
  end
end

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

Returns content from sheet specified by sheetUri. Data are streamed. On the input can be selected output data stream format(UXML file, UDF archive).

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:



133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 133

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
    res = svc.get('getSheetData', sheet_uri)
    if res
      return UU::OS::REST::BinaryValue.new(res,true)
    else
      return nil
    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



61
62
63
64
65
66
67
68
69
70
71
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 61

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:



308
309
310
311
312
313
314
315
316
317
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 308

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

- (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:



330
331
332
333
334
335
336
337
338
339
340
341
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 330

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:



241
242
243
244
245
246
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 241

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.



227
228
229
230
231
232
233
234
235
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 227

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:



287
288
289
290
291
292
293
294
295
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 287

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:



251
252
253
254
255
256
# File 'uu_os_client-0.10.6/lib/uu/os/sheet.rb', line 251

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