Module: UU::OS::Shortcut

Extended by:
Shortcut
Included in:
Shortcut
Defined in:
uu_os-0.29.16/lib/uu/os/shortcut.rb,
uu_os-0.29.16/lib/uu/os/shortcut/shortcut_create.rb,
uu_os-0.29.16/lib/uu/os/shortcut/shortcut_relocate.rb,
uu_os-0.29.16/lib/uu/os/shortcut/shortcut_attributes.rb,
uu_os-0.29.16/lib/uu/os/shortcut/shortcut_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/shortcut/shortcut_get_shortcut_list.rb

Defined Under Namespace

Classes: ShortcutAttributes, ShortcutCreate, ShortcutGetShortcutList, ShortcutRelocate, ShortcutSetAttributes

Constant Summary

PATH =

Service path

'ues/core/container/UESShortcut'

Instance Method Summary (collapse)

Instance Method Details

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

This command creates a new shortcut for the specified artifact. At the very least, referenced artifact have to be specified in this command.

Examples:

# Create shortcut in specified location
UU::OS::Shortcut.create('ues:TERRITORY:LOCATION', :name=>'Shortcut name', :code=>'CODE', :artifact_uri=>'ues:TERRITORY:ARTIFACT')

Parameters:

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

    UESURI of the location (folder, org. unit, territory etc.) where the new shortcut is created

  • shortcut (ShortcutCreate) (defaults to: nil)

    DTO containing attributes of the new shortcut

Options Hash (shortcut):

  • :name (String)

    Name of the new shortcut. When nil is set, the name of the referenced artifact is used (and this equality is kept from now on for a shortcut referencing an artifact in the same territory).

  • :code (String)

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

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

    UESURI of the referenced artifact. Cannot be nil.

Returns:



31
32
33
34
35
36
37
38
39
# File 'uu_os-0.29.16/lib/uu/os/shortcut.rb', line 31

def create(location_uri, shortcut = nil)
  svc = UU::OS::REST::RemoteClient.new(Shortcut)
  payload = UU::OS::Shortcut::ShortcutCreate.new(shortcut).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(shortcut_uri)

This command deletes the shortcut from the system.

Examples:

# Delete shortcut specified by UESURI.
UU::OS::Shortcut.delete('ues:TERRITORY:SHORTCUT')

Parameters:

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

    UESURI of the shortcut to be deleted



124
125
126
127
128
129
# File 'uu_os-0.29.16/lib/uu/os/shortcut.rb', line 124

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

- (ShortcutAttributes) get_attributes(shortcut_uri)

This command returns attributes representing the shortcut specified by the shortcutUri parameter. The command does not change the state of the shortcut in the system.

Examples:

# Get shortcut attributes.
UU::OS::Shortcut.get_attributes('ues:TERRITORY:SHORTCUT')

Parameters:

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

    UESURI of a shortcut whose attributes are returned

Returns:



52
53
54
55
56
57
58
# File 'uu_os-0.29.16/lib/uu/os/shortcut.rb', line 52

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

- (UU::OS::REST::ResultList<Shortcut::ShortcutGetShortcutList, Shortcut::ShortcutAttributes>) get_shortcut_list(artifact_uri, criteria = nil)

This command returns a list of shortcuts to the specified artifact. The command does not return all shortcuts, only a sublist. Only the shortcuts from the territory of the artifact are returned. The list of returned shortcuts could be filtered by the name or code of a shortcut. The list is sorted by the name (and codes in case are equal) of a shortcut by default, or it can be sorted arbitrarily by any of shortcut attributes usable for the filtering or these attributes combinations. See the UES query documentation for more information.

Examples:

# Get shortcut list with ordering.
UU::OS::Shortcut.get_shortcut_list('ues:TERRITORY:ARTIFACT',:query=>'ORDER BY name, code')

Parameters:

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. When nil is set, no filtering is applied and entries are ordered by name and code as the second criteria.

  • :code_filter (String)

    Filter for filtering the result according to the shortcut code. When nil is set or if codeFilter is an empty string, no filtering according to the code is applied. Filter behavior is similar to the SQL like predicate pattern string. It is a wildcard with these special characters: % (percent sign) allows matching any string of any length (including zero length) _ (underscore) allows matching a single character \ (backslash) is used to escape any of these special characters.

  • :name_filter (String)

    Filter for filtering the result according to the shortcut name. When nil is set or if nameFilter is an empty string, no filtering according to the name is applied. Filter behavior is similar to the SQL like predicate pattern string. It is a wildcard with these special characters: % (percent sign) allows matching any string of any length (including zero length) _ (underscore) allows matching a single character \ (backslash) is used to escape any of these special characters.

Returns:



79
80
81
82
83
84
85
86
87
88
89
# File 'uu_os-0.29.16/lib/uu/os/shortcut.rb', line 79

def get_shortcut_list(artifact_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Shortcut)
  dto = Shortcut::ShortcutGetShortcutList.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('getShortcutList', artifact_uri)
    return UU::OS::REST::ResultList.new(Shortcut::ShortcutGetShortcutList, Shortcut::ShortcutAttributes, res)
  end
end

- (UU::OS::UESURI) relocate(shortcut_uri, shortcut = nil)

This command relocates the shortcut to the new location. It means the shortcut is deleted and created again in a new location. It is recreated with the same attributes. But its UESURI is different because the shortcut is deleted and created again in another location. At the very least new location have to be specified in this command. The new location has to be in the same territory.

Examples:

# Relocate shortcut.
UU::OS::Shortcut.relocate('ues:TERRITORY:SHORTCUT', :location_uri=>'ues:TERRITORY:LOCATION')

Parameters:

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

    UESURI of the shortcut to relocate

  • shortcut (ShortcutRelocate) (defaults to: nil)

    DTO containing attributes for the shortcut relocation

Options Hash (shortcut):

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

    The new location for the shortcut. Cannot be nil.

Returns:

  • (UU::OS::UESURI)

    UESURI of the relocated shortcut. UESURI is different because the shortcut is deleted and created again in another location.



107
108
109
110
111
112
113
114
115
# File 'uu_os-0.29.16/lib/uu/os/shortcut.rb', line 107

def relocate(shortcut_uri, shortcut = nil)
  svc = UU::OS::REST::RemoteClient.new(Shortcut)
  payload = UU::OS::Shortcut::ShortcutRelocate.new(shortcut).to_json

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

- (UU::OS::UESURI) set_attributes(shortcut_uri, shortcut = nil)

This command updates some basic attributes of a shortcut.

Examples:

# Set attributes for shortcut.
UU::OS::Shortcut.set_attributes('ues:TERRITORY:SHORTCUT', :name=>'Shortcut name', :code=>'CODE', :artifact_uri=>'ues:TERRITORY:ARTIFACT')

Parameters:

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

    UESURI of the shortcut whose attributes are to be changed.

  • shortcut (ShortcutSetAttributes) (defaults to: nil)

    DTO containing new attributes the shortcut.

Options Hash (shortcut):

  • :name (String)

    The new name of the shortcut. When nil is set, the name is not modified. When empty string is set, the name is set the same as the name of referenced artifact (and this equality is kept from now on for a shortcut referencing an artifact in the same territory).

  • :code (String)

    The new code of the shortcut. When nil is set, the code is not modified. The code must be unique in a given artifact, otherwise the setAttributes command fails.

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

    UESURI of the referenced artifact. When nil is set, the reference is not modified.

Returns:

  • (UU::OS::UESURI)

    UESURI of the shortcut. It could be changed because command could change the code.



145
146
147
148
149
150
151
152
153
# File 'uu_os-0.29.16/lib/uu/os/shortcut.rb', line 145

def set_attributes(shortcut_uri, shortcut = nil)
  svc = UU::OS::REST::RemoteClient.new(Shortcut)
  payload = UU::OS::Shortcut::ShortcutSetAttributes.new(shortcut).to_json

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