-
Notifications
You must be signed in to change notification settings - Fork 1
Entities
Entities represent instances of data in TreeStore. Entity names mist be unique with their category (more on this later). In the first place an entity is just a name. About an entity can have assigned multiple Tags to it. Each of the tags facet properties can have value at this entity.
Entites are created with the New-Item cmdlet under the main folder \Entities:
PS> New-Item \Entities\example_entity
example_entity
The output shows only the entity name. This is because TreeStore defines a custom format for displaying single entities which is handy later on if the entity has tags assigned with property values. To see the default properties you might use the Format-Table cmdlet with the entity:
PS Get-Item /Entites/example_entity | ft
Name ItemType
---- --------
example_entity Entity
To assign a tag you simply create a new item under an entity having the same name as a tag:
PS> New-Item /Entities/example_entity/example_tag
Name ItemType
---- --------
example_tag AssignedTag
The tag remain is now connected to the entity. Its facet properties can now set with a value. The provided view of the entity shows the data structure now in a hierarchical output:
PS> Get-Item \Entities\example_entity
example_entity
example_tag
example_property : <no value>
The property 'example_property' doesn't have a value assigned. This is visualized with the placeholder <no value>. If the property value is fetched it will be $null.
A property value can be assigned by using the Set-ItemProperty cmdlet at the entity:
PS> Set-ItemProperty /Entities/example_entity/example_tag -Name example_property -Value "assigned value"
PS> Get-Item example_entity
example_entity
example_tag
example_property : assigned value
Now the output shows the entity/tag/property and value. The property value can be read with the Get-ItemPropertyValue cmdlet or from the PSObject returned from Get-Item:
PS> Get-ItemPropertyValue .\example_entity\example_tag -Name "example_property"
assigned value
PS> (Get-Item .\example_entity).example_tag.example_property
assigned value
PS> (Get-Item .\example_entity\example_tag).example_property
assigned value
The value of a property can be removed:
PS> Clear-ItemPropertyValue .\example_entity\example_tag -Name "example_property"
Entities can be renamed at any time:
PS> Rename-Item /Entities/example_entity -NewName changed_name
Entities having no tags assigned can be removed at any time:
PS> Remove-Item /Entities/example_entity
Entities having tags assigned but no properties set may be removed with -Recurse:
PS> Remove-Item /Entities/example_entity -Recurse
if properties of assigned tags have values set deletion will require -Force:
PS> Remove-Item /Entities/example_entity -Recurse -Force
RemoveItem: Can't delete entity(name='example_entity'): It is has property values. Use -Force to delete anyway."
PS> Remove-Item /Entities/example_entity -Recurse -Force
Entities may be moved or copied between categories (more about Categories...)
Assigned tags can be removed from an entity:
PS> Remove-Item /Entities/example_entity/example_tag
If this would cause loss of property values -Force must be specified. Otherwise the operation will fail:
PS> Remove-Item /Entities/example_entity/example_tag
RemoveItem: Can't delete assigned tag(name='example_tag'): Its properties have values. Use -Force to delete anyway."
PS> Remove-Item /Entities/example_entity/example_tag -Force