Module: UU::OS::SheetTemplate

Extended by:
SheetTemplate
Included in:
SheetTemplate
Defined in:
uu_os_client-0.10.6/lib/uu/os/sheet_template.rb,
uu_os_client-0.10.6/lib/uu/os/sheet_template/sheet_template_create.rb,
uu_os_client-0.10.6/lib/uu/os/sheet_template/sheet_template_check_in.rb,
uu_os_client-0.10.6/lib/uu/os/sheet_template/sheet_template_get_data.rb,
uu_os_client-0.10.6/lib/uu/os/sheet_template/sheet_template_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/sheet_template/sheet_template_set_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/sheet_template/sheet_template_get_sheet_template_list.rb

Defined Under Namespace

Classes: SheetTemplateAttributes, SheetTemplateCheckIn, SheetTemplateCreate, SheetTemplateGetData, SheetTemplateGetSheetTemplateList, SheetTemplateSetAttributes

Constant Summary

PATH =

Service path

'ues/core/content/UESSheetTemplate'

Instance Method Summary (collapse)

Instance Method Details

- (Object) check_in(sheet_template_uri, sheet_template = nil)

Replaces the content of the specified sheet template and unlock it by default. Sheet template content must be in UXML or UDF format. Sheet template must be locked by the current user or must be unlocked.

Examples:

#Create data for check in
data = UU::OS::BinaryValue.new(File.open('document.xml', 'rb'))

#Check in sheet template
UU::OS::SheetTemplate.check_in('ues:TERRITORY:META_ARTIFACT:SHEET_TEMPLATE', :name => 'newName', :code => 'newCode', :description => 'newDesc',
       :content => data, :version_label => 'newLabel', :version_strategy => 'OVERWRITE_VERSION') 

Parameters:

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

    URI of the sheet template.

  • sheet_template (SheetTemplateCheckIn) (defaults to: nil)

    Attributes of importing sheet template.

Options Hash (sheet_template):

  • :name (String)

    The new name of the sheet template. When null is set, the name is not modified. The name must be unique in a given Meta Artifact, otherwise the command fails.

  • :code (String)

    The new code of the sheet template. When null is set, the code is not modified. The code must be unique in a given Meta Artifact, otherwise the command fails.

  • :description (String)

    The new description of the sheet template. When null is set, the description is not modified.

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

    Not nil. The new content of the sheet template in UXML or UDF format.

  • :version_label (String)

    The version label of the new sheet template version. When null is set, it is left empty.

  • :version_strategy (String, UU::OS::Env::VersionStrategy)

    Specifies how to work with versions (see Env::VersionStrategy for possible values). When null is set, the OVERWRITE_VERSION strategy is used.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'uu_os_client-0.10.6/lib/uu/os/sheet_template.rb', line 56

def check_in(sheet_template_uri, sheet_template = nil)
  svc = UU::OS::REST::RemoteClient.new(SheetTemplate)
  payload = UU::OS::SheetTemplate::SheetTemplateCheckIn.new(sheet_template).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_template_uri, payload)
  end
end

- (UU::OS::UESURI) create(meta_artifact_uri, sheet_template = nil)

Creates a new sheet template on the specified Meta Artifact. Initial sheet template content can be specified.

Examples:

#Create initial data
data = UU::OS::BinaryValue.new(File.open('document.xml', 'rb'))

#Create sheet template
UU::OS::SheetTemplate.create('ues:TERRITORY:META_ARTIFACT', :name => 'testTemplate', :code => 'TEMPLATE_CODE', :description => 'newDesc', :content => data,
      :main => false, :order => 0, :version_label => 'New Sheet Template', :visible => true, :implicit_creation => false,
      :width => UU::OS::Sheet::SheetWidthType::WIDTH_1226PX) 

Parameters:

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

    URI of Meta Artifact.

  • sheet_template (SheetTemplateCreate) (defaults to: nil)

    Object containing attributes of the sheet template.

Options Hash (sheet_template):

  • :name (String)

    Name of the new sheet template. When null is set, the name is generated automatically. The name must be unique in a given Meta Artifact, otherwise the command fails.

  • :code (String)

    Code of the new sheet template. When null is set, the code is generated automatically using the system sequence. The code must be unique in a given Meta Artifact, otherwise the command fails.

  • :description (String)

    Description of the new sheet template.

  • :source_template_uri (UU::OS::UESURI)

    UESURI of the sheet template from which the new sheet template will be copied. Source sheet template must be located on the Meta Artifact from which the Meta Artifact with new sheet template was copied.

  • :main (Boolean)

    Specifies whether created sheet template is set as the main sheet template on meta-artifact. When not set, sheet template is not set as main. When true is set, the sheet template should be visible.

  • :order (Integer)

    Specifies the order (or index) of the new sheet template on the specified meta-artifact. All sheet templates on a meta-artifact are ordered sequentially. The first sheet template has index 0. When null is set or when the order exceeds the number of sheet templates on the meta-artifact, the sheet template is inserted at the end of the sheet template list. When 0 or less is set, the sheet template is inserted at the beginning of the sheet template list. Sheet template currently at that position (if any) and any subsequent sheet templates are shifted to the right (adds one to their order).

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

    Initial content of sheet template. Must be in UXML or UDF format.

  • :version_label (String)

    Label of the new sheet template version.

  • :visible (Boolean)

    Specifies the visibility of the sheet template.

  • :width (String, UU::OS::Sheet::SheetWidthType)

    Width of the sheet template.

  • :implicit_creation (Boolean)

    Specifies whether sheet should be created by the sheet template simultaneously with artifact creation.

Returns:



168
169
170
171
172
173
174
175
176
177
178
179
# File 'uu_os_client-0.10.6/lib/uu/os/sheet_template.rb', line 168

def create(meta_artifact_uri, sheet_template = nil)
  svc = UU::OS::REST::RemoteClient.new(SheetTemplate)
  payload = UU::OS::SheetTemplate::SheetTemplateCreate.new(sheet_template)
  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', meta_artifact_uri, payload)
    return UU::OS::UESURI.new(res)
  end
end

- (Object) delete(sheet_template_uri)

Deletes the sheet template from the system.

Examples:

#Delete sheet template
UU::OS::SheetTemplate.delete('ues:TERRITORY:META_ARTIFACT:SHEET_TEMPLATE')

Parameters:

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

    UESURI of the sheet template which is about to be deleted.



188
189
190
191
192
193
# File 'uu_os_client-0.10.6/lib/uu/os/sheet_template.rb', line 188

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

- (SheetTemplateAttributes) get_attributes(sheet_template_uri)

Returns attributes representing specified sheet template.

Examples:


#Get attributes of a sheet template
UU::OS::SheetTemplate.get_attributes('ues:TERRITORY:META_ARTIFACT:SHEET_TEMPLATE')

Parameters:

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

    URI of sheet template which attributes will be retrieved

Returns:



29
30
31
32
33
34
35
# File 'uu_os_client-0.10.6/lib/uu/os/sheet_template.rb', line 29

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

- (UU::OS::REST::BinaryValue) get_data(sheet_template_uri, sheet_template = nil)

Returns the content of the sheet template. The content may be returned as structured UXML or full content including images in a compressed UDF format. The type of the returned stream is determined by options (see UU::OS::SheetTemplate::SheetTemplateGetData#requested_mime_type), UXML is returned by default.

Examples:

#Get sheet template data
UU::OS::SheetTemplate.get_data('ues:TERRITORY:META_ARTIFACT:SHEET_TEMPLATE', :requested_mime_type => UU::OS::Sheet::MimeType::UXML)

Parameters:

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

    URI of the sheet template.

  • sheet_template (SheetTemplateGetData) (defaults to: nil)

    Object containing options for content retrieving

Options Hash (sheet_template):

  • :requested_mime_type (String, UU::OS::Sheet::MimeType)

    The format of the returned sheet template content. Possible values are UU::OS::Sheet::MimeType#UXML and UU::OS::Sheet::MimeType#UARCHIVE. When null is set, the UXML is used.

Returns:



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'uu_os_client-0.10.6/lib/uu/os/sheet_template.rb', line 93

def get_data(sheet_template_uri, sheet_template = nil)
  svc = UU::OS::REST::RemoteClient.new(SheetTemplate)
  dto = UU::OS::SheetTemplate::SheetTemplateGetData.new(sheet_template)
  svc.add_parameter('requestedMimeType', dto.requested_mime_type)

  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getData', sheet_template_uri)
    if res
      return UU::OS::REST::BinaryValue.new(res,true)
    else
      return nil
    end
  end
end

- (Array) get_sheet_template_list(meta_artifact_uri, criteria = nil)

Returns a list of sheet templates on the specified Meta Artifact. Command does not return all sheet templates, only a sublist. The list of returned sheet templates could be filtered by the name, code, main, visible, order of a sheet template, state of the lock and width. The list is sorted by the name (and code in case are equal) of a sheet template by default, or it can be sorted arbitrarily by any of sheet template attributes usable for the filtering or these attributes combinations. See the UES query documentation for more information.

It is possible to filter result by: name, code, order, main, locked, lockTime, visible and width : UU::OS::Sheet::SheetWidthType.

Examples:

#Get sheet template list
UU::OS::SheetTemplate.get_sheet_template_list('ues:TERRITORY:META_ARTIFACT', :query => "name='Description%'")

Parameters:

Options Hash (criteria):

  • :query (String)

    Query for filtering and ordering of the result list (more information in uuQuery - Guideline).

Returns:



127
128
129
130
131
132
133
134
135
136
137
# File 'uu_os_client-0.10.6/lib/uu/os/sheet_template.rb', line 127

def get_sheet_template_list(meta_artifact_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(SheetTemplate)
  dto = SheetTemplate::SheetTemplateGetSheetTemplateList.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('getSheetTemplateList', meta_artifact_uri)
    return UU::OS::REST::ResultList.new(SheetTemplate::SheetTemplateGetSheetTemplateList, SheetTemplate::SheetTemplateAttributes, res)
  end
end

- (UU::OS::UESURI) set_attributes(sheet_template_uri, sheet_template = nil)

Updates basic attributes of the sheet template.

Examples:

#Set attributes of sheet template
UU::OS::SheetTemplate.set_attributes('ues:TERRITORY:META_ARTIFACT:SHEET_TEMPLATE', :name => 'newName', :code => 'newCode', :main => true, :visible => true, 
    :order => 3, :description => 'newDesc', :width => UU::OS::Sheet::SheetWidthType::WIDTH_650PX, :implicit_creation => true)

Parameters:

Options Hash (sheet_template):

  • :name (String)

    The new name of the sheet template. When null is set, the name is not modified. The name must be unique in a given Meta Artifact, otherwise the command fails.

  • :code (String)

    The new code of the sheet template. When null is set, the code is not modified. The code must be unique in a given Meta Artifact, otherwise the command fails.

  • :main (Boolean)

    Specifies if the sheet template is to be set as main on the Meta Artifact. When null is set, the main is not modified. When true is set, the sheet template must be visible. When false is set and the sheet template is set as main, system sets the first visible sheet template as main. If the main sheet template is at the same time the first visible, nothing happens.

  • :visible (Boolean)

    Specifies if the sheet template is set as visible. When null is set, the visible is not modified. When false is set, the sheet template cannot be main at the same time.

  • :order (Integer)

    Specifies the order (or index) of the sheet template on the specified Meta Artifact. All sheet templates are ordered sequentially. The first sheet template has index 0. When 0 or less is set, the sheet template is inserted at the beginning of the sheet template list. When null is set, the order is not modified. Sheet template currently at that position (if any) and any subsequent sheet templates are shifted to the right (adds one to their order).

  • :description (String)

    The new description of the sheet template. When null is set, the description is not modified.

  • :width (String, UU::OS::Sheet::SheetWidthType)

    The new width of the sheet template. When null is set, the width is not modified.

  • :implicit_creation (Boolean)

    Specifies whether sheet should be created by the sheet template simultaneously with artifact creation.

Returns:



219
220
221
222
223
224
225
226
227
# File 'uu_os_client-0.10.6/lib/uu/os/sheet_template.rb', line 219

def set_attributes(sheet_template_uri, sheet_template = nil)
  svc = UU::OS::REST::RemoteClient.new(SheetTemplate)
  payload = UU::OS::SheetTemplate::SheetTemplateSetAttributes.new(sheet_template).to_json

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