Module: UU::OS::Property

Extended by:
Property
Included in:
Property
Defined in:
uu_os-0.29.16/lib/uu/os/property.rb,
uu_os-0.29.16/lib/uu/os/property/property_move.rb,
uu_os-0.29.16/lib/uu/os/property/property_type.rb,
uu_os-0.29.16/lib/uu/os/property/property_create.rb,
uu_os-0.29.16/lib/uu/os/property/property_attributes.rb,
uu_os-0.29.16/lib/uu/os/property/property_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/property/property_get_entry_list.rb,
uu_os-0.29.16/lib/uu/os/property/property_move_collection.rb,
uu_os-0.29.16/lib/uu/os/property/property_entry_attributes.rb,
uu_os-0.29.16/lib/uu/os/property/property_delete_collection.rb,
uu_os-0.29.16/lib/uu/os/property/property_get_property_list.rb,
uu_os-0.29.16/lib/uu/os/property/property_create_collection.rb,
uu_os-0.29.16/lib/uu/os/property/property_collection_attributes.rb,
uu_os-0.29.16/lib/uu/os/property/property_get_collection_attributes.rb,
uu_os-0.29.16/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



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 116

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
  if (prop.value.kind_of?UU::OS::REST::BinaryValue)
    payload = prop.to_hash
    payload.delete(:value)
    if (prop.value.data.kind_of?File)
      payload[:value] = create_file_with_file_name(prop.value)
    else
      payload[:value] = create_stream_with_file_name(prop.value)
    end
  else
    payload = prop.to_json
  end
     
  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:



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

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.



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

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



250
251
252
253
254
255
256
257
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 250

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:



34
35
36
37
38
39
40
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 34

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:



220
221
222
223
224
225
226
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 220

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:



181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 181

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



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 88

def get_value(property_uri)
  svc = UU::OS::REST::RemoteClient.new(Property)
  UU::OS::QoS::QoSHandler.auto_retry do
    raw = svc.raw_get_binary('getValue', property_uri)
    type = raw[2][:uu_property_value_type]
    value = svc.process_result(raw)
    result = deserialize_by_type(value,type)
    if (result.kind_of?UU::OS::REST::BinaryValue)
      if (raw[2][:content_disposition] != nil)
        disps = raw[2][:content_disposition].split(";")
        disps.each do |part|
          kv = part.lstrip.split("=")
          if kv[0]=="filename"
            result.name = kv[1]
          end
        end
      end
    end
    return result
  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.



283
284
285
286
287
288
289
290
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 283

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



267
268
269
270
271
272
273
274
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 267

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:



160
161
162
163
164
165
166
167
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 160

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.



234
235
236
237
238
239
240
241
242
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 234

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



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
# File 'uu_os-0.29.16/lib/uu/os/property.rb', line 56

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