Module: UU::OS::Property

Extended by:
Property
Included in:
Property
Defined in:
uu_os_client-0.10.6/lib/uu/os/property.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_move.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_type.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_create.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_set_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_get_entry_list.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_move_collection.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_entry_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_delete_collection.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_get_property_list.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_create_collection.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_collection_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_get_collection_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/property/property_set_collection_attributes.rb

Overview

UES Property service.

Defined Under Namespace

Classes: PropertyAttributes, PropertyCollectionAttributes, PropertyCreate, PropertyCreateCollection, PropertyDeleteCollection, PropertyEntryAttributes, PropertyGetCollectionAttributes, PropertyGetEntryList, PropertyGetPropertyList, PropertyMove, PropertyMoveCollection, PropertySetAttributes, PropertySetCollectionAttributes, PropertyType

Constant Summary

PATH =

Service path

'ues/core/property/UESProperty'

Instance Method Summary (collapse)

Instance Method Details

- (Object) create(parent_node_uri, property = nil)

Creates a new property on the specified artifact or in the specified property collection. At the very least, property template or property type and name have to be specified in this command. Value of the property is optional.

Parameters:

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

    UESURI of the artifact or of the property collection where the new property is to be created

  • property (PropertyCreate) (defaults to: nil)

    DTO containing attributes of a new property



105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 105

def create(parent_node_uri, property = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  prop = UU::OS::Property::PropertyCreate.new(property)
  value = prop.value
  if (value.kind_of?File)
    prop.value = UU::OS::REST::BinaryValue.new(value)
  end
  payload = prop.to_json
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('create', parent_node_uri, payload)
    return UU::OS::UESURI.new(res)
  end
end

- (UU::OS::UESURI) create_collection(parent_node_uri, property = nil)

This command creates a new property collection on the specified artifact or in the specified property collection. At the very least property collection name has to be specified in this command.

Parameters:

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

    UESURI of the artifact or of the property collection where the new property collection is created.

  • property (PropertyCreateCollection) (defaults to: nil)

    DTO containing attributes of the new property collection.

Returns:



179
180
181
182
183
184
185
186
187
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 179

def create_collection(parent_node_uri, property = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  payload = UU::OS::Property::PropertyCreateCollection.new(property).to_json

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

- (Object) delete(property_uri)

Deletes the specified property.

Parameters:

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

    UESURI of the property which is about to be deleted.



122
123
124
125
126
127
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 122

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

- (Object) delete_collection(collection_uri, property = nil)

This command deletes the specified property collection from the system. When the collection is not empty, it's need explicite to allow deletion of the collection with its all nested objects.

Parameters:

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

    UESURI of the property collection which is about to be deleted

  • property (PropertyDeleteCollection) (defaults to: nil)

    DTO containing settings for deletion



226
227
228
229
230
231
232
233
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 226

def delete_collection(collection_uri, property = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  payload = UU::OS::Property::PropertyDeleteCollection.new(property).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('deleteCollection', collection_uri, payload)
  end
end

- (PropertyAttributes) get_attributes(property_uri)

Returns attributes representing the artifact property specified by the property_uri attribute.

Parameters:

Returns:



33
34
35
36
37
38
39
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 33

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

- (PropertyCollectionAttributes) get_collection_attributes(collection_uri)

This command returns attributes representing the property collection specified by the collectionUri parameter. The command does not change the state of the property collection in the system.

Parameters:

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

    UESURI of the property collection which attributes are returned.

Returns:



196
197
198
199
200
201
202
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 196

def get_collection_attributes(collection_uri)
  svc = UU::OS::REST::RemoteClient.new(Property)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getCollectionAttributes', collection_uri)
    return Property::PropertyCollectionAttributes.new(res)
  end
end

- (UU::OS::REST::ResultList<Property::PropertyGetEntryList, Property::PropertyEntryAttributes>) get_entry_list(parent_node_uri, criteria = nil)

Returns a list of entries (properties or property collections) enlisted in the specified property collection or on the specified artifact (properties from the artiffact root property collection are returned in that case). Command does not return all entries, only a sublist. The list of returned entries could be filtered by the name, code or type of an entry. The list is sorted by the name (and codes in case are equal) of a entry by default, or it can be sorted arbitrarily by any of entry attributes usable for the filtering or these attributes combinations. See the UES query documentation for more information.

Parameters:

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

    UESURI of the artifact or of the property collection from where entries (properties or property collections) are listed.

  • criteria (PropertyGetEntryList) (defaults to: nil)

    DTO containing criteria for listing entries.

Returns:



157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 157

def get_entry_list(parent_node_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  dto = Property::PropertyGetEntryList.new(criteria)
  svc.add_parameter('pageIndex', dto.page_index)
  svc.add_parameter('pageSize', dto.page_size)
  svc.add_parameter('query', dto.query)
  svc.add_parameter('recursive', dto.recursive)
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.get('getEntryList', parent_node_uri)
    res = UU::OS::REST::ResultList.new(Property::PropertyGetEntryList, Property::PropertyEntryAttributes, res)
    return res
  end
end

- (Object) get_value(property_uri)

Returns a value of the specified property.

Parameters:

Returns:

  • (Object)

    The value of the specified property



89
90
91
92
93
94
95
96
97
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 89

def get_value(property_uri)
  svc = UU::OS::REST::RemoteClient.new(Property)
  UU::OS::QoS::QoSHandler.auto_retry do
    raw = svc.raw_get('getValue', property_uri)
    type = raw[2][:uu_property_value_type]
    value = svc.process_result(raw)
    return deserialize_by_type(value,type)
  end
end

- (Object) move(property_uri, property = nil)

Moves the specified property to a new location in same artifact in which the property is. For the property move - the logged user, which invokes this command, must have access rights to modify target property collection.

Parameters:

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

    UESURI of the property which is about to be moved.

  • property (PropertyMove) (defaults to: nil)

    DTO containing attributes specifying a location to where the property is about to be moved.



259
260
261
262
263
264
265
266
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 259

def move(property_uri, property = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  payload = UU::OS::Property::PropertyMove.new(property).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('move', property_uri, payload)
  end
end

- (Object) move_collection(collection_uri, property = nil)

This command moves a property collection to the new location in the same artifact. This collection can not be base collection. New location can be property collection or artifact, and it can not be child of property collection which is about to move. New location can not be child of the moved collection. User must have access rights to modify property collection on artifact to which is collection related.

Parameters:

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

    UESURI of the property collection which is about to be moved.

  • property (PropertyMoveCollection) (defaults to: nil)

    DTO contains parameters that specify the move



243
244
245
246
247
248
249
250
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 243

def move_collection(collection_uri, property = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  payload = UU::OS::Property::PropertyMoveCollection.new(property).to_json

  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('moveCollection', collection_uri, payload)
  end
end

- (UU::OS::UESURI) set_attributes(property_uri, property = nil)

Sets attributes of the specified property.

Parameters:

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

    UESURI of the property whose attributes are about to be changed.

  • property (PropertySetAttributes) (defaults to: nil)

    DTO containing the attributes of the property to be set.

Returns:



136
137
138
139
140
141
142
143
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 136

def set_attributes(property_uri, property = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  payload = UU::OS::Property::PropertySetAttributes.new(property).to_json
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('setAttributes', property_uri, payload)
    return UU::OS::UESURI.new(res)
  end
end

- (UU::OS::UESURI) set_collection_attributes(collection_uri, property = nil)

This command sets attributes of the specified property collection.

Parameters:

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

    UESURI of the property collection whose attributes are about to be changed.

  • property (PropertySetCollectionAttributes) (defaults to: nil)

    DTO containing the attributes of the property collection to be set.

Returns:

  • (UU::OS::UESURI)

    UESURI of the property collection whose attributes are to changed.



210
211
212
213
214
215
216
217
218
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 210

def set_collection_attributes(collection_uri, property = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  payload = UU::OS::Property::PropertySetCollectionAttributes.new(property).to_json

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

- (Object) set_value(property_uri, value = nil)

This command sets a new value on the specified property. The data type of value must match the data type of the specified property. If the property value is set as file, is highly recommended to open file in binary mode, for example: File.open("file_name.txt", "rb").

Parameters:

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

    UES URI of property

  • value (Object) (defaults to: nil)

    The new value of property. Possible types of property’s value (there may be additional business restrictions based on property type):

    • Nil value

    • Numeric value

    • Time value

    • String

    • UESURI

    • BinaryValue

    • File



55
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
# File 'uu_os_client-0.10.6/lib/uu/os/property.rb', line 55

def set_value(property_uri, value = nil)
  svc = UU::OS::REST::RemoteClient.new(Property)
  
  file_value = false
  payload = {}
    
  if (value.kind_of?File)
    file_value = true
    payload[:value] = value
  elsif (value.kind_of?IO)
   payload = UU::OS::REST::BinaryValue.new(value).to_json
  elsif ((value.kind_of?UU::OS::REST::BinaryValue) && (value.data.kind_of?File) && (File.basename(value.data.path) == value.name))
   payload[:value] = value.data  
   payload[:defaultName] = value.name    
  elsif ((value.kind_of?UU::OS::REST::BinaryValue) && (value.data.nil?) && (!value.name.nil? && !value.name.empty?))
    payload[:defaultName] = value.name  
  else
    payload = value.to_json
  end
  
  UU::OS::QoS::QoSHandler.auto_retry do
    if file_value
      payload[:value].rewind
    end

    svc.post('setValue', property_uri, payload)
  end
end