Module: UU::OS::Widget

Extended by:
Widget
Included in:
Widget
Defined in:
uu_os-0.29.16/lib/uu/os/widget.rb,
uu_os-0.29.16/lib/uu/os/widget/widget_create.rb,
uu_os-0.29.16/lib/uu/os/widget/widget_export.rb,
uu_os-0.29.16/lib/uu/os/widget/widget_attributes.rb,
uu_os-0.29.16/lib/uu/os/widget/placeholder_image.rb,
uu_os-0.29.16/lib/uu/os/widget/widget_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/widget/widget_get_export_data.rb,
uu_os-0.29.16/lib/uu/os/widget/widget_get_widget_list.rb,
uu_os-0.29.16/lib/uu/os/widget/widget_get_widget_list_item.rb

Overview

Module Widget.

Defined Under Namespace

Classes: PlaceholderImage, WidgetAttributes, WidgetCreate, WidgetExport, WidgetGetExportData, WidgetGetWidgetList, WidgetGetWidgetListItem, WidgetSetAttributes

Constant Summary

PATH =

Service path

'uu/os/Widget'

Instance Method Summary (collapse)

Instance Method Details

- (UU::OS::UESURI) create(location_uri, widget = nil)

Creates a widget in specified location. At the very least meta artifact must be specified in WidgetCreate object. Competent role for the new widget will be selected as the most suitable according to specified package and meta artifact (executive/authorized role with connected interface), or can be also specified in WidgetCreate Object.

Examples:

# Create a new widget.
UU::OS::Widget.create('ues:TERRITORY:PACKAGE',
  :meta_artifact_uri => 'ues:TERRITORY:UU.OS/RUNTIME/WIDGET',
  :name => 'New Widget',
  :code => 'NEW_WIDGET',
  :description => 'My new widget',
  :controller_url_path => '',
  :trusted => false,
  :editor_available => true,
  :placeholder_image => UU::OS::Widget::PlaceholderImage::GENERAL,
  :width => 200,
  :height => 200
)

Parameters:

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

    URI of an uuApp Package where the widget will be created.

  • widget (Object) (defaults to: nil)

    Object containing the attributes of the widget.

Options Hash (widget):

  • :name (String)

    Name of the new widget. When nil is set, default name from meta artifact is used if set, otherwise the create command fails.

  • :code (String)

    Code of the new widget. When nil is set, the code is generated automatically using the system sequence. The code must be unique in the given territory, otherwise the create command fails.

  • :description (String)

    Description of the new widget. When nil is set, default description from meta artifact is used if set, otherwise no description is set on the new widget.

  • :security_level (String)

    Security level. When nil is set, security level is taken from the meta artifact default security level. If the meta artifact template security level is higher than the user’s security clearance, the create command fails.

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

    UESURI of the widget’s icon. When nil is set, the role uses icon from meta artifact. An example of icon URI: ‘ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_077}’.

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

    UESURI of the competent role. When nil is set, the executive role from authorization is used. If no role is authorized to create the widget into specified container, the create command fails. If the selected role doesn’t have connected the role interface with the selected meta artifact, the create command fails. If the selected role doesn’t belong to the same organizational unit as a new widget or if it doesn’t belong to one of superior organizational units, the create command fails.

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

    UESURI of the meta artifact. Only a meta artifact with the template class of widget (not its descendants) can be used. If the rights does not permit to create a new widget from the meta artifact in the specified location, the create command fails.

  • :controller_url_path (String)

    Path at which the widget’s controller is deployed. The value can be a relative or absolute URL (absolute URL has to be in format <something>.plus4u.net/…). If an absolute URL is set, it is used as entered, without adding any postfix (e.g. /render which is added for relative URL). If it is not set, the widget cannot be used in the sheet content.

  • :trusted (Boolean)

    Describes whether the widget will by inserted into the HTML directly or in the iframe. The default value is false.

  • :editor_available (Boolean)

    Describes whether the widget will be in the list of available widgets in editor. The default value is true.

  • :placeholder_image (String, UU::OS::Widget::PlaceholderImage)

    Placeholder image of the widget in editor. The default value is GENERAL.

  • :width (Number)

    Default width of the widget in content. It must be set together with height. If the attributes width and height or placeholder_width and placeholder_height are not set, the widget cannot be used in the sheet content.

  • :height (Number)

    Default height of the widget in content. It must be set together with width. If the attributes width and height or placeholder_width and placeholder_height are not set, the widget cannot be used in the sheet content.

  • :placeholder_width (Number)

    Width of the widget placeholder in editor. It is defined for widgets for which it is not possible to set width and height. It must be set together with placeholder_height. If the attributes width and height or placeholder_width and placeholder_height are not set, the widget cannot be used in the sheet content.

  • :placeholder_height (Number)

    Height of the widget placeholder in editor. It is defined for widgets for which it is not possible to set width and height. It must be set together with placeholder_width. If the attributes width and height or placeholder_width and placeholder_height are not set, the widget cannot be used in the sheet content.

Returns:



57
58
59
60
61
62
63
64
65
# File 'uu_os-0.29.16/lib/uu/os/widget.rb', line 57

def create(location_uri, widget = nil)
  svc = UU::OS::REST::RemoteClient.new(Widget)
  payload = UU::OS::Widget::WidgetCreate.new(widget).to_json

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

- (Object) delete(widget_uri)

Deletes the specified widget from the system. The widget is deleted even if it contains a locked sheet or attachment. The widget cannot be deleted when: the widget's workflow is not created a property contains a reference to this widget a time sheet exists with a reference to this widget

Examples:

# Delete widget with specified URI.
UU::OS::Widget.delete('ues:TERRITORY:WIDGET')

Parameters:

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

    URI of the widget which is about to be deleted.



77
78
79
80
81
82
# File 'uu_os-0.29.16/lib/uu/os/widget.rb', line 77

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

- (UU::OS::UESURI) export(widget_uri)

Exports a widget to the XML file, which is saved to the export storage. The export is an asynchronous process. It is possible to wait for the end of the process. More information in Env::Process and in REST::Future.

Examples:

# Start exporting a widget.
process_uri = UU::OS::Widget.export('ues:TERRITORY:WIDGET')

# Wait for the end of the process.
export_uri = UU::OS::REST::Future.new(process_uri).get(nil, 600)

# Get exported XML file.
exported_data = UU::OS::Widget.get_export_data(export_uri, :requested_mime_type => 'application/xml')

Parameters:

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

    URI of the widget to export.

Returns:



204
205
206
207
208
209
210
211
212
# File 'uu_os-0.29.16/lib/uu/os/widget.rb', line 204

def export(widget_uri)
  svc = UU::OS::REST::RemoteClient.new(Widget)
  payload = UU::OS::Widget::WidgetExport.new(nil).to_json

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

- (WidgetAttributes) get_attributes(widget_uri)

Returns attributes of the specified widget.

Examples:

# Get widget attributes.
attributes = UU::OS::Widget.get_attributes('ues:TERRITORY:WIDGET')

Parameters:

Returns:

  • (WidgetAttributes)

    Returns object containing attributes of selected widget.



93
94
95
96
97
98
99
# File 'uu_os-0.29.16/lib/uu/os/widget.rb', line 93

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

- (UU::OS::REST::BinaryValue) get_export_data(widget_uri, widget = nil)

Returns a XML file generated by the export command.Widget#export.

Examples:

# Start exporting a widget.
process_uri = UU::OS::Widget.export('ues:TERRITORY:WIDGET')

# Wait for the end of the process.
export_uri = UU::OS::REST::Future.new(process_uri).get(nil, 600)

# Get exported XML file.
exported_data = UU::OS::Widget.get_export_data(export_uri, :requested_mime_type => 'application/xml')

Parameters:

Options Hash (widget):

  • :requested_mime_type (String)

    MIME type of the returned value. All possible MIME types can be found as constants in UU::OS::Artifact::ExportMimeType class. ZIP is returned by default.

Returns:



231
232
233
234
235
236
237
238
239
240
# File 'uu_os-0.29.16/lib/uu/os/widget.rb', line 231

def get_export_data(widget_uri,widget = nil)
  svc = UU::OS::REST::RemoteClient.new(Widget)
  dto = UU::OS::Widget::WidgetGetExportData.new(widget)
  if dto.requested_mime_type
    svc.add_parameter('requestedMimeType', dto.requested_mime_type)
  end
  UU::OS::QoS::QoSHandler.auto_retry do
    return svc.get_binary('getExportData', widget_uri)
  end
end

- (UU::OS::REST::ResultList<Widget::WidgetGetWidgetListItem, Widget::WidgetGetWidgetList>) get_registered_widget_list(container_uri, criteria = nil)

Returns the list of widgets, which are registered in the selected territory or uuApp meta model. Returned list does not contain widgets located in the system territory. Returned list does not contain any objects filtered out by executed UESQuery. # See UESQuery Documentation.

Examples:

UU::OS::Widget.get_registered_widget_list('ues:TERRITORY:TERRITORY', criteria = nil)

Parameters:

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

    URI of the territory or uuApp meta model whose registered widget will be returned.

  • criteria (Object) (defaults to: nil)

    Specific options.

Options Hash (criteria):

  • :query (String)

    The UES query string. It has to conform the ues query syntax (see documentation for more info). Filtering and order of the result list can be specified there. It is possible to filter the result list by name and code of widget. When nil is set, no filtering is applied and entries are ordered by name of referenced artifact (and code and type as the second and the third criteria).

Returns:



176
177
178
179
180
181
182
183
184
185
186
# File 'uu_os-0.29.16/lib/uu/os/widget.rb', line 176

def get_registered_widget_list(container_uri, criteria=nil)
  svc = UU::OS::REST::RemoteClient.new(Widget)
  dto = Widget::WidgetGetWidgetList.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('getRegisteredWidgetList', container_uri)
    return UU::OS::REST::ResultList.new(Widget::WidgetGetWidgetList, Widget::WidgetGetWidgetListItem, res)
  end
end

- (UU::OS::REST::ResultList<Widget::WidgetGetWidgetListItem, Widget::WidgetGetWidgetList>) get_widget_list(entity_uri, criteria = nil)

Returns the list of widgets whose instances can be inserted into the content of selected sheet or into the content of a sheet on a given Artifact. Returned list does not contain any objects filtered out by executed UESQuery. See UESQuery Documentation.

Examples:

UU::OS::Widget.get_widget_list('ues:TERRITORY:ARTIFACT:SHEET', criteria = nil)

Parameters:

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

    URI of the sheet or Artifact, which widget list will be returned.

  • criteria (Object) (defaults to: nil)

    Specific options.

Options Hash (criteria):

  • :query (String)

    The UES query string. It has to conform the ues query syntax (see documentation for more info). Filtering and order of the result list can be specified there. It is possible to filter the result list by name and code of widget. When nil is set, no filtering is applied and entries are ordered by name of referenced artifact (and code and type as the second and the third criteria).

Returns:



152
153
154
155
156
157
158
159
160
161
162
163
# File 'uu_os-0.29.16/lib/uu/os/widget.rb', line 152

def get_widget_list(entity_uri, criteria=nil)
  svc = UU::OS::REST::RemoteClient.new(Widget)
  dto = Widget::WidgetGetWidgetList.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('getWidgetList', entity_uri)

    return UU::OS::REST::ResultList.new(Widget::WidgetGetWidgetList, Widget::WidgetGetWidgetListItem, res)
  end
end

- (UU::OS::UESURI) set_attributes(widget_uri, widget = nil)

Sets attributes of widget. Command cannot modify references to objects like location, competent role and so on. Changing the code of the widget will cause malfunction of widget instances. #

Examples:

# Set widget attributes.
UU::OS::Widget.set_attributes('ues:TERRITORY:WIDGET',
  :name => 'New Widget Name',
  :code => 'NEW_WIDGET_CODE',
  :description => 'My new widget',
  :editor_available => false,
  :width => 300,
  :height => 300,
)

Parameters:

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

    URI of the widget which attributes will be changed.

  • widget (Object) (defaults to: nil)

    Object containing new attributes of the widget.

Options Hash (widget):

  • :name (String)

    The new name of the widget. When nil is set, the name is not modified.

  • :code (String)

    The new code of the widget. When nil is set, the code is not modified.

  • :description (String)

    The new description of the widget. When nil is set, the description is not modified.

  • :security_level (String)

    Security level of the widget. When nil is set, the security level is not modified.

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

    UESURI of the widget icon. When nil is set, the icon is not modified. If nil UESURI (“ues:[-1]:[-1]:”) is set, the widget icon is removed and the widget uses icon from meta artifact. An example of icon URI: ‘ues:#{system}:#{ues_v5.core_v1.codetable_v1.base_v1.CodeTable_Icons}:#{ART_077}’.

  • :controller_url_path (String)

    Path at which the widget’s controller is deployed. The value can be a relative or absolute URL (absolute URL has to be in format <something>.plus4u.net/…). If an absolute URL is set, it is used as entered, without adding any postfix (e.g. /render which is added for relative URL). If it is not set, the widget cannot be used in the sheet content.

  • :trusted (Boolean)

    Describes whether the widget will by inserted into the HTML directly or in the iframe. The default value is false.

  • :editor_available (Boolean)

    Describes whether the widget will be in the list of available widgets in editor. The default value is true.

  • :placeholder_image (String, UU::OS::Widget::PlaceholderImage)

    Placeholder image of the widget in editor. The default value is GENERAL.

  • :width (Number)

    Default width of the widget in content. It must be set together with height. If the attributes width and height or placeholder_width and placeholder_height are not set, the widget cannot be used in the sheet content.

  • :height (Number)

    Default height of the widget in content. It must be set together with width. If the attributes width and height or placeholder_width and placeholder_height are not set, the widget cannot be used in the sheet content.

  • :placeholder_width (Number)

    Width of the widget placeholder in editor. It is defined for widgets for which it is not possible to set width and height. It must be set together with placeholder_height. If the attributes width and height or placeholder_width and placeholder_height are not set, the widget cannot be used in the sheet content.

  • :placeholder_height (Number)

    Height of the widget placeholder in editor. It is defined for widgets for which it is not possible to set width and height. It must be set together with placeholder_width. If the attributes width and height or placeholder_width and placeholder_height are not set, the widget cannot be used in the sheet content.

Returns:



131
132
133
134
135
136
137
138
139
# File 'uu_os-0.29.16/lib/uu/os/widget.rb', line 131

def set_attributes(widget_uri, widget = nil)
  svc = UU::OS::REST::RemoteClient.new(Widget)
  payload = UU::OS::Widget::WidgetSetAttributes.new(widget).to_json

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