Module: UU::OS::PropertyTemplate

Extended by:
PropertyTemplate
Included in:
PropertyTemplate
Defined in:
uu_os-0.29.16/lib/uu/os/property_template.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_move.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_create.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_attributes.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_get_entry_list.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_move_collection.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_entry_attributes.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_delete_collection.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_collection_create.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_collection_attributes.rb,
uu_os-0.29.16/lib/uu/os/property_template/property_template_set_collection_attributes.rb

Overview

UES Property Template service.

Defined Under Namespace

Classes: PropertyTemplateAttributes, PropertyTemplateCollectionAttributes, PropertyTemplateCollectionCreate, PropertyTemplateCreate, PropertyTemplateDeleteCollection, PropertyTemplateEntryAttributes, PropertyTemplateGetEntryList, PropertyTemplateMove, PropertyTemplateMoveCollection, PropertyTemplateSetAttributes, PropertyTemplateSetCollectionAttributes

Constant Summary

PATH =

Service path

'ues/core/property/UESPropertyTemplate'

Instance Method Summary (collapse)

Instance Method Details

- (UU::OS::UESURI) create(parent_node_uri, property_template = nil)

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

Examples:

#Create number with regular expression restriction 
uri = UU::OS::PropertyTemplate.create('ues:TERRITORY:META_ARTIFACT', :name => 'number Property', :type => UU::OS::Property::PropertyType::NUMBER, 
    :value => 4, :value_restriction => '[0-9]')
#Create text with enum restriction
uri = UU::OS::PropertyTemplate.create('ues:TERRITORY:META_ARTIFACT', :name => 'text Property', :type => UU::OS::Property::PropertyType::TEXT, 
    :value => 'valueFromEnum', :value_restriction => 'ues:TERRITORY:META_ARTIFACT:ENUM')
#Create reference with only mar restriction
uri = UU::OS::PropertyTemplate.create('ues:TERRITORY:META_ARTIFACT', :name => 'ref Property', :type => UU::OS::Property::PropertyType::REFERENCE, 
    :value => 'ues:TERRITORY:ARTIFACT', :value_restriction => "metaArtifactUri = 'ues:TERRITORY:META_ARTIFACT'")
#Create reference with mar and ou restriction
uri = UU::OS::PropertyTemplate.create('ues:TERRITORY:META_ARTIFACT', :name => 'ref Property', :type => UU::OS::Property::PropertyType::REFERENCE, 
    :value_restriction => "metaArtifactUri = 'ues:TERRITORY:META_ARTIFACT' AND organizationalUnitUri = ${this-ou}")

Parameters:

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

    of the Meta Artifact or of the property template group where the new property template is created

  • property_template (PropertyTemplateCreate) (defaults to: nil)

    Object containing attributes of the new property template

Options Hash (property_template):

  • :name (String)

    Not nil. Name of the new property template.

  • :code (String)

    Code of the new property template. When null is set, the code is generated automatically using the system sequence. The code must be unique in a given Meta Artifact, otherwise the command fails.

  • :description (String)

    Description of the new property template.

  • :type (UU::OS::Property::PropertyType)

    Not nil. Specifies the type of the new property template.

  • :value (Object)

    The value of the new property template. Passed object type has to correspond to the type of the new property template, see UU::OS::Property::PropertyType for possible types

  • :value_restriction (String)

    String defining value restriction, one of the following values are possible: string with UESURI - to define enumeration restriction, string with Pattern - to define regular expression restriction, string with Query in form “metaArtifactUri = ‘…’ OR metaArtifactUri = ‘…’ AND organizationalUnitUri = ‘…’ OR organizationalUnitUri = ‘…’ (organizationalUnitUri = $this-ou)” - to define restriction on Meta Artifact and organizational unit

Returns:



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 183

def create(parent_node_uri, property_template = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  prop = UU::OS::PropertyTemplate::PropertyTemplateCreate.new(property_template)
  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, collection = nil)

Creates a new property template collection on the specified Meta Artifact or in the specified property collection template. At the very least property template collection name has to be specified in this command.

Examples:

#Create property template collection 
uri = UU::OS::PropertyTemplate.create_collection('ues:TERRITORY:META_ARTIFACT', :name => 'new Collection', :code => 'COLL')   

Parameters:

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

    of the Meta Artifact or of the property collection template where the new property collection template is created

  • collection (PropertyTemplateCollectionCreate) (defaults to: nil)

    Object containing attributes of a new property collection template

Options Hash (collection):

  • :name (String)

    Not nil. Name of the new property collection template.

  • :code (String)

    Code of the property collection template. When null is set, the code is generated automatically using the system sequence. The code must be unique within a given Meta Artifact, otherwise the command fails.

  • :description (String)

    Description of the new property template collection. When null is set, the description is left empty.

Returns:



271
272
273
274
275
276
277
278
279
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 271

def create_collection(parent_node_uri, collection = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  payload = UU::OS::PropertyTemplate::PropertyTemplateCollectionCreate.new(collection).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(template_uri)

Deletes the property template from the system.

Examples:

#Delete property template  
UU::OS::PropertyTemplate.delete('ues:TERRITORY:META_ARTIFACT:PROPERTY_TEMPLATE')

Parameters:

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

    of the property template which is about to be deleted



216
217
218
219
220
221
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 216

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

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

Deletes the specified property collection template. When recursive is set in options, all nested objects in property collection template are also removed.

Examples:

#Delete property template collection
UU::OS::PropertyTemplate.delete_collection('ues:TERRITORY:META_ARTIFACT:COLLECTION')

Parameters:

Options Hash (collection):

  • :recursive (Boolean)

    Flag specifies if non-empty property collection template will be deleted. When property template collection is not empty, and the flag is set to true, all the nested objects will be deleted with the collection template asynchronously. If property template collection is not empty, and the flag is set to false, or not set, the command will fail.



375
376
377
378
379
380
381
382
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 375

def delete_collection(collection_uri, collection = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  payload = UU::OS::PropertyTemplate::PropertyTemplateDeleteCollection.new(collection).to_json

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

- (PropertyTemplateAttributes) get_attributes(template_uri)

Returns attributes representing the specified property template.

Examples:

#Get attributes of a property template 
UU::OS::PropertyTemplate.get_attributes('ues:TERRITORY:META_ARTIFACT:PROPERTY_TEMPLATE')

Parameters:

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

    UESURI of of the property template

Returns:



36
37
38
39
40
41
42
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 36

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

- (PropertyTemplateCollectionAttributes) get_collection_attributes(collection_uri)

Returns attributes of the specified property collection template.

Examples:

#Get property template collection attributes
attrs = UU::OS::PropertyTemplate.get_collection_attributes('ues:TERRITORY:META_ARTIFACT:COLLECTION')   

Parameters:

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

    of the property collection template, which attributes are to be retrieved.

Returns:



290
291
292
293
294
295
296
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 290

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

- (Array) get_entry_list(parent_node_uri, criteria = nil)

Returns a list of entries (property templates or property template collections) enlisted in the specified property template collection or on the specified Meta Artifact (property template entries from the Meta Artifact root property template 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 code in case are equal) of an 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.

It is possible to filter result by: name, code, entityTypeUri, valueType

Examples:

#Get list of entries
list = UU::OS::PropertyTemplate.get_entry_list('ues:TERRITORY:META_ARTIFACT')
#Write property template values
list.each { |e| puts e.value }

Parameters:

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

    UESURI of the Meta Artifact or of the property template collection from where entries (property templates or property template collections) are listed.

  • criteria (PropertyTemplateGetEntryList) (defaults to: nil)

    criteria Specific options.

Options Hash (criteria):

  • :query (String)

    Query for filtering and ordering of the result list (more information in uuQuery - Guideline).

Returns:



138
139
140
141
142
143
144
145
146
147
148
149
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 138

def get_entry_list(parent_node_uri, criteria = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  dto = PropertyTemplate::PropertyTemplateGetEntryList.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('getEntryList', parent_node_uri)
    res = UU::OS::REST::ResultList.new(PropertyTemplate::PropertyTemplateGetEntryList, PropertyTemplate::PropertyTemplateEntryAttributes, res)
    return res
  end
end

- (Object) get_value(template_uri)

Returns the value of the given property template of the corresponding type. Null in case the value is not set.

Examples:

#Get value of the property template
value = UU::OS::PropertyTemplate.get_value('ues:TERRITORY:META_ARTIFACT:PROPERTY_TEMPLATE')

Parameters:

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

    UESURI of the property template

Returns:

  • (Object)

    the value of the property template



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 94

def get_value(template_uri)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  UU::OS::QoS::QoSHandler.auto_retry do
    raw = svc.raw_get_binary('getValue', template_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(template_uri, collection = nil)

Moves a property template to the new location (see UU::OS::PropertyTemplate::PropertyTemplateMove#parent_node_uri) on the same artifact. New location can be property template collection or Meta Artifact.

Examples:

#Move property template 
UU::OS::PropertyTemplate.move('ues:TERRITORY:META_ARTIFACT:TEMPLATE', :parent_node_uri => 'ues:TERRITORY:META_ARTIFACT:COLLECTION')

Parameters:

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

    UESURI of the property template to be moved.

  • collection (PropertyTemplateMove) (defaults to: nil)

    Object containing the new location of the property template

Options Hash (collection):

  • :parent_node_uri (String)

    Not nil. UESURI of a parent node (Meta Artifact or property template collection) where the property template will be moved. Property template can be moved only in the same Meta Artifact.



333
334
335
336
337
338
339
340
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 333

def move(template_uri, collection = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  payload = UU::OS::PropertyTemplate::PropertyTemplateMove.new(collection).to_json

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

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

Moves a property template collection to the new location (see UU::OS::PropertyTemplate::PropertyTemplateMoveCollection#parent_node_uri) on the same Meta Artifact. This template collection can not be base template collection. New location can be property template collection or Meta Artifact, and it can not be child of or the same as property template collection which is about to be moved.

Examples:

#Move property template collection
UU::OS::PropertyTemplate.move_collection('ues:TERRITORY:META_ARTIFACT:COLLECTION', :parent_node_uri => 'ues:TERRITORY:META_ARTIFACT:COLLECTION')

Parameters:

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

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

  • collection (PropertyTemplateMoveCollection) (defaults to: nil)

    Object containing the new location of the property template collection.

Options Hash (collection):

  • :parent_node_uri (String)

    Not nil. UESURI of Meta Artifact or Property Template Collection where the property template collection will be moved. Property template collection can be moved only in the same Meta Artifact. ParentNodeUri can not be child of the moved collection or the same.



354
355
356
357
358
359
360
361
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 354

def move_collection(collection_uri, collection = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  payload = UU::OS::PropertyTemplate::PropertyTemplateMoveCollection.new(collection).to_json
  
  UU::OS::QoS::QoSHandler.auto_retry do
    svc.post('moveCollection', collection_uri, payload)
  end
end

- (UU::OS::UESURI) set_attributes(template_uri, property_template = nil)

Sets basic attributes of the specified property template.

Examples:

#PropertyTemplate uri  
uri = 'ues:TERRITORY:META_ARTIFACT:PROPERTY_TEMPLATE'
#Remove restrictions from text 
uri = UU::OS::PropertyTemplate.set_attributes(uri, :value_restriction => '')
#Remove value 
uri = UU::OS::PropertyTemplate.set_value(uri, '')
#Set new restrictions 
uri = UU::OS::PropertyTemplate.set_attributes(uri, :value_restriction => '^[a-zA-Z]+$')

Parameters:

Options Hash (property_template):

  • :name (String)

    The new name of the property template. When null is set, the name is not modified. If set, name cannot be blank.

  • :code (String)

    The new code of the property template. When null is set, the code is not modified. The code must be unique in a given Meta Artifact, otherwise the command fails.

  • :description (String)

    The new description of the property template. When null is set, the description is not modified.

  • :value_restriction (String)

    String defining value restriction, one of the following values are possible: string with UESURI - to define enumeration restriction, string with Pattern - to define regular expression restriction, string with Query in form “metaArtifactUri = ‘…’ OR metaArtifactUri = ‘…’ AND organizationalUnitUri = ‘…’ OR organizationalUnitUri = ‘…’ (organizationalUnitUri = $this-ou)” - to define restriction on meta-artifact and organizational unit, empty string - will remove existing restrictions from property template.

Returns:

  • (UU::OS::UESURI)

    UESURI of the property template with new attributes



247
248
249
250
251
252
253
254
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 247

def set_attributes(template_uri, property_template = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  payload = UU::OS::PropertyTemplate::PropertyTemplateSetAttributes.new(property_template).to_json
  UU::OS::QoS::QoSHandler.auto_retry do
    res = svc.post('setAttributes', template_uri, payload)
    return UU::OS::UESURI.new(res)
  end
end

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

Modifies basic attributes of the property collection template specified in collTemplateUri.

Examples:

#Set new attributes
newUri = UU::OS::PropertyTemplate.set_collection_attributes('ues:TERRITORY:META_ARTIFACT:COLLECTION', :name => 'new Name', :code => 'NEW_COLL')

Parameters:

Options Hash (collection):

  • :name (String)

    The new name of the property collection template. When null is set, the name is not modified. If set, name cannot be blank.

  • :code (String)

    The new code of the property collection template. When null is set, the code is not modified. The code must be unique in a given Meta Artifact, otherwise the command fails.

  • :description (String)

    The new description of the property collection template. When null is set, the description is not modified.

Returns:



312
313
314
315
316
317
318
319
320
# File 'uu_os-0.29.16/lib/uu/os/property_template.rb', line 312

def set_collection_attributes(collection_uri, collection = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  payload = UU::OS::PropertyTemplate::PropertyTemplateSetCollectionAttributes.new(collection).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(template_uri, value = nil)

Sets a new value on the specified property template. The data type of the value must match the data type of the specified property template.

Examples:

#Set value of a property template of binary type
UU::OS::PropertyTemplate.set_value('ues:TERRITORY:META_ARTIFACT:PROPERTY_TEMPLATE_BLOB', 
  UU::OS::REST::BinaryValue.new(data:'example', name:'my_name.txt'))

#Set value of a property template of text type
UU::OS::PropertyTemplate.set_value('ues:TERRITORY:META_ARTIFACT:PROPERTY_TEMPLATE_TEXT', 'some string')

Parameters:

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

    UES URI of property template

  • value (Object) (defaults to: nil)

    the new value of the property template. Possible types of property’s value (there may be additional business restrictions based on property type, see UU::OS::Property::PropertyType for possible types



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

def set_value(template_uri, value = nil)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  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', template_uri, payload)
  end
end