Class: UU::OS::Content::Row

Inherits:
ContentClient
  • Object
show all
Defined in:
lib/uu/os/content/row.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Row

Creates a new instance of Row.

Parameters:

  • session (UU::OS::Security::Session)

    Session to use for remote calls.



14
15
16
# File 'lib/uu/os/content/row.rb', line 14

def initialize(session)
  @cmd = UU::OS::CMD::CommandClient.new('uu-os-content', session)
end

Class Method Details

.create(sheet_uri, dto = nil) ⇒ Object

#create convenience self-instantiating shortcut



69
70
71
72
# File 'lib/uu/os/content/row.rb', line 69

def self.create(sheet_uri, dto = nil)
  session = UU::OS::Security::Session.current_session 
  self.new(session).create(sheet_uri, dto)
end

.delete(sheet_uri, row_id) ⇒ Object

#delete convenience self-instantiating shortcut



87
88
89
90
# File 'lib/uu/os/content/row.rb', line 87

def self.delete(sheet_uri, row_id)
  session = UU::OS::Security::Session.current_session
  self.new(session).delete(sheet_uri, row_id)
end

.get_attributes(sheet_uri, row_id) ⇒ Object

#get_attributes convenience self-instantiating shortcut



123
124
125
126
# File 'lib/uu/os/content/row.rb', line 123

def self.get_attributes(sheet_uri, row_id)
  session = UU::OS::Security::Session.current_session
 self.new(session).get_attributes(sheet_uri, row_id)
end

.get_data(sheet_uri, row_id) ⇒ Object

#get_data convenience self-instantiating shortcut



176
177
178
179
# File 'lib/uu/os/content/row.rb', line 176

def self.get_data(sheet_uri, row_id)
  session = UU::OS::Security::Session.current_session
  self.new(session).get_data(sheet_uri, row_id)
end

.set_attributes(sheet_uri, row = nil) ⇒ Object

#set_attributes convinience self-instantiating shortcut



203
204
205
206
# File 'lib/uu/os/content/row.rb', line 203

def self.set_attributes(sheet_uri, row = nil)
  session = UU::OS::Security::Session.current_session
  self.new(session).set_attributes(sheet_uri, row)
end

.set_constraints(sheet_uri, constraints = nil) ⇒ Object

#set_constraints convenience self-instantiating shortcut



227
228
229
230
# File 'lib/uu/os/content/row.rb', line 227

def self.set_constraints(sheet_uri,  constraints = nil)
  session = UU::OS::Security::Session.current_session
  self.new(session).set_constraints(sheet_uri ,  constraints)
end

.set_data(sheet_uri, data = nil) ⇒ Object

#set_data convenience self-instantiating shortcut



273
274
275
276
# File 'lib/uu/os/content/row.rb', line 273

def self.set_data(sheet_uri,  data = nil)
  session = UU::OS::Security::Session.current_session
  self.new(session).set_data(sheet_uri,  data)
end

Instance Method Details

#create(sheet_uri, row = nil) ⇒ String

Creates a new row in a given sheet. The row data and its position within the content can be specified.

Examples:

UU::OS::Content::Row.create('ues:TER:ART:SHEET', :code=>'rowcode', :order=>1, :data=> { :columns=>[ { :code=>"columncode",
:data=>{ :components=>[ { :code=>"componentcode", :component_code=>"UU.OS.RICHTEXT/RICHTEXT",
:opt=>{:readonly=>true, :mandatory=>false, :visible=>true, :add_before=>true, :add_after=>true, :no_padding=>false}}]}}]})

Parameters:

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

    UESURI of the sheet, where the row will be added to the content.

  • row (Hash) (defaults to: nil)

    Object containing attributes, location and structure of the row.

Options Hash (row):

  • :code (String)

    User-defined code of the row. Must be unique in a scope of the Content. If nil or empty, the code is automatically generated (and is the same as the id).

  • :order (Integer)

    Represents the order of the row in a scope of content starting with 0. If the value is less than 0 the row is created at the beginning of the content. If order is nil or empty, or the value is greater than the number of existing rows in content the row is created at the end of the content (after last existing row).

  • :opt (Hash)

    Object contains additional attributes of the row.

    • :readonly ([Boolean]) Defines whether the row is read only (no columns can be added to the row, row's attributes cannot be changed, row cannot be deleted). Readonly constraint on the row is propagated to all content parts contained in it. Default value is false.

    • :mandatory ([Boolean]) Defines whether the row is mandatory (cannot be deleted). Default value is false.

    • :visible ([Boolean]) Defines whether the row is displayed in sheet content. The value of this attribute does not affect operating with the row through API. Default value is true.

    • :add_before ([Boolean]) Defines, whether it is possible to create new row before the given one. The value of this attribute does not affect operating with the row through API. Default value is true.

    • :add_after ([Boolean]) Defines, whether it is possible to create new row after the given one. The value of this attribute does not affect operating with the row through API. Default value is true.

    • :no_padding ([Boolean]) False for default row view, true for extra width on the row - as if row had no vertical padding.

    • :html_attributes ([Hash]) Contains the HTML attributes for the row.

  • :data (Hash)

    Object contains the internal structure of the row.

    • :columns ([Array<Hash>]) - An array of the columns contained in the row. Each object contains the attributes of the column.

      • :code (String) - User-defined code of the column. Must be unique in a scope of the Content. If nil or empty, the code is automatically generated (the same as id).

      • :opt (Hash) - Object contains the additional attributes of the column.

        • :readonly ([Boolean]) - default: false - Defines whether the column is readonly (no columns can be added to the row, row's attributes cannot be changed, row cannot be deleted). Readonly constraint on the column is propagated to all content parts contained in it

          • :mandatory ([Boolean]) - default: false - Defines whether the column is mandatory in sheet content (cannot be deleted). Mandatory constraint is propagated to the roe that contains the column.

          • :visible ([Boolean]) - default: true - Defines whether the column is displayed in sheet content. The value of this attribute does not affect operating with the column through API.

          • :add_before ([Boolean]) - default: true - Defines, whether it is possible to create new column before the given one. The value of this attribute does not affect operating with the column through API.

          • :add_after ([Boolean]) - default: true - Defines, whether it is possible to create new column after the given one. The value of this attribute does not affect operating with the column through API.

          • :html_attributes ([Hash]) - Contains the HTML attributes for the column.

          • :width ([Hash]) - Hash contains the definition of the column width for the different display area sizes. Possible attributes are: xs, sm, md, lg. The superior row can be edited only if the sum of xs, sm, md, lg is 12.

      • :data (Hash) - Object contains the internal structure of the column.

        • :components ([Array<Hash>]) - An array of the components contained in the column. Each object contains the attributes of the component.

          • :code (String) - User-defined code of the component. Must be unique in a scope of the Content. If nil or empty, the code is automatically generated.

          • :component_code (String) - The type of the component. If not set, default component is UU.OS.RICHTEXT/RICHTEXT.

          • :component_engine (String) - The attribute defines the engine of the component. Possible values are: COMPONENT_CONTENT (the only possible component code is UU.OS.RICHTEXT/RICHTEXT at the moment), UUOS8_WIDGET (for widgets registered using UU::OS::Widget) and UUOS9_WIDGET (for widgets in uuOS9). Default value is COMPONENT_CONTENT.

          • :opt (Hash) - Object contains the additional attributes of the component.

            • :readonly ([Boolean]) - default: false - Defines whether the component is readonly (component content cannot be modified, component attributes cannot be modified, component cannot be deleted).

            • :mandatory ([Boolean]) - default: false - Defines whether the component is mandatory in sheet content (component cannot be deleted). Mandatory constraint is propagated to the column and row, which contain the component.

            • :visible ([Boolean]) - default: true - Defines whether the component is displayed in sheet content. The value of this attribute does not affect operating with the component through API.

            • :add_before ([Boolean]) - default: true - Defines, whether it is possible to create new component before the given one. The value of this attribute does not affect operating with the component through API.

            • :add_after ([Boolean]) - default: true - Defines, whether it is possible to create new component after the given one. The value of this attribute does not affect operating with the component through API.

            • :html_attributes ([Hash]) - Contains the HTML attributes for the component.

            • :alignment (String) - default: left - Indicates how the widget will be aligned in content, default value is left. If component_engine is COMPONENT_CONTENT the attribute is ignored.

          • :props (Hash) - Contains the specific attributes for the component.

Returns:

  • (String)

    Returns id of the newly created row.



63
64
65
66
# File 'lib/uu/os/content/row.rb', line 63

def create(sheet_uri, row = nil)
  res = @cmd.invoke("Row/create",sheet_uri,prepare_params(row))
  return res
end

#delete(sheet_uri, row_id) ⇒ Object

Removes the given row from the structure of the content including its data. If last row in content is deleted, a new row with one empty column is created.

Examples:

UU::OS::Content::Row.delete('ues:TER:ART:SHEET', :row_id => "12345678")

Parameters:

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

    UESURI of an existing sheet which row will be deleted.

  • row_id (Hash)

    Object containing basic attributes of the row that will be deleted.

Options Hash (row_id):

  • :row_id (String)

    An identifier of an existing row, which attributes will be deleted.



82
83
84
# File 'lib/uu/os/content/row.rb', line 82

def delete(sheet_uri, row_id)
  @cmd.invoke("Row/delete",sheet_uri, prepare_params(row_id)) 
end

#get_attributes(sheet_uri, row_id) ⇒ Hash

Retrieves the attributes of the given row.

Examples:

UU::OS::Content::Row.get_attributes('ues:TER:ART:SHEET', :row_id => "12345678")

Parameters:

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

    UESURI of the existing sheet, which row's attributes will be returned.

  • row_id (Hash)

    Object containing basic attributes of the row that will be returned.

Options Hash (row_id):

  • :row_id (String)

    An identifier of an existing row, which attributes will be returned.

Returns:

  • (Hash)

    Returns Object containing the attributes of the given row.

    • :id (String) - Automatically generated row identifier. Unique in a scope of sheet content. Not nil.

    • :code (String) - The code of the row. Unique in a scope of sheet content. Not nil.

    • :order (Integer) - Row order in a scope of Sheet content. Not nil.

    • :revision (Integer) - The number of the row revision. Not nil.

    • :opt (Hash) - Object contains additional attributes of the row.

      • :readonly ([Boolean]) - Defines whether the row is readonly (no columns can be added to the row, row's attributes cannot be changed, row cannot be deleted). Readonly constraint on the row is propagated to all content parts contained in it

      • :mandatory ([Boolean]) - Defines whether the row is mandatory (cannot be deleted).

      • :visible ([Boolean]) - Defines whether the row is displayed in sheet content. The value of this attribute does not affect operating with the row through API.

      • :add_before ([Boolean]) - Defines, whether it is possible to create new row before the given one. The value of this attribute does not affect operating with the row through API.

      • :add_after ([Boolean]) - Defines, whether it is possible to create new row after the given one. The value of this attribute does not affect operating with the row through API.

      • :html_attributes ([Hash]) - Contains the HTML attributes for the row.

      • :no_padding ([Boolean]) - False for default row view, true for extra width on the row - as if row had no vertical padding.

    • :lock_time (String) - Time when the row was locked (if locked) in ISO 8601 format.

    • :lock_role_uri (UU::OS::UESURI) - Normalized UESURI of the role that locked the row (if locked).

    • :lock_access_role_uri (UU::OS::UESURI) - Normalized UESURI of the access role that locked the row (if locked).



118
119
120
# File 'lib/uu/os/content/row.rb', line 118

def get_attributes(sheet_uri, row_id)
  transform(@cmd.invoke('Row/getAttributes', sheet_uri, prepare_params(row_id))) #, invocation_method: 'get')
end

#get_data(sheet_uri, row_id) ⇒ Array<Hash>

Retrieves the data of the given row in json format. The structure of the row data is returned, data of each component in row is not returned.

Examples:

UU::OS::Content::Row.get_data('ues:TER:ART:SHEET', :row_id=>"12345")

Parameters:

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

    UESURI of the sheet, which row's data will be retrieved.

  • row_id (Hash)

    Object containing basic attributes of the row that will be retrieved.

Options Hash (row_id):

  • :row_id (String)

    An identifier of an existing row, which attributes will be retrieved.

Returns:

  • (Array<Hash>)

    Returns JSON, containing row data structure.

    • :columns ([Array<Hash>]) - An array of the columns contained in the row. Each object contains the attributes of the column.

      • :id (String) - Unique identifier of the column.

      • :code (String) User-defined code of the column. Must be unique in a scope of the Content. If nil or empty, the code is automatically generated.

      • :revision (Integer) - The revision of the column.

      • :opt (Hash) - Object contains the additional attributes of the column.

        • :readonly ([Boolean]) - Defines whether the column is readonly (no components can be added to the column, column's attributes cannot be modified, column cannot be deleted). Readonly constraint is propagated to all content parts contained in the column.

        • :mandatory ([Boolean]) - Defines whether the column is mandatory in sheet content (cannot be deleted). Mandatory constraint is propagated to the roe that contains the column.

        • :visible ([Boolean]) - Defines whether the column is displayed in sheet content. The value of this attribute does not affect operating with the column through API.

        • :add_before ([Boolean]) - Defines, whether it is possible to create new column before the given one. The value of this attribute does not affect operating with the column through API.

        • :add_after ([Boolean]) - Defines, whether it is possible to create new column after the given one. The value of this attribute does not affect operating with the column through API.

        • :html_attributes ([Hash]) - Contains the HTML attributes for the column.

        • :width ([Hash]) - Object contains the definition of the column width for the different display areay sizes.

      • :lock_time (String) - Time when the row was locked in ISO 8601 format.

      • :lock_role_uri (UU::OS::UESURI) - Normalized UESURI of the role that locked the row.

      • :lock_access_role_uri (UU::OS::UESURI) - Normalized UESURI of the access role that locked the row.

      • :data Hash) - Object contains the internal structure of the column.

        • :components ([Array<Hash>]) - An array of the components contained in the column. Each object contains the attributes of the component.

          • :id (String) - Unique identifier of the component.

          • :code (String) - User-defined code of the component. Must be unique in a scope of the Content. If nil or empty, the code is automatically generated.

          • :component_code (String) - The code of the component artifact.

          • :component_engine (String) - The engine of the component.

          • :revision (Integer) - The revision of the component.

          • :props (Hash) - Contains the specific attributes for the given component.

          • :opt (Hash) - Object contains the additional attributes of the component.

            • :readonly ([Boolean]) - Defines whether the component is readonly (component content cannot be modified, component attributes cannot be modified, component cannot be deleted).

            • :mandatory ([Boolean]) - Defines whether the component is mandatory in sheet content (component cannot be deleted). Mandatory constraint is propagated to the column and row, which contain the component.

            • :visible ([Boolean]) - Defines whether the component is displayed in sheet content. The value of this attribute does not affect operating with the component through API.

            • :add_before ([Boolean]) - Defines, whether it is possible to create new component before the given one. The value of this attribute does not affect operating with the component through API.

            • :add_after ([Boolean]) - Defines, whether it is possible to create new component after the given one. The value of this attribute does not affect operating with the component through API.

            • :html_attributes ([Hash]) - Contains the attributes defining HTML attributes for the component.

            • :alignment (String) - default: left - Indicates how the widget will be aligned in content, default value is left. If component_engine is COMPONENT_CONTENT the attribute is ignored.

          • :lock_time (String) - Time when the component was locked in ISO 8601 format.

          • :lock_role_uri (UU::OS::UESURI) - Normalized UESURI of the role that locked the component.

          • :lock_access_role_uri (UU::OS::UESURI) - Normalized UESURI of the access role that locked the component.



171
172
173
# File 'lib/uu/os/content/row.rb', line 171

def get_data(sheet_uri, row_id)
  transform(@cmd.invoke('Row/getData', sheet_uri, prepare_params(row_id))) #, invocation_method: 'get')
end

#set_attributes(sheet_uri, row = nil) ⇒ String

Updates basic attributes of the specified row.

Examples:

UU::OS::Content::Row.set_attributes('ues:TER:ART:SHEET', :row_id => "12345678", :code => "ROW_2",
:order => 1)

Parameters:

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

    UESURI of the sheet, which row's attributes will be updated.

  • row (Hash) (defaults to: nil)

    Object containing basic attributes of the row that will be updated.

Options Hash (row):

  • :row_id (String)

    An identifier of an existing row, which attributes will be updated.

  • :code (String)

    User-defined code of the row. Must be unique in a scope of the Content. If empty, the code is automatically generated.

  • :html_attributes (Object)

    Contains the HTML attributes of the row.

  • :no_padding (Boolean)

    False for default row view, true for extra width on the row - as if row had no vertical padding.

  • :order (Integer)

    Represents the order of the row in a scope of content starting with 0. If the value is less than 0 the row is moved to the beginning of the content. If order is nil or empty, or the value is greater than the number of existing rows in content the row is moved at the end of the content (after last existing row). The orders of the existing rows is changed accordingly.

Returns:

  • (String)

    Returns an id of the updated row.



196
197
198
199
200
# File 'lib/uu/os/content/row.rb', line 196

def
set_attributes(sheet_uri,row = nil)
  res = @cmd.invoke('Row/setAttributes', sheet_uri, prepare_params(row))
  return res
end

#set_constraints(sheet_uri, constraints = nil) ⇒ Object

Sets constraints on the row.

Examples:

UU::OS::Content::Row.set_constraints('ues:TER:ART:SHEET', :row_id => "12345678", :readonly => true,
:visible => false)

Parameters:

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

    UESURI of the sheet, which row's constraints will be set.

  • constraints (Hash) (defaults to: nil)

    Object containing constraints definitions.

Options Hash (constraints):

  • :row_id (String)

    An identifier of the row, which constraints will be set.

  • :readonly (Boolean)

    Defines whether the row is readonly (no columns can be added to the row, row's attributes cannot be changed, row cannot be deleted). Readonly constraint on the row is propagated to all content parts contained in it.

  • :mandatory (Boolean)

    Defines whether the row is mandatory (cannot be deleted).

  • :visible (Boolean)

    Defines whether the row is displayed in sheet content. The value of this attribute does not affect operating with the row through API.

  • :add_before (Boolean)

    Defines, whether it is possible to create new row before the given one. The value of this attribute does not affect operating with the row through API.

  • :add_after (Boolean)

    Defines, whether it is possible to create new row after the given one. The value of this attribute does not affect operating with the row through API.



222
223
224
# File 'lib/uu/os/content/row.rb', line 222

def set_constraints(sheet_uri, constraints = nil)
  @cmd.invoke('Row/setConstraints', sheet_uri,  prepare_params(constraints))
end

#set_data(sheet_uri, data = nil) ⇒ Object

Modifies data structure of the given row. In case input data contains part that is already defined in the row (recognized by its id) it is updated, otherwise replaced.

Examples:

UU::OS::Content::Row.set_data('ues:TER:ART:SHEET',:row_id=>"12345", :data=> { :columns=>[ { :code=>"columncode",
:data=>{ :components=>[ { :code=>"componentcode", :component_code=>"UU.OS.RICHTEXT/RICHTEXT",
:opt=>{:readonly=>true, :mandatory=>false, :visible=>true, :add_before=>true, :add_after=>true}}]}}]})

Parameters:

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

    UESURI of the sheet, which row will be modified.

  • data (Hash) (defaults to: nil)

    Contains structure of the row content.

Options Hash (data):

  • :row_id (String)

    A unique identifier of an existing row in the content.

  • :columns (String)

    An array of the rows contained in the sheet. Each object contains the attributes of the row.

    • :id (String) - Unique identifier of the column.

    • :code (String) - User-defined code of the column. Must be unique in a scope of the Content. If empty, the code is automatically generated.

    • :opt (Hash) - Object contains the additional attributes of the column.

      • :readonly ([Boolean]) - Defines whether the column is readonly (no components can be added to the column, column's attributes cannot be modified, column cannot be deleted). Readonly constraint is propagated to all content parts contained in the column.

      • :mandatory ([Boolean]) - Defines whether the column is mandatory in sheet content (cannot be deleted). Mandatory constraint is propagated to the roe that contains the column.

      • :visible ([Boolean]) - Defines whether the column is displayed in sheet content. The value of this attribute does not affect operating with the column through API.

      • :add_before ([Boolean]) - Defines, whether it is possible to create new column before the given one. The value of this attribute does not affect operating with the column through API.

      • :add_after ([Boolean]) - Defines, whether it is possible to create new column after the given one. The value of this attribute does not affect operating with the column through API.

      • :html_attributes ([Hash]) - Contains the HTML attributes for the column.

      • :width ([Hash]) - Object contains the definition of the column width for the different display array sizes.

    • :data Hash) - Object contains the internal structure of the column.

      • :components ([Array<Hash>]) - An array of the components contained in the column. Each object contains the attributes of the component.

        • :id (String) - Unique identifier of the component.

        • :code (String) - User-defined code of the component. Must be unique in a scope of the Content. If empty, the code is automatically generated.

        • :component_code (String) - The address of the component. For the existing components in the content (already have id), the attribute cannot be changed (if set, the new value is ignored). If not set, defaults to UU.OS.RICHTEXT/RICHTEXT.

        • :component_engine (String) - The engine of the component. For the existing components in the content (already have id), the attribute cannot be changed (if set, the new value is ignored). If not set, default engine is COMPONENT_CONTENT.

        • :props (Hash) - Contains the specific attributes for the given component.

        • :opt (Hash) - Object contains the additional attributes of the component.

          • :readonly ([Boolean]) - Defines whether the component is readonly (component content cannot be modified, component attributes cannot be modified, component cannot be deleted).

          • :mandatory ([Boolean]) - Defines whether the component is mandatory in sheet content (component cannot be deleted). Mandatory constraint is propagated to the column and row, which contain the component.

          • :visible ([Boolean]) - Defines whether the component is displayed in sheet content. The value of this attribute does not affect operating with the component through API.

          • :add_before ([Boolean]) - Defines, whether it is possible to create new component before the given one. The value of this attribute does not affect operating with the component through API.

          • :add_after ([Boolean]) - Defines, whether it is possible to create new component after the given one. The value of this attribute does not affect operating with the component through API.

          • :html_attributes ([Hash]) - Contains the attributes definining HTML attributes for the component.

          • :alignment (String) - default: left - Indicates how the widget will be aligned in content, default value is left. If component_engine is COMPONENT_CONTENT the attribute is ignored.



268
269
270
# File 'lib/uu/os/content/row.rb', line 268

def set_data(sheet_uri,  data = nil)
  @cmd.invoke('Row/setData', sheet_uri,  prepare_params(data))
end