Module: UU::OS::SheetTemplate

Extended by:
SheetTemplate
Included in:
SheetTemplate
Defined in:
uu_os-0.29.16/lib/uu/os/sheet_template.rb,
uu_os-0.29.16/lib/uu/os/sheet_template/sheet_template_create.rb,
uu_os-0.29.16/lib/uu/os/sheet_template/sheet_template_check_in.rb,
uu_os-0.29.16/lib/uu/os/sheet_template/sheet_template_get_data.rb,
uu_os-0.29.16/lib/uu/os/sheet_template/sheet_template_attributes.rb,
uu_os-0.29.16/lib/uu/os/sheet_template/sheet_template_set_attributes.rb,
uu_os-0.29.16/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
80
81
82
83
84
85
86
87
88
89
# File 'uu_os-0.29.16/lib/uu/os/sheet_template.rb', line 56

def check_in(sheet_template_uri, sheet_template = nil)
  svc = UU::OS::REST::RemoteClient.new(SheetTemplate)
  dto = UU::OS::SheetTemplate::SheetTemplateCheckIn.new(sheet_template)
  payload = dto.to_hash
  payload.delete(:content)
  tmpfile = Tempfile.new("SheetTemplateCheckIn")
  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_template_uri, payload)
    end
  ensure
    tmpfile.close
    tmpfile.unlink
  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:



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
213
214
215
216
217
218
219
# File 'uu_os-0.29.16/lib/uu/os/sheet_template.rb', line 182

def create(meta_artifact_uri, sheet_template = nil)
  svc = UU::OS::REST::RemoteClient.new(SheetTemplate)
  dto = UU::OS::SheetTemplate::SheetTemplateCreate.new(sheet_template)
  
  payload = dto.to_hash
  payload.delete(:content)
  tmpfile = Tempfile.new("SheetTemplateCreate")
  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', meta_artifact_uri, payload)
      return UU::OS::UESURI.new(res)
    end
  ensure
    tmpfile.close
    tmpfile.unlink
  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.



228
229
230
231
232
233
# File 'uu_os-0.29.16/lib/uu/os/sheet_template.rb', line 228

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-0.29.16/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:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'uu_os-0.29.16/lib/uu/os/sheet_template.rb', line 103

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_binary('getData', sheet_template_uri)
    if res
      if (dto.requested_mime_type == UU::OS::Sheet::MimeType::UXML)
        return UU::OS::REST::BinaryValue.new(StringIO.new(res.data.read.force_encoding("UTF-8")),false)
      else
        return res
      end
    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:



141
142
143
144
145
146
147
148
149
150
151
# File 'uu_os-0.29.16/lib/uu/os/sheet_template.rb', line 141

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:



259
260
261
262
263
264
265
266
267
# File 'uu_os-0.29.16/lib/uu/os/sheet_template.rb', line 259

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