Module: UU::OS::PropertyTemplate

Extended by:
PropertyTemplate
Included in:
PropertyTemplate
Defined in:
uu_os_client-0.10.6/lib/uu/os/property_template.rb,
uu_os_client-0.10.6/lib/uu/os/property_template/property_template_create.rb,
uu_os_client-0.10.6/lib/uu/os/property_template/property_template_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/property_template/property_template_get_entry_list.rb,
uu_os_client-0.10.6/lib/uu/os/property_template/property_template_set_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/property_template/property_template_entry_attributes.rb,
uu_os_client-0.10.6/lib/uu/os/property_template/property_template_delete_collection.rb,
uu_os_client-0.10.6/lib/uu/os/property_template/property_template_collection_create.rb,
uu_os_client-0.10.6/lib/uu/os/property_template/property_template_collection_attributes.rb,
uu_os_client-0.10.6/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, 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)

    Name of the new property template. Name can not be null.

  • :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)

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

  • :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:



169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'uu_os_client-0.10.6/lib/uu/os/property_template.rb', line 169

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
  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, 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

  • Object (PropertyTemplateCollectionCreate)

    containing attributes of a new property collection template

  • collection (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (collection):

  • :name (String)

    Name of the new property collection template. Name cannot be null.

  • :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:



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

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



190
191
192
193
194
195
# File 'uu_os_client-0.10.6/lib/uu/os/property_template.rb', line 190

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:



306
307
308
309
310
311
312
313
# File 'uu_os_client-0.10.6/lib/uu/os/property_template.rb', line 306

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:



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

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:



265
266
267
268
269
270
271
# File 'uu_os_client-0.10.6/lib/uu/os/property_template.rb', line 265

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:



124
125
126
127
128
129
130
131
132
133
134
135
# File 'uu_os_client-0.10.6/lib/uu/os/property_template.rb', line 124

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



93
94
95
96
97
98
99
100
# File 'uu_os_client-0.10.6/lib/uu/os/property_template.rb', line 93

def get_value(template_uri)
  svc = UU::OS::REST::RemoteClient.new(PropertyTemplate)
  UU::OS::QoS::QoSHandler.auto_retry do
    value = svc.get('getValue', template_uri)
    type = get_attributes(template_uri).type()
    return deserialize_by_type(value,type)
  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



222
223
224
225
226
227
228
229
# File 'uu_os_client-0.10.6/lib/uu/os/property_template.rb', line 222

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:

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

    UESURI of the property collection template which attributes is modified

  • Object (PropertyTemplateSetCollectionAttributes)

    containing attributes of the property collection template

  • collection (Hash) (defaults to: nil)

    a customizable set of options

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:



287
288
289
290
291
292
293
294
295
# File 'uu_os_client-0.10.6/lib/uu/os/property_template.rb', line 287

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



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_template.rb', line 55

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