Skip to content
Wolfgang Groß edited this page Apr 6, 2020 · 13 revisions

Tags are TreeStores representations of data structures. They can be assigned to other item of the TreeStore file system like entities. Assigning an empty Tag can be used as a classification of an item. But a Tag can also add data properties called (facet properties) to a an item.

Creating Tags

Tags are created by creating a new item in the /Tags directory:

PS> New-Item /Tags/example_tag

Name        ItemType 
----        -------- 
example_tag      Tag 

The Tag written to the pipe by the New-Item Cmdlet shows by default the tags name and the TreeStore ItemType 'Tag'. After creation the tags doesn't have any facet properties.

Creating Facet Properties

Facet properties are created as child items of a Tag. Their name is unique within the Tag and any property must have a data type assigned. Available data types are:

  • String : a text of arbitrary length
  • Bool: true or false
  • DateTime: a date including a time see MSDN
  • Decimal: a large decimal number see MSDN
  • Double: a floating point number see MSDN
  • Guid: a global unique identifier see MSDN
  • Long: a number with decimals see MSDN

Names of Facet Properties exclude names which are already used internally to describe Facet Properties. These are:

  • Id
  • Name
  • ValueType
  • ItemType

A Facet Property is created by creating a new item as child item to a Tag:

PS> New-Item /Tags/example_tag/example_property -ValueType String
                                      
Name      ItemType ValueType          
----      -------- ---------          
p    FacetProperty    String          

The facet properties type can't be changed afterwards. Facet properties also don't support the Set-ItemProperty cmdlet to rename the property.

Managing Tags and Facet Properties

It is possible to rearrange some aspects of TreeStores data model any any time after creation.

Rename Tags

A tags name can be changed at any time:

PS>  Rename-Item .\example_tag -NewName changed_name

Copy Tags

Any Tag may be replicated with a different name by copying it.

PS> Copy-Item -Path /Tags/example_tag -Destination  /Tags/changed_name

A copy of a Tag will always replicate the source Tags Facet Properties with the same name and type. But these are different properties from the perspective of the data model.

Remove Tags

An unused tag without properties can be deleted at any time:

PS> Remove-Item -Path /Tags/example_tag

If the tag has properties -Recurse has to be specified or PowerShell will ask you for permission

PS> Remove-Item -Path /Tags/example_tag -Recurse

If a tag is assigned to at least one entity it can't be removed without forcing it:

PS> Remove-Item -Path /Tags/example_tag -Force
Remove-Item: Can't delete tag(name='example_tag'): It is used by at least one entity. Use -Force to delete anyway.

PS> Remove-Item -Path /Tags/example_tag -Force

In this case it makes no difference if the tag has properties or not or if values are assigned to the properties or not.

Rename Facet Properties

Like tags facet properties can renamed at any time:

PS> Rename-Item ./example_tag/example_property -NewName changed_name

Copy Facet Properties Between Tags

If a Facet properties was created at a Tag and is needed by another Tag with the same definition (Name, ValueType) it can be copied to the other tag:

PS> Copy-Item -Path /Tags/example_tag/example_property -Destination /Tags/other_tag

Move Facet Properties Between Tags

Moving a facet property between Tags is currently possible because of a design flaw: Moving is implemented using Copy and remove which isn't moving because the property looses its Id and therefore its data assigned at entities. In the future moving will be excluded from the allowed operations of facet proprties.