Class: UU::OS::Content::Column

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Column

Creates a new instance of Column.

Parameters:

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

    Session to use for remote calls.



14
15
16
# File 'lib/uu/os/content/column.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



60
61
62
63
# File 'lib/uu/os/content/column.rb', line 60

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, column_id) ⇒ Object

#delete convinience self-instantiating shortcut



79
80
81
82
# File 'lib/uu/os/content/column.rb', line 79

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

.get_attributes(sheet_uri, column_id) ⇒ Object

#get_attributes convenience self-instantiating shortcut



114
115
116
117
# File 'lib/uu/os/content/column.rb', line 114

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

.get_data(sheet_uri, column_id) ⇒ Object

#get_data convinience self-instantiating shortcut



152
153
154
155
# File 'lib/uu/os/content/column.rb', line 152

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

.set_attributes(sheet_uri, column = nil) ⇒ Object

#set_attributes convinience self-instantiating shortcut



177
178
179
180
# File 'lib/uu/os/content/column.rb', line 177

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

.set_constraints(sheet_uri, constraints = nil) ⇒ Object

#set_constraints convenience self-instantiating shortcut



201
202
203
204
# File 'lib/uu/os/content/column.rb', line 201

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 convinience self-instantiating shortcut



233
234
235
236
# File 'lib/uu/os/content/column.rb', line 233

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, column = nil) ⇒ String

Creates a new column in a given row. The column data structure can be specified.

Examples:

UU::OS::Content::Column.create('ues:TER:ART:SHEET', :row_id => "12345678", :code => "COLUMN_2",
:order=>1, :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 where the column will be created.

  • column (Hash) (defaults to: nil)

    Object containing attributes and structure of the column.

Options Hash (column):

  • :row_id (String)

    An identifier of an existing row, where the new column will be created.

  • :code (String)

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

  • :order (Integer)

    Represents the order of the column in a scope of row starting with 0. If the value is less than 0 the column is created at the beginning of the row. If order is nil or empty, or the value is greater than the number of existing columns in row the column is created at the end of the row (after last existing 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. Default value is false.

    • :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. Default value is false.

    • :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. Default value is true.

    • :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. Default value is true.

    • :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. Default value is true.

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

    • :width [Hash] Object contains the definition of the column width for the different display area sizes: xs, sm, md, lg. Default value is 1 for any size.

  • :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 column.



54
55
56
57
# File 'lib/uu/os/content/column.rb', line 54

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

#delete(sheet_uri, column_id) ⇒ Object

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

Examples:

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

Parameters:

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

    UESURI of the sheet, which content's column will be deleted.

  • column_id (Hash)

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

Options Hash (column_id):

  • :column_id (String)

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



74
75
76
# File 'lib/uu/os/content/column.rb', line 74

def delete(sheet_uri, column_id)
  @cmd.invoke("Column/delete",sheet_uri, prepare_params(column_id))
end

#get_attributes(sheet_uri, column_id) ⇒ Hash

Retrieves the attributes of the given column.

Examples:

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

Parameters:

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

    UESURI of the sheet, which content's column attributes will be retrieved.

  • column_id (Hash)

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

Options Hash (column_id):

  • :column_id (String)

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

Returns:

  • (Hash)

    Returns Object containing the attributes of the given column.

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

    • :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. Not nil.

    • :order (Integer) - The order of the column in a scope of row. Not nil.

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

    • :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 area sizes.

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

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

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



109
110
111
# File 'lib/uu/os/content/column.rb', line 109

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

#get_data(sheet_uri, column_id) ⇒ Hash

Retrieves the data of the given column in json format. The data of each component in content is not returned.

Examples:

UU::OS::Content::Column.get_data('ues:TER:ART:SHEET', :column_id => "12354567")

Parameters:

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

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

  • column_id (Hash)

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

Options Hash (column_id):

  • :column_id (String)

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

Returns:

  • (Hash)

    Returns JSON, containing column content.

    • :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.



147
148
149
# File 'lib/uu/os/content/column.rb', line 147

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

#set_attributes(sheet_uri, column = nil) ⇒ String

Updates basic attributes of the specified column.

Examples:

UU::OS::Content::Column.set_attributes('ues:TER:ART:SHEET', :column_id => "12345678", :code => "BOX_2")

Parameters:

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

    UESURI of sheet, which content's column attributes will be set.

  • column (Hash) (defaults to: nil)

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

Options Hash (column):

  • :column_id (String)

    An identifier of the column, which attributes will be set.

  • :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.

  • :html_attributes (Object)

    Contains the HTML attributes for the column.

  • :width (Object)

    Object contains the definition of the column width for the different display area sizes.

  • :order (Integer)

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

Returns:

  • (String)

    Returns id of the updated column.



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

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

#set_constraints(sheet_uri, constraints = nil) ⇒ Object

Sets constraints on the column.

Examples:

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

Parameters:

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

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

  • constraints (Hash) (defaults to: nil)

    Object containing constraints definitions.

Options Hash (constraints):

  • :column_id (String)

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

  • :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.



196
197
198
# File 'lib/uu/os/content/column.rb', line 196

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

#set_data(sheet_uri, data = nil) ⇒ Object

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

Examples:

UU::OS::Content::Column.set_data('ues:TER:ART:SHEET', :column_id => "12345678", :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 column data will be modified.

  • data (Hash) (defaults to: nil)

    Contains structure of the column content.

Options Hash (data):

  • :column_id (String)

    An identifier of the existing column, which data will be modified.

  • :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 code of the component artifact. For the existing components in the content (already have id), the attribute cannot be changed (if set, the new value will be 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 will be 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 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.



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

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